Add PowerPC power-management state check callback.
[qemu] / hw / ppc405_boards.c
index 2e2ca0e..8c00148 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * QEMU PowerPC 405 evaluation boards emulation
- * 
+ *
  * Copyright (c) 2007 Jocelyn Mayer
- * 
+ *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
  * in the Software without restriction, including without limitation the rights
@@ -172,9 +172,9 @@ static void ref405ep_fpga_init (uint32_t base)
 }
 
 static void ref405ep_init (int ram_size, int vga_ram_size, int boot_device,
-                           DisplayState *ds, const char **fd_filename, 
+                           DisplayState *ds, const char **fd_filename,
                            int snapshot,
-                           const char *kernel_filename, 
+                           const char *kernel_filename,
                            const char *kernel_cmdline,
                            const char *initrd_filename,
                            const char *cpu_model)
@@ -184,7 +184,7 @@ static void ref405ep_init (int ram_size, int vga_ram_size, int boot_device,
     CPUPPCState *env;
     qemu_irq *pic;
     ram_addr_t sram_offset, bios_offset, bdloc;
-    target_ulong ram_bases[2], ram_sizes[2];
+    target_phys_addr_t ram_bases[2], ram_sizes[2];
     target_ulong sram_size, bios_size;
     //int phy_addr = 0;
     //static int phy_addr = 1;
@@ -226,8 +226,8 @@ static void ref405ep_init (int ram_size, int vga_ram_size, int boot_device,
                fl_idx, bios_size, bios_offset, -bios_size,
                bdrv_get_device_name(pflash_table[fl_idx]), fl_sectors);
 #endif
-        pflash_register(-(bios_size), bios_offset, pflash_table[fl_idx],
-                        65536, fl_sectors, 2,
+        pflash_register((uint32_t)(-bios_size), bios_offset,
+                        pflash_table[fl_idx], 65536, fl_sectors, 2,
                         0x0001, 0x22DA, 0x0000, 0x0000);
         fl_idx++;
     } else
@@ -236,14 +236,16 @@ static void ref405ep_init (int ram_size, int vga_ram_size, int boot_device,
 #ifdef DEBUG_BOARD_INIT
         printf("Load BIOS from file\n");
 #endif
-        snprintf(buf, sizeof(buf), "%s/%s", bios_dir, BIOS_FILENAME);
+        if (bios_name == NULL)
+            bios_name = BIOS_FILENAME;
+        snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
         bios_size = load_image(buf, phys_ram_base + bios_offset);
         if (bios_size < 0 || bios_size > BIOS_SIZE) {
             fprintf(stderr, "qemu: could not load PowerPC bios '%s'\n", buf);
             exit(1);
         }
         bios_size = (bios_size + 0xfff) & ~0xfff;
-        cpu_register_physical_memory((uint32_t)(-bios_size), 
+        cpu_register_physical_memory((uint32_t)(-bios_size),
                                      bios_size, bios_offset | IO_MEM_ROM);
     }
     bios_offset += bios_size;
@@ -266,7 +268,7 @@ static void ref405ep_init (int ram_size, int vga_ram_size, int boot_device,
         memset(&bd, 0, sizeof(bd));
         bd.bi_memstart = 0x00000000;
         bd.bi_memsize = ram_size;
-        bd.bi_flashstart = -(bios_size);
+        bd.bi_flashstart = -bios_size;
         bd.bi_flashsize = -bios_size;
         bd.bi_flashoffset = 0;
         bd.bi_sramstart = 0xFFF00000;
@@ -288,13 +290,13 @@ static void ref405ep_init (int ram_size, int vga_ram_size, int boot_device,
         bd.bi_plb_busfreq = 33333333;
         bd.bi_pci_busfreq = 33333333;
         bd.bi_opbfreq = 33333333;
-        bdloc = ppc405_set_bootinfo(env, &bd);
+        bdloc = ppc405_set_bootinfo(env, &bd, 0x00000001);
         env->gpr[3] = bdloc;
         kernel_base = KERNEL_LOAD_ADDR;
         /* now we can load the kernel */
         kernel_size = load_image(kernel_filename, phys_ram_base + kernel_base);
         if (kernel_size < 0) {
-            fprintf(stderr, "qemu: could not load kernel '%s'\n", 
+            fprintf(stderr, "qemu: could not load kernel '%s'\n",
                     kernel_filename);
             exit(1);
         }
@@ -310,7 +312,7 @@ static void ref405ep_init (int ram_size, int vga_ram_size, int boot_device,
             initrd_size = load_image(initrd_filename,
                                      phys_ram_base + initrd_base);
             if (initrd_size < 0) {
-                fprintf(stderr, "qemu: could not load initial ram disk '%s'\n", 
+                fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
                         initrd_filename);
                 exit(1);
             }
@@ -495,9 +497,9 @@ static void taihu_cpld_init (uint32_t base)
 }
 
 static void taihu_405ep_init(int ram_size, int vga_ram_size, int boot_device,
-                             DisplayState *ds, const char **fd_filename, 
+                             DisplayState *ds, const char **fd_filename,
                              int snapshot,
-                             const char *kernel_filename, 
+                             const char *kernel_filename,
                              const char *kernel_cmdline,
                              const char *initrd_filename,
                              const char *cpu_model)
@@ -506,12 +508,12 @@ static void taihu_405ep_init(int ram_size, int vga_ram_size, int boot_device,
     CPUPPCState *env;
     qemu_irq *pic;
     ram_addr_t bios_offset;
-    target_ulong ram_bases[2], ram_sizes[2];
+    target_phys_addr_t ram_bases[2], ram_sizes[2];
     target_ulong bios_size;
     target_ulong kernel_base, kernel_size, initrd_base, initrd_size;
     int linux_boot;
     int fl_idx, fl_sectors;
-    
+
     /* RAM is soldered to the board so the size cannot be changed */
     ram_bases[0] = 0x00000000;
     ram_sizes[0] = 0x04000000;
@@ -539,8 +541,8 @@ static void taihu_405ep_init(int ram_size, int vga_ram_size, int boot_device,
                fl_idx, bios_size, bios_offset, -bios_size,
                bdrv_get_device_name(pflash_table[fl_idx]), fl_sectors);
 #endif
-        pflash_register(-(bios_size), bios_offset, pflash_table[fl_idx],
-                        65536, fl_sectors, 4,
+        pflash_register((uint32_t)(-bios_size), bios_offset,
+                        pflash_table[fl_idx], 65536, fl_sectors, 4,
                         0x0001, 0x22DA, 0x0000, 0x0000);
         fl_idx++;
     } else
@@ -549,14 +551,16 @@ static void taihu_405ep_init(int ram_size, int vga_ram_size, int boot_device,
 #ifdef DEBUG_BOARD_INIT
         printf("Load BIOS from file\n");
 #endif
-        snprintf(buf, sizeof(buf), "%s/%s", bios_dir, BIOS_FILENAME);
+        if (bios_name == NULL)
+            bios_name = BIOS_FILENAME;
+        snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
         bios_size = load_image(buf, phys_ram_base + bios_offset);
         if (bios_size < 0 || bios_size > BIOS_SIZE) {
             fprintf(stderr, "qemu: could not load PowerPC bios '%s'\n", buf);
             exit(1);
         }
         bios_size = (bios_size + 0xfff) & ~0xfff;
-        cpu_register_physical_memory((uint32_t)(-bios_size), 
+        cpu_register_physical_memory((uint32_t)(-bios_size),
                                      bios_size, bios_offset | IO_MEM_ROM);
     }
     bios_offset += bios_size;
@@ -592,7 +596,7 @@ static void taihu_405ep_init(int ram_size, int vga_ram_size, int boot_device,
         /* now we can load the kernel */
         kernel_size = load_image(kernel_filename, phys_ram_base + kernel_base);
         if (kernel_size < 0) {
-            fprintf(stderr, "qemu: could not load kernel '%s'\n", 
+            fprintf(stderr, "qemu: could not load kernel '%s'\n",
                     kernel_filename);
             exit(1);
         }
@@ -603,7 +607,7 @@ static void taihu_405ep_init(int ram_size, int vga_ram_size, int boot_device,
                                      phys_ram_base + initrd_base);
             if (initrd_size < 0) {
                 fprintf(stderr,
-                        "qemu: could not load initial ram disk '%s'\n", 
+                        "qemu: could not load initial ram disk '%s'\n",
                         initrd_filename);
                 exit(1);
             }