Support config option to disable APM BIOS calls.
[seabios.git] / src / rombios32.c
index fde32a9526b2dcb70fc12b573d7043303bf185f6..3e73323ad02eee1add6a506a616134da50f24b58 100644 (file)
@@ -17,7 +17,7 @@
 //  License along with this library; if not, write to the Free Software
 //  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
 
-#include "util.h" // BX_INFO
+#include "util.h" // dprintf
 #include "pci.h" // PCIDevice
 #include "types.h" // u32
 #include "config.h" // CONFIG_*
@@ -164,7 +164,7 @@ void smp_probe(void)
 
         smp_cpus = readw((void *)CPU_COUNT_ADDR);
     }
-    BX_INFO("Found %d cpu(s)\n", smp_cpus);
+    dprintf(1, "Found %d cpu(s)\n", smp_cpus);
 }
 
 /****************************************************/
@@ -197,7 +197,7 @@ static u32 pci_bios_bigmem_addr;
 static u8 pci_irqs[4] = { 11, 9, 11, 9 };
 static PCIDevice i440_pcidev;
 
-static void pci_set_io_region_addr(PCIDevice *d, int region_num, u32 addr)
+static void pci_set_io_region_addr(PCIDevice d, int region_num, u32 addr)
 {
     u16 cmd;
     u32 ofs, old_addr;
@@ -211,7 +211,7 @@ static void pci_set_io_region_addr(PCIDevice *d, int region_num, u32 addr)
     old_addr = pci_config_readl(d, ofs);
 
     pci_config_writel(d, ofs, addr);
-    BX_INFO("region %d: 0x%08x\n", region_num, addr);
+    dprintf(1, "region %d: 0x%08x\n", region_num, addr);
 
     /* enable memory mappings */
     cmd = pci_config_readw(d, PCI_COMMAND);
@@ -227,15 +227,15 @@ static void pci_set_io_region_addr(PCIDevice *d, int region_num, u32 addr)
 /* return the global irq number corresponding to a given device irq
    pin. We could also use the bus number to have a more precise
    mapping. */
-static int pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num)
+static int pci_slot_get_pirq(PCIDevice pci_dev, int irq_num)
 {
     int slot_addend;
-    slot_addend = (pci_dev->devfn >> 3) - 1;
+    slot_addend = (pci_dev.devfn >> 3) - 1;
     return (irq_num + slot_addend) & 3;
 }
 
 static void
-copy_bios(PCIDevice *d, int v)
+copy_bios(PCIDevice d, int v)
 {
     pci_config_writeb(d, 0x59, v);
     memcpy((void *)0x000f0000, (void *)BIOS_TMP_STORAGE, 0x10000);
@@ -249,11 +249,11 @@ copy_bios(PCIDevice *d, int v)
             (__addr - __start < __size); \
         })
 
-static void bios_shadow_init(PCIDevice *d)
+static void bios_shadow_init(PCIDevice d)
 {
     bios_table_cur_addr = 0xf0000 | OFFSET_freespace2_start;
     bios_table_end_addr = 0xf0000 | OFFSET_freespace2_end;
-    BX_INFO("bios_table_addr: 0x%08lx end=0x%08lx\n",
+    dprintf(1, "bios_table_addr: 0x%08lx end=0x%08lx\n",
             bios_table_cur_addr, bios_table_end_addr);
 
     /* remap the BIOS to shadow RAM an keep it read/write while we
@@ -268,7 +268,7 @@ static void bios_shadow_init(PCIDevice *d)
         // Current code is in shadowed area.  Perform the copy from
         // the code that is in the temporary location.
         u32 pos = (u32)copy_bios - 0xf0000 + BIOS_TMP_STORAGE;
-        void (*func)(PCIDevice *, int) = (void*)pos;
+        void (*func)(PCIDevice, int) = (void*)pos;
         func(d, v);
     } else {
         copy_bios(d, v);
@@ -277,12 +277,12 @@ static void bios_shadow_init(PCIDevice *d)
     // Clear the area just copied.
     memset((void *)BIOS_TMP_STORAGE, 0, 0x10000);
 
-    i440_pcidev = *d;
+    i440_pcidev = d;
 }
 
 static void bios_lock_shadow_ram(void)
 {
-    PCIDevice *d = &i440_pcidev;
+    PCIDevice d = i440_pcidev;
     int v;
 
     wbinvd();
@@ -291,7 +291,7 @@ static void bios_lock_shadow_ram(void)
     pci_config_writeb(d, 0x59, v);
 }
 
-static void pci_bios_init_bridges(PCIDevice *d)
+static void pci_bios_init_bridges(PCIDevice d)
 {
     u16 vendor_id, device_id;
 
@@ -315,7 +315,7 @@ static void pci_bios_init_bridges(PCIDevice *d)
         }
         outb(elcr[0], 0x4d0);
         outb(elcr[1], 0x4d1);
-        BX_INFO("PIIX3 init: elcr=%02x %02x\n",
+        dprintf(1, "PIIX3 init: elcr=%02x %02x\n",
                 elcr[0], elcr[1]);
     } else if (vendor_id == 0x8086 && device_id == 0x1237) {
         /* i440 PCI bridge */
@@ -396,7 +396,7 @@ extern u8 smm_relocation_start, smm_relocation_end;
 extern u8 smm_code_start, smm_code_end;
 
 #if (CONFIG_USE_SMM == 1)
-static void smm_init(PCIDevice *d)
+static void smm_init(PCIDevice d)
 {
     u32 value;
 
@@ -422,7 +422,7 @@ static void smm_init(PCIDevice *d)
             ;
 
         /* enable the SMM memory window */
-        pci_config_writeb(&i440_pcidev, 0x72, 0x02 | 0x48);
+        pci_config_writeb(i440_pcidev, 0x72, 0x02 | 0x48);
 
         /* copy the SMM code */
         memcpy((void *)0xa8000, &smm_code_start,
@@ -430,12 +430,12 @@ static void smm_init(PCIDevice *d)
         wbinvd();
 
         /* close the SMM memory window and enable normal SMM */
-        pci_config_writeb(&i440_pcidev, 0x72, 0x02 | 0x08);
+        pci_config_writeb(i440_pcidev, 0x72, 0x02 | 0x08);
     }
 }
 #endif
 
-static void pci_bios_init_device(PCIDevice *d)
+static void pci_bios_init_device(PCIDevice d)
 {
     int class;
     u32 *paddr;
@@ -444,8 +444,8 @@ static void pci_bios_init_device(PCIDevice *d)
     class = pci_config_readw(d, PCI_CLASS_DEVICE);
     vendor_id = pci_config_readw(d, PCI_VENDOR_ID);
     device_id = pci_config_readw(d, PCI_DEVICE_ID);
-    BX_INFO("PCI: bus=%d devfn=0x%02x: vendor_id=0x%04x device_id=0x%04x\n",
-            d->bus, d->devfn, vendor_id, device_id);
+    dprintf(1, "PCI: bus=%d devfn=0x%02x: vendor_id=0x%04x device_id=0x%04x\n",
+            d.bus, d.devfn, vendor_id, device_id);
     switch(class) {
     case 0x0101:
         if (vendor_id == 0x8086 && device_id == 0x7010) {
@@ -537,16 +537,14 @@ static void pci_bios_init_device(PCIDevice *d)
     }
 }
 
-void pci_for_each_device(void (*init_func)(PCIDevice *d))
+void pci_for_each_device(void (*init_func)(PCIDevice d))
 {
-    PCIDevice d1, *d = &d1;
     int bus, devfn;
     u16 vendor_id, device_id;
 
     for(bus = 0; bus < 1; bus++) {
         for(devfn = 0; devfn < 256; devfn++) {
-            d->bus = bus;
-            d->devfn = devfn;
+            PCIDevice d = pci_bd(bus, devfn);
             vendor_id = pci_config_readw(d, PCI_VENDOR_ID);
             device_id = pci_config_readw(d, PCI_DEVICE_ID);
             if (vendor_id != 0xffff || device_id != 0xffff) {
@@ -738,7 +736,7 @@ static void mptable_init(void)
 #else
     bios_table_cur_addr += (q - float_pointer_struct);
 #endif
-    BX_INFO("MP table addr=0x%08lx MPC table addr=0x%08lx size=0x%x\n",
+    dprintf(1, "MP table addr=0x%08lx MPC table addr=0x%08lx size=0x%x\n",
             (unsigned long)float_pointer_struct,
             (unsigned long)mp_config_table,
             mp_config_table_size);
@@ -1080,7 +1078,8 @@ void acpi_bios_init(void)
 
     acpi_tables_size = addr - base_addr;
 
-    BX_INFO("ACPI tables: RSDP addr=0x%08lx ACPI DATA addr=0x%08lx size=0x%x\n",
+    dprintf(1, "ACPI tables: RSDP addr=0x%08lx"
+            " ACPI DATA addr=0x%08lx size=0x%x\n",
             (unsigned long)rsdp,
             (unsigned long)rsdt, acpi_tables_size);
 
@@ -1662,7 +1661,7 @@ void smbios_init(void)
     bios_table_cur_addr += (p - (char *)start);
 #endif
 
-    BX_INFO("SMBIOS table addr=0x%08lx\n", (unsigned long)start);
+    dprintf(1, "SMBIOS table addr=0x%08lx\n", (unsigned long)start);
 }
 
 void rombios32_init(void)
@@ -1671,11 +1670,11 @@ void rombios32_init(void)
         // XXX - not supported on coreboot yet.
         return;
 
-    BX_INFO("Starting rombios32\n");
+    dprintf(1, "Starting rombios32\n");
 
 #if (CONFIG_USE_EBDA_TABLES == 1)
     ebda_cur_addr = ((*(u16 *)(0x40e)) << 4) + 0x380;
-    BX_INFO("ebda_cur_addr: 0x%08lx\n", ebda_cur_addr);
+    dprintf(1, "ebda_cur_addr: 0x%08lx\n", ebda_cur_addr);
 #endif
 
     cpu_probe();
@@ -1697,7 +1696,7 @@ void rombios32_init(void)
 
         bios_lock_shadow_ram();
 
-        BX_INFO("bios_table_cur_addr: 0x%08lx\n", bios_table_cur_addr);
+        dprintf(1, "bios_table_cur_addr: 0x%08lx\n", bios_table_cur_addr);
         if (bios_table_cur_addr > bios_table_end_addr)
             BX_PANIC("bios_table_end_addr overflow!\n");
     }