[coreboot] [v2] r4110 - in trunk/coreboot-v2/util: . cbfstool cbfstool/tools cbfstool/tools/lzma/C

svn at coreboot.org svn at coreboot.org
Tue Apr 14 02:08:34 CEST 2009


Author: stuge
Date: 2009-04-14 02:08:34 +0200 (Tue, 14 Apr 2009)
New Revision: 4110

Added:
   trunk/coreboot-v2/util/cbfstool/
   trunk/coreboot-v2/util/cbfstool/cbfs.h
   trunk/coreboot-v2/util/cbfstool/cbfstool.c
   trunk/coreboot-v2/util/cbfstool/cbfstool.h
Removed:
   trunk/coreboot-v2/util/cbfstool/romfs.h
   trunk/coreboot-v2/util/cbfstool/romtool.c
   trunk/coreboot-v2/util/cbfstool/romtool.h
   trunk/coreboot-v2/util/romtool/
Modified:
   trunk/coreboot-v2/util/cbfstool/EXAMPLE
   trunk/coreboot-v2/util/cbfstool/Makefile
   trunk/coreboot-v2/util/cbfstool/README
   trunk/coreboot-v2/util/cbfstool/TODO
   trunk/coreboot-v2/util/cbfstool/add.c
   trunk/coreboot-v2/util/cbfstool/bootblock.c
   trunk/coreboot-v2/util/cbfstool/create.c
   trunk/coreboot-v2/util/cbfstool/delete.c
   trunk/coreboot-v2/util/cbfstool/fs.c
   trunk/coreboot-v2/util/cbfstool/print.c
   trunk/coreboot-v2/util/cbfstool/resize.c
   trunk/coreboot-v2/util/cbfstool/tools/common.c
   trunk/coreboot-v2/util/cbfstool/tools/common.h
   trunk/coreboot-v2/util/cbfstool/tools/compress.c
   trunk/coreboot-v2/util/cbfstool/tools/lzma/C/ORIGIN
   trunk/coreboot-v2/util/cbfstool/tools/rom-mkpayload.c
   trunk/coreboot-v2/util/cbfstool/tools/rom-mkstage.c
   trunk/coreboot-v2/util/cbfstool/types.c
   trunk/coreboot-v2/util/cbfstool/util.c
Log:
v2/util: romfs -> cbfs rename

It's all sed here. romfs->cbfs, ROMFS->CBFS, romtool->cbfstool

Signed-off-by: Peter Stuge <peter at stuge.se>
Acked-by: Ronald G. Minnich <rminnich at gmail.com>


Modified: trunk/coreboot-v2/util/cbfstool/EXAMPLE
===================================================================
--- trunk/coreboot-v2/util/romtool/EXAMPLE	2009-04-13 21:42:49 UTC (rev 4108)
+++ trunk/coreboot-v2/util/cbfstool/EXAMPLE	2009-04-14 00:08:34 UTC (rev 4110)
@@ -1,8 +1,8 @@
  rm coreboot.rom; 
-./romtool coreboot.rom create 0x80000 0x10000 /tmp/coreboot.strip
-./romtool coreboot.rom add-payload /tmp/filo.elf normal/payload l
-./romtool coreboot.rom print
-#./romtool coreboot.rom add-stage /tmp/filo.elf normal/payload
+./cbfstool coreboot.rom create 0x80000 0x10000 /tmp/coreboot.strip
+./cbfstool coreboot.rom add-payload /tmp/filo.elf normal/payload l
+./cbfstool coreboot.rom print
+#./cbfstool coreboot.rom add-stage /tmp/filo.elf normal/payload
 
-./romtool coreboot.rom print
+./cbfstool coreboot.rom print
 cp coreboot.rom /home/rminnich/qemutest/

Modified: trunk/coreboot-v2/util/cbfstool/Makefile
===================================================================
--- trunk/coreboot-v2/util/romtool/Makefile	2009-04-13 21:42:49 UTC (rev 4108)
+++ trunk/coreboot-v2/util/cbfstool/Makefile	2009-04-14 00:08:34 UTC (rev 4110)
@@ -5,17 +5,17 @@
 obj ?= $(shell pwd)
 
 COMMANDS=create.o bootblock.o delete.o add.o print.o resize.o
-OBJ=$(COMMANDS) romtool.o util.o fs.o
-INC=romtool.h romfs.h
+OBJ=$(COMMANDS) cbfstool.o util.o fs.o
+INC=cbfstool.h cbfs.h
 
 CC=gcc
 CFLAGS=-g -Wall # -W -Werror
 
 DESTDIR ?= /usr/local/bin
 
-all: $(obj)/romtool $(obj)/tools/rom-mkpayload $(obj)/tools/rom-mkstage
+all: $(obj)/cbfstool $(obj)/tools/rom-mkpayload $(obj)/tools/rom-mkstage
 
-$(obj)/romtool: $(patsubst %,$(obj)/%,$(OBJ))
+$(obj)/cbfstool: $(patsubst %,$(obj)/%,$(OBJ))
 	$(CC) -o $@ $(patsubst %,$(obj)/%,$(OBJ))
 
 tobj = $(obj)/tools
@@ -26,9 +26,9 @@
 $(obj)/%.o: %.c $(INC)
 	$(CC) $(CFLAGS) -c -o $@ $<
 
-install: $(obj)/romtool $(obj)/tools/rom-mkpayload $(obj)/tools/rom-mkstage
+install: $(obj)/cbfstool $(obj)/tools/rom-mkpayload $(obj)/tools/rom-mkstage
 	@ install -d $(DESTDIR)
-	@ install -m 0755 $(obj)/romtool $(DESTDIR)/romtool
+	@ install -m 0755 $(obj)/cbfstool $(DESTDIR)/cbfstool
 	@ install -m 0755 $(obj)/tools/rom-mkstage $(DESTDIR)/rom-mkstage
 	@ install -m 0755 $(obj)/tools/rom-mkpayload $(DESTDIR)/rom-mkpayload
 
@@ -36,5 +36,5 @@
 	ctags *.[ch] */*.[ch]
 
 clean: tools-clean
-	rm -f $(patsubst %,$(obj)/%,$(OBJ)) $(obj)/romtool
+	rm -f $(patsubst %,$(obj)/%,$(OBJ)) $(obj)/cbfstool
 

Modified: trunk/coreboot-v2/util/cbfstool/README
===================================================================
--- trunk/coreboot-v2/util/romtool/README	2009-04-13 21:42:49 UTC (rev 4108)
+++ trunk/coreboot-v2/util/cbfstool/README	2009-04-14 00:08:34 UTC (rev 4110)
@@ -1,16 +1,16 @@
-Coreboot ROMFS Specification
+Coreboot CBFS Specification
 Jordan Crouse <jordan at cosmicpenguin.net>
 
 = Introduction =
 
-This document describes the coreboot ROMFS specification (from here referred 
-to as ROMFS).  ROMFS is a scheme for managing independent chunks of data in
+This document describes the coreboot CBFS specification (from here referred 
+to as CBFS).  CBFS is a scheme for managing independent chunks of data in
 a system ROM.  Though not a true filesystem, the style and concepts are
 similar.
 
 = Architecture =
 
-The ROMFS architecture looks like the following:
+The CBFS architecture looks like the following:
 
 /---------------\ <-- Start of ROM
 | /-----------\ | --|
@@ -41,7 +41,7 @@
 \---------------/ 
 
 
-The ROMFS architecture consists of a binary associated with a physical
+The CBFS architecture consists of a binary associated with a physical
 ROM disk referred hereafter as the ROM. A number of independent of
 components, each with a  header prepended on to data are located within
 the ROM.  The components are nominally arranged sequentially, though they
@@ -50,12 +50,12 @@
 The bootblock occupies the last 20k of the ROM.  Within
 the bootblock is a master header containing information about the ROM
 including the size, alignment of the components, and the offset of the
-start of the first ROMFS component within the ROM.
+start of the first CBFS component within the ROM.
 
 = Master Header =
 
 The master header contains essential information about the ROM that is
-used by both the ROMFS implementation within coreboot at runtime as well
+used by both the CBFS implementation within coreboot at runtime as well
 as host based utilities to create and manage the ROM.  The master header
 will be located somewhere within the bootblock (high end of the ROM).  A
 pointer to the location of the header will be located at offset
@@ -67,7 +67,7 @@
 
 The following is the structure of the master header:
 
-struct romfs_header {
+struct cbfs_header {
 	unsigned int magic;
 	unsigned int version; 
 	unsigned int romsize;
@@ -79,10 +79,10 @@
 
 The meaning of each member is as follows:
 
-'magic' is a 32 bit number that identifies the ROM as a ROMFS type.  The magic
+'magic' is a 32 bit number that identifies the ROM as a CBFS type.  The magic
 number is 0x4F524243, which is 'ORBC' in ASCII. 
 
-'version' is a 32 bit number that identifies the version of ROMFS. The current
+'version' is a 32 bit number that identifies the version of CBFS. The current
 version is 0x31313131 ('1111' in ASCII) which is endian-independent. 
 
 'romsize' is the size of the ROM in bytes.  Coreboot will subtract 'size' from
@@ -96,7 +96,7 @@
 regards to the erase block sizes on the ROM - allowing one to replace a
 component at runtime without disturbing the others.
 
-'offset' is the offset of the the first ROMFS component (from the start of
+'offset' is the offset of the the first CBFS component (from the start of
 the ROM).  This is to allow for arbitrary space to be left at the beginning
 of the ROM for things like embedded controller firmware.
 
@@ -111,19 +111,19 @@
 
 = Components =
 
-ROMFS components are placed in the ROM starting at 'offset' specified in
+CBFS components are placed in the ROM starting at 'offset' specified in
 the master header and ending at the bootblock.  Thus the total size available
-for components in the ROM is (ROM size - bootblocksize - 'offset').  Each ROMFS
+for components in the ROM is (ROM size - bootblocksize - 'offset').  Each CBFS
 component is to be aligned according to the 'align' value in the header.
 Thus, if a component of size 1052 is located at offset 0 with an 'align' value
 of 1024, the next component will be located at offset 2048.
 
-Each ROMFS component will be indexed with a unique ASCII string name of
+Each CBFS component will be indexed with a unique ASCII string name of
 unlimited size. 
 
-Each ROMFS component starts with a header:
+Each CBFS component starts with a header:
 
-struct ROMFS_file {
+struct CBFS_file {
         char magic[8];
         unsigned int len;
         unsigned int type;
@@ -155,7 +155,7 @@
 
 /--------\  <- start
 | Header |
-|--------|  <- sizeof(struct romfs_file)
+|--------|  <- sizeof(struct cbfs_file)
 | Name   |
 |--------|  <- 'offset'
 | Data   |
@@ -165,25 +165,25 @@
 == Searching Alogrithm ==
 
 To locate a specific component in the ROM, one starts at the 'offset'
-specified in the ROMFS master header.  For this example, the offset will
+specified in the CBFS master header.  For this example, the offset will
 be 0.  
 
 From that offset, the code should search for the magic string on the
 component, jumping 'align' bytes each time.  So, assuming that 'align' is
 16, the code will search for the string 'LARCHIVE' at offset 0, 16, 32, etc.
-If the offset ever exceeds the allowable range for ROMFS components, then no
+If the offset ever exceeds the allowable range for CBFS components, then no
 component was found.
 
 Upon recognizing a component, the software then has to search for the
 specific name of the component.  This is accomplished by comparing the
 desired name with the string on the component located at
-offset + sizeof(struct romfs_file).  If the string matches, then the component
+offset + sizeof(struct cbfs_file).  If the string matches, then the component
 has been located, otherwise the software should add 'offset' + 'len' to
 the offset and resume the search for the magic value.
 
 == Data Types ==
 
-The 'type' member of struct romfs_file is used to identify the content
+The 'type' member of struct cbfs_file is used to identify the content
 of the component data, and is used by coreboot and other
 run-time entities to make decisions about how to handle the data.
 
@@ -214,7 +214,7 @@
 
 The header is defined as:
 
-struct romfs_stage {
+struct cbfs_stage {
         unsigned int compression;
         unsigned long long entry;
         unsigned long long load;
@@ -273,8 +273,8 @@
 
 The header is as follows:
 
-struct romfs_payload {
-        struct romfs_payload_segment segments;
+struct cbfs_payload {
+        struct cbfs_payload_segment segments;
 }
 
 The header contains a number of segments corresponding to the segments
@@ -282,7 +282,7 @@
 
 The following is the structure of each segment header:
 
-struct romfs_payload_segment {
+struct cbfs_payload_segment {
         unsigned int type;
         unsigned int compression;
         unsigned int offset;

Modified: trunk/coreboot-v2/util/cbfstool/TODO
===================================================================
--- trunk/coreboot-v2/util/romtool/TODO	2009-04-13 21:42:49 UTC (rev 4108)
+++ trunk/coreboot-v2/util/cbfstool/TODO	2009-04-14 00:08:34 UTC (rev 4110)
@@ -1,4 +1,4 @@
 Add interactive mode
-Add script mode (./romtool [ROM] -s script)
+Add script mode (./cbfstool [ROM] -s script)
 Support compression for stages and payloads
 Add nrv2b

Modified: trunk/coreboot-v2/util/cbfstool/add.c
===================================================================
--- trunk/coreboot-v2/util/romtool/add.c	2009-04-13 21:42:49 UTC (rev 4108)
+++ trunk/coreboot-v2/util/cbfstool/add.c	2009-04-14 00:08:34 UTC (rev 4110)
@@ -1,5 +1,5 @@
 /*
- * romtool
+ * cbfstool
  *
  * Copyright (C) 2008 Jordan Crouse <jordan at cosmicpenguin.net>
  *
@@ -26,7 +26,7 @@
 #include <sys/stat.h>
 #include <sys/mman.h>
 #include <sys/wait.h>
-#include "romtool.h"
+#include "cbfstool.h"
 
 #define MAX_PATH 255
 
@@ -221,7 +221,7 @@
 
 int add_handler(struct rom *rom, int argc, char **argv)
 {
-	unsigned int type = ROMFS_COMPONENT_NULL;
+	unsigned int type = CBFS_COMPONENT_NULL;
 
 	if (argc < 2) {
 		add_usage();
@@ -240,7 +240,7 @@
 			type = strtoul(argv[2], 0, 0);
 	}
 
-	if (type == ROMFS_COMPONENT_NULL)
+	if (type == CBFS_COMPONENT_NULL)
 		WARN("No file type was given for %s - using default\n",
 		     argv[0]);
 
@@ -250,18 +250,18 @@
 char *find_tool(char *tool)
 {
 	static char toolpath[MAX_PATH];
-	extern char romtool_bindir[];
+	extern char cbfstool_bindir[];
 
 	snprintf(toolpath, MAX_PATH - 1, "tools/%s", tool);
 	if (!access(toolpath, X_OK))
 		return toolpath;
 
-	snprintf(toolpath, MAX_PATH - 1, "%s/tools/%s", romtool_bindir, tool);
+	snprintf(toolpath, MAX_PATH - 1, "%s/tools/%s", cbfstool_bindir, tool);
 
 	if (!access(toolpath, X_OK))
 		return toolpath;
 
-	snprintf(toolpath, MAX_PATH - 1, "%s/%s", romtool_bindir, tool);
+	snprintf(toolpath, MAX_PATH - 1, "%s/%s", cbfstool_bindir, tool);
 
 	if (!access(toolpath, X_OK))
 		return toolpath;
@@ -294,7 +294,7 @@
 	}
 
 	return fork_tool_and_add(rom, find_tool("rom-mkpayload"), argv[0],
-				 argv[1], ROMFS_COMPONENT_PAYLOAD, argc - 2,
+				 argv[1], CBFS_COMPONENT_PAYLOAD, argc - 2,
 				 argc > 2 ? &argv[2] : NULL);
 }
 
@@ -322,6 +322,6 @@
 	}
 
 	return fork_tool_and_add(rom, find_tool("rom-mkstage"), argv[0],
-				 argv[1], ROMFS_COMPONENT_STAGE, argc - 2,
+				 argv[1], CBFS_COMPONENT_STAGE, argc - 2,
 				 argc > 2 ? &argv[2] : NULL);
 }

Modified: trunk/coreboot-v2/util/cbfstool/bootblock.c
===================================================================
--- trunk/coreboot-v2/util/romtool/bootblock.c	2009-04-13 21:42:49 UTC (rev 4108)
+++ trunk/coreboot-v2/util/cbfstool/bootblock.c	2009-04-14 00:08:34 UTC (rev 4110)
@@ -1,5 +1,5 @@
 /*
- * romtool
+ * cbfstool
  *
  * Copyright (C) 2008 Jordan Crouse <jordan at cosmicpenguin.net>
  *
@@ -20,7 +20,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include "romtool.h"
+#include "cbfstool.h"
 
 void bootblock_usage(void)
 {

Copied: trunk/coreboot-v2/util/cbfstool/cbfs.h (from rev 4108, trunk/coreboot-v2/util/romtool/romfs.h)
===================================================================
--- trunk/coreboot-v2/util/cbfstool/cbfs.h	                        (rev 0)
+++ trunk/coreboot-v2/util/cbfstool/cbfs.h	2009-04-14 00:08:34 UTC (rev 4110)
@@ -0,0 +1,129 @@
+/*
+ * cbfstool
+ *
+ * Copyright (C) 2008 Jordan Crouse <jordan at cosmicpenguin.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
+ */
+
+#ifndef _CBFS_H_
+#define _CBFS_H_
+
+/** These are standard values for the known compression
+    alogrithms that coreboot knows about for stages and
+    payloads.  Of course, other LAR users can use whatever
+    values they want, as long as they understand them. */
+
+#define CBFS_COMPRESS_NONE  0
+#define CBFS_COMPRESS_LZMA  1
+#define CBFS_COMPRESS_NRV2B 2
+
+/** These are standard component types for well known
+    components (i.e - those that coreboot needs to consume.
+    Users are welcome to use any other value for their
+    components */
+
+#define CBFS_COMPONENT_STAGE     0x10
+#define CBFS_COMPONENT_PAYLOAD   0x20
+#define CBFS_COMPONENT_OPTIONROM 0x30
+
+#define CBFS_COMPONENT_NULL 0xFFFFFFFF
+
+/** this is the master cbfs header - it need to be
+    located somewhere in the bootblock.  Where it
+    actually lives is up to coreboot. A pointer to
+    this header will live at 0xFFFFFFF4, so we can
+    easily find it. */
+
+#define HEADER_MAGIC 0x4F524243
+
+/* this is a version that gives the right answer in any endian-ness */
+#define VERSION1 0x31313131
+
+struct cbfs_header {
+	unsigned int magic;
+	unsigned int version; 
+	unsigned int romsize;
+	unsigned int bootblocksize;
+	unsigned int align;
+	unsigned int offset;
+	unsigned int pad[2];
+} __attribute__ ((packed));
+
+/** This is a component header - every entry in the CBFS
+    will have this header.
+
+    This is how the component is arranged in the ROM:
+
+    --------------   <- 0
+    component header 
+    --------------   <- sizeof(struct component)
+    component name
+    --------------   <- offset
+    data
+    ...
+    --------------   <- offset + len
+*/
+
+#define COMPONENT_MAGIC "LARCHIVE"
+
+struct cbfs_file {
+	char magic[8];
+	unsigned int len;
+	unsigned int type;
+	unsigned int checksum;
+	unsigned int offset;
+} __attribute__ ((packed));
+
+/*** Component sub-headers ***/
+
+/* Following are component sub-headers for the "standard"
+   component types */
+
+/** This is the sub-header for stage components.  Stages are
+    loaded by coreboot during the normal boot process */
+
+struct cbfs_stage {
+	unsigned int compression;  /** Compression type */
+	unsigned long long entry;  /** entry point */
+	unsigned long long load;   /** Where to load in memory */
+	unsigned int len;	   /** length of data to load */
+	unsigned int memlen;	   /** total length of object in memory */
+} __attribute__ ((packed));
+
+/** this is the sub-header for payload components.  Payloads
+    are loaded by coreboot at the end of the boot process */
+
+struct cbfs_payload_segment {
+	unsigned int type;
+	unsigned int compression;
+	unsigned int offset;
+	unsigned long long load_addr;
+	unsigned int len;
+	unsigned int mem_len;
+} __attribute__ ((packed));
+
+struct cbfs_payload {
+	struct cbfs_payload_segment segments;
+};
+
+#define PAYLOAD_SEGMENT_CODE   0x45444F43
+#define PAYLOAD_SEGMENT_DATA   0x41544144
+#define PAYLOAD_SEGMENT_BSS    0x20535342
+#define PAYLOAD_SEGMENT_PARAMS 0x41524150
+#define PAYLOAD_SEGMENT_ENTRY  0x52544E45
+
+#define CBFS_NAME(_c) (((unsigned char *) (_c)) + sizeof(struct cbfs_file))
+
+#endif

Copied: trunk/coreboot-v2/util/cbfstool/cbfstool.c (from rev 4108, trunk/coreboot-v2/util/romtool/romtool.c)
===================================================================
--- trunk/coreboot-v2/util/cbfstool/cbfstool.c	                        (rev 0)
+++ trunk/coreboot-v2/util/cbfstool/cbfstool.c	2009-04-14 00:08:34 UTC (rev 4110)
@@ -0,0 +1,157 @@
+/*
+ * cbfstool
+ *
+ * Copyright (C) 2008 Jordan Crouse <jordan at cosmicpenguin.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
+ */
+
+/* v2 compat: First, assumes a 64K bootblock. 
+ * cbfstool coreboot.rom create 0x80000 coreboot.strip 
+ * cbfstool coreboot.rom add-payload /tmp/filo.elf payload 
+ * cbfstool coreboot.rom print
+ */
+
+
+#include <string.h>
+#include <unistd.h>
+#include <libgen.h>
+#include <sys/mman.h>
+#include "cbfstool.h"
+
+extern int create_handler(struct rom *, int, char **);
+extern int bootblock_handler(struct rom *, int, char **);
+extern int print_handler(struct rom *, int, char **);
+extern int add_handler(struct rom *, int, char **);
+extern int delete_handler(struct rom *, int, char **);
+extern int resize_handler(struct rom *, int, char **);
+extern int add_payload_handler(struct rom *, int, char **);
+extern int add_stage_handler(struct rom *, int, char **);
+
+extern void create_usage(void);
+extern void bootblock_usage(void);
+extern void print_usage(void);
+extern void add_usage(void);
+extern void delete_usage(void);
+extern void resize_usage(void);
+extern void add_payload_usage(void);
+extern void add_stage_usage(void);
+
+struct {
+	char *command;
+	int (*handler) (struct rom *, int, char **);
+	void (*help) (void);
+} commands[] = {
+	{
+	"add", add_handler, add_usage}, {
+	"add-payload", add_payload_handler, add_payload_usage}, {
+	"add-stage", add_stage_handler, add_stage_usage}, {
+	"bootblock", bootblock_handler, bootblock_usage}, {
+	"create", create_handler, create_usage}, {
+	"delete", delete_handler, delete_usage}, {
+	"print", print_handler, print_usage}, {
+	"resize", resize_handler, resize_usage}, {
+"", NULL},};
+
+static struct rom rom;
+
+char cbfstool_bindir[255];
+
+void show_help(void)
+{
+	int i;
+
+	printf("cbfstool [OPTION] [[FILE] [COMMAND] [PARAMETERS]...\n");
+	printf("Apply COMMANDS with PARAMETERS to FILE.  If no COMMAND is\n");
+	printf("given, run in interactive mode\n\n");
+	printf("OPTIONs:\n");
+	printf(" -h\t\tDisplay this help message\n");
+	printf(" -C <dir>\tChange to the directory before operating\n\n");
+	printf("COMMANDs:\n");
+
+	for (i = 0; commands[i].handler != NULL; i++)
+		commands[i].help();
+}
+
+int main(int argc, char **argv)
+{
+	char *cdir = NULL;
+	char *rname;
+	char *cmd;
+	int ret = -1, i;
+
+	strncpy(cbfstool_bindir, dirname(argv[0]), 254);
+
+	while (1) {
+		signed ch = getopt(argc, argv, "hC:");
+		if (ch == -1)
+			break;
+		switch (ch) {
+		case 'h':
+			show_help();
+			return -1;
+		case 'C':
+			cdir = optarg;
+			break;
+		}
+	}
+
+	if (optind >= argc) {
+		show_help();
+		return -1;
+	}
+
+	if (cdir != NULL && chdir(cdir)) {
+		ERROR("Unable to switch to %s: %m\n", cdir);
+		return -1;
+	}
+
+	rname = argv[optind];
+	cmd = optind + 1 < argc ? argv[optind + 1] : NULL;
+
+	/* Open the ROM (if it exists) */
+	rom.name = (unsigned char *)strdup(rname);
+
+	if (!access(rname, F_OK)) {
+		if (open_rom(&rom, rname)) {
+			ERROR("Problem while reading the ROM\n");
+			return -1;
+		}
+	}
+
+	if (cmd) {
+		/* Process the incoming comand */
+
+		for (i = 0; commands[i].handler != NULL; i++) {
+			if (!strcmp(commands[i].command, cmd)) {
+				ret = commands[i].handler(&rom,
+							  argc - 3, &argv[3]);
+				goto leave;
+			}
+		}
+
+		ERROR("Command %s not valid\n", cmd);
+	} else {
+		printf("Interactive mode not ready yet!\n");
+	}
+
+leave:
+	if (rom.ptr != NULL && rom.ptr != MAP_FAILED)
+		munmap(rom.ptr, rom.size);
+
+	if (rom.fd > 0)
+		close(rom.fd);
+
+	return ret;
+}

Copied: trunk/coreboot-v2/util/cbfstool/cbfstool.h (from rev 4108, trunk/coreboot-v2/util/romtool/romtool.h)
===================================================================
--- trunk/coreboot-v2/util/cbfstool/cbfstool.h	                        (rev 0)
+++ trunk/coreboot-v2/util/cbfstool/cbfstool.h	2009-04-14 00:08:34 UTC (rev 4110)
@@ -0,0 +1,77 @@
+/*
+ * cbfstool
+ *
+ * Copyright (C) 2008 Jordan Crouse <jordan at cosmicpenguin.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
+ */
+
+#ifndef _ROMTOOL_H_
+#define _ROMTOOL_H_
+
+#include <stdio.h>
+#include <arpa/inet.h>
+#include "cbfs.h"
+
+/* Definitions */
+
+/* Structures */
+
+struct rom {
+	unsigned char *name;
+	unsigned char *ptr;
+
+	int fd;
+	int size;
+	int fssize;
+
+	struct cbfs_header *header;
+};
+
+/* Macros */
+
+#define ROM_OFFSET(_r, _c) ((unsigned int) ((unsigned char *) (_c) - (_r)->ptr))
+
+#define ROM_PTR(_r, _o) ((_r)->ptr + (_o))
+#define ROM_WRITEL(_r, _o, _v) do { *((unsigned int *) ROM_PTR((_r), (_o))) = (_v); } while(0)
+#define ROM_READL(_r, _o) *((unsigned int *) (ROM_PTR((_r), (_o))))
+
+#define ERROR(err, args...) fprintf(stderr, "(cbfstool) E: " err, ##args)
+#define WARN(err, args...) fprintf(stderr, "(cbfstool) W: " err, ##args)
+#define VERBOSE(str, args...) printf(str, ##args)
+
+#define ALIGN(_v, _a) ( ( (_v) + ( (_a) - 1 ) ) & ~( (_a) - 1 ) )
+
+/* Function prototypes */
+
+/* util.c */
+int open_rom(struct rom *rom, const char *filename);
+int create_rom(struct rom *rom, const unsigned char *filename, int size,
+	int bootblocksize,  int align);
+int size_and_open(const char *filename, unsigned int *size);
+int copy_from_fd(int fd, void *ptr, int size);
+int get_size(const char *size);
+int add_bootblock(struct rom *rom, const char *filename);
+
+/* fs.c */
+
+struct cbfs_file *rom_find(struct rom *rom, unsigned int offset);
+struct cbfs_file *rom_find_first(struct rom *);
+struct cbfs_file *rom_find_next(struct rom *, struct cbfs_file *);
+int rom_add(struct rom *rom, const char *name, void *, int size, int type);
+int rom_remove(struct rom *rom, const char *name);
+unsigned int rom_used_space(struct rom *rom);
+int rom_exists(struct rom *rom);
+
+#endif

Modified: trunk/coreboot-v2/util/cbfstool/create.c
===================================================================
--- trunk/coreboot-v2/util/romtool/create.c	2009-04-13 21:42:49 UTC (rev 4108)
+++ trunk/coreboot-v2/util/cbfstool/create.c	2009-04-14 00:08:34 UTC (rev 4110)
@@ -1,5 +1,5 @@
 /*
- * romtool
+ * cbfstool
  *
  * Copyright (C) 2008 Jordan Crouse <jordan at cosmicpenguin.net>
  *
@@ -20,7 +20,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include "romtool.h"
+#include "cbfstool.h"
 
 void create_usage(void)
 {

Modified: trunk/coreboot-v2/util/cbfstool/delete.c
===================================================================
--- trunk/coreboot-v2/util/romtool/delete.c	2009-04-13 21:42:49 UTC (rev 4108)
+++ trunk/coreboot-v2/util/cbfstool/delete.c	2009-04-14 00:08:34 UTC (rev 4110)
@@ -1,5 +1,5 @@
 /*
- * romtool
+ * cbfstool
  *
  * Copyright (C) 2008 Jordan Crouse <jordan at cosmicpenguin.net>
  *
@@ -20,7 +20,7 @@
 #include <ctype.h>
 #include <stdlib.h>
 #include <unistd.h>
-#include "romtool.h"
+#include "cbfstool.h"
 
 void delete_usage(void)
 {

Modified: trunk/coreboot-v2/util/cbfstool/fs.c
===================================================================
--- trunk/coreboot-v2/util/romtool/fs.c	2009-04-13 21:42:49 UTC (rev 4108)
+++ trunk/coreboot-v2/util/cbfstool/fs.c	2009-04-14 00:08:34 UTC (rev 4110)
@@ -1,5 +1,5 @@
 /*
- * romtool
+ * cbfstool
  *
  * Copyright (C) 2008 Jordan Crouse <jordan at cosmicpenguin.net>
  *
@@ -18,13 +18,13 @@
  */
 
 #include <string.h>
-#include "romtool.h"
+#include "cbfstool.h"
 
-struct romfs_file *rom_find(struct rom *rom, unsigned int offset)
+struct cbfs_file *rom_find(struct rom *rom, unsigned int offset)
 {
 	while (offset < rom->fssize) {
-		struct romfs_file *c =
-		    (struct romfs_file *)ROM_PTR(rom, offset);
+		struct cbfs_file *c =
+		    (struct cbfs_file *)ROM_PTR(rom, offset);
 
 		if (!strcmp(c->magic, COMPONENT_MAGIC))
 			return c;
@@ -35,12 +35,12 @@
 	return NULL;
 }
 
-struct romfs_file *rom_find_first(struct rom *rom)
+struct cbfs_file *rom_find_first(struct rom *rom)
 {
 	return rom_find(rom, ntohl(rom->header->offset));
 }
 
-struct romfs_file *rom_find_next(struct rom *rom, struct romfs_file *prev)
+struct cbfs_file *rom_find_next(struct rom *rom, struct cbfs_file *prev)
 {
 	unsigned int offset = ROM_OFFSET(rom, prev);
 
@@ -49,15 +49,15 @@
 			      ntohl(rom->header->align)));
 }
 
-struct romfs_file *rom_find_empty(struct rom *rom)
+struct cbfs_file *rom_find_empty(struct rom *rom)
 {
 	unsigned int offset = ntohl(rom->header->offset);
 	unsigned int ret = ntohl(rom->header->offset);
 
 	while (offset < rom->fssize) {
 
-		struct romfs_file *c =
-		    (struct romfs_file *)ROM_PTR(rom, offset);
+		struct cbfs_file *c =
+		    (struct cbfs_file *)ROM_PTR(rom, offset);
 
 		if (!strcmp(c->magic, COMPONENT_MAGIC)) {
 			offset += ALIGN(ntohl(c->offset) + ntohl(c->len),
@@ -69,15 +69,15 @@
 	}
 
 	return (ret < rom->fssize) ?
-	    (struct romfs_file *)ROM_PTR(rom, ret) : NULL;
+	    (struct cbfs_file *)ROM_PTR(rom, ret) : NULL;
 }
 
-struct romfs_file *rom_find_by_name(struct rom *rom, const char *name)
+struct cbfs_file *rom_find_by_name(struct rom *rom, const char *name)
 {
-	struct romfs_file *c = rom_find_first(rom);
+	struct cbfs_file *c = rom_find_first(rom);
 
 	while (c) {
-		if (!strcmp((char *)ROMFS_NAME(c), name))
+		if (!strcmp((char *)CBFS_NAME(c), name))
 			return c;
 
 		c = rom_find_next(rom, c);
@@ -88,7 +88,7 @@
 
 unsigned int rom_used_space(struct rom *rom)
 {
-	struct romfs_file *c = rom_find_first(rom);
+	struct cbfs_file *c = rom_find_first(rom);
 	unsigned int ret = 0;
 
 	while (c) {
@@ -101,8 +101,8 @@
 
 int rom_remove(struct rom *rom, const char *name)
 {
-	struct romfs_file *c = rom_find_by_name(rom, name);
-	struct romfs_file *n;
+	struct cbfs_file *c = rom_find_by_name(rom, name);
+	struct cbfs_file *n;
 	int clear;
 
 	if (c == NULL) {
@@ -126,7 +126,7 @@
 
 int rom_add(struct rom *rom, const char *name, void *buffer, int size, int type)
 {
-	struct romfs_file *c = rom_find_empty(rom);
+	struct cbfs_file *c = rom_find_empty(rom);
 	unsigned int offset;
 	unsigned int csize;
 
@@ -140,7 +140,7 @@
 		return -1;
 	}
 
-	csize = sizeof(struct romfs_file) + ALIGN(strlen(name), 16) + size;
+	csize = sizeof(struct cbfs_file) + ALIGN(strlen(name), 16) + size;
 
 	offset = ROM_OFFSET(rom, c);
 
@@ -154,14 +154,14 @@
 
 	strcpy(c->magic, COMPONENT_MAGIC);
 
-	csize = sizeof(struct romfs_file) + ALIGN(strlen(name) + 1, 16);
+	csize = sizeof(struct cbfs_file) + ALIGN(strlen(name) + 1, 16);
 
 	c->len = htonl(size);
 	c->offset = htonl(csize);
 	c->type = htonl(type);
 
-	memset(ROMFS_NAME(c), 0, ALIGN(strlen(name) + 1, 16));
-	strcpy((char *)ROMFS_NAME(c), name);
+	memset(CBFS_NAME(c), 0, ALIGN(strlen(name) + 1, 16));
+	strcpy((char *)CBFS_NAME(c), name);
 
 	memcpy(((unsigned char *)c) + csize, buffer, size);
 	return 0;

Modified: trunk/coreboot-v2/util/cbfstool/print.c
===================================================================
--- trunk/coreboot-v2/util/romtool/print.c	2009-04-13 21:42:49 UTC (rev 4108)
+++ trunk/coreboot-v2/util/cbfstool/print.c	2009-04-14 00:08:34 UTC (rev 4110)
@@ -1,5 +1,5 @@
 /*
- * romtool
+ * cbfstool
  *
  * Copyright (C) 2008 Jordan Crouse <jordan at cosmicpenguin.net>
  *
@@ -18,7 +18,7 @@
  */
 
 #include <string.h>
-#include "romtool.h"
+#include "cbfstool.h"
 
 void print_usage(void)
 {
@@ -31,7 +31,7 @@
 				ntohl(rom->header->bootblocksize), ntohl(rom->header->romsize), ntohl(rom->header->offset));
 	printf("Alignment: %d bytes\n\n", ntohl(rom->header->align));
 
-	struct romfs_file *c = rom_find_first(rom);
+	struct cbfs_file *c = rom_find_first(rom);
 
 	printf("%-30s Offset     %-12s Size\n", "Name", "Type");
 
@@ -39,13 +39,13 @@
 		char type[12];
 
 		switch (htonl(c->type)) {
-		case ROMFS_COMPONENT_STAGE:
+		case CBFS_COMPONENT_STAGE:
 			strcpy(type, "stage");
 			break;
-		case ROMFS_COMPONENT_PAYLOAD:
+		case CBFS_COMPONENT_PAYLOAD:
 			strcpy(type, "payload");
 			break;
-		case ROMFS_COMPONENT_OPTIONROM:
+		case CBFS_COMPONENT_OPTIONROM:
 			strcpy(type, "optionrom");
 			break;
 		default:
@@ -53,7 +53,7 @@
 			break;
 		}
 
-		printf("%-30s 0x%-8x %-12s %d\n", ROMFS_NAME(c),
+		printf("%-30s 0x%-8x %-12s %d\n", CBFS_NAME(c),
 		       ROM_OFFSET(rom, c), type, htonl(c->len));
 
 		c = rom_find_next(rom, c);

Modified: trunk/coreboot-v2/util/cbfstool/resize.c
===================================================================
--- trunk/coreboot-v2/util/romtool/resize.c	2009-04-13 21:42:49 UTC (rev 4108)
+++ trunk/coreboot-v2/util/cbfstool/resize.c	2009-04-14 00:08:34 UTC (rev 4110)
@@ -1,5 +1,5 @@
 /*
- * romtool
+ * cbfstool
  *
  * Copyright (C) 2008 Jordan Crouse <jordan at cosmicpenguin.net>
  *
@@ -23,7 +23,7 @@
 #include <unistd.h>
 #include <sys/mman.h>
 
-#include "romtool.h"
+#include "cbfstool.h"
 
 void resize_usage(void)
 {
@@ -89,7 +89,7 @@
 	/* We only have to rewrite the entries if the alignment changed */
 
 	if (align != ntohl(rom->header->align)) {
-		struct romfs_file *c;
+		struct cbfs_file *c;
 
 		/* The first entry doesn't have to move */
 
@@ -97,7 +97,7 @@
 		offset = rom->header->offset;
 
 		while (c) {
-			struct romfs_file *n = rom_find_next(rom, c);
+			struct cbfs_file *n = rom_find_next(rom, c);
 			unsigned int next;
 
 			if (n == NULL)
@@ -113,7 +113,7 @@
 			memmove(ROM_PTR(rom, next), n,
 				ntohl(n->offset) + ntohl(n->len));
 
-			c = (struct romfs_file *)ROM_PTR(rom, next);
+			c = (struct cbfs_file *)ROM_PTR(rom, next);
 
 			/* If the previous header wasn't overwritten by the change,
 			   corrupt the header so we don't accidently find it */
@@ -133,7 +133,7 @@
 
 	offset = ROM_READL(rom, size - 12);
 
-	rom->header = (struct romfs_header *)
+	rom->header = (struct cbfs_header *)
 	    ROM_PTR(rom, size - (0xFFFFFFFF - offset) - 1);
 
 	/* Put the new values in the header */

Deleted: trunk/coreboot-v2/util/cbfstool/romfs.h
===================================================================
--- trunk/coreboot-v2/util/romtool/romfs.h	2009-04-13 21:42:49 UTC (rev 4108)
+++ trunk/coreboot-v2/util/cbfstool/romfs.h	2009-04-14 00:08:34 UTC (rev 4110)
@@ -1,129 +0,0 @@
-/*
- * romtool
- *
- * Copyright (C) 2008 Jordan Crouse <jordan at cosmicpenguin.net>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
- */
-
-#ifndef _ROMFS_H_
-#define _ROMFS_H_
-
-/** These are standard values for the known compression
-    alogrithms that coreboot knows about for stages and
-    payloads.  Of course, other LAR users can use whatever
-    values they want, as long as they understand them. */
-
-#define ROMFS_COMPRESS_NONE  0
-#define ROMFS_COMPRESS_LZMA  1
-#define ROMFS_COMPRESS_NRV2B 2
-
-/** These are standard component types for well known
-    components (i.e - those that coreboot needs to consume.
-    Users are welcome to use any other value for their
-    components */
-
-#define ROMFS_COMPONENT_STAGE     0x10
-#define ROMFS_COMPONENT_PAYLOAD   0x20
-#define ROMFS_COMPONENT_OPTIONROM 0x30
-
-#define ROMFS_COMPONENT_NULL 0xFFFFFFFF
-
-/** this is the master romfs header - it need to be
-    located somewhere in the bootblock.  Where it
-    actually lives is up to coreboot. A pointer to
-    this header will live at 0xFFFFFFF4, so we can
-    easily find it. */
-
-#define HEADER_MAGIC 0x4F524243
-
-/* this is a version that gives the right answer in any endian-ness */
-#define VERSION1 0x31313131
-
-struct romfs_header {
-	unsigned int magic;
-	unsigned int version; 
-	unsigned int romsize;
-	unsigned int bootblocksize;
-	unsigned int align;
-	unsigned int offset;
-	unsigned int pad[2];
-} __attribute__ ((packed));
-
-/** This is a component header - every entry in the ROMFS
-    will have this header.
-
-    This is how the component is arranged in the ROM:
-
-    --------------   <- 0
-    component header 
-    --------------   <- sizeof(struct component)
-    component name
-    --------------   <- offset
-    data
-    ...
-    --------------   <- offset + len
-*/
-
-#define COMPONENT_MAGIC "LARCHIVE"
-
-struct romfs_file {
-	char magic[8];
-	unsigned int len;
-	unsigned int type;
-	unsigned int checksum;
-	unsigned int offset;
-} __attribute__ ((packed));
-
-/*** Component sub-headers ***/
-
-/* Following are component sub-headers for the "standard"
-   component types */
-
-/** This is the sub-header for stage components.  Stages are
-    loaded by coreboot during the normal boot process */
-
-struct romfs_stage {
-	unsigned int compression;  /** Compression type */
-	unsigned long long entry;  /** entry point */
-	unsigned long long load;   /** Where to load in memory */
-	unsigned int len;	   /** length of data to load */
-	unsigned int memlen;	   /** total length of object in memory */
-} __attribute__ ((packed));
-
-/** this is the sub-header for payload components.  Payloads
-    are loaded by coreboot at the end of the boot process */
-
-struct romfs_payload_segment {
-	unsigned int type;
-	unsigned int compression;
-	unsigned int offset;
-	unsigned long long load_addr;
-	unsigned int len;
-	unsigned int mem_len;
-} __attribute__ ((packed));
-
-struct romfs_payload {
-	struct romfs_payload_segment segments;
-};
-
-#define PAYLOAD_SEGMENT_CODE   0x45444F43
-#define PAYLOAD_SEGMENT_DATA   0x41544144
-#define PAYLOAD_SEGMENT_BSS    0x20535342
-#define PAYLOAD_SEGMENT_PARAMS 0x41524150
-#define PAYLOAD_SEGMENT_ENTRY  0x52544E45
-
-#define ROMFS_NAME(_c) (((unsigned char *) (_c)) + sizeof(struct romfs_file))
-
-#endif

Deleted: trunk/coreboot-v2/util/cbfstool/romtool.c
===================================================================
--- trunk/coreboot-v2/util/romtool/romtool.c	2009-04-13 21:42:49 UTC (rev 4108)
+++ trunk/coreboot-v2/util/cbfstool/romtool.c	2009-04-14 00:08:34 UTC (rev 4110)
@@ -1,157 +0,0 @@
-/*
- * romtool
- *
- * Copyright (C) 2008 Jordan Crouse <jordan at cosmicpenguin.net>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
- */
-
-/* v2 compat: First, assumes a 64K bootblock. 
- * romtool coreboot.rom create 0x80000 coreboot.strip 
- * romtool coreboot.rom add-payload /tmp/filo.elf payload 
- * romtool coreboot.rom print
- */
-
-
-#include <string.h>
-#include <unistd.h>
-#include <libgen.h>
-#include <sys/mman.h>
-#include "romtool.h"
-
-extern int create_handler(struct rom *, int, char **);
-extern int bootblock_handler(struct rom *, int, char **);
-extern int print_handler(struct rom *, int, char **);
-extern int add_handler(struct rom *, int, char **);
-extern int delete_handler(struct rom *, int, char **);
-extern int resize_handler(struct rom *, int, char **);
-extern int add_payload_handler(struct rom *, int, char **);
-extern int add_stage_handler(struct rom *, int, char **);
-
-extern void create_usage(void);
-extern void bootblock_usage(void);
-extern void print_usage(void);
-extern void add_usage(void);
-extern void delete_usage(void);
-extern void resize_usage(void);
-extern void add_payload_usage(void);
-extern void add_stage_usage(void);
-
-struct {
-	char *command;
-	int (*handler) (struct rom *, int, char **);
-	void (*help) (void);
-} commands[] = {
-	{
-	"add", add_handler, add_usage}, {
-	"add-payload", add_payload_handler, add_payload_usage}, {
-	"add-stage", add_stage_handler, add_stage_usage}, {
-	"bootblock", bootblock_handler, bootblock_usage}, {
-	"create", create_handler, create_usage}, {
-	"delete", delete_handler, delete_usage}, {
-	"print", print_handler, print_usage}, {
-	"resize", resize_handler, resize_usage}, {
-"", NULL},};
-
-static struct rom rom;
-
-char romtool_bindir[255];
-
-void show_help(void)
-{
-	int i;
-
-	printf("romtool [OPTION] [[FILE] [COMMAND] [PARAMETERS]...\n");
-	printf("Apply COMMANDS with PARAMETERS to FILE.  If no COMMAND is\n");
-	printf("given, run in interactive mode\n\n");
-	printf("OPTIONs:\n");
-	printf(" -h\t\tDisplay this help message\n");
-	printf(" -C <dir>\tChange to the directory before operating\n\n");
-	printf("COMMANDs:\n");
-
-	for (i = 0; commands[i].handler != NULL; i++)
-		commands[i].help();
-}
-
-int main(int argc, char **argv)
-{
-	char *cdir = NULL;
-	char *rname;
-	char *cmd;
-	int ret = -1, i;
-
-	strncpy(romtool_bindir, dirname(argv[0]), 254);
-
-	while (1) {
-		signed ch = getopt(argc, argv, "hC:");
-		if (ch == -1)
-			break;
-		switch (ch) {
-		case 'h':
-			show_help();
-			return -1;
-		case 'C':
-			cdir = optarg;
-			break;
-		}
-	}
-
-	if (optind >= argc) {
-		show_help();
-		return -1;
-	}
-
-	if (cdir != NULL && chdir(cdir)) {
-		ERROR("Unable to switch to %s: %m\n", cdir);
-		return -1;
-	}
-
-	rname = argv[optind];
-	cmd = optind + 1 < argc ? argv[optind + 1] : NULL;
-
-	/* Open the ROM (if it exists) */
-	rom.name = (unsigned char *)strdup(rname);
-
-	if (!access(rname, F_OK)) {
-		if (open_rom(&rom, rname)) {
-			ERROR("Problem while reading the ROM\n");
-			return -1;
-		}
-	}
-
-	if (cmd) {
-		/* Process the incoming comand */
-
-		for (i = 0; commands[i].handler != NULL; i++) {
-			if (!strcmp(commands[i].command, cmd)) {
-				ret = commands[i].handler(&rom,
-							  argc - 3, &argv[3]);
-				goto leave;
-			}
-		}
-
-		ERROR("Command %s not valid\n", cmd);
-	} else {
-		printf("Interactive mode not ready yet!\n");
-	}
-
-leave:
-	if (rom.ptr != NULL && rom.ptr != MAP_FAILED)
-		munmap(rom.ptr, rom.size);
-
-	if (rom.fd > 0)
-		close(rom.fd);
-
-	return ret;
-}

Deleted: trunk/coreboot-v2/util/cbfstool/romtool.h
===================================================================
--- trunk/coreboot-v2/util/romtool/romtool.h	2009-04-13 21:42:49 UTC (rev 4108)
+++ trunk/coreboot-v2/util/cbfstool/romtool.h	2009-04-14 00:08:34 UTC (rev 4110)
@@ -1,77 +0,0 @@
-/*
- * romtool
- *
- * Copyright (C) 2008 Jordan Crouse <jordan at cosmicpenguin.net>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
- */
-
-#ifndef _ROMTOOL_H_
-#define _ROMTOOL_H_
-
-#include <stdio.h>
-#include <arpa/inet.h>
-#include "romfs.h"
-
-/* Definitions */
-
-/* Structures */
-
-struct rom {
-	unsigned char *name;
-	unsigned char *ptr;
-
-	int fd;
-	int size;
-	int fssize;
-
-	struct romfs_header *header;
-};
-
-/* Macros */
-
-#define ROM_OFFSET(_r, _c) ((unsigned int) ((unsigned char *) (_c) - (_r)->ptr))
-
-#define ROM_PTR(_r, _o) ((_r)->ptr + (_o))
-#define ROM_WRITEL(_r, _o, _v) do { *((unsigned int *) ROM_PTR((_r), (_o))) = (_v); } while(0)
-#define ROM_READL(_r, _o) *((unsigned int *) (ROM_PTR((_r), (_o))))
-
-#define ERROR(err, args...) fprintf(stderr, "(romtool) E: " err, ##args)
-#define WARN(err, args...) fprintf(stderr, "(romtool) W: " err, ##args)
-#define VERBOSE(str, args...) printf(str, ##args)
-
-#define ALIGN(_v, _a) ( ( (_v) + ( (_a) - 1 ) ) & ~( (_a) - 1 ) )
-
-/* Function prototypes */
-
-/* util.c */
-int open_rom(struct rom *rom, const char *filename);
-int create_rom(struct rom *rom, const unsigned char *filename, int size,
-	int bootblocksize,  int align);
-int size_and_open(const char *filename, unsigned int *size);
-int copy_from_fd(int fd, void *ptr, int size);
-int get_size(const char *size);
-int add_bootblock(struct rom *rom, const char *filename);
-
-/* fs.c */
-
-struct romfs_file *rom_find(struct rom *rom, unsigned int offset);
-struct romfs_file *rom_find_first(struct rom *);
-struct romfs_file *rom_find_next(struct rom *, struct romfs_file *);
-int rom_add(struct rom *rom, const char *name, void *, int size, int type);
-int rom_remove(struct rom *rom, const char *name);
-unsigned int rom_used_space(struct rom *rom);
-int rom_exists(struct rom *rom);
-
-#endif

Modified: trunk/coreboot-v2/util/cbfstool/tools/common.c
===================================================================
--- trunk/coreboot-v2/util/romtool/tools/common.c	2009-04-13 21:42:49 UTC (rev 4108)
+++ trunk/coreboot-v2/util/cbfstool/tools/common.c	2009-04-14 00:08:34 UTC (rev 4110)
@@ -1,5 +1,5 @@
 /*
- * romtool
+ * cbfstool
  *
  * Copyright (C) 2008 Jordan Crouse <jordan at cosmicpenguin.net>
  *

Modified: trunk/coreboot-v2/util/cbfstool/tools/common.h
===================================================================
--- trunk/coreboot-v2/util/romtool/tools/common.h	2009-04-13 21:42:49 UTC (rev 4108)
+++ trunk/coreboot-v2/util/cbfstool/tools/common.h	2009-04-14 00:08:34 UTC (rev 4110)
@@ -1,5 +1,5 @@
 /*
- * romtool
+ * cbfstool
  *
  * Copyright (C) 2008 Jordan Crouse <jordan at cosmicpenguin.net>
  *

Modified: trunk/coreboot-v2/util/cbfstool/tools/compress.c
===================================================================
--- trunk/coreboot-v2/util/romtool/tools/compress.c	2009-04-13 21:42:49 UTC (rev 4108)
+++ trunk/coreboot-v2/util/cbfstool/tools/compress.c	2009-04-14 00:08:34 UTC (rev 4110)
@@ -1,5 +1,5 @@
 /*
- * romtool
+ * cbfstool
  *
  * Copyright (C) 2008 Jordan Crouse <jordan at cosmicpenguin.net>
  *

Modified: trunk/coreboot-v2/util/cbfstool/tools/lzma/C/ORIGIN
===================================================================
--- trunk/coreboot-v2/util/romtool/tools/lzma/C/ORIGIN	2009-04-13 21:42:49 UTC (rev 4108)
+++ trunk/coreboot-v2/util/cbfstool/tools/lzma/C/ORIGIN	2009-04-14 00:08:34 UTC (rev 4110)
@@ -1,3 +1,3 @@
 The contents of this directory are extracted from
 the official LZMA SDK, version lzma442.tar.bz2 ,
-for the use in mkcromfs.
+for the use in mkccbfs.

Modified: trunk/coreboot-v2/util/cbfstool/tools/rom-mkpayload.c
===================================================================
--- trunk/coreboot-v2/util/romtool/tools/rom-mkpayload.c	2009-04-13 21:42:49 UTC (rev 4108)
+++ trunk/coreboot-v2/util/cbfstool/tools/rom-mkpayload.c	2009-04-14 00:08:34 UTC (rev 4110)
@@ -28,7 +28,7 @@
 #include <arpa/inet.h>
 
 #include "common.h"
-#include "../romfs.h"
+#include "../cbfs.h"
 
 int parse_elf(unsigned char *input, unsigned char **output, int algo,
 	      void (*compress) (char *, int, char *, int *))
@@ -43,7 +43,7 @@
 	int segments = 1;
 	int isize = 0, osize = 0;
 	int doffset = 0;
-	struct romfs_payload_segment *segs;
+	struct cbfs_payload_segment *segs;
 	int i;
 
 	ehdr = (Elf32_Ehdr *) input;
@@ -93,14 +93,14 @@
 	/* Allocate a block of memory to store the data in */
 
 	sptr =
-	    calloc((segments * sizeof(struct romfs_payload_segment)) + isize,
+	    calloc((segments * sizeof(struct cbfs_payload_segment)) + isize,
 		   1);
-	doffset = (segments * sizeof(struct romfs_payload_segment));
+	doffset = (segments * sizeof(struct cbfs_payload_segment));
 
 	if (sptr == NULL)
 		goto err;
 
-	segs = (struct romfs_payload_segment *)sptr;
+	segs = (struct cbfs_payload_segment *)sptr;
 	segments = 0;
 
 	for (i = 0; i < ehdr->e_shnum; i++) {
@@ -182,7 +182,7 @@
 
 	*output = sptr;
 
-	return (segments * sizeof(struct romfs_payload_segment)) + osize;
+	return (segments * sizeof(struct cbfs_payload_segment)) + osize;
 
 err:
 	return -1;
@@ -218,10 +218,10 @@
 			output = optarg;
 			break;
 		case 'l':
-			algo = ROMFS_COMPRESS_LZMA;
+			algo = CBFS_COMPRESS_LZMA;
 			break;
 		case 'n':
-			algo = ROMFS_COMPRESS_NONE;
+			algo = CBFS_COMPRESS_NONE;
 			break;
 		default:
 			//usage();
@@ -245,10 +245,10 @@
 	}
 
 	switch (algo) {
-	case ROMFS_COMPRESS_NONE:
+	case CBFS_COMPRESS_NONE:
 		compress = none_compress;
 		break;
-	case ROMFS_COMPRESS_LZMA:
+	case CBFS_COMPRESS_LZMA:
 		compress = lzma_compress;
 		break;
 	}

Modified: trunk/coreboot-v2/util/cbfstool/tools/rom-mkstage.c
===================================================================
--- trunk/coreboot-v2/util/romtool/tools/rom-mkstage.c	2009-04-13 21:42:49 UTC (rev 4108)
+++ trunk/coreboot-v2/util/cbfstool/tools/rom-mkstage.c	2009-04-14 00:08:34 UTC (rev 4110)
@@ -27,7 +27,7 @@
 #include <sys/stat.h>
 
 #include "common.h"
-#include "../romfs.h"
+#include "../cbfs.h"
 
 int parse_elf(unsigned char *input, unsigned char **output,
 	      int mode, void (*compress) (char *, int, char *, int *))
@@ -40,7 +40,7 @@
 
 	int headers;
 	int i;
-	struct romfs_stage *stage;
+	struct cbfs_stage *stage;
 	unsigned int data_start, data_end, mem_end;
 
 	headers = ehdr->e_phnum;
@@ -107,14 +107,14 @@
 	}
 
 	/* Now make the output buffer */
-	out = calloc(sizeof(struct romfs_stage) + data_end - data_start, 1);
+	out = calloc(sizeof(struct cbfs_stage) + data_end - data_start, 1);
 
 	if (out == NULL) {
 		fprintf(stderr, "E: Unable to allocate memory: %m\n");
 		return -1;
 	}
 
-	stage = (struct romfs_stage *)out;
+	stage = (struct cbfs_stage *)out;
 
 	stage->load = data_start;
 	stage->memlen = mem_end - data_start;
@@ -122,18 +122,18 @@
 	stage->entry = ehdr->e_entry;
 
 	compress(buffer, data_end - data_start,
-		 (char *)(out + sizeof(struct romfs_stage)),
+		 (char *)(out + sizeof(struct cbfs_stage)),
 		 (int *)&stage->len);
 
 	*output = out;
 
-	return sizeof(struct romfs_stage) + stage->len;
+	return sizeof(struct cbfs_stage) + stage->len;
 }
 
 int main(int argc, char **argv)
 {
 	void (*compress) (char *, int, char *, int *);
-	int algo = ROMFS_COMPRESS_LZMA;
+	int algo = CBFS_COMPRESS_LZMA;
 
 	char *output = NULL;
 	char *input = NULL;
@@ -160,10 +160,10 @@
 			output = optarg;
 			break;
 		case 'l':
-			algo = ROMFS_COMPRESS_LZMA;
+			algo = CBFS_COMPRESS_LZMA;
 			break;
 		case 'n':
-			algo = ROMFS_COMPRESS_NONE;
+			algo = CBFS_COMPRESS_NONE;
 			break;
 		default:
 			//usage();
@@ -185,10 +185,10 @@
 	}
 
 	switch (algo) {
-	case ROMFS_COMPRESS_NONE:
+	case CBFS_COMPRESS_NONE:
 		compress = none_compress;
 		break;
-	case ROMFS_COMPRESS_LZMA:
+	case CBFS_COMPRESS_LZMA:
 		compress = lzma_compress;
 		break;
 	}

Modified: trunk/coreboot-v2/util/cbfstool/types.c
===================================================================
--- trunk/coreboot-v2/util/romtool/types.c	2009-04-13 21:42:49 UTC (rev 4108)
+++ trunk/coreboot-v2/util/cbfstool/types.c	2009-04-14 00:08:34 UTC (rev 4110)
@@ -1,5 +1,5 @@
 /*
- * romtool
+ * cbfstool
  *
  * Copyright (C) 2008 Jordan Crouse <jordan at cosmicpenguin.net>
  *
@@ -18,7 +18,7 @@
  */
 
 #include <string.h>
-#include "romtool.h"
+#include "cbfstool.h"
 
 static const struct {
 	char *type;

Modified: trunk/coreboot-v2/util/cbfstool/util.c
===================================================================
--- trunk/coreboot-v2/util/romtool/util.c	2009-04-13 21:42:49 UTC (rev 4108)
+++ trunk/coreboot-v2/util/cbfstool/util.c	2009-04-14 00:08:34 UTC (rev 4110)
@@ -1,5 +1,5 @@
 /*
- * romtool
+ * cbfstool
  *
  * Copyright (C) 2008 Jordan Crouse <jordan at cosmicpenguin.net>
  *
@@ -23,7 +23,7 @@
 #include <fcntl.h>
 #include <sys/stat.h>
 #include <sys/mman.h>
-#include "romtool.h"
+#include "cbfstool.h"
 
 int get_size(const char *size)
 {
@@ -127,7 +127,7 @@
 
 	offset = ROM_READL(rom, s.st_size - 4);
 
-	rom->header = (struct romfs_header *)
+	rom->header = (struct cbfs_header *)
 	    ROM_PTR(rom, s.st_size - (0xFFFFFFFF - offset) - 1);
 
 	if (ntohl(rom->header->magic) != HEADER_MAGIC) {
@@ -205,11 +205,11 @@
 	memset(rom->ptr + rom->size - 16, 0, 16);
 
 	ROM_WRITEL(rom, rom->size - 4,
-		   0xFFFFFFF0 - sizeof(struct romfs_header));
+		   0xFFFFFFF0 - sizeof(struct cbfs_header));
 
 	/* This is a pointer to the header for easy access */
-	rom->header = (struct romfs_header *)
-	    ROM_PTR(rom, rom->size - 16 - sizeof(struct romfs_header));
+	rom->header = (struct cbfs_header *)
+	    ROM_PTR(rom, rom->size - 16 - sizeof(struct cbfs_header));
 
 	rom->header->magic = htonl(HEADER_MAGIC);
 	rom->header->romsize = htonl(romsize);
@@ -226,7 +226,7 @@
 	//unsigned int offset;
 	int fd = size_and_open(filename, &size);
 	int ret;
-	struct romfs_header tmp;
+	struct cbfs_header tmp;
 
 	if (fd == -1)
 		return -1;
@@ -238,7 +238,7 @@
 	}
 
 	/* Copy the current header into a temporary buffer */
-	memcpy(&tmp, rom->header, sizeof(struct romfs_header));
+	memcpy(&tmp, rom->header, sizeof(struct cbfs_header));
 
 	/* Copy the bootblock into place at the end of the file */
 
@@ -254,22 +254,22 @@
 	/* FIXME: This should point to a location defined by coreboot */
 
 	ROM_WRITEL(rom, rom->size - 4,
-		   0xFFFFFFF0 - sizeof(struct romfs_header));
+		   0xFFFFFFF0 - sizeof(struct cbfs_header));
 
 	/* This is a pointer to the header for easy access */
-	rom->header = (struct romfs_header *)
-	    ROM_PTR(rom, rom->size - 16 - sizeof(struct romfs_header));
+	rom->header = (struct cbfs_header *)
+	    ROM_PTR(rom, rom->size - 16 - sizeof(struct cbfs_header));
 
 #if 0
 	/* Figure out the new location for the header */
 	offset = ROM_READL(rom, rom->size - 4);
 
-	rom->header = (struct romfs_header *)
+	rom->header = (struct cbfs_header *)
 	    ROM_PTR(rom, offset - (0xFFFFFFFF - rom->size));
 #endif
 
 	/* Replace the LAR header */
-	memcpy(rom->header, &tmp, sizeof(struct romfs_header));
+	memcpy(rom->header, &tmp, sizeof(struct cbfs_header));
 
 	return 0;
 }





More information about the coreboot mailing list