[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC v5 09/86] memory: I/O address space support
From: |
Avi Kivity |
Subject: |
[Qemu-devel] [RFC v5 09/86] memory: I/O address space support |
Date: |
Wed, 20 Jul 2011 19:49:19 +0300 |
Allow registering I/O ports via the same mechanism as mmio ranges.
Signed-off-by: Avi Kivity <address@hidden>
---
exec-memory.h | 3 ++
memory.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
memory.h | 2 +
3 files changed, 64 insertions(+), 1 deletions(-)
diff --git a/exec-memory.h b/exec-memory.h
index 7eb9085..aad21b5 100644
--- a/exec-memory.h
+++ b/exec-memory.h
@@ -18,6 +18,9 @@ MemoryRegion *get_system_memory(void);
/* Set the root memory region. This region is the system memory map. */
void set_system_memory_map(MemoryRegion *mr);
+/* Set the I/O memory region. This region is the I/O memory map. */
+void set_system_io_map(MemoryRegion *mr);
+
#endif
#endif
diff --git a/memory.c b/memory.c
index bc8bfa2..62bd60b 100644
--- a/memory.c
+++ b/memory.c
@@ -13,6 +13,7 @@
#include "memory.h"
#include "exec-memory.h"
+#include "ioport.h"
#include <assert.h>
typedef struct AddrRange AddrRange;
@@ -210,6 +211,52 @@ static AddressSpace address_space_memory = {
.ops = &address_space_ops_memory,
};
+static void memory_region_iorange_read(IORange *iorange,
+ uint64_t offset,
+ unsigned width,
+ uint64_t *data)
+{
+ MemoryRegion *mr = container_of(iorange, MemoryRegion, iorange);
+
+ *data = mr->ops->read(mr->opaque, offset, width);
+}
+
+static void memory_region_iorange_write(IORange *iorange,
+ uint64_t offset,
+ unsigned width,
+ uint64_t data)
+{
+ MemoryRegion *mr = container_of(iorange, MemoryRegion, iorange);
+
+ mr->ops->write(mr->opaque, offset, data, width);
+}
+
+static const IORangeOps memory_region_iorange_ops = {
+ .read = memory_region_iorange_read,
+ .write = memory_region_iorange_write,
+};
+
+static void as_io_range_add(AddressSpace *as, FlatRange *fr)
+{
+ iorange_init(&fr->mr->iorange, &memory_region_iorange_ops,
+ fr->addr.start,fr->addr.size);
+ ioport_register(&fr->mr->iorange);
+}
+
+static void as_io_range_del(AddressSpace *as, FlatRange *fr)
+{
+ isa_unassign_ioport(fr->addr.start, fr->addr.size);
+}
+
+static const AddressSpaceOps address_space_ops_io = {
+ .range_add = as_io_range_add,
+ .range_del = as_io_range_del,
+};
+
+static AddressSpace address_space_io = {
+ .ops = &address_space_ops_io,
+};
+
/* Render a memory region into the global view. Ranges in @view obscure
* ranges in @mr.
*/
@@ -358,7 +405,12 @@ static void address_space_update_topology(AddressSpace *as)
static void memory_region_update_topology(void)
{
- address_space_update_topology(&address_space_memory);
+ if (address_space_memory.root) {
+ address_space_update_topology(&address_space_memory);
+ }
+ if (address_space_io.root) {
+ address_space_update_topology(&address_space_io);
+ }
}
void memory_region_init(MemoryRegion *mr,
@@ -772,3 +824,9 @@ void set_system_memory_map(MemoryRegion *mr)
address_space_memory.root = mr;
memory_region_update_topology();
}
+
+void set_system_io_map(MemoryRegion *mr)
+{
+ address_space_io.root = mr;
+ memory_region_update_topology();
+}
diff --git a/memory.h b/memory.h
index 0994b18..2afbf13 100644
--- a/memory.h
+++ b/memory.h
@@ -9,6 +9,7 @@
#include "cpu-common.h"
#include "targphys.h"
#include "qemu-queue.h"
+#include "iorange.h"
typedef struct MemoryRegionOps MemoryRegionOps;
typedef struct MemoryRegion MemoryRegion;
@@ -78,6 +79,7 @@ struct MemoryRegion {
target_phys_addr_t offset;
bool backend_registered;
ram_addr_t ram_addr;
+ IORange iorange;
bool terminates;
MemoryRegion *alias;
target_phys_addr_t alias_offset;
--
1.7.5.3
- [Qemu-devel] [RFC v5 11/86] memory: add backward compatibility for old mmio registration, (continued)
- [Qemu-devel] [RFC v5 11/86] memory: add backward compatibility for old mmio registration, Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 77/86] sysbus: add a variant of sysbus_init_mmio_cb with an unmap callback, Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 37/86] e1000: convert to memory API, Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 02/86] Hierarchical memory region API, Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 41/86] ivshmem: convert to memory API, Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 82/86] sysbus: remove sysbus_init_mmio_cb(), Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 70/86] tusb6010: move declarations to new file tusb6010.h, Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 17/86] pc: convert pc_memory_init() to memory API, Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 07/86] memory: rename MemoryRegion::has_ram_addr to ::terminates, Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 48/86] pcnet: convert to memory API, Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 09/86] memory: I/O address space support,
Avi Kivity <=
- [Qemu-devel] [RFC v5 43/86] ahci: convert to memory API, Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 56/86] pci: remove pci_register_bar_simple(), Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 28/86] cirrus: simplify vga window mmio access functions, Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 47/86] ne2000: convert to memory API, Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 58/86] pci: remove pci_register_bar(), Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 29/86] vga: simplify vga window mmio access functions, Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 05/86] Internal interfaces for memory API, Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 79/86] arm11mpcore: use sysbus_init_mmio_cb2, Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 67/86] arm_timer: convert to memory API, Avi Kivity, 2011/07/20
- [Qemu-devel] [RFC v5 10/86] memory: add backward compatibility for old portio registration, Avi Kivity, 2011/07/20