Commit fd0bbb12c3de53b52f2ac7bf6e55fd7233c6f476

Authored by bellard
1 parent f2aa58c6

cmdline init fix


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@956 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 26 additions and 9 deletions
hw/ppc.c
@@ -22,6 +22,7 @@ @@ -22,6 +22,7 @@
22 * THE SOFTWARE. 22 * THE SOFTWARE.
23 */ 23 */
24 #include "vl.h" 24 #include "vl.h"
  25 +#include "m48t59.h"
25 26
26 /*****************************************************************************/ 27 /*****************************************************************************/
27 /* PPC time base and decrementer emulation */ 28 /* PPC time base and decrementer emulation */
@@ -109,7 +110,7 @@ uint32_t cpu_ppc_load_decr (CPUState *env) @@ -109,7 +110,7 @@ uint32_t cpu_ppc_load_decr (CPUState *env)
109 110
110 decr = muldiv64(tb_env->decr_next - qemu_get_clock(vm_clock), 111 decr = muldiv64(tb_env->decr_next - qemu_get_clock(vm_clock),
111 tb_env->tb_freq, ticks_per_sec); 112 tb_env->tb_freq, ticks_per_sec);
112 -#ifdef DEBUG_TB 113 +#if defined(DEBUG_TB)
113 printf("%s: 0x%08x\n", __func__, decr); 114 printf("%s: 0x%08x\n", __func__, decr);
114 #endif 115 #endif
115 116
@@ -257,7 +258,7 @@ CPUReadMemoryFunc *PPC_io_read[] = { @@ -257,7 +258,7 @@ CPUReadMemoryFunc *PPC_io_read[] = {
257 258
258 /*****************************************************************************/ 259 /*****************************************************************************/
259 /* Debug port */ 260 /* Debug port */
260 -void PREP_debug_write (void *opaque, uint32_t addr, uint32_t val) 261 +void PPC_debug_write (void *opaque, uint32_t addr, uint32_t val)
261 { 262 {
262 addr &= 0xF; 263 addr &= 0xF;
263 switch (addr) { 264 switch (addr) {
@@ -270,7 +271,7 @@ void PREP_debug_write (void *opaque, uint32_t addr, uint32_t val) @@ -270,7 +271,7 @@ void PREP_debug_write (void *opaque, uint32_t addr, uint32_t val)
270 break; 271 break;
271 case 2: 272 case 2:
272 printf("Set loglevel to %04x\n", val); 273 printf("Set loglevel to %04x\n", val);
273 - cpu_set_log(val); 274 + cpu_set_log(val | 0x100);
274 break; 275 break;
275 } 276 }
276 } 277 }
@@ -397,13 +398,16 @@ uint16_t NVRAM_compute_crc (m48t59_t *nvram, uint32_t start, uint32_t count) @@ -397,13 +398,16 @@ uint16_t NVRAM_compute_crc (m48t59_t *nvram, uint32_t start, uint32_t count)
397 return crc; 398 return crc;
398 } 399 }
399 400
  401 +#define CMDLINE_ADDR 0x017ff000
  402 +
400 int PPC_NVRAM_set_params (m48t59_t *nvram, uint16_t NVRAM_size, 403 int PPC_NVRAM_set_params (m48t59_t *nvram, uint16_t NVRAM_size,
401 const unsigned char *arch, 404 const unsigned char *arch,
402 uint32_t RAM_size, int boot_device, 405 uint32_t RAM_size, int boot_device,
403 uint32_t kernel_image, uint32_t kernel_size, 406 uint32_t kernel_image, uint32_t kernel_size,
404 - uint32_t cmdline, uint32_t cmdline_size, 407 + const char *cmdline,
405 uint32_t initrd_image, uint32_t initrd_size, 408 uint32_t initrd_image, uint32_t initrd_size,
406 - uint32_t NVRAM_image) 409 + uint32_t NVRAM_image,
  410 + int width, int height, int depth)
407 { 411 {
408 uint16_t crc; 412 uint16_t crc;
409 413
@@ -416,13 +420,24 @@ int PPC_NVRAM_set_params (m48t59_t *nvram, uint16_t NVRAM_size, @@ -416,13 +420,24 @@ int PPC_NVRAM_set_params (m48t59_t *nvram, uint16_t NVRAM_size,
416 NVRAM_set_byte(nvram, 0x34, boot_device); 420 NVRAM_set_byte(nvram, 0x34, boot_device);
417 NVRAM_set_lword(nvram, 0x38, kernel_image); 421 NVRAM_set_lword(nvram, 0x38, kernel_image);
418 NVRAM_set_lword(nvram, 0x3C, kernel_size); 422 NVRAM_set_lword(nvram, 0x3C, kernel_size);
419 - NVRAM_set_lword(nvram, 0x40, cmdline);  
420 - NVRAM_set_lword(nvram, 0x44, cmdline_size); 423 + if (cmdline) {
  424 + /* XXX: put the cmdline in NVRAM too ? */
  425 + strcpy(phys_ram_base + CMDLINE_ADDR, cmdline);
  426 + NVRAM_set_lword(nvram, 0x40, CMDLINE_ADDR);
  427 + NVRAM_set_lword(nvram, 0x44, strlen(cmdline));
  428 + } else {
  429 + NVRAM_set_lword(nvram, 0x40, 0);
  430 + NVRAM_set_lword(nvram, 0x44, 0);
  431 + }
421 NVRAM_set_lword(nvram, 0x48, initrd_image); 432 NVRAM_set_lword(nvram, 0x48, initrd_image);
422 NVRAM_set_lword(nvram, 0x4C, initrd_size); 433 NVRAM_set_lword(nvram, 0x4C, initrd_size);
423 NVRAM_set_lword(nvram, 0x50, NVRAM_image); 434 NVRAM_set_lword(nvram, 0x50, NVRAM_image);
424 - crc = NVRAM_compute_crc(nvram, 0x00, 0x5C);  
425 - NVRAM_set_word(nvram, 0x5C, crc); 435 +
  436 + NVRAM_set_word(nvram, 0x54, width);
  437 + NVRAM_set_word(nvram, 0x56, height);
  438 + NVRAM_set_word(nvram, 0x58, depth);
  439 + crc = NVRAM_compute_crc(nvram, 0x00, 0xF8);
  440 + NVRAM_set_word(nvram, 0xFC, crc);
426 441
427 return 0; 442 return 0;
428 } 443 }
@@ -442,4 +457,6 @@ void ppc_init (int ram_size, int vga_ram_size, int boot_device, @@ -442,4 +457,6 @@ void ppc_init (int ram_size, int vga_ram_size, int boot_device,
442 snapshot, kernel_filename, kernel_cmdline, 457 snapshot, kernel_filename, kernel_cmdline,
443 initrd_filename); 458 initrd_filename);
444 } 459 }
  460 + /* Special port to get debug messages from Open-Firmware */
  461 + register_ioport_write(0x0F00, 4, 1, &PPC_debug_write, NULL);
445 } 462 }