Author: myles
Date: 2009-04-25 14:39:04 +0200 (Sat, 25 Apr 2009)
New Revision: 4209

Modified:
   trunk/coreboot-v2/util/cbfstool/cbfstool.h
   trunk/coreboot-v2/util/cbfstool/create.c
   trunk/coreboot-v2/util/cbfstool/util.c
Log:
The master cbfs record was located at the end of the flash and overwrote
anything that was there.  For ck804 or mcp55-based machines that was the
romstrap.

The fix is simple:
1. Put the master cbfs record above the bootblock instead of on it.

Signed-off-by: Myles Watson <[email protected]>
Acked-by: Peter Stuge <[email protected]>
Acked-by: Ronald G. Minnich <[email protected]>


Modified: trunk/coreboot-v2/util/cbfstool/cbfstool.h
===================================================================
--- trunk/coreboot-v2/util/cbfstool/cbfstool.h  2009-04-25 07:33:25 UTC (rev 
4208)
+++ trunk/coreboot-v2/util/cbfstool/cbfstool.h  2009-04-25 12:39:04 UTC (rev 
4209)
@@ -58,7 +58,8 @@
 /* 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);
+              const unsigned char *bootblockname, 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);

Modified: trunk/coreboot-v2/util/cbfstool/create.c
===================================================================
--- trunk/coreboot-v2/util/cbfstool/create.c    2009-04-25 07:33:25 UTC (rev 
4208)
+++ trunk/coreboot-v2/util/cbfstool/create.c    2009-04-25 12:39:04 UTC (rev 
4209)
@@ -59,11 +59,8 @@
                return -1;
        }
 
-       if (create_rom(rom, rom->name, size, bootblocksize, align))
+       if (create_rom(rom, rom->name, size, bootblock, bootblocksize, align))
                return -1;
 
-       if (bootblock != NULL)
-               return add_bootblock(rom, bootblock);
-
        return 0;
 }

Modified: trunk/coreboot-v2/util/cbfstool/util.c
===================================================================
--- trunk/coreboot-v2/util/cbfstool/util.c      2009-04-25 07:33:25 UTC (rev 
4208)
+++ trunk/coreboot-v2/util/cbfstool/util.c      2009-04-25 12:39:04 UTC (rev 
4209)
@@ -168,7 +168,8 @@
 }
 
 int create_rom(struct rom *rom, const unsigned char *filename,
-              int romsize, int bootblocksize, int align)
+              int romsize, const unsigned char *bootblockname,
+              int bootblocksize, int align)
 {
        unsigned char null = '\0';
 
@@ -180,8 +181,9 @@
        /* Remember the size of the entire ROM */
        rom->size = romsize;
 
-       /* The size of the archive section is everything but the bootblock */
-       rom->fssize = romsize - bootblocksize;
+       /* The size of the archive section is everything but the bootblock and
+        * the cbfs master header. */
+       rom->fssize = romsize - bootblocksize - sizeof(struct cbfs_header);
 
        /* Open the file descriptor */
 
@@ -201,29 +203,27 @@
                return -1;
        }
 
-       /* Clear the reset vector */
-       memset(rom->ptr + rom->size - 16, 0, 16);
-
-       ROM_WRITEL(rom, rom->size - 4,
-                  0xFFFFFFF0 - sizeof(struct cbfs_header));
-
        /* This is a pointer to the header for easy access */
        rom->header = (struct cbfs_header *)
-           ROM_PTR(rom, rom->size - 16 - sizeof(struct cbfs_header));
-
+           ROM_PTR(rom, rom->size - 16 - bootblocksize - sizeof(struct 
cbfs_header));
        rom->header->magic = htonl(HEADER_MAGIC);
        rom->header->romsize = htonl(romsize);
        rom->header->bootblocksize = htonl(bootblocksize);
        rom->header->align = htonl(align);
        rom->header->offset = htonl(0);
 
+       add_bootblock(rom, bootblockname);
+
+       /* Write the cbfs master header address at the end of the ROM. */
+
+       ROM_WRITEL(rom, rom->size - 4,
+                  0xFFFFFFF0 - bootblocksize - sizeof(struct cbfs_header));
        return 0;
 }
 
 int add_bootblock(struct rom *rom, const char *filename)
 {
        unsigned int size;
-       //unsigned int offset;
        int fd = size_and_open(filename, &size);
        int ret;
        struct cbfs_header tmp;
@@ -237,11 +237,7 @@
                return -1;
        }
 
-       /* Copy the current header into a temporary buffer */
-       memcpy(&tmp, rom->header, sizeof(struct cbfs_header));
-
        /* Copy the bootblock into place at the end of the file */
-
        ret = copy_from_fd(fd, ROM_PTR(rom, rom->size - 
ntohl(rom->header->bootblocksize)), size);
 
        close(fd);
@@ -251,26 +247,6 @@
                return -1;
        }
 
-       /* FIXME: This should point to a location defined by coreboot */
-
-       ROM_WRITEL(rom, rom->size - 4,
-                  0xFFFFFFF0 - sizeof(struct cbfs_header));
-
-       /* This is a pointer to the header for easy access */
-       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 cbfs_header *)
-           ROM_PTR(rom, offset - (0xFFFFFFFF - rom->size));
-#endif
-
-       /* Replace the LAR header */
-       memcpy(rom->header, &tmp, sizeof(struct cbfs_header));
-
        return 0;
 }
 


-- 
coreboot mailing list: [email protected]
http://www.coreboot.org/mailman/listinfo/coreboot

Reply via email to