Re: [U-Boot] [PATCH] Add a CBFS driver and commands to u-boot

2012-01-07 Thread Mike Frysinger
On Saturday 03 December 2011 06:47:01 Gabe Black wrote:
 --- /dev/null
 +++ b/common/cmd_cbfs.c

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

static

 + if (argc  2) {
 + printf(usage: cbfsls [end of rom]\n);
 + return 0;
 + }

return cmd_usage(cmdtp)

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

static

no space before that (

 + if (argc  3) {
 + printf(usage: cbfsload addr filename [bytes]\n);
 + return 1;
 + }

return cmd_usage(cmdtp)

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

static

no space before that (

 + char *typeName = NULL;

const, and don't use camelCase in var names

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

static

no space before that (

 + const CbfsHeader *header = file_cbfs_get_header();

camelCase ...

 + 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

 --- a/fs/Makefile
 +++ b/fs/Makefile
 
  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

 --- /dev/null
 +++ b/fs/cbfs/cbfs.c

 +const char *file_cbfs_error(void)
 +{
 + switch (file_cbfs_result) {
 + case CBFS_SUCCESS:
 + return Success;
 + 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;
 + }
 +}

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

 +typedef struct CbfsFileHeader {
 ...
 +} __attribute__((packed)) CbfsFileHeader;

__packed

 +typedef struct CbfsCacheNode {
 ...
 +} __attribute__((packed)) CbfsCacheNode;

__packed

 +static void file_cbfs_fill_cache(u8 *start, u32 size, u32 align)
 +{
 ...
 + newNode = (CbfsCacheNode *)malloc(sizeof(CbfsCacheNode));

useless cast

 --- /dev/null
 +++ b/include/cbfs.h

 +typedef struct CbfsHeader {
 ...
 +} __attribute__((packed)) CbfsHeader;

__packed
-mike


signature.asc
Description: This is a digitally signed message part.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] Add a CBFS driver and commands to u-boot

2011-12-05 Thread Wolfgang Denk
Dear Gabe Black,

In message 1322912821-32677-1-git-send-email-gabebl...@chromium.org 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 0x 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.
 
 Signed-off-by: Gabe Black gabebl...@chromium.org

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

-- 
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: w...@denx.de
The human race is faced with a cruel choice: work  or  daytime  tele-
vision.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] Add a CBFS driver and commands to u-boot

2011-12-05 Thread Gabe Black
On Mon, Dec 5, 2011 at 2:25 PM, Wolfgang Denk w...@denx.de wrote:

 Dear Gabe Black,

 In message 1322912821-32677-1-git-send-email-gabebl...@chromium.org 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
 0x 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.
 
  Signed-off-by: Gabe Black gabebl...@chromium.org

 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.




 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: w...@denx.de
 The human race is faced with a cruel choice: work  or  daytime  tele-
 vision.

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] Add a CBFS driver and commands to u-boot

2011-12-05 Thread Gabe Black
On Mon, Dec 5, 2011 at 2:35 PM, Gabe Black gabebl...@google.com wrote:



 On Mon, Dec 5, 2011 at 2:25 PM, Wolfgang Denk w...@denx.de wrote:

 Dear Gabe Black,

 In message 1322912821-32677-1-git-send-email-gabebl...@chromium.org
 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
 0x 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.
 
  Signed-off-by: Gabe Black gabebl...@chromium.org

 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
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] Add a CBFS driver and commands to u-boot

2011-12-03 Thread Gabe Black
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 0x 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.

Signed-off-by: Gabe Black gabebl...@chromium.org
---
 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

diff --git a/Makefile b/Makefile
index d84b350..e1e2ff1 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/README b/README
index fda0190..b878c4b 100644
--- a/README
+++ b/README
@@ -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_CONSOLEconinfo
CONFIG_CMD_CRC32* crc32
CONFIG_CMD_DATE * support for RTC, date/time...
diff --git a/common/Makefile b/common/Makefile
index 1b672ad..6cfba67 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -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
diff --git a/common/cmd_cbfs.c b/common/cmd_cbfs.c
new file mode 100644
index 000..a357831
--- /dev/null
+++ b/common/cmd_cbfs.c
@@ -0,0 +1,212 @@
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * 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., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+/*
+ * CBFS commands
+ */
+#include common.h
+#include command.h
+#include cbfs.h
+
+int do_cbfs_init(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
+{
+   uintptr_t end_of_rom = 0x;
+   char *ep;
+
+   if (argc  2) {
+   printf(usage: cbfsls [end of rom]\n);
+   return 0;
+   }
+   if (argc == 2) {
+   end_of_rom = (int)simple_strtoul(argv[1],