Commit e8afa06581cb7ea808d6568d4106eb1b6f1ab334

Authored by aurel32
1 parent f364515c

target-sh4: r2d --append option support

Add linux kernel command line ("--append" option) support.
Fix kernel loading address to appropriate position when --append used.
Using --kernel but --append case is left untouched for backward compatibility.

This also change the host<->SH address mapping for r2d to
 host addr == phys_ram_base + SH addr.

Signed-off-by: Takashi YOSHII <takasi-y@ops.dti.ne.jp>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6916 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 16 additions and 5 deletions
hw/r2d.c
@@ -37,6 +37,9 @@ @@ -37,6 +37,9 @@
37 37
38 #define SM501_VRAM_SIZE 0x800000 38 #define SM501_VRAM_SIZE 0x800000
39 39
  40 +/* CONFIG_BOOT_LINK_OFFSET of Linux kernel */
  41 +#define LINUX_LOAD_OFFSET 0x800000
  42 +
40 #define PA_IRLMSK 0x00 43 #define PA_IRLMSK 0x00
41 #define PA_POWOFF 0x30 44 #define PA_POWOFF 0x30
42 #define PA_VERREG 0x32 45 #define PA_VERREG 0x32
@@ -212,6 +215,7 @@ static void r2d_init(ram_addr_t ram_size, int vga_ram_size, @@ -212,6 +215,7 @@ static void r2d_init(ram_addr_t ram_size, int vga_ram_size,
212 } 215 }
213 216
214 /* Allocate memory space */ 217 /* Allocate memory space */
  218 + qemu_ram_alloc(SDRAM_BASE); /* to adjust the offset */
215 sdram_addr = qemu_ram_alloc(SDRAM_SIZE); 219 sdram_addr = qemu_ram_alloc(SDRAM_SIZE);
216 cpu_register_physical_memory(SDRAM_BASE, SDRAM_SIZE, sdram_addr); 220 cpu_register_physical_memory(SDRAM_BASE, SDRAM_SIZE, sdram_addr);
217 /* Register peripherals */ 221 /* Register peripherals */
@@ -233,20 +237,27 @@ static void r2d_init(ram_addr_t ram_size, int vga_ram_size, @@ -233,20 +237,27 @@ static void r2d_init(ram_addr_t ram_size, int vga_ram_size,
233 pci_nic_init(pci, &nd_table[i], (i==0)? 2<<3: -1, "rtl8139"); 237 pci_nic_init(pci, &nd_table[i], (i==0)? 2<<3: -1, "rtl8139");
234 238
235 /* Todo: register on board registers */ 239 /* Todo: register on board registers */
236 - { 240 + if (kernel_filename) {
237 int kernel_size; 241 int kernel_size;
238 /* initialization which should be done by firmware */ 242 /* initialization which should be done by firmware */
239 stl_phys(SH7750_BCR1, 1<<3); /* cs3 SDRAM */ 243 stl_phys(SH7750_BCR1, 1<<3); /* cs3 SDRAM */
240 stw_phys(SH7750_BCR2, 3<<(3*2)); /* cs3 32bit */ 244 stw_phys(SH7750_BCR2, 3<<(3*2)); /* cs3 32bit */
241 245
242 - kernel_size = load_image(kernel_filename, phys_ram_base); 246 + if (kernel_cmdline) {
  247 + kernel_size = load_image_targphys(kernel_filename,
  248 + SDRAM_BASE + LINUX_LOAD_OFFSET,
  249 + SDRAM_SIZE - LINUX_LOAD_OFFSET);
  250 + env->pc = (SDRAM_BASE + LINUX_LOAD_OFFSET) | 0xa0000000;
  251 + pstrcpy_targphys(SDRAM_BASE + 0x10100, 256, kernel_cmdline);
  252 + } else {
  253 + kernel_size = load_image(kernel_filename, SDRAM_BASE);
  254 + env->pc = SDRAM_BASE | 0xa0000000; /* Start from P2 area */
  255 + }
243 256
244 if (kernel_size < 0) { 257 if (kernel_size < 0) {
245 fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename); 258 fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename);
246 exit(1); 259 exit(1);
247 } 260 }
248 -  
249 - env->pc = SDRAM_BASE | 0xa0000000; /* Start from P2 area */  
250 } 261 }
251 } 262 }
252 263
@@ -254,5 +265,5 @@ QEMUMachine r2d_machine = { @@ -254,5 +265,5 @@ QEMUMachine r2d_machine = {
254 .name = "r2d", 265 .name = "r2d",
255 .desc = "r2d-plus board", 266 .desc = "r2d-plus board",
256 .init = r2d_init, 267 .init = r2d_init,
257 - .ram_require = (SDRAM_SIZE + SM501_VRAM_SIZE) | RAMSIZE_FIXED, 268 + .ram_require = (SDRAM_BASE + SDRAM_SIZE + SM501_VRAM_SIZE) | RAMSIZE_FIXED,
258 }; 269 };