From ca63027ef7627ba60f6776f2c9bd373cdb2afbb0 Mon Sep 17 00:00:00 2001 From: Aaron Durbin Date: Tue, 5 Aug 2014 10:48:20 -0500 Subject: cbfstool: process cbfs_payload_segment(s) in host byte order The printing routines of the cbfs_payload_segment assumed the type could be accessed in host order. Each of the fields need to be converted to the host order before inspecting the fields. In addition, this removes all the ntoh*() calls while processing the cbfs_payload_segment structures. cbfstool would crash adding entries or just printing entries containing a payload when -v was passed on the command line. Change-Id: Iff41c64a99001b9e3920e2e26828c5fd6e671239 Signed-off-by: Aaron Durbin Reviewed-on: http://review.coreboot.org/6498 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel Reviewed-by: Martin Roth --- util/cbfstool/cbfs-mkpayload.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'util/cbfstool/cbfs-mkpayload.c') diff --git a/util/cbfstool/cbfs-mkpayload.c b/util/cbfstool/cbfs-mkpayload.c index 67002b0e66..adbe313b18 100644 --- a/util/cbfstool/cbfs-mkpayload.c +++ b/util/cbfstool/cbfs-mkpayload.c @@ -50,6 +50,23 @@ void xdr_segs(struct buffer *output, xdr_be.put32(&outheader, segs[i].mem_len); } } + +void xdr_get_seg(struct cbfs_payload_segment *out, + struct cbfs_payload_segment *in) +{ + struct buffer inheader; + + inheader.data = (void *)in; + inheader.size = sizeof(*in); + + out->type = xdr_be.get32(&inheader); + out->compression = xdr_be.get32(&inheader); + out->offset = xdr_be.get32(&inheader); + out->load_addr = xdr_be.get64(&inheader); + out->len = xdr_be.get32(&inheader); + out->mem_len = xdr_be.get32(&inheader); +} + int parse_elf_to_payload(const struct buffer *input, struct buffer *output, uint32_t arch, comp_algo algo) { -- cgit v1.2.3