From patchwork Wed Sep 9 15:41:18 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?5q2m55SwID0/SVNPLTIwMjItSlA/Qj9JQnNrUWoxVFRHa2JLRUk9Pz0=?= X-Patchwork-Id: 33203 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by bilbo.ozlabs.org (Postfix) with ESMTPS id 5074DB6F31 for ; Thu, 10 Sep 2009 02:14:44 +1000 (EST) Received: from localhost ([127.0.0.1]:51199 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MlPoe-00080W-R7 for incoming@patchwork.ozlabs.org; Wed, 09 Sep 2009 12:14:40 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MlPIb-0007xL-1d for qemu-devel@nongnu.org; Wed, 09 Sep 2009 11:41:33 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MlPIW-0007v9-2e for qemu-devel@nongnu.org; Wed, 09 Sep 2009 11:41:32 -0400 Received: from [199.232.76.173] (port=58207 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MlPIV-0007ux-Kp for qemu-devel@nongnu.org; Wed, 09 Sep 2009 11:41:27 -0400 Received: from smtp-vip.mem.interq.net ([210.157.1.50]:21968 helo=smtp01.mem.internal-gmo) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MlPIU-0007U7-S7 for qemu-devel@nongnu.org; Wed, 09 Sep 2009 11:41:27 -0400 Received: (from root@localhost) by smtp01.mem.internal-gmo (8.13.8/8.12.6) id n89FfPuq012524 for qemu-devel@nongnu.org; Thu, 10 Sep 2009 00:41:25 +0900 (JST) Received: from YOUR-BD18D6DD63.m1.interq.or.jp (ntymns034018.ymns.nt.ftth.ppp.infoweb.ne.jp [211.2.27.18]) by smtp01.mem.internal-gmo with ESMTP id n89FfPLZ012519 for ; (me101664 for with PLAIN) Thu, 10 Sep 2009 00:41:25 +0900 (JST) Message-Id: <200909091541.AA00086@YOUR-BD18D6DD63.m1.interq.or.jp> From: t-takeda@m1.interq.or.jp (=?ISO-2022-JP?B?GyRCSXBFRBsoQg==?= =?ISO-2022-JP?B?IBskQj1TTGkbKEI=?=) Date: Thu, 10 Sep 2009 00:41:18 +0900 To: qemu-devel MIME-Version: 1.0 X-Mailer: AL-Mail32 Version 1.13 X-detected-operating-system: by monty-python.gnu.org: Solaris 10 (beta) Subject: [Qemu-devel] [PATCH 03/14] ioport: divide ioport_opaque for read/write functions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Now ioport read function and write function that have the same address must be registered with one opaque. But there may be the case that read-only iodevice and write-only one are assigned to same address. This patch is to divide ioport_opaque for read/write functions. diff -ur a/ioport.c b/ioport.c --- a/ioport.c Tue Sep 8 21:26:50 2009 +++ b/ioport.c Wed Sep 9 21:50:06 2009 @@ -47,7 +47,8 @@ /* XXX: use a two level table to limit memory usage */ -static void *ioport_opaque[MAX_IOPORTS]; +static void *ioport_read_opaque[MAX_IOPORTS]; +static void *ioport_write_opaque[MAX_IOPORTS]; static IOPortReadFunc *ioport_read_table[3][MAX_IOPORTS]; static IOPortWriteFunc *ioport_write_table[3][MAX_IOPORTS]; @@ -64,7 +65,7 @@ IOPortReadFunc *func = ioport_read_table[index][address]; if (!func) func = default_func[index]; - return func(ioport_opaque[address], address); + return func(ioport_read_opaque[address], address); } static void ioport_write(int index, uint32_t address, uint32_t data) @@ -77,7 +78,7 @@ IOPortWriteFunc *func = ioport_write_table[index][address]; if (!func) func = default_func[index]; - func(ioport_opaque[address], address, data); + func(ioport_write_opaque[address], address, data); } static uint32_t default_ioport_readb(void *opaque, uint32_t address) @@ -147,9 +148,9 @@ } for(i = start; i < start + length; i += size) { ioport_read_table[bsize][i] = func; - if (ioport_opaque[i] != NULL && ioport_opaque[i] != opaque) + if (ioport_read_opaque[i] != NULL && ioport_read_opaque[i] != opaque) hw_error("register_ioport_read: invalid opaque"); - ioport_opaque[i] = opaque; + ioport_read_opaque[i] = opaque; } return 0; } @@ -166,14 +167,14 @@ } for(i = start; i < start + length; i += size) { ioport_write_table[bsize][i] = func; - if (ioport_opaque[i] != NULL && ioport_opaque[i] != opaque) + if (ioport_write_opaque[i] != NULL && ioport_write_opaque[i] != opaque) hw_error("register_ioport_write: invalid opaque"); - ioport_opaque[i] = opaque; + ioport_write_opaque[i] = opaque; } return 0; } -void isa_unassign_ioport(pio_addr_t start, int length) +void isa_unassign_ioport_read(pio_addr_t start, int length) { int i; @@ -182,12 +183,27 @@ ioport_read_table[1][i] = default_ioport_readw; ioport_read_table[2][i] = default_ioport_readl; + ioport_read_opaque[i] = NULL; + } +} + +void isa_unassign_ioport_write(pio_addr_t start, int length) +{ + int i; + + for(i = start; i < start + length; i++) { ioport_write_table[0][i] = default_ioport_writeb; ioport_write_table[1][i] = default_ioport_writew; ioport_write_table[2][i] = default_ioport_writel; - ioport_opaque[i] = NULL; + ioport_write_opaque[i] = NULL; } +} + +void isa_unassign_ioport(pio_addr_t start, int length) +{ + isa_unassign_ioport_read(start, length); + isa_unassign_ioport_write(start, length); } /***********************************************************/ diff -ur a/ioport.h b/ioport.h --- a/ioport.h Tue Sep 8 21:26:50 2009 +++ b/ioport.h Wed Sep 9 21:49:58 2009 @@ -40,6 +40,8 @@ IOPortReadFunc *func, void *opaque); int register_ioport_write(pio_addr_t start, int length, int size, IOPortWriteFunc *func, void *opaque); +void isa_unassign_ioport_read(pio_addr_t start, int length); +void isa_unassign_ioport_write(pio_addr_t start, int length); void isa_unassign_ioport(pio_addr_t start, int length);