Skip to contentSkip to conversation

sh4: Fix initramfs initialization for endiannes-mismatched targets

PATCH In review Guenter Roeck 2 participants 2 messages Aug 12, 2015 – Aug 17, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sh4: Fix initramfs initialization for endiannes-mismatched targets

If host and target endianness does not match, loding an initramfs does not work. Fix by writing boot parameters with appropriate endianness conversion.

---
 hw/sh4/r2d.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
hw/sh4/r2d.c +3 -3
index 5e22ed7..3b0b2ec 100644
@@ -338,9 +338,9 @@ static void r2d_init(MachineState *machine)
         }
 
         /* initialization which should be done by firmware */
-        boot_params.loader_type = 1;
-        boot_params.initrd_start = INITRD_LOAD_OFFSET;
-        boot_params.initrd_size = initrd_size;
+        boot_params.loader_type = tswap32(1);
+        boot_params.initrd_start = tswap32(INITRD_LOAD_OFFSET);
+        boot_params.initrd_size = tswap32(initrd_size);
     }
 
     if (kernel_cmdline) {
Signature · 1 line
2.1.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 15 lines · Guenter Roeck

If host and target endianness does not match, loding an initramfs does not work. Fix by writing boot parameters with appropriate endianness conversion.

---
 hw/sh4/r2d.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
hw/sh4/r2d.c +0 -0
index 5e22ed7..3b0b2ec 100644
@@ -338,9 +338,9 @@ static void r2d_init(MachineState *machine)
         }
 

hw/sh4/r2d.c static void r2d_init(MachineState *machine) · line 346

Quoted 10 lines
hw/sh4/r2d.c +3 -3
         /* initialization which should be done by firmware */
-        boot_params.loader_type = 1;
-        boot_params.initrd_start = INITRD_LOAD_OFFSET;
-        boot_params.initrd_size = initrd_size;
+        boot_params.loader_type = tswap32(1);
+        boot_params.initrd_start = tswap32(INITRD_LOAD_OFFSET);
+        boot_params.initrd_size = tswap32(initrd_size);
     }
 
     if (kernel_cmdline) {

Good catch. I have added it to my sh4-next queue:

http://git.aurel32.net/?p=qemu.git;a=shortlog;h=refs/heads/sh4-next

Signature · 2 lines
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
[email protected]                 http://www.aurel32.net