VirtIO: Fix QEMU crash during Windows PNP tests
[qemu] / hw / isa_mmio.c
index 4e7914e..ec5da5f 100644 (file)
  * THE SOFTWARE.
  */
 
-#include "vl.h"
+#include "hw.h"
+#include "isa.h"
 
 static void isa_mmio_writeb (void *opaque, target_phys_addr_t addr,
                                   uint32_t val)
 {
-    cpu_outb(NULL, addr & 0xffff, val);
+    cpu_outb(NULL, addr & IOPORTS_MASK, val);
 }
 
 static void isa_mmio_writew (void *opaque, target_phys_addr_t addr,
@@ -36,7 +37,7 @@ static void isa_mmio_writew (void *opaque, target_phys_addr_t addr,
 #ifdef TARGET_WORDS_BIGENDIAN
     val = bswap16(val);
 #endif
-    cpu_outw(NULL, addr & 0xffff, val);
+    cpu_outw(NULL, addr & IOPORTS_MASK, val);
 }
 
 static void isa_mmio_writel (void *opaque, target_phys_addr_t addr,
@@ -45,14 +46,14 @@ static void isa_mmio_writel (void *opaque, target_phys_addr_t addr,
 #ifdef TARGET_WORDS_BIGENDIAN
     val = bswap32(val);
 #endif
-    cpu_outl(NULL, addr & 0xffff, val);
+    cpu_outl(NULL, addr & IOPORTS_MASK, val);
 }
 
 static uint32_t isa_mmio_readb (void *opaque, target_phys_addr_t addr)
 {
     uint32_t val;
 
-    val = cpu_inb(NULL, addr & 0xffff);
+    val = cpu_inb(NULL, addr & IOPORTS_MASK);
     return val;
 }
 
@@ -60,7 +61,7 @@ static uint32_t isa_mmio_readw (void *opaque, target_phys_addr_t addr)
 {
     uint32_t val;
 
-    val = cpu_inw(NULL, addr & 0xffff);
+    val = cpu_inw(NULL, addr & IOPORTS_MASK);
 #ifdef TARGET_WORDS_BIGENDIAN
     val = bswap16(val);
 #endif
@@ -71,20 +72,20 @@ static uint32_t isa_mmio_readl (void *opaque, target_phys_addr_t addr)
 {
     uint32_t val;
 
-    val = cpu_inl(NULL, addr & 0xffff);
+    val = cpu_inl(NULL, addr & IOPORTS_MASK);
 #ifdef TARGET_WORDS_BIGENDIAN
     val = bswap32(val);
 #endif
     return val;
 }
 
-static CPUWriteMemoryFunc *isa_mmio_write[] = {
+static CPUWriteMemoryFunc * const isa_mmio_write[] = {
     &isa_mmio_writeb,
     &isa_mmio_writew,
     &isa_mmio_writel,
 };
 
-static CPUReadMemoryFunc *isa_mmio_read[] = {
+static CPUReadMemoryFunc * const isa_mmio_read[] = {
     &isa_mmio_readb,
     &isa_mmio_readw,
     &isa_mmio_readl,
@@ -95,7 +96,7 @@ static int isa_mmio_iomemtype = 0;
 void isa_mmio_init(target_phys_addr_t base, target_phys_addr_t size)
 {
     if (!isa_mmio_iomemtype) {
-        isa_mmio_iomemtype = cpu_register_io_memory(0, isa_mmio_read,
+        isa_mmio_iomemtype = cpu_register_io_memory(isa_mmio_read,
                                                     isa_mmio_write, NULL);
     }
     cpu_register_physical_memory(base, size, isa_mmio_iomemtype);