Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LXGta-00045q-L8 for qemu-devel@nongnu.org; Wed, 11 Feb 2009 10:21:02 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LXGta-00045e-2X for qemu-devel@nongnu.org; Wed, 11 Feb 2009 10:21:02 -0500 Received: from [199.232.76.173] (port=52347 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LXGtZ-00045b-Vo for qemu-devel@nongnu.org; Wed, 11 Feb 2009 10:21:02 -0500 Received: from savannah.gnu.org ([199.232.41.3]:40295 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LXGtZ-0002Dn-NE for qemu-devel@nongnu.org; Wed, 11 Feb 2009 10:21:01 -0500 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1LXGtY-0004rK-ME for qemu-devel@nongnu.org; Wed, 11 Feb 2009 15:21:00 +0000 Received: from aliguori by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1LXGtX-0004rG-MB for qemu-devel@nongnu.org; Wed, 11 Feb 2009 15:21:00 +0000 MIME-Version: 1.0 Errors-To: aliguori Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Anthony Liguori Message-Id: Date: Wed, 11 Feb 2009 15:20:59 +0000 Subject: [Qemu-devel] [6601] qemu: add cpu_unregister_io_memory and make io mem table index dynamic ( Marcelo Tosatti) Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 6601 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6601 Author: aliguori Date: 2009-02-11 15:20:58 +0000 (Wed, 11 Feb 2009) Log Message: ----------- qemu: add cpu_unregister_io_memory and make io mem table index dynamic (Marcelo Tosatti) 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 Signed-off-by: Anthony Liguori Modified Paths: -------------- trunk/cpu-all.h trunk/exec.c Modified: trunk/cpu-all.h =================================================================== --- trunk/cpu-all.h 2009-02-11 15:20:51 UTC (rev 6600) +++ trunk/cpu-all.h 2009-02-11 15:20:58 UTC (rev 6601) @@ -909,6 +909,7 @@ 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); Modified: trunk/exec.c =================================================================== --- trunk/exec.c 2009-02-11 15:20:51 UTC (rev 6600) +++ trunk/exec.c 2009-02-11 15:20:58 UTC (rev 6601) @@ -179,7 +179,7 @@ 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 @@ return mmio; } +static int get_free_io_mem_idx(void) +{ + int i; + + for (i = 0; i> 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 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 @@ 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];