diff options
| author | Nathan Rossi <nathan.rossi@xilinx.com> | 2013-06-11 14:06:58 +1000 |
|---|---|---|
| committer | Nathan Rossi <nathan.rossi@xilinx.com> | 2013-06-19 14:26:08 +1000 |
| commit | ea421c57de200dc6b02e1ad025186d32b8f72ad0 (patch) | |
| tree | 33f75e49c695507c240d5f8275fc7c569165784f /recipes-devtools | |
| parent | bd5773b10e482e551427b64fee902ca38846e5af (diff) | |
| download | meta-xilinx-ea421c57de200dc6b02e1ad025186d32b8f72ad0.tar.gz | |
qemu: Add MicroBlaze specific patches for QEMU
* Added initrd support for MicroBlaze QEMU
Signed-off-by: Nathan Rossi <nathan.rossi@xilinx.com>
Diffstat (limited to 'recipes-devtools')
| -rw-r--r-- | recipes-devtools/qemu/files/microblaze-Add-support-for-loading-initrd-images.patch | 176 | ||||
| -rw-r--r-- | recipes-devtools/qemu/qemu_1.5.0.bbappend | 6 |
2 files changed, 182 insertions, 0 deletions
diff --git a/recipes-devtools/qemu/files/microblaze-Add-support-for-loading-initrd-images.patch b/recipes-devtools/qemu/files/microblaze-Add-support-for-loading-initrd-images.patch new file mode 100644 index 00000000..0115f23f --- /dev/null +++ b/recipes-devtools/qemu/files/microblaze-Add-support-for-loading-initrd-images.patch | |||
| @@ -0,0 +1,176 @@ | |||
| 1 | From: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
| 2 | Subject: [PATCH] microblaze: Add support for loading initrd images | ||
| 3 | |||
| 4 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
| 5 | --- | ||
| 6 | hw/microblaze/boot.c | 61 ++++++++++++++++++++++++++--- | ||
| 7 | hw/microblaze/boot.h | 7 ++- | ||
| 8 | hw/microblaze/petalogix_ml605_mmu.c | 6 ++- | ||
| 9 | hw/microblaze/petalogix_s3adsp1800_mmu.c | 4 +- | ||
| 10 | 4 files changed, 66 insertions(+), 12 deletions(-) | ||
| 11 | |||
| 12 | diff --git a/hw/microblaze/boot.c b/hw/microblaze/boot.c | ||
| 13 | index e543d88..8f52a5c 100644 | ||
| 14 | --- a/hw/microblaze/boot.c | ||
| 15 | +++ b/hw/microblaze/boot.c | ||
| 16 | @@ -38,6 +38,8 @@ static struct | ||
| 17 | void (*machine_cpu_reset)(MicroBlazeCPU *); | ||
| 18 | uint32_t bootstrap_pc; | ||
| 19 | uint32_t cmdline; | ||
| 20 | + uint32_t initrd_start; | ||
| 21 | + uint32_t initrd_end; | ||
| 22 | uint32_t fdt; | ||
| 23 | } boot_info; | ||
| 24 | |||
| 25 | @@ -48,6 +50,7 @@ static void main_cpu_reset(void *opaque) | ||
| 26 | |||
| 27 | cpu_reset(CPU(cpu)); | ||
| 28 | env->regs[5] = boot_info.cmdline; | ||
| 29 | + env->regs[6] = boot_info.initrd_start; | ||
| 30 | env->regs[7] = boot_info.fdt; | ||
| 31 | env->sregs[SR_PC] = boot_info.bootstrap_pc; | ||
| 32 | if (boot_info.machine_cpu_reset) { | ||
| 33 | @@ -56,9 +59,11 @@ static void main_cpu_reset(void *opaque) | ||
| 34 | } | ||
| 35 | |||
| 36 | static int microblaze_load_dtb(hwaddr addr, | ||
| 37 | - uint32_t ramsize, | ||
| 38 | - const char *kernel_cmdline, | ||
| 39 | - const char *dtb_filename) | ||
| 40 | + uint32_t ramsize, | ||
| 41 | + uint32_t initrd_start, | ||
| 42 | + uint32_t initrd_end, | ||
| 43 | + const char *kernel_cmdline, | ||
| 44 | + const char *dtb_filename) | ||
| 45 | { | ||
| 46 | int fdt_size; | ||
| 47 | #ifdef CONFIG_FDT | ||
| 48 | @@ -80,6 +85,20 @@ static int microblaze_load_dtb(hwaddr addr, | ||
| 49 | } | ||
| 50 | } | ||
| 51 | |||
| 52 | + if (initrd_start) { | ||
| 53 | + r = qemu_devtree_setprop_cell(fdt, "/chosen", "linux,initrd-start", | ||
| 54 | + initrd_start); | ||
| 55 | + if (r < 0) { | ||
| 56 | + fprintf(stderr, "couldn't set /chosen/linux,initrd-start\n"); | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + r = qemu_devtree_setprop_cell(fdt, "/chosen", "linux,initrd-end", | ||
| 60 | + initrd_end); | ||
| 61 | + if (r < 0) { | ||
| 62 | + fprintf(stderr, "couldn't set /chosen/linux,initrd-end\n"); | ||
| 63 | + } | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | cpu_physical_memory_write(addr, fdt, fdt_size); | ||
| 67 | #else | ||
| 68 | /* We lack libfdt so we cannot manipulate the fdt. Just pass on the blob | ||
| 69 | @@ -101,8 +120,11 @@ static uint64_t translate_kernel_address(void *opaque, uint64_t addr) | ||
| 70 | } | ||
| 71 | |||
| 72 | void microblaze_load_kernel(MicroBlazeCPU *cpu, hwaddr ddr_base, | ||
| 73 | - uint32_t ramsize, const char *dtb_filename, | ||
| 74 | - void (*machine_cpu_reset)(MicroBlazeCPU *)) | ||
| 75 | + uint32_t ramsize, | ||
| 76 | + const char *initrd_filename, | ||
| 77 | + const char *dtb_filename, | ||
| 78 | + void (*machine_cpu_reset)(MicroBlazeCPU *), | ||
| 79 | + void *machine_cpu_reset_opaque) | ||
| 80 | { | ||
| 81 | QemuOpts *machine_opts; | ||
| 82 | const char *kernel_filename = NULL; | ||
| 83 | @@ -164,14 +186,39 @@ void microblaze_load_kernel(MicroBlazeCPU *cpu, hwaddr ddr_base, | ||
| 84 | high = (ddr_base + kernel_size + 3) & ~3; | ||
| 85 | } | ||
| 86 | |||
| 87 | + if (initrd_filename) { | ||
| 88 | + int initrd_size; | ||
| 89 | + uint32_t initrd_offset; | ||
| 90 | + | ||
| 91 | + high += kernel_size + 3; | ||
| 92 | + high &= ~3; | ||
| 93 | + boot_info.initrd_start = high; | ||
| 94 | + initrd_offset = boot_info.initrd_start - ddr_base; | ||
| 95 | + | ||
| 96 | + initrd_size = load_image_targphys(initrd_filename, | ||
| 97 | + boot_info.initrd_start, | ||
| 98 | + ram_size - initrd_offset); | ||
| 99 | + if (initrd_size < 0) { | ||
| 100 | + fprintf(stderr, "qemu: could not load initrd '%s'\n", | ||
| 101 | + initrd_filename); | ||
| 102 | + exit(1); | ||
| 103 | + } | ||
| 104 | + boot_info.initrd_end = boot_info.initrd_start + initrd_size; | ||
| 105 | + high += initrd_size + 3; | ||
| 106 | + high &= ~3; | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | boot_info.cmdline = high + 4096; | ||
| 110 | if (kernel_cmdline && strlen(kernel_cmdline)) { | ||
| 111 | pstrcpy_targphys("cmdline", boot_info.cmdline, 256, kernel_cmdline); | ||
| 112 | } | ||
| 113 | /* Provide a device-tree. */ | ||
| 114 | boot_info.fdt = boot_info.cmdline + 4096; | ||
| 115 | - microblaze_load_dtb(boot_info.fdt, ram_size, kernel_cmdline, | ||
| 116 | - dtb_filename); | ||
| 117 | + microblaze_load_dtb(boot_info.fdt, ram_size, | ||
| 118 | + boot_info.initrd_start, | ||
| 119 | + boot_info.initrd_end, | ||
| 120 | + kernel_cmdline, | ||
| 121 | + dtb_filename); | ||
| 122 | } | ||
| 123 | |||
| 124 | } | ||
| 125 | diff --git a/hw/microblaze/boot.h b/hw/microblaze/boot.h | ||
| 126 | index b14ef2b..bae7cae 100644 | ||
| 127 | --- a/hw/microblaze/boot.h | ||
| 128 | +++ b/hw/microblaze/boot.h | ||
| 129 | @@ -4,7 +4,10 @@ | ||
| 130 | #include "hw/hw.h" | ||
| 131 | |||
| 132 | void microblaze_load_kernel(MicroBlazeCPU *cpu, hwaddr ddr_base, | ||
| 133 | - uint32_t ramsize, const char *dtb_filename, | ||
| 134 | - void (*machine_cpu_reset)(MicroBlazeCPU *)); | ||
| 135 | + uint32_t ramsize, | ||
| 136 | + const char *initrd_filename, | ||
| 137 | + const char *dtb_filename, | ||
| 138 | + void (*machine_cpu_reset)(MicroBlazeCPU *), | ||
| 139 | + void *machine_cpu_reset_opaque); | ||
| 140 | |||
| 141 | #endif /* __MICROBLAZE_BOOT __ */ | ||
| 142 | diff --git a/hw/microblaze/petalogix_ml605_mmu.c b/hw/microblaze/petalogix_ml605_mmu.c | ||
| 143 | index 3340468..3d1861f 100644 | ||
| 144 | --- a/hw/microblaze/petalogix_ml605_mmu.c | ||
| 145 | +++ b/hw/microblaze/petalogix_ml605_mmu.c | ||
| 146 | @@ -176,8 +176,10 @@ petalogix_ml605_init(QEMUMachineInitArgs *args) | ||
| 147 | } | ||
| 148 | } | ||
| 149 | |||
| 150 | - microblaze_load_kernel(cpu, ddr_base, ram_size, BINARY_DEVICE_TREE_FILE, | ||
| 151 | - machine_cpu_reset); | ||
| 152 | + microblaze_load_kernel(cpu, ddr_base, ram_size, | ||
| 153 | + args->initrd_filename, | ||
| 154 | + BINARY_DEVICE_TREE_FILE, | ||
| 155 | + machine_cpu_reset, NULL); | ||
| 156 | |||
| 157 | } | ||
| 158 | |||
| 159 | diff --git a/hw/microblaze/petalogix_s3adsp1800_mmu.c b/hw/microblaze/petalogix_s3adsp1800_mmu.c | ||
| 160 | index 7c258f0..21c0ffb 100644 | ||
| 161 | --- a/hw/microblaze/petalogix_s3adsp1800_mmu.c | ||
| 162 | +++ b/hw/microblaze/petalogix_s3adsp1800_mmu.c | ||
| 163 | @@ -108,7 +108,9 @@ petalogix_s3adsp1800_init(QEMUMachineInitArgs *args) | ||
| 164 | xilinx_ethlite_create(&nd_table[0], ETHLITE_BASEADDR, irq[1], 0, 0); | ||
| 165 | |||
| 166 | microblaze_load_kernel(cpu, ddr_base, ram_size, | ||
| 167 | - BINARY_DEVICE_TREE_FILE, machine_cpu_reset); | ||
| 168 | + args->initrd_filename, | ||
| 169 | + BINARY_DEVICE_TREE_FILE, | ||
| 170 | + machine_cpu_reset, NULL); | ||
| 171 | } | ||
| 172 | |||
| 173 | static QEMUMachine petalogix_s3adsp1800_machine = { | ||
| 174 | -- | ||
| 175 | 1.7.5.4 | ||
| 176 | |||
diff --git a/recipes-devtools/qemu/qemu_1.5.0.bbappend b/recipes-devtools/qemu/qemu_1.5.0.bbappend new file mode 100644 index 00000000..28c67341 --- /dev/null +++ b/recipes-devtools/qemu/qemu_1.5.0.bbappend | |||
| @@ -0,0 +1,6 @@ | |||
| 1 | QEMU_TARGETS += "microblazeel" | ||
| 2 | |||
| 3 | FILESEXTRAPATHS_append := "${THISDIR}/files:" | ||
| 4 | SRC_URI_append += " \ | ||
| 5 | file://microblaze-Add-support-for-loading-initrd-images.patch \ | ||
| 6 | " | ||
