#include <sys/mman.h>
#include "cbfstool.h"
+int uninitialized_flash_value = 0xff;
+
+void flashinit(void *ptr, size_t len)
+{
+ memset(ptr, uninitialized_flash_value, len);
+}
+
int get_size(const char *size)
{
char *next;
}
rom->size = ntohl(rom->header->romsize);
+ /* compute a 32-bit value of rombase.
+ * This does the right thing on 64-bit machines.
+ */
+ rom->rombase = 0-rom->size;
+ rom->rombase &= 0xffffffff;
rom->fssize = rom->size - ntohl(rom->header->bootblocksize);
return 0;
}
int create_rom(struct rom *rom, const unsigned char *filename,
- int romsize, const unsigned char *bootblockname,
+ int romsize, const char *bootblockname,
int bootblocksize, int align)
{
unsigned char null = '\0';
return -1;
}
+ /* mmap'ed pages are by default zero-filled. Fix that. */
+ flashinit(rom->ptr, romsize);
+
/* This is a pointer to the header for easy access */
rom->header = (struct cbfs_header *)
ROM_PTR(rom, rom->size - 16 - bootblocksize - sizeof(struct cbfs_header));
rom->header->align = htonl(align);
rom->header->offset = htonl(0);
- add_bootblock(rom, bootblockname);
+ if (add_bootblock(rom, bootblockname) == -1)
+ return -1;
/* Write the cbfs master header address at the end of the ROM. */
ROM_WRITEL(rom, rom->size - 4,
0xFFFFFFF0 - bootblocksize - sizeof(struct cbfs_header));
+
+ /* write the empty header */
+ rom_set_header(rom, (struct cbfs_file *)rom->ptr, "", -1, CBFS_COMPONENT_NULL);
return 0;
}
unsigned int size;
int fd = size_and_open(filename, &size);
int ret;
- struct cbfs_header tmp;
if (fd == -1)
return -1;