From a946e4a596f3f93ee3b9cc6b0a4285882bf4e1f1 Mon Sep 17 00:00:00 2001 From: "Ronald G. Minnich" Date: Fri, 20 Jun 2003 16:46:48 +0000 Subject: tool for building roms, to eliminate icky shell scripts. git-svn-id: svn://svn.coreboot.org/coreboot/trunk@887 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1 --- util/buildrom/buildrom.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 util/buildrom/buildrom.c (limited to 'util/buildrom') diff --git a/util/buildrom/buildrom.c b/util/buildrom/buildrom.c new file mode 100644 index 0000000000..44f0c44186 --- /dev/null +++ b/util/buildrom/buildrom.c @@ -0,0 +1,93 @@ +#include +#include +#include +#include +#include +#include + + +/* this is the beginning of a tool which will eventually + * be able to build rom images with both fallback and + * normal. For now it just builds a single image + * into a rom iamge + */ +/* one switch we already need: -zero allowing you to tell what + * to do with numbers that are "zero": make them 0xff or whatever + * for flash + * For now we assume "zero" is 0xff + */ + +void +usage(){ + fprintf(stderr, "Usage: buildrom "); + fprintf(stderr, " size) + fatal("input file larger than allowed size!\n"); + + if (fstat(payloadfd, &payloadbuf) < 0) + fatal("stat of infile"); + if (payloadbuf.st_size > (romsize - size)) + fatal("payload + linuxbios size larger than ROM size!\n"); + + cp = malloc(romsize); + if (! cp) + fatal("malloc buffer"); + + for(i = 0; i < romsize; i++) + cp[i] = zero; + /* read the input file in at the END of the array */ + readlen = read(infd, &cp[romsize - inbuf.st_size], inbuf.st_size); + if (readlen < inbuf.st_size) { + fprintf(stderr, "Wanted %d, got %d\n", inbuf.st_size, readlen); + fatal("Read input file"); + } + + /* read the payload file in at the START of the array */ + readlen = read(payloadfd, cp, payloadbuf.st_size); + if (readlen < payloadbuf.st_size) { + fprintf(stderr, "Wanted %d, got %d\n", + payloadbuf.st_size, readlen); + fatal("Read payload file"); + } + writelen = write(outfd, cp, romsize); + if (writelen < size) { + fprintf(stderr, "Wanted %d, got %d\n", size, writelen); + fatal("Write output file"); + } + + return 0; +} -- cgit v1.2.3