Skip to contentSkip to conversation

target-sh4: Fix initrd initialization for endiannes-mismatched targets

PATCH New Guenter Roeck 1 participant 1 message Oct 8, 2014

lore
Share & tools
lore
#0 lore raw

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

If host and target endianness does not match, loding an initrd does not work, but results in a kernel log message similar to the following.

... MOUNT_ROOT_RDONLY - 00000000

... RAMDISK_FLAGS     - 00000000
... ORIG_ROOT_DEV     - 00000000
... LOADER_TYPE       - 01000000
... INITRD_START      - 00008001
... INITRD_SIZE       - 00a01b00

Booting machvec: RTS7751R2D
initrd must be page aligned
initrd disabled

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 321379e..d86eb12 100644
@@ -336,9 +336,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
1.9.1