[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [patch 10/19] qemu: add cpu_unregister_io_memory and make i
From: |
Marcelo Tosatti |
Subject: |
[Qemu-devel] [patch 10/19] qemu: add cpu_unregister_io_memory and make io mem table index dynamic |
Date: |
Tue, 10 Feb 2009 18:31:01 -0200 |
User-agent: |
quilt/0.46-1 |
So drivers can clear their mem io table entries on exit back to unassigned
state.
Also make the io mem index allocation dynamic.
Signed-off-by: Marcelo Tosatti <address@hidden>
Index: trunk/cpu-all.h
===================================================================
--- trunk.orig/cpu-all.h
+++ trunk/cpu-all.h
@@ -909,6 +909,7 @@ int cpu_register_io_memory(int io_index,
CPUReadMemoryFunc **mem_read,
CPUWriteMemoryFunc **mem_write,
void *opaque);
+void cpu_unregister_io_memory(int table_address);
CPUWriteMemoryFunc **cpu_get_io_memory_write(int io_index);
CPUReadMemoryFunc **cpu_get_io_memory_read(int io_index);
Index: trunk/exec.c
===================================================================
--- trunk.orig/exec.c
+++ trunk/exec.c
@@ -179,7 +179,7 @@ static void io_mem_init(void);
CPUWriteMemoryFunc *io_mem_write[IO_MEM_NB_ENTRIES][4];
CPUReadMemoryFunc *io_mem_read[IO_MEM_NB_ENTRIES][4];
void *io_mem_opaque[IO_MEM_NB_ENTRIES];
-static int io_mem_nb;
+char io_mem_used[IO_MEM_NB_ENTRIES];
static int io_mem_watch;
#endif
@@ -2799,12 +2799,28 @@ static void *subpage_init (target_phys_a
return mmio;
}
+static int get_free_io_mem_idx(void)
+{
+ int i;
+
+ for (i = 0; i<IO_MEM_NB_ENTRIES; i++)
+ if (!io_mem_used[i]) {
+ io_mem_used[i] = 1;
+ return i;
+ }
+
+ return -1;
+}
+
static void io_mem_init(void)
{
+ int i;
+
cpu_register_io_memory(IO_MEM_ROM >> IO_MEM_SHIFT, error_mem_read,
unassigned_mem_write, NULL);
cpu_register_io_memory(IO_MEM_UNASSIGNED >> IO_MEM_SHIFT,
unassigned_mem_read, unassigned_mem_write, NULL);
cpu_register_io_memory(IO_MEM_NOTDIRTY >> IO_MEM_SHIFT, error_mem_read,
notdirty_mem_write, NULL);
- io_mem_nb = 5;
+ for (i=0; i<5; i++)
+ io_mem_used[i] = 1;
io_mem_watch = cpu_register_io_memory(0, watch_mem_read,
watch_mem_write, NULL);
@@ -2829,9 +2845,9 @@ int cpu_register_io_memory(int io_index,
int i, subwidth = 0;
if (io_index <= 0) {
- if (io_mem_nb >= IO_MEM_NB_ENTRIES)
- return -1;
- io_index = io_mem_nb++;
+ io_index = get_free_io_mem_idx();
+ if (io_index == -1)
+ return io_index;
} else {
if (io_index >= IO_MEM_NB_ENTRIES)
return -1;
@@ -2847,6 +2863,19 @@ int cpu_register_io_memory(int io_index,
return (io_index << IO_MEM_SHIFT) | subwidth;
}
+void cpu_unregister_io_memory(int io_table_address)
+{
+ int i;
+ int io_index = io_table_address >> IO_MEM_SHIFT;
+
+ for (i=0;i < 3; i++) {
+ io_mem_read[io_index][i] = unassigned_mem_read[i];
+ io_mem_write[io_index][i] = unassigned_mem_write[i];
+ }
+ io_mem_opaque[io_index] = NULL;
+ io_mem_used[io_index] = 0;
+}
+
CPUWriteMemoryFunc **cpu_get_io_memory_write(int io_index)
{
return io_mem_write[io_index >> IO_MEM_SHIFT];
--
- [Qemu-devel] [patch 00/19] acpi pci hotplug, Marcelo Tosatti, 2009/02/10
- [Qemu-devel] [patch 02/19] qemu: return PCIDevice on net device init and record devfn, Marcelo Tosatti, 2009/02/10
- [Qemu-devel] [patch 03/19] qemu: dynamic drive/drive_opt index allocation, Marcelo Tosatti, 2009/02/10
- [Qemu-devel] [patch 01/19] qemu: add pci helper functions, Marcelo Tosatti, 2009/02/10
- [Qemu-devel] [patch 04/19] qemu: dynamic nic info index allocation, Marcelo Tosatti, 2009/02/10
- [Qemu-devel] [patch 05/19] qemu: drive removal support, Marcelo Tosatti, 2009/02/10
- [Qemu-devel] [patch 06/19] qemu: record devfn on block driver instance, Marcelo Tosatti, 2009/02/10
- [Qemu-devel] [patch 07/19] qemu: move drives_opt for external use, Marcelo Tosatti, 2009/02/10
- [Qemu-devel] [patch 09/19] qemu: add net_client_uninit / qemu_find_vlan_client, Marcelo Tosatti, 2009/02/10
- [Qemu-devel] [patch 08/19] qemu: net/drive add/remove tweaks, Marcelo Tosatti, 2009/02/10
- [Qemu-devel] [patch 10/19] qemu: add cpu_unregister_io_memory and make io mem table index dynamic,
Marcelo Tosatti <=
- [Qemu-devel] [patch 11/19] qemu: add qemu_free_irqs, Marcelo Tosatti, 2009/02/10
- [Qemu-devel] [patch 12/19] qemu: add pci_unregister_device, Marcelo Tosatti, 2009/02/10
- [Qemu-devel] [patch 13/19] qemu: warn if PCI region is not power of two, Marcelo Tosatti, 2009/02/10
- [Qemu-devel] [patch 14/19] qemu: LSI SCSI and e1000 unregister callbacks, Marcelo Tosatti, 2009/02/10
- [Qemu-devel] [patch 16/19] qemu: initialize hot add system / acpi gpe, Marcelo Tosatti, 2009/02/10
- [Qemu-devel] [patch 15/19] qemu: zero ioport_opaque on isa_unassign_ioport, Marcelo Tosatti, 2009/02/10
- [Qemu-devel] [patch 18/19] From: Markus Armbruster <address@hidden>, Marcelo Tosatti, 2009/02/10
- [Qemu-devel] [patch 17/19] qemu: pci hotplug GPE support, Marcelo Tosatti, 2009/02/10
- [Qemu-devel] [patch 19/19] qemu: PCI device, disk and host network hot-add / hot-remove, Marcelo Tosatti, 2009/02/10