Peter,
You're right, that u64 cast wasn't needed, but I needed to cast the result to u32. The (void*) is evidently expecting a u32. Is that correct? Would SeaBIOS always be expecting a u32 for an address to execute from?
I also cleaned up the macro to use the existing ntohl. The new patch is below. I also tested it.
dave
commit 66c82fdbf283340067a8531ef6e3afae82102396 Author: Dave Frodin dave.frodin@se-eng.com Date: Tue Aug 7 17:01:08 2012 -0600
Seabios: This fixes reading of CBFS 64 bit destination addresses from payload headers. This allows img/payloads to run.
diff --git a/src/coreboot.c b/src/coreboot.c index e116a14..b989517 100644 --- a/src/coreboot.c +++ b/src/coreboot.c @@ -470,6 +470,8 @@ struct cbfs_payload { struct cbfs_payload_segment segments[1]; };
+#define ntohll(in) (((u64) ntohl( (in) & 0xFFFFFFFF) << 32) | ((u64) ntohl( (in) >> 32))) + void cbfs_run_payload(struct cbfs_file *file) { @@ -480,7 +482,7 @@ cbfs_run_payload(struct cbfs_file *file) struct cbfs_payload_segment *seg = pay->segments; for (;;) { void *src = (void*)pay + ntohl(seg->offset); - void *dest = (void*)ntohl((u32)seg->load_addr); + void *dest = (void*)(u32)ntohll(seg->load_addr); u32 src_len = ntohl(seg->len); u32 dest_len = ntohl(seg->mem_len); switch (seg->type) {
----- Original Message -----
From: "Peter Stuge" peter@stuge.se To: seabios@seabios.org Sent: Wednesday, August 8, 2012 5:29:57 AM Subject: Re: [SeaBIOS] The cbfs header for a payloads dest addr is a u64, use ntohll instead of ntohl
Dave Frodin wrote:
@@ -480,7 +491,7 @@ cbfs_run_payload(struct cbfs_file *file) struct cbfs_payload_segment *seg = pay->segments; for (;;) { void *src = (void*)pay + ntohl(seg->offset);
void *dest = (void*)ntohl((u32)seg->load_addr);
void *dest = (void*)ntohll((u64)seg->load_addr);
Is the (u64) cast still needed? The less casts the better.
//Peter
SeaBIOS mailing list SeaBIOS@seabios.org http://www.seabios.org/mailman/listinfo/seabios