]> Git Repo - qemu.git/blobdiff - hw/isa_mmio.c
Merge remote-tracking branch 'kraxel/usb.29' into staging
[qemu.git] / hw / isa_mmio.c
index 070f6f587a0be614e67cc05824178b8898b2d912..fd755ab4a8853bd75567cefbbb595ea2d943eb9b 100644 (file)
@@ -2,7 +2,7 @@
  * Memory mapped access to ISA IO space.
  *
  * Copyright (c) 2006 Fabrice Bellard
- * 
+ *
  * 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
  * THE SOFTWARE.
  */
 
-#include "vl.h"
+#include "hw.h"
+#include "isa.h"
+#include "exec-memory.h"
 
 static void isa_mmio_writeb (void *opaque, target_phys_addr_t addr,
                                   uint32_t val)
 {
-    cpu_outb(NULL, addr & 0xffff, val);
+    cpu_outb(addr & IOPORTS_MASK, val);
 }
 
-static void isa_mmio_writew (void *opaque, target_phys_addr_t addr,
-                                  uint32_t val)
+static void isa_mmio_writew(void *opaque, target_phys_addr_t addr,
+                               uint32_t val)
 {
-#ifdef TARGET_WORDS_BIGENDIAN
-    val = bswap16(val);
-#endif
-    cpu_outw(NULL, addr & 0xffff, val);
+    cpu_outw(addr & IOPORTS_MASK, val);
 }
 
-static void isa_mmio_writel (void *opaque, target_phys_addr_t addr,
-                                uint32_t val)
+static void isa_mmio_writel(void *opaque, target_phys_addr_t addr,
+                               uint32_t val)
 {
-#ifdef TARGET_WORDS_BIGENDIAN
-    val = bswap32(val);
-#endif
-    cpu_outl(NULL, addr & 0xffff, val);
+    cpu_outl(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);
-    return val;
+    return cpu_inb(addr & IOPORTS_MASK);
 }
 
-static uint32_t isa_mmio_readw (void *opaque, target_phys_addr_t addr)
+static uint32_t isa_mmio_readw(void *opaque, target_phys_addr_t addr)
 {
-    uint32_t val;
-
-    val = cpu_inw(NULL, addr & 0xffff);
-#ifdef TARGET_WORDS_BIGENDIAN
-    val = bswap16(val);
-#endif
-    return val;
+    return cpu_inw(addr & IOPORTS_MASK);
 }
 
-static uint32_t isa_mmio_readl (void *opaque, target_phys_addr_t addr)
+static uint32_t isa_mmio_readl(void *opaque, target_phys_addr_t addr)
 {
-    uint32_t val;
-
-    val = cpu_inl(NULL, addr & 0xffff);
-#ifdef TARGET_WORDS_BIGENDIAN
-    val = bswap32(val);
-#endif
-    return val;
+    return cpu_inl(addr & IOPORTS_MASK);
 }
 
-static CPUWriteMemoryFunc *isa_mmio_write[] = {
-    &isa_mmio_writeb,
-    &isa_mmio_writew,
-    &isa_mmio_writel,
+static const MemoryRegionOps isa_mmio_ops = {
+    .old_mmio = {
+        .write = { isa_mmio_writeb, isa_mmio_writew, isa_mmio_writel },
+        .read = { isa_mmio_readb, isa_mmio_readw, isa_mmio_readl, },
+    },
+    .endianness = DEVICE_LITTLE_ENDIAN,
 };
 
-static CPUReadMemoryFunc *isa_mmio_read[] = {
-    &isa_mmio_readb,
-    &isa_mmio_readw,
-    &isa_mmio_readl,
-};
-
-static int isa_mmio_iomemtype = 0;
+void isa_mmio_setup(MemoryRegion *mr, target_phys_addr_t size)
+{
+    memory_region_init_io(mr, &isa_mmio_ops, NULL, "isa-mmio", size);
+}
 
 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_write, NULL);
-    }
-    cpu_register_physical_memory(base, size, isa_mmio_iomemtype);
+    MemoryRegion *mr = g_malloc(sizeof(*mr));
+
+    isa_mmio_setup(mr, size);
+    memory_region_add_subregion(get_system_memory(), base, mr);
 }
This page took 0.028169 seconds and 4 git commands to generate.