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>
Reviewed-on: http://review.coreboot.org/5115
Tested-by: build bot (Jenkins)
Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
This commit is contained in:
Ronald G. Minnich 2014-02-04 08:29:35 -08:00 committed by Ronald G. Minnich
parent 35850ae88e
commit 818f369da2
3 changed files with 33 additions and 29 deletions

View File

@ -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;

View File

@ -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*)&params, 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;
}

View File

@ -134,4 +134,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