Skip to contentSkip to conversation

Add a CBFS driver and commands to u-boot

PATCH Superseded Gabe Black 4 participants 13 messages Dec 3, 2011 – Jan 8, 2012

Subsystems (2)
lore
Share & tools
lore

Gabe Black

author
#0 lore raw

PATCH 1/1 Add a CBFS driver and commands to u-boot

Coreboot uses a very simple "file system" called CBFS to keep track of and allow access to multiple "files" in a ROM image. This change adds CBFS support and some commands to use it to u-boot. These commands are:

cbfsinit - Initialize CBFS support and pull all metadata into RAM. The end of the ROM is an optional parameter which defaults to the standard 0xffffffff and can be used to support multiple CBFSes in a system. The last one set up with cbfsinit is the one that will be used.

cbfsinfo - Print information from the CBFS header.

cbfsls - Print out the size, type, and name of all the files in the current CBFS. Recognized types are translated into symbolic names.

cbfsload - Load a file from CBFS into memory. Like the similar command for fat filesystems, you can optionally provide a maximum size.

Also, if u-boot needs something out of CBFS very early before the heap is configured, it won't be able to use the normal CBFS support which caches some information in memory it allocates from the heap. This change adds a new cbfs_file_find_uncached function which searchs a CBFS instance without touching the heap.

Support for CBFS is compiled in when the CONFIG_CMD_CBFS option is specified.

---
 Makefile          |    6 +-
 README            |    1 +
 common/Makefile   |    1 +
 common/cmd_cbfs.c |  212 ++++++++++++++++++++++++++++++++
 fs/Makefile       |    1 +
 fs/cbfs/Makefile  |   44 +++++++
 fs/cbfs/cbfs.c    |  351 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/cbfs.h    |  163 +++++++++++++++++++++++++
 8 files changed, 776 insertions(+), 3 deletions(-)
 create mode 100644 common/cmd_cbfs.c
 create mode 100644 fs/cbfs/Makefile
 create mode 100644 fs/cbfs/cbfs.c
 create mode 100644 include/cbfs.h
Makefile +3 -3
index d84b350..e1e2ff1 100644
@@ -234,9 +234,9 @@ ifeq ($(CONFIG_OF_EMBED),y)
 LIBS += dts/libdts.o
 endif
 LIBS += arch/$(ARCH)/lib/lib$(ARCH).o
-LIBS += fs/cramfs/libcramfs.o fs/fat/libfat.o fs/fdos/libfdos.o fs/jffs2/libjffs2.o \
-	fs/reiserfs/libreiserfs.o fs/ext2/libext2fs.o fs/yaffs2/libyaffs2.o \
-	fs/ubifs/libubifs.o
+LIBS += fs/cramfs/libcramfs.o fs/fat/libfat.o fs/fdos/libfdos.o \
+	fs/jffs2/libjffs2.o fs/reiserfs/libreiserfs.o fs/ext2/libext2fs.o \
+	fs/yaffs2/libyaffs2.o fs/ubifs/libubifs.o fs/cbfs/libcbfs.o
 LIBS += net/libnet.o
 LIBS += disk/libdisk.o
 LIBS += drivers/bios_emulator/libatibiosemu.o
README +1 -0
index fda0190..b878c4b 100644
@@ -721,6 +721,7 @@ The following options need to be configured:
 		CONFIG_CMD_BSP		* Board specific commands
 		CONFIG_CMD_BOOTD	  bootd
 		CONFIG_CMD_CACHE	* icache, dcache
+		CONFIG_CMD_CBFS		* Support for coreboot's CBFS
 		CONFIG_CMD_CONSOLE	  coninfo
 		CONFIG_CMD_CRC32	* crc32
 		CONFIG_CMD_DATE		* support for RTC, date/time...
common/Makefile +1 -0
index 1b672ad..6cfba67 100644
@@ -89,6 +89,7 @@ COBJS-$(CONFIG_ENV_IS_IN_EEPROM) += cmd_eeprom.o
 COBJS-$(CONFIG_CMD_EEPROM) += cmd_eeprom.o
 COBJS-$(CONFIG_CMD_ELF) += cmd_elf.o
 COBJS-$(CONFIG_SYS_HUSH_PARSER) += cmd_exit.o
+COBJS-$(CONFIG_CMD_CBFS) += cmd_cbfs.o
 COBJS-$(CONFIG_CMD_EXT2) += cmd_ext2.o
 COBJS-$(CONFIG_CMD_FAT) += cmd_fat.o
 COBJS-$(CONFIG_CMD_FDC)$(CONFIG_CMD_FDOS) += cmd_fdc.o
common/cmd_cbfs.c new file +212 -0

212 lines not on this page · raw message

fs/Makefile +1 -0
index 22aad12..ca21464 100644
@@ -23,6 +23,7 @@
 #
 
 subdirs-$(CONFIG_CMD_CRAMFS) := cramfs
+subdirs-$(CONFIG_CMD_CBFS) += cbfs
 subdirs-$(CONFIG_CMD_EXT2) += ext2
 subdirs-$(CONFIG_CMD_FAT) += fat
 subdirs-$(CONFIG_CMD_FDOS) += fdos
fs/cbfs/Makefile new file +44 -0

44 lines not on this page · raw message

fs/cbfs/cbfs.c new file +351 -0

351 lines not on this page · raw message

include/cbfs.h new file +163 -0

163 lines not on this page · raw message

Signature · 1 line
1.7.3.1
#1 lore raw

PATCH 1/1 Add a CBFS driver and commands to u-boot

Dear Gabe Black,

Quoted 23 lines · In message <[email protected]> you wrote:

Coreboot uses a very simple "file system" called CBFS to keep track of and allow access to multiple "files" in a ROM image. This change adds CBFS support and some commands to use it to u-boot. These commands are:

cbfsinit - Initialize CBFS support and pull all metadata into RAM. The end of the ROM is an optional parameter which defaults to the standard 0xffffffff and can be used to support multiple CBFSes in a system. The last one set up with cbfsinit is the one that will be used.

cbfsinfo - Print information from the CBFS header.

cbfsls - Print out the size, type, and name of all the files in the current CBFS. Recognized types are translated into symbolic names.

cbfsload - Load a file from CBFS into memory. Like the similar command for fat filesystems, you can optionally provide a maximum size.

Also, if u-boot needs something out of CBFS very early before the heap is configured, it won't be able to use the normal CBFS support which caches some information in memory it allocates from the heap. This change adds a new cbfs_file_find_uncached function which searchs a CBFS instance without touching the heap.

Quoted 3 lines

Support for CBFS is compiled in when the CONFIG_CMD_CBFS option is specified.

Checkpatch reports 2 errors, 15 warnings

Please clean up and resubmit.

Also, please use puts() instead of printf() when you have constant strings without formatting.

And fix your identifiers: CamelCaps identifiers are not allowed in U-Boot.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The human race is faced with a cruel choice: work  or  daytime  tele-
vision.
#2 lore raw

PATCH 1/1 Add a CBFS driver and commands to u-boot

Quoted 33 lines · Wolfgang Denk

Dear Gabe Black,

In message <[email protected]> you

Quoted 1 line · wrote:

Coreboot uses a very simple "file system" called CBFS to keep track of

and

Quoted 4 lines

allow access to multiple "files" in a ROM image. This change adds CBFS support and some commands to use it to u-boot. These commands are:

cbfsinit - Initialize CBFS support and pull all metadata into RAM. The

end of

Quoted 1 line

the ROM is an optional parameter which defaults to the standard

0xffffffff and

Quoted 1 line

can be used to support multiple CBFSes in a system. The last one set up

with

Quoted 5 lines

cbfsinit is the one that will be used.

cbfsinfo - Print information from the CBFS header.

cbfsls - Print out the size, type, and name of all the files in the

current

Quoted 3 lines

CBFS. Recognized types are translated into symbolic names.

cbfsload - Load a file from CBFS into memory. Like the similar command

for fat

Quoted 4 lines

filesystems, you can optionally provide a maximum size.

Also, if u-boot needs something out of CBFS very early before the heap is configured, it won't be able to use the normal CBFS support which caches

some

Quoted 2 lines

information in memory it allocates from the heap. This change adds a new cbfs_file_find_uncached function which searchs a CBFS instance without

touching

Quoted 9 lines
Quoted 3 lines

the heap.

Support for CBFS is compiled in when the CONFIG_CMD_CBFS option is

specified.

Quoted 2 lines

Checkpatch reports 2 errors, 15 warnings

A few of these are checkpatch getting confused by inline assembly, but I'll fix up the rest and the things below.

Quoted 20 lines

Please clean up and resubmit.

Also, please use puts() instead of printf() when you have constant strings without formatting.

And fix your identifiers: CamelCaps identifiers are not allowed in U-Boot.

Best regards,

Wolfgang Denk

--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de The human race is faced with a cruel choice: work or daytime tele- vision.

#3 lore raw

PATCH 1/1 Add a CBFS driver and commands to u-boot

Quoted 43 lines · Gabe Black
Quoted 39 lines · Wolfgang Denk

Dear Gabe Black,

In message <[email protected]>

Quoted 1 line · you

Coreboot uses a very simple "file system" called CBFS to keep track of

and

Quoted 4 lines

allow access to multiple "files" in a ROM image. This change adds CBFS support and some commands to use it to u-boot. These commands are:

cbfsinit - Initialize CBFS support and pull all metadata into RAM. The

end of

Quoted 1 line

the ROM is an optional parameter which defaults to the standard

0xffffffff and

Quoted 1 line

can be used to support multiple CBFSes in a system. The last one set up

with

Quoted 5 lines

cbfsinit is the one that will be used.

cbfsinfo - Print information from the CBFS header.

cbfsls - Print out the size, type, and name of all the files in the

current

Quoted 3 lines

CBFS. Recognized types are translated into symbolic names.

cbfsload - Load a file from CBFS into memory. Like the similar command

for fat

Quoted 3 lines

filesystems, you can optionally provide a maximum size.

Also, if u-boot needs something out of CBFS very early before the heap

is

Quoted 1 line

configured, it won't be able to use the normal CBFS support which

caches some

Quoted 2 lines

information in memory it allocates from the heap. This change adds a new cbfs_file_find_uncached function which searchs a CBFS instance without

touching

Quoted 3 lines

the heap.

Support for CBFS is compiled in when the CONFIG_CMD_CBFS option is

specified.

Quoted 1 line
Quoted 10 lines
Quoted 4 lines
Quoted 1 line

Checkpatch reports 2 errors, 15 warnings

A few of these are checkpatch getting confused by inline assembly, but I'll fix up the rest and the things below.

Oops, wrong patch series. There's no inline assembly in this one.

Gabe

author
#4 lore raw

PATCH v2 1/1 Add a CBFS driver and commands to u-boot

In reply to Wolfgang Denk

Coreboot uses a very simple "file system" called CBFS to keep track of and allow access to multiple "files" in a ROM image. This change adds CBFS support and some commands to use it to u-boot. These commands are:

cbfsinit - Initialize CBFS support and pull all metadata into RAM. The end of the ROM is an optional parameter which defaults to the standard 0xffffffff and can be used to support multiple CBFSes in a system. The last one set up with cbfsinit is the one that will be used.

cbfsinfo - Print information from the CBFS header.

cbfsls - Print out the size, type, and name of all the files in the current CBFS. Recognized types are translated into symbolic names.

cbfsload - Load a file from CBFS into memory. Like the similar command for fat filesystems, you can optionally provide a maximum size.

Also, if u-boot needs something out of CBFS very early before the heap is configured, it won't be able to use the normal CBFS support which caches some information in memory it allocates from the heap. This change adds a new cbfs_file_find_uncached function which searchs a CBFS instance without touching the heap.

Support for CBFS is compiled in when the CONFIG_CMD_CBFS option is specified.

---
Changes in v2:
Fix checkpatch problems, change around identifiers, and change printf to puts where possible.

 Makefile          |    6 +-
 README            |    1 +
 common/Makefile   |    1 +
 common/cmd_cbfs.c |  212 ++++++++++++++++++++++++++++++++
 fs/Makefile       |    1 +
 fs/cbfs/Makefile  |   44 +++++++
 fs/cbfs/cbfs.c    |  354 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/cbfs.h    |  164 +++++++++++++++++++++++++
 8 files changed, 780 insertions(+), 3 deletions(-)
 create mode 100644 common/cmd_cbfs.c
 create mode 100644 fs/cbfs/Makefile
 create mode 100644 fs/cbfs/cbfs.c
 create mode 100644 include/cbfs.h
Makefile +3 -3
index d84b350..e1e2ff1 100644
@@ -234,9 +234,9 @@ ifeq ($(CONFIG_OF_EMBED),y)
 LIBS += dts/libdts.o
 endif
 LIBS += arch/$(ARCH)/lib/lib$(ARCH).o
-LIBS += fs/cramfs/libcramfs.o fs/fat/libfat.o fs/fdos/libfdos.o fs/jffs2/libjffs2.o \
-	fs/reiserfs/libreiserfs.o fs/ext2/libext2fs.o fs/yaffs2/libyaffs2.o \
-	fs/ubifs/libubifs.o
+LIBS += fs/cramfs/libcramfs.o fs/fat/libfat.o fs/fdos/libfdos.o \
+	fs/jffs2/libjffs2.o fs/reiserfs/libreiserfs.o fs/ext2/libext2fs.o \
+	fs/yaffs2/libyaffs2.o fs/ubifs/libubifs.o fs/cbfs/libcbfs.o
 LIBS += net/libnet.o
 LIBS += disk/libdisk.o
 LIBS += drivers/bios_emulator/libatibiosemu.o
README +1 -0
index fda0190..b878c4b 100644
@@ -721,6 +721,7 @@ The following options need to be configured:
 		CONFIG_CMD_BSP		* Board specific commands
 		CONFIG_CMD_BOOTD	  bootd
 		CONFIG_CMD_CACHE	* icache, dcache
+		CONFIG_CMD_CBFS		* Support for coreboot's CBFS
 		CONFIG_CMD_CONSOLE	  coninfo
 		CONFIG_CMD_CRC32	* crc32
 		CONFIG_CMD_DATE		* support for RTC, date/time...
common/Makefile +1 -0
index 1b672ad..6cfba67 100644
@@ -89,6 +89,7 @@ COBJS-$(CONFIG_ENV_IS_IN_EEPROM) += cmd_eeprom.o
 COBJS-$(CONFIG_CMD_EEPROM) += cmd_eeprom.o
 COBJS-$(CONFIG_CMD_ELF) += cmd_elf.o
 COBJS-$(CONFIG_SYS_HUSH_PARSER) += cmd_exit.o
+COBJS-$(CONFIG_CMD_CBFS) += cmd_cbfs.o
 COBJS-$(CONFIG_CMD_EXT2) += cmd_ext2.o
 COBJS-$(CONFIG_CMD_FAT) += cmd_fat.o
 COBJS-$(CONFIG_CMD_FDC)$(CONFIG_CMD_FDOS) += cmd_fdc.o
common/cmd_cbfs.c new file +212 -0

212 lines not on this page · raw message

fs/Makefile +1 -0
index 22aad12..ca21464 100644
@@ -23,6 +23,7 @@
 #
 
 subdirs-$(CONFIG_CMD_CRAMFS) := cramfs
+subdirs-$(CONFIG_CMD_CBFS) += cbfs
 subdirs-$(CONFIG_CMD_EXT2) += ext2
 subdirs-$(CONFIG_CMD_FAT) += fat
 subdirs-$(CONFIG_CMD_FDOS) += fdos
fs/cbfs/Makefile new file +44 -0

44 lines not on this page · raw message

fs/cbfs/cbfs.c new file +354 -0

354 lines not on this page · raw message

include/cbfs.h new file +164 -0

164 lines not on this page · raw message

Signature · 1 line
1.7.3.1
#5 lore raw

PATCH v2 1/1 Add a CBFS driver and commands to u-boot

Dear Gabe Black,

Quoted 23 lines · In message <[email protected]> you wrote:

Coreboot uses a very simple "file system" called CBFS to keep track of and allow access to multiple "files" in a ROM image. This change adds CBFS support and some commands to use it to u-boot. These commands are:

cbfsinit - Initialize CBFS support and pull all metadata into RAM. The end of the ROM is an optional parameter which defaults to the standard 0xffffffff and can be used to support multiple CBFSes in a system. The last one set up with cbfsinit is the one that will be used.

cbfsinfo - Print information from the CBFS header.

cbfsls - Print out the size, type, and name of all the files in the current CBFS. Recognized types are translated into symbolic names.

cbfsload - Load a file from CBFS into memory. Like the similar command for fat filesystems, you can optionally provide a maximum size.

Also, if u-boot needs something out of CBFS very early before the heap is configured, it won't be able to use the normal CBFS support which caches some information in memory it allocates from the heap. This change adds a new cbfs_file_find_uncached function which searchs a CBFS instance without touching the heap.

Quoted 8 lines

Support for CBFS is compiled in when the CONFIG_CMD_CBFS option is specified.

---
Changes in v2:
Fix checkpatch problems, change around identifiers, and change printf to puts where possible.

There is still a checkpatch warning that should be fixed:

WARNING: do not add new typedefs
#853: FILE: include/cbfs.h:61:
+typedef const struct cbfs_cache_node *cbfs_file;

Makefile ifeq ($(CONFIG_OF_EMBED),y) · line 239

Quoted 12 lines
Makefile +3 -3
@@ -234,9 +234,9 @@ ifeq ($(CONFIG_OF_EMBED),y)
 LIBS += dts/libdts.o
 endif
 LIBS += arch/$(ARCH)/lib/lib$(ARCH).o
-LIBS += fs/cramfs/libcramfs.o fs/fat/libfat.o fs/fdos/libfdos.o fs/jffs2/libjffs2.o \
-	fs/reiserfs/libreiserfs.o fs/ext2/libext2fs.o fs/yaffs2/libyaffs2.o \
-	fs/ubifs/libubifs.o
+LIBS += fs/cramfs/libcramfs.o fs/fat/libfat.o fs/fdos/libfdos.o \
+	fs/jffs2/libjffs2.o fs/reiserfs/libreiserfs.o fs/ext2/libext2fs.o \
+	fs/yaffs2/libyaffs2.o fs/ubifs/libubifs.o fs/cbfs/libcbfs.o

Please keep the list sorted. [It may make sense to split it into a list of entries with one FS per line.]

common/Makefile COBJS-$(CONFIG_ENV_IS_IN_EEPROM) += cmd_eeprom.o · line 95

Quoted 10 lines
common/Makefile +1 -0
@@ -89,6 +89,7 @@ COBJS-$(CONFIG_ENV_IS_IN_EEPROM) += cmd_eeprom.o
 COBJS-$(CONFIG_CMD_EEPROM) += cmd_eeprom.o
 COBJS-$(CONFIG_CMD_ELF) += cmd_elf.o
 COBJS-$(CONFIG_SYS_HUSH_PARSER) += cmd_exit.o
+COBJS-$(CONFIG_CMD_CBFS) += cmd_cbfs.o
 COBJS-$(CONFIG_CMD_EXT2) += cmd_ext2.o
 COBJS-$(CONFIG_CMD_FAT) += cmd_fat.o
 COBJS-$(CONFIG_CMD_FDC)$(CONFIG_CMD_FDOS) += cmd_fdc.o

Please keep sorted (by object file names).

common/Makefile

Quoted 7 lines
common/Makefile +7 -0
+int do_cbfs_init(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
+{
+	uintptr_t end_of_rom = 0xffffffff;
+	char *ep;
+
+	if (argc > 2) {
+		puts("usage: cbfsls [end of rom]>\n");

What is the meaning / intention of that tailing '>' ?

common/Makefile

Quoted 2 lines
common/Makefile +2 -0
+	if (file_cbfs_result != CBFS_SUCCESS) {
+		printf("%s.\n", file_cbfs_error());

Use

		puts(file_cbfs_error());

?

Quoted 2 lines
common/Makefile +2 -0
+int do_cbfs_fsload(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
+{

...

common/Makefile

Quoted 5 lines
common/Makefile +5 -0
+	if (!file) {
+		if (file_cbfs_result == CBFS_FILE_NOT_FOUND)
+			printf("%s: %s\n", file_cbfs_error(), argv[2]);
+		else
+			printf("%s.\n", file_cbfs_error());

See above. Please consider changing globally.

common/Makefile

Quoted 5 lines
common/Makefile +5 -0
+	printf("reading %s\n", file_cbfs_name(file));
+
+	size = file_cbfs_read(file, (void *)offset, count);
+
+	printf("\n%ld bytes read\n", size);

There should be no need for the initial newline here. Please drop it (fix globally?).

...

common/Makefile

Quoted 4 lines
common/Makefile +4 -0
+		if (type_name)
+			printf("  %16s", type_name);
+		else
+			printf("  %16d", type);

This is probably confusing to the user. How can he know if the file type has the numerical value of "123" or if the file name is "123" ?

common/Makefile

Quoted 4 lines
common/Makefile +4 -0
+		if (filename[0])
+			printf("  %s\n", filename);
+		else
+			printf("  %s\n", "(empty)");

Use puts().

common/Makefile

Quoted 1 line
common/Makefile +1 -0
+	printf("\n%d file(s)\n\n", files);

Please do not print that many empty lines.

Imagine output is going to a QVGA display or similar which shows only 12 text lines or so...

common/Makefile

Quoted 7 lines
common/Makefile +7 -0
+int do_cbfs_fsinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
+{
+	const struct cbfs_header *header = file_cbfs_get_header();
+	if (!header) {
+		printf("%s.\n", file_cbfs_error());
+		return 1;
+	}

Please always insert a blank line between declarations and code. Please fix globally.

common/Makefile

Quoted 1 line
common/Makefile +1 -0
+	puts("\n");

What is this blank line good for? Drop it!

common/Makefile

Quoted 7 lines
common/Makefile +7 -0
+	printf("CBFS version: %#x\n", header->version);
+	printf("ROM size: %#x\n", header->rom_size);
+	printf("Boot block size: %#x\n", header->boot_block_size);
+	printf("CBFS size: %#x\n",
+		header->rom_size - header->boot_block_size - header->offset);
+	printf("Alignment: %d\n", header->align);
+	printf("Offset: %#x\n", header->offset);

How about some vertical alignment of the output?

common/Makefile

Quoted 1 line
common/Makefile +1 -0
+	puts("\n");

Drop that, too.

Quoted 5 lines
common/Makefile +5 -0
+const char *file_cbfs_error(void)
+{
+	switch (file_cbfs_result) {
+	case CBFS_SUCCESS:
+		return "Success";

common/Makefile

Quoted 10 lines
common/Makefile +10 -0
+	case CBFS_NOT_INITIALIZED:
+		return "CBFS not initialized";
+	case CBFS_BAD_HEADER:
+		return "Bad CBFS header";
+	case CBFS_BAD_FILE:
+		return "Bad CBFS file";
+	case CBFS_FILE_NOT_FOUND:
+		return "File not found";
+	default:
+		return "Unknown";

Better make this "Unknown error" or similar, otherwise the user might not know what "Unknown" means.

Best regards,

Wolfgang Denk

Signature · 7 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
A good aphorism is too hard for the tooth of time, and  is  not  worn
away  by  all  the  centuries,  although  it serves as food for every
epoch.                                  - Friedrich Wilhelm Nietzsche
                          _Miscellaneous Maxims and Opinions_ no. 168
#6 lore raw

PATCH v2 1/1 Add a CBFS driver and commands to u-boot

Quoted 42 lines · Wolfgang Denk

Dear Gabe Black,

In message <[email protected]> you

Quoted 1 line · wrote:

Coreboot uses a very simple "file system" called CBFS to keep track of

and

Quoted 4 lines

allow access to multiple "files" in a ROM image. This change adds CBFS support and some commands to use it to u-boot. These commands are:

cbfsinit - Initialize CBFS support and pull all metadata into RAM. The

end

Quoted 2 lines

of the ROM is an optional parameter which defaults to the standard 0xffffffff and can be used to support multiple CBFSes in a system. The

last

Quoted 5 lines

one set up with cbfsinit is the one that will be used.

cbfsinfo - Print information from the CBFS header.

cbfsls - Print out the size, type, and name of all the files in the

current

Quoted 3 lines

CBFS. Recognized types are translated into symbolic names.

cbfsload - Load a file from CBFS into memory. Like the similar command

for

Quoted 6 lines

fat filesystems, you can optionally provide a maximum size.

Also, if u-boot needs something out of CBFS very early before the heap is configured, it won't be able to use the normal CBFS support which caches some information in memory it allocates from the heap. This change adds a new cbfs_file_find_uncached function which searchs a CBFS instance

without

Quoted 10 lines

touching the heap.

Support for CBFS is compiled in when the CONFIG_CMD_CBFS option is specified.

---
Changes in v2:
Fix checkpatch problems, change around identifiers, and change printf to puts where possible.

Quoted 6 lines

There is still a checkpatch warning that should be fixed:

WARNING: do not add new typedefs
#853: FILE: include/cbfs.h:61:
+typedef const struct cbfs_cache_node *cbfs_file;

This typedef is to create an opaque handle for CBFS files. If you look here:

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=Documentation/CodingStyle

In chapter 5 in the list of acceptable uses for typedefs, creating an opaque type is item a. This use of typedef is consistent with the Linux coding standards as described in that document and functionally important for this change and should stay.

Quoted 12 lines
Quoted 1 line

+int do_cbfs_init(cmd_tbl_t *cmdtp, int flag, int argc, char *const

argv[])

common/cmd_cbfs.c line 36

Quoted 6 lines
common/cmd_cbfs.c new file +6 -0
+{
+     uintptr_t end_of_rom = 0xffffffff;
+     char *ep;
+
+     if (argc > 2) {
+             puts("usage: cbfsls [end of rom]>\n");

What is the meaning / intention of that tailing '>' ?

A typo.

Quoted 7 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+     if (file_cbfs_result != CBFS_SUCCESS) {
+             printf("%s.\n", file_cbfs_error());

Use

               puts(file_cbfs_error());

?

That would leave out the \n. Whatever came next (like the prompt) would continue on the same line which would be wrong.

Quoted 4 lines
Quoted 2 lines

+int do_cbfs_fsload(cmd_tbl_t *cmdtp, int flag, int argc, char *const

argv[])

Quoted 1 line

+{

Quoted 9 lines

...

common/cmd_cbfs.c line 88

Quoted 5 lines
common/cmd_cbfs.c new file +5 -0
+     if (!file) {
+             if (file_cbfs_result == CBFS_FILE_NOT_FOUND)
+                     printf("%s: %s\n", file_cbfs_error(), argv[2]);
+             else
+                     printf("%s.\n", file_cbfs_error());

See above. Please consider changing globally.

The same explanation applies globally.

Quoted 9 lines

...

common/cmd_cbfs.c line 167

Quoted 4 lines
common/cmd_cbfs.c new file +4 -0
+             if (type_name)
+                     printf("  %16s", type_name);
+             else
+                     printf("  %16d", type);

This is probably confusing to the user. How can he know if the file type has the numerical value of "123" or if the file name is "123" ?

This isn't file name, it's the file type. No file type is named after a number. There are also labels on the columns indicating which is which.

Quoted 8 lines

common/cmd_cbfs.c line 172

Quoted 5 lines
common/cmd_cbfs.c new file +4 -0
+             if (filename[0])
+                     printf("  %s\n", filename);
+             else
+                     printf("  %s\n", "(empty)");

Use puts().

The first one can't be a puts, it would have to be three. That's a lot of clutter to avoid a slight performance penalty when interacting with a human that won't notice such a tiny delay anyway. The second one could be a puts, but that would make the two branches of the if uneven. I'll change the second one.

Quoted 8 lines
Quoted 2 lines

+ printf("\n%d file(s)\n\n", files);

Please do not print that many empty lines.

Imagine output is going to a QVGA display or similar which shows only 12 text lines or so...

I put newlines there because the FAT commands do, and I have no problem removing them. You may want to look at the other commands and remove them there too.

Quoted 5 lines
Quoted 2 lines

+ puts("\n");

What is this blank line good for? Drop it!

Readability? I don't care that much one way or the other though. I'll change it.

Gabe

#7 lore raw

PATCH v2 1/1 Add a CBFS driver and commands to u-boot

Dear Gabe Black,

Quoted 5 lines · In message <CAPPXG1nqDa_UgZsJx_g_RDCQOfJLjM=zaK5K7W9pgcsRrc9kig@mail.gmail.com>…
Quoted 4 lines

WARNING: do not add new typedefs
#853: FILE: include/cbfs.h:61:
+typedef const struct cbfs_cache_node *cbfs_file;

Quoted 8 lines

This typedef is to create an opaque handle for CBFS files. If you look here:

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=Documentation/CodingStyle

In chapter 5 in the list of acceptable uses for typedefs, creating an opaque type is item a. This use of typedef is consistent with the Linux coding standards as described in that document and functionally important for this change and should stay.

Sorry, but you have to explain this better to me.

What would be wrong with using "struct cbfs_cache_node *" ?

And what of this exactly is "functionally important" here?

While we are quoting the CodingStyle, we should also code the next lines:

NOTE! Opaqueness and "accessor functions" are not good in themselves.

Why do you think it is needed here?

Quoted 9 lines
Quoted 6 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+     if (file_cbfs_result != CBFS_SUCCESS) {
+             printf("%s.\n", file_cbfs_error());

Use

               puts(file_cbfs_error());

?

That would leave out the \n. Whatever came next (like the prompt) would continue on the same line which would be wrong.

It appears your only use of file_cbfs_error() is in such constructs, so just change file_cbfs_error() to include the newline. There is only a single call that doesn't really fit:

+ if (file_cbfs_result == CBFS_FILE_NOT_FOUND)
===> + printf("%s: %s\n", file_cbfs_error(), argv[2]);
+ else
+ printf("%s.\n", file_cbfs_error());

but that would be better written with arguments swapped anyway:

	printf("%s: %s", argv[2], file_cbfs_error());

While we are at it: for consistent style, please also omit the trailing '.' in all such output.

Actually you can then even simplify the code:

	if (file_cbfs_result == CBFS_FILE_NOT_FOUND)
		printf("%s: argv[2]);
	puts(file_cbfs_error());
Quoted 11 lines
Quoted 7 lines

common/cmd_cbfs.c line 167

Quoted 4 lines
common/cmd_cbfs.c new file +4 -0
+             if (type_name)
+                     printf("  %16s", type_name);
+             else
+                     printf("  %16d", type);

This is probably confusing to the user. How can he know if the file type has the numerical value of "123" or if the file name is "123" ?

This isn't file name, it's the file type. No file type is named after a number. There are also labels on the columns indicating which is which.

Please explain the meaning of this numeric versus string value is, then, and how the user is supposed to understand when he sees a string and when a numeric value.

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
common/cmd_cbfs.c new file +4 -0
+             if (filename[0])
+                     printf("  %s\n", filename);
+             else
+                     printf("  %s\n", "(empty)");
Quoted 8 lines
Quoted 1 line

Use puts().

The first one can't be a puts, it would have to be three. That's a lot of clutter to avoid a slight performance penalty when interacting with a human that won't notice such a tiny delay anyway. The second one could be a puts, but that would make the two branches of the if uneven. I'll change the second one.

Come on. It this really that difficlt? How about:

		puts("  ");
		puts(filename[0] ? filename : "(empty)");
Quoted 3 lines

I put newlines there because the FAT commands do, and I have no problem removing them. You may want to look at the other commands and remove them there too.

Patches are welcome.

Quoted 2 lines

Readability? I don't care that much one way or the other though. I'll change it.

Thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
How many hardware guys does it take to change a light bulb? "Well the
diagnostics say it's fine buddy, so it's a software problem."
author
#8 lore raw

PATCH v3 1/1 Add a CBFS driver and commands to u-boot

In reply to Wolfgang Denk

Coreboot uses a very simple "file system" called CBFS to keep track of and allow access to multiple "files" in a ROM image. This change adds CBFS support and some commands to use it to u-boot. These commands are:

cbfsinit - Initialize CBFS support and pull all metadata into RAM. The end of the ROM is an optional parameter which defaults to the standard 0xffffffff and can be used to support multiple CBFSes in a system. The last one set up with cbfsinit is the one that will be used.

cbfsinfo - Print information from the CBFS header.

cbfsls - Print out the size, type, and name of all the files in the current CBFS. Recognized types are translated into symbolic names.

cbfsload - Load a file from CBFS into memory. Like the similar command for fat filesystems, you can optionally provide a maximum size.

Also, if u-boot needs something out of CBFS very early before the heap is configured, it won't be able to use the normal CBFS support which caches some information in memory it allocates from the heap. This change adds a new cbfs_file_find_uncached function which searchs a CBFS instance without touching the heap.

Support for CBFS is compiled in when the CONFIG_CMD_CBFS option is specified.

---
Changes in v2:
Fix checkpatch problems, change around identifiers, and change printf to puts where possible.

Changes in v3:
Formatting changes, "Unknown" => "Unknown error", Makefile sorting, fix a typo.

 Makefile          |    6 +-
 README            |    1 +
 common/Makefile   |    1 +
 common/cmd_cbfs.c |  212 +++++++++++++++++++++++++++++++
 fs/Makefile       |    1 +
 fs/cbfs/Makefile  |   44 +++++++
 fs/cbfs/cbfs.c    |  355 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/cbfs.h    |  164 ++++++++++++++++++++++++
 8 files changed, 781 insertions(+), 3 deletions(-)
 create mode 100644 common/cmd_cbfs.c
 create mode 100644 fs/cbfs/Makefile
 create mode 100644 fs/cbfs/cbfs.c
 create mode 100644 include/cbfs.h
Makefile +3 -3
index d84b350..3056fed 100644
@@ -234,9 +234,9 @@ ifeq ($(CONFIG_OF_EMBED),y)
 LIBS += dts/libdts.o
 endif
 LIBS += arch/$(ARCH)/lib/lib$(ARCH).o
-LIBS += fs/cramfs/libcramfs.o fs/fat/libfat.o fs/fdos/libfdos.o fs/jffs2/libjffs2.o \
-	fs/reiserfs/libreiserfs.o fs/ext2/libext2fs.o fs/yaffs2/libyaffs2.o \
-	fs/ubifs/libubifs.o
+LIBS += fs/cbfs/libcbfs.o fs/cramfs/libcramfs.o fs/fat/libfat.o \
+	fs/fdos/libfdos.o fs/jffs2/libjffs2.o fs/reiserfs/libreiserfs.o \
+	fs/ext2/libext2fs.o fs/yaffs2/libyaffs2.o fs/ubifs/libubifs.o
 LIBS += net/libnet.o
 LIBS += disk/libdisk.o
 LIBS += drivers/bios_emulator/libatibiosemu.o
README +1 -0
index fda0190..b878c4b 100644
@@ -721,6 +721,7 @@ The following options need to be configured:
 		CONFIG_CMD_BSP		* Board specific commands
 		CONFIG_CMD_BOOTD	  bootd
 		CONFIG_CMD_CACHE	* icache, dcache
+		CONFIG_CMD_CBFS		* Support for coreboot's CBFS
 		CONFIG_CMD_CONSOLE	  coninfo
 		CONFIG_CMD_CRC32	* crc32
 		CONFIG_CMD_DATE		* support for RTC, date/time...
common/Makefile +1 -0
index 1b672ad..d3633a3 100644
@@ -72,6 +72,7 @@ COBJS-$(CONFIG_CMD_BEDBUG) += bedbug.o cmd_bedbug.o
 COBJS-$(CONFIG_CMD_BMP) += cmd_bmp.o
 COBJS-$(CONFIG_CMD_BOOTLDR) += cmd_bootldr.o
 COBJS-$(CONFIG_CMD_CACHE) += cmd_cache.o
+COBJS-$(CONFIG_CMD_CBFS) += cmd_cbfs.o
 COBJS-$(CONFIG_CMD_CONSOLE) += cmd_console.o
 COBJS-$(CONFIG_CMD_CPLBINFO) += cmd_cplbinfo.o
 COBJS-$(CONFIG_DATAFLASH_MMC_SELECT) += cmd_dataflash_mmc_mux.o
common/cmd_cbfs.c new file +212 -0

212 lines not on this page · raw message

fs/Makefile +1 -0
index 22aad12..ca21464 100644
@@ -23,6 +23,7 @@
 #
 
 subdirs-$(CONFIG_CMD_CRAMFS) := cramfs
+subdirs-$(CONFIG_CMD_CBFS) += cbfs
 subdirs-$(CONFIG_CMD_EXT2) += ext2
 subdirs-$(CONFIG_CMD_FAT) += fat
 subdirs-$(CONFIG_CMD_FDOS) += fdos
fs/cbfs/Makefile new file +44 -0

44 lines not on this page · raw message

fs/cbfs/cbfs.c new file +355 -0

355 lines not on this page · raw message

include/cbfs.h new file +164 -0

164 lines not on this page · raw message

Signature · 1 line
1.7.3.1
#9 lore raw

PATCH v3 1/1 Add a CBFS driver and commands to u-boot

Dear Gabe Black,

Quoted 23 lines · In message <[email protected]> you wrote:

Coreboot uses a very simple "file system" called CBFS to keep track of and allow access to multiple "files" in a ROM image. This change adds CBFS support and some commands to use it to u-boot. These commands are:

cbfsinit - Initialize CBFS support and pull all metadata into RAM. The end of the ROM is an optional parameter which defaults to the standard 0xffffffff and can be used to support multiple CBFSes in a system. The last one set up with cbfsinit is the one that will be used.

cbfsinfo - Print information from the CBFS header.

cbfsls - Print out the size, type, and name of all the files in the current CBFS. Recognized types are translated into symbolic names.

cbfsload - Load a file from CBFS into memory. Like the similar command for fat filesystems, you can optionally provide a maximum size.

Also, if u-boot needs something out of CBFS very early before the heap is configured, it won't be able to use the normal CBFS support which caches some information in memory it allocates from the heap. This change adds a new cbfs_file_find_uncached function which searchs a CBFS instance without touching the heap.

Quoted 4 lines

Support for CBFS is compiled in when the CONFIG_CMD_CBFS option is specified.

See previous message.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
...when fits of creativity run strong, more than  one  programmer  or
writer  has  been  known to abandon the desktop for the more spacious
floor.                                             - Fred Brooks, Jr.
#10 lore raw

PATCH v3 1/1 Add a CBFS driver and commands to u-boot

Quoted 31 lines · Wolfgang Denk

Dear Gabe Black,

In message <[email protected]> you

Quoted 1 line · wrote:

Coreboot uses a very simple "file system" called CBFS to keep track of

and

Quoted 4 lines

allow access to multiple "files" in a ROM image. This change adds CBFS support and some commands to use it to u-boot. These commands are:

cbfsinit - Initialize CBFS support and pull all metadata into RAM. The

end

Quoted 2 lines

of the ROM is an optional parameter which defaults to the standard 0xffffffff and can be used to support multiple CBFSes in a system. The

last

Quoted 5 lines

one set up with cbfsinit is the one that will be used.

cbfsinfo - Print information from the CBFS header.

cbfsls - Print out the size, type, and name of all the files in the

current

Quoted 3 lines

CBFS. Recognized types are translated into symbolic names.

cbfsload - Load a file from CBFS into memory. Like the similar command

for

Quoted 6 lines

fat filesystems, you can optionally provide a maximum size.

Also, if u-boot needs something out of CBFS very early before the heap is configured, it won't be able to use the normal CBFS support which caches some information in memory it allocates from the heap. This change adds a new cbfs_file_find_uncached function which searchs a CBFS instance

without

Quoted 9 lines
Quoted 6 lines

touching the heap.

Support for CBFS is compiled in when the CONFIG_CMD_CBFS option is specified.

See previous message.

Could you be more specific?

Gabe

#11 lore raw

PATCH v3 1/1 Add a CBFS driver and commands to u-boot

Dear Gabe Black,

Quoted 5 lines · In message <CAPPXG1k-kGa=BnHC=qoVZaVTedEvF5zWkWx-jX0g-SrbzfFseA@mail.gmail.com>…
Quoted 2 lines

See previous message.

Could you be more specific?

------- Forwarded Message

Dear Gabe Black,

Quoted 5 lines · In message <CAPPXG1nqDa_UgZsJx_g_RDCQOfJLjM=zaK5K7W9pgcsRrc9kig@mail.gmail.com>…
Quoted 4 lines

WARNING: do not add new typedefs
#853: FILE: include/cbfs.h:61:
+typedef const struct cbfs_cache_node *cbfs_file;

Quoted 8 lines

This typedef is to create an opaque handle for CBFS files. If you look here:

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=Documentation/CodingStyle

In chapter 5 in the list of acceptable uses for typedefs, creating an opaque type is item a. This use of typedef is consistent with the Linux coding standards as described in that document and functionally important for this change and should stay.

Sorry, but you have to explain this better to me.

What would be wrong with using "struct cbfs_cache_node *" ?

And what of this exactly is "functionally important" here?

While we are quoting the CodingStyle, we should also code the next lines:

NOTE! Opaqueness and "accessor functions" are not good in themselves.

Why do you think it is needed here?

Quoted 9 lines
Quoted 6 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+     if (file_cbfs_result != CBFS_SUCCESS) {
+             printf("%s.\n", file_cbfs_error());

Use

               puts(file_cbfs_error());

?

That would leave out the \n. Whatever came next (like the prompt) would continue on the same line which would be wrong.

It appears your only use of file_cbfs_error() is in such constructs, so just change file_cbfs_error() to include the newline. There is only a single call that doesn't really fit:

+ if (file_cbfs_result == CBFS_FILE_NOT_FOUND)
===> + printf("%s: %s\n", file_cbfs_error(), argv[2]);
+ else
+ printf("%s.\n", file_cbfs_error());

but that would be better written with arguments swapped anyway:

	printf("%s: %s", argv[2], file_cbfs_error());

While we are at it: for consistent style, please also omit the trailing '.' in all such output.

Actually you can then even simplify the code:

	if (file_cbfs_result == CBFS_FILE_NOT_FOUND)
		printf("%s: argv[2]);
	puts(file_cbfs_error());
Quoted 11 lines
Quoted 7 lines

common/cmd_cbfs.c line 168

Quoted 4 lines
common/cmd_cbfs.c new file +4 -0
+             if (type_name)
+                     printf("  %16s", type_name);
+             else
+                     printf("  %16d", type);

This is probably confusing to the user. How can he know if the file type has the numerical value of "123" or if the file name is "123" ?

This isn't file name, it's the file type. No file type is named after a number. There are also labels on the columns indicating which is which.

Please explain the meaning of this numeric versus string value is, then, and how the user is supposed to understand when he sees a string and when a numeric value.

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
common/cmd_cbfs.c new file +4 -0
+             if (filename[0])
+                     printf("  %s\n", filename);
+             else
+                     printf("  %s\n", "(empty)");
Quoted 8 lines
Quoted 1 line

Use puts().

The first one can't be a puts, it would have to be three. That's a lot of clutter to avoid a slight performance penalty when interacting with a human that won't notice such a tiny delay anyway. The second one could be a puts, but that would make the two branches of the if uneven. I'll change the second one.

Come on. It this really that difficlt? How about:

		puts("  ");
		puts(filename[0] ? filename : "(empty)");
Quoted 3 lines

I put newlines there because the FAT commands do, and I have no problem removing them. You may want to look at the other commands and remove them there too.

Patches are welcome.

Quoted 2 lines

Readability? I don't care that much one way or the other though. I'll change it.

Thanks.

------- End of Forwarded Message

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
I haven't lost my mind -- it's backed up on tape somewhere.
#12 lore raw

PATCH 1/1 Add a CBFS driver and commands to u-boot

In reply to Gabe Black

common/cmd_cbfs.c

Quoted 4 lines · On Saturday 03 December 2011 06:47:01 Gabe Black wrote:
common/cmd_cbfs.c new file +1 -0
 
+int do_cbfs_init(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])

static

common/cmd_cbfs.c line 38

Quoted 4 lines
common/cmd_cbfs.c new file +4 -0
+	if (argc > 2) {
+		printf("usage: cbfsls [end of rom]>\n");
+		return 0;
+	}

return cmd_usage(cmdtp)

Quoted 1 line

+int do_cbfs_fsload (cmd_tbl_t *cmdtp, int flag, int argc, char *const

static

no space before that "("

common/cmd_cbfs.c line 74

Quoted 4 lines
common/cmd_cbfs.c new file +4 -0
+	if (argc < 3) {
+		printf("usage: cbfsload <addr> <filename> [bytes]\n");
+		return 1;
+	}

return cmd_usage(cmdtp)

Quoted 1 line

+int do_cbfs_ls (cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])

static

no space before that "("

common/cmd_cbfs.c line 125

Quoted 1 line
common/cmd_cbfs.c new file +1 -0
+		char *typeName = NULL;

const, and don't use camelCase in var names

Quoted 1 line

+int do_cbfs_fsinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *const

static

no space before that "("

common/cmd_cbfs.c line 189

Quoted 1 line
common/cmd_cbfs.c new file +1 -0
+	const CbfsHeader *header = file_cbfs_get_header();

camelCase ...

common/cmd_cbfs.c line 203

Quoted 9 lines
common/cmd_cbfs.c new file +9 -0
+	printf("\n");
+	printf("CBFS version: %#x\n", header->version);
+	printf("ROM size: %#x\n", header->romSize);
+	printf("Boot block size: %#x\n", header->bootBlockSize);
+	printf("CBFS size: %#x\n",
+		header->romSize - header->bootBlockSize - header->offset);
+	printf("Alignment: %d\n", header->align);
+	printf("Offset: %#x\n", header->offset);
+	printf("\n");

should be easy to merge into a single printf() call

fs/Makefile line 29

Quoted 8 lines
fs/Makefile +1 -0
 
 subdirs-$(CONFIG_CMD_CRAMFS) := cramfs
+subdirs-$(CONFIG_CMD_CBFS) += cbfs
 subdirs-$(CONFIG_CMD_EXT2) += ext2
 subdirs-$(CONFIG_CMD_FAT) += fat
 subdirs-$(CONFIG_CMD_FDOS) += fdos

unrelated, but that ":=" is most likely wrong as it doesn't do what it is actually intended

Quoted 10 lines
fs/cbfs/cbfs.c new file +7 -0
 
+const char *file_cbfs_error(void)
+{
+	switch (file_cbfs_result) {
+	    case CBFS_SUCCESS:
+		return "Success";
+	    case CBFS_NOT_INITIALIZED:
+		return "CBFS not initialized";

fs/cbfs/cbfs.c line 45

Quoted 10 lines
fs/cbfs/cbfs.c new file +10 -0
+	    case CBFS_BAD_HEADER:
+		return "Bad CBFS header";
+	    case CBFS_BAD_FILE:
+		return "Bad CBFS file";
+	    case CBFS_FILE_NOT_FOUND:
+		return "File not found";
+	    default:
+		return "Unknown";
+	}
+}

CbfsResult starts CBFS_SUCCESS at 0, so this should be easy to rewrite as an array of strings which this func simply indexes

fs/cbfs/cbfs.c line 53

Quoted 3 lines
fs/cbfs/cbfs.c new file +2 -0
+typedef struct CbfsFileHeader {
...
+} __attribute__((packed)) CbfsFileHeader;

__packed

fs/cbfs/cbfs.c line 63

Quoted 3 lines
fs/cbfs/cbfs.c new file +2 -0
+typedef struct CbfsCacheNode {
...
+} __attribute__((packed)) CbfsCacheNode;

__packed

fs/cbfs/cbfs.c line 175

Quoted 4 lines
fs/cbfs/cbfs.c new file +3 -0
+static void file_cbfs_fill_cache(u8 *start, u32 size, u32 align)
+{
...
+		newNode = (CbfsCacheNode *)malloc(sizeof(CbfsCacheNode));

useless cast

include/cbfs.h line 57

Quoted 6 lines
include/cbfs.h new file +2 -0
 
+typedef struct CbfsHeader {
...
+} __attribute__((packed)) CbfsHeader;

__packed
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120107/cf21e940/attachment.pgp>