mips bios loading fix
[qemu] / hw / pc.c
diff --git a/hw/pc.c b/hw/pc.c
index 8e750b6..b9bfd83 100644 (file)
--- a/hw/pc.c
+++ b/hw/pc.c
 #define LINUX_BOOT_FILENAME "linux_boot.bin"
 
 #define KERNEL_LOAD_ADDR     0x00100000
-#define INITRD_LOAD_ADDR     0x00400000
+#define INITRD_LOAD_ADDR     0x00600000
 #define KERNEL_PARAMS_ADDR   0x00090000
 #define KERNEL_CMDLINE_ADDR  0x00099000
 
-int speaker_data_on;
-int dummy_refresh_clock;
 static fdctrl_t *floppy_controller;
 static RTCState *rtc_state;
 static PITState *pit;
@@ -273,21 +271,6 @@ static void cmos_init(int ram_size, int boot_device, BlockDriverState **hd_table
     //    rtc_set_memory(s, 0x38, 1);
 }
 
-static void speaker_ioport_write(void *opaque, uint32_t addr, uint32_t val)
-{
-    speaker_data_on = (val >> 1) & 1;
-    pit_set_gate(pit, 2, val & 1);
-}
-
-static uint32_t speaker_ioport_read(void *opaque, uint32_t addr)
-{
-    int out;
-    out = pit_get_out(pit, 2, qemu_get_clock(vm_clock));
-    dummy_refresh_clock ^= 1;
-    return (speaker_data_on << 1) | pit_get_gate(pit, 2) | (out << 5) |
-      (dummy_refresh_clock << 4);
-}
-
 void ioport_set_a20(int enable)
 {
     /* XXX: send to all CPUs ? */
@@ -606,6 +589,16 @@ static void audio_init (PCIBus *pci_bus)
 }
 #endif
 
+static void pc_init_ne2k_isa(NICInfo *nd)
+{
+    static int nb_ne2k = 0;
+
+    if (nb_ne2k == NE2000_NB_MAX)
+        return;
+    isa_ne2000_init(ne2000_io[nb_ne2k], ne2000_irq[nb_ne2k], nd);
+    nb_ne2k++;
+}
+
 /* PC hardware initialisation */
 static void pc_init1(int ram_size, int vga_ram_size, int boot_device,
                      DisplayState *ds, const char **fd_filename, int snapshot,
@@ -614,11 +607,12 @@ static void pc_init1(int ram_size, int vga_ram_size, int boot_device,
                      int pci_enabled)
 {
     char buf[1024];
-    int ret, linux_boot, initrd_size, i, nb_nics1;
+    int ret, linux_boot, initrd_size, i;
     unsigned long bios_offset, vga_bios_offset;
     int bios_size, isa_bios_size;
     PCIBus *pci_bus;
     CPUState *env;
+    NICInfo *nd;
 
     linux_boot = (kernel_filename != NULL);
 
@@ -772,8 +766,6 @@ static void pc_init1(int ram_size, int vga_ram_size, int boot_device,
     }
 
     rtc_state = rtc_init(0x70, 8);
-    register_ioport_read(0x61, 1, 1, speaker_ioport_read, NULL);
-    register_ioport_write(0x61, 1, 1, speaker_ioport_write, NULL);
 
     register_ioport_read(0x92, 1, 1, ioport92_read, NULL);
     register_ioport_write(0x92, 1, 1, ioport92_write, NULL);
@@ -783,6 +775,7 @@ static void pc_init1(int ram_size, int vga_ram_size, int boot_device,
     }
     isa_pic = pic_init(pic_irq_request, first_cpu);
     pit = pit_init(0x40, 0);
+    pcspk_init(pit);
     if (pci_enabled) {
         pic_set_alt_irq_func(isa_pic, ioapic_set_irq, ioapic);
     }
@@ -800,19 +793,28 @@ static void pc_init1(int ram_size, int vga_ram_size, int boot_device,
         }
     }
 
-    if (pci_enabled) {
-        for(i = 0; i < nb_nics; i++) {
-            pci_ne2000_init(pci_bus, &nd_table[i]);
+    for(i = 0; i < nb_nics; i++) {
+        nd = &nd_table[i];
+        if (!nd->model) {
+            if (pci_enabled) {
+                nd->model = "ne2k_pci";
+            } else {
+                nd->model = "ne2k_isa";
+            }
         }
-        pci_piix3_ide_init(pci_bus, bs_table);
-    } else {
-        nb_nics1 = nb_nics;
-        if (nb_nics1 > NE2000_NB_MAX)
-            nb_nics1 = NE2000_NB_MAX;
-        for(i = 0; i < nb_nics1; i++) {
-            isa_ne2000_init(ne2000_io[i], ne2000_irq[i], &nd_table[i]);
+        if (strcmp(nd->model, "ne2k_isa") == 0) {
+            pc_init_ne2k_isa(nd);
+        } else if (pci_enabled) {
+            pci_nic_init(pci_bus, nd);
+        } else {
+            fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd->model);
+            exit(1);
         }
+    }
 
+    if (pci_enabled) {
+        pci_piix3_ide_init(pci_bus, bs_table);
+    } else {
         for(i = 0; i < 2; i++) {
             isa_ide_init(ide_iobase[i], ide_iobase2[i], ide_irq[i],
                          bs_table[2 * i], bs_table[2 * i + 1]);
@@ -834,10 +836,15 @@ static void pc_init1(int ram_size, int vga_ram_size, int boot_device,
         usb_attach(usb_root_ports[0], vm_usb_hub);
     }
 
+    if (pci_enabled && acpi_enabled) {
+        piix4_pm_init(pci_bus);
+    }
     /* must be done after all PCI devices are instanciated */
     /* XXX: should be done in the Bochs BIOS */
     if (pci_enabled) {
         pci_bios_init();
+        if (acpi_enabled)
+            acpi_bios_init();
     }
 }