Ronald G. Minnich (rminnich@gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/5115
-gerrit
commit bfb5a18cb2223515e693bffe9a3b4e659818b2b5 Author: Ronald G. Minnich rminnich@google.com Date: Tue Feb 4 08:29:35 2014 -0800
Change the linux payload generator to use the standard header generator
When I changed mkpayload, I did not realize we had a duplicate block of code in the linux payload code. Have it use the same header generator as the standard payload code does.
Change-Id: Ie39540089ce89b704290c89127da4c7b051ecb0e Signed-off-by: Ronald G. Minnich rminnich@google.com --- util/cbfstool/cbfs-mkpayload.c | 2 +- util/cbfstool/cbfs-payload-linux.c | 56 +++++++++++++++++++------------------- util/cbfstool/cbfs.h | 4 +++ 3 files changed, 33 insertions(+), 29 deletions(-)
diff --git a/util/cbfstool/cbfs-mkpayload.c b/util/cbfstool/cbfs-mkpayload.c index b1dd1c0..9f4b7c1 100644 --- a/util/cbfstool/cbfs-mkpayload.c +++ b/util/cbfstool/cbfs-mkpayload.c @@ -32,7 +32,7 @@ /* serialize the seg array into the buffer. * The buffer is assumed to be large enough. */ -static void xdr_segs(struct buffer *output, +void xdr_segs(struct buffer *output, struct cbfs_payload_segment *segs, int nseg) { struct buffer outheader; diff --git a/util/cbfstool/cbfs-payload-linux.c b/util/cbfstool/cbfs-payload-linux.c index 149265c..c965e39 100644 --- a/util/cbfstool/cbfs-payload-linux.c +++ b/util/cbfstool/cbfs-payload-linux.c @@ -156,29 +156,29 @@ int parse_bzImage_to_payload(const struct buffer *input, return -1; memset(output->data, 0, output->size);
- segs = (struct cbfs_payload_segment *)output->data; + segs = calloc(num_segments, sizeof(*segs));
/* parameter block */ segs[0].type = PAYLOAD_SEGMENT_DATA; - segs[0].load_addr = htonll(LINUX_PARAM_LOC); - segs[0].mem_len = htonl(sizeof(params)); - segs[0].offset = htonl(doffset); + segs[0].load_addr = LINUX_PARAM_LOC; + segs[0].mem_len = sizeof(params); + segs[0].offset = doffset;
compress((void*)¶ms, sizeof(params), output->data + doffset, &cur_len); - segs[0].compression = htonl(algo); - segs[0].len = htonl(cur_len); + segs[0].compression = algo; + segs[0].len = cur_len;
doffset += cur_len;
/* code block */ segs[1].type = PAYLOAD_SEGMENT_CODE; - segs[1].load_addr = htonll(kernel_base); - segs[1].mem_len = htonl(kernel_size); - segs[1].offset = htonl(doffset); + segs[1].load_addr = kernel_base; + segs[1].mem_len = kernel_size; + segs[1].offset = doffset;
compress(kernel_data, kernel_size, output->data + doffset, &cur_len); - segs[1].compression = htonl(algo); - segs[1].len = htonl(cur_len); + segs[1].compression = algo; + segs[1].len = cur_len;
doffset += cur_len;
@@ -189,26 +189,26 @@ int parse_bzImage_to_payload(const struct buffer *input, unsigned int entrypoint = 0x40000; /* TODO: any better place? */
segs[2].type = PAYLOAD_SEGMENT_CODE; - segs[2].load_addr = htonll(entrypoint); - segs[2].mem_len = htonl(trampoline_size); - segs[2].offset = htonl(doffset); + segs[2].load_addr = entrypoint; + segs[2].mem_len = trampoline_size; + segs[2].offset = doffset;
compress(trampoline_start, trampoline_size, output->data + doffset, &cur_len); - segs[2].compression = htonl(algo); - segs[2].len = htonl(cur_len); + segs[2].compression = algo; + segs[2].len = cur_len;
doffset += cur_len;
if (cmdline_size > 0) { /* command line block */ segs[3].type = PAYLOAD_SEGMENT_DATA; - segs[3].load_addr = htonll(COMMAND_LINE_LOC); - segs[3].mem_len = htonl(cmdline_size); - segs[3].offset = htonl(doffset); + segs[3].load_addr = COMMAND_LINE_LOC; + segs[3].mem_len = cmdline_size; + segs[3].offset = doffset;
compress(cmdline, cmdline_size, output->data + doffset, &cur_len); - segs[3].compression = htonl(algo); - segs[3].len = htonl(cur_len); + segs[3].compression = algo; + segs[3].len = cur_len;
doffset += cur_len; } @@ -216,22 +216,22 @@ int parse_bzImage_to_payload(const struct buffer *input, if (initrd_size > 0) { /* setup block */ segs[num_segments-1].type = PAYLOAD_SEGMENT_DATA; - segs[num_segments-1].load_addr = htonll(initrd_base); - segs[num_segments-1].mem_len = htonl(initrd_size); - segs[num_segments-1].offset = htonl(doffset); + segs[num_segments-1].load_addr = initrd_base; + segs[num_segments-1].mem_len = initrd_size; + segs[num_segments-1].offset = doffset;
compress(initrd_data, initrd_size, output->data + doffset, &cur_len); - segs[num_segments-1].compression = htonl(algo); - segs[num_segments-1].len = htonl(cur_len); + segs[num_segments-1].compression = algo; + segs[num_segments-1].len = cur_len;
doffset += cur_len; }
/* prepare entry point segment */ segs[num_segments].type = PAYLOAD_SEGMENT_ENTRY; - segs[num_segments].load_addr = htonll(entrypoint); + segs[num_segments].load_addr = entrypoint; output->size = doffset; - + xdr_segs(output, segs, num_segments); return 0; }
diff --git a/util/cbfstool/cbfs.h b/util/cbfstool/cbfs.h index 585a26d..c0de313 100644 --- a/util/cbfstool/cbfs.h +++ b/util/cbfstool/cbfs.h @@ -140,4 +140,8 @@ elf_headers(const struct buffer *pinput, Elf64_Phdr **pphdr, Elf64_Shdr **pshdr);
+/* cbfs-mkpayload.c */ +void xdr_segs(struct buffer *output, + struct cbfs_payload_segment *segs, int nseg); + #endif