From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:40562) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TBLHD-0007xE-6Y for qemu-devel@nongnu.org; Tue, 11 Sep 2012 03:52:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TBLHC-0007OA-2p for qemu-devel@nongnu.org; Tue, 11 Sep 2012 03:52:55 -0400 Received: from mail-oa0-f45.google.com ([209.85.219.45]:55446) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TBLHB-0007Nx-PM for qemu-devel@nongnu.org; Tue, 11 Sep 2012 03:52:54 -0400 Received: by oagn12 with SMTP id n12so86743oag.4 for ; Tue, 11 Sep 2012 00:52:53 -0700 (PDT) From: Liu Ping Fan Date: Tue, 11 Sep 2012 15:51:48 +0800 Message-Id: <1347349912-15611-8-git-send-email-qemulist@gmail.com> In-Reply-To: <1347349912-15611-1-git-send-email-qemulist@gmail.com> References: <1347349912-15611-1-git-send-email-qemulist@gmail.com> Subject: [Qemu-devel] [PATCH V3 07/11] memory: implement e1000's MemoryRegionOps ref/unref List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Jan Kiszka , Marcelo Tosatti , Avi Kivity , Anthony Liguori , Paolo Bonzini From: Liu Ping Fan With this, e1000 show to memory core that it can be protected by refcnt. Signed-off-by: Liu Ping Fan --- hw/e1000.c | 17 +++++++++++++++++ 1 files changed, 17 insertions(+), 0 deletions(-) diff --git a/hw/e1000.c b/hw/e1000.c index ae8a6c5..df3a349 100644 --- a/hw/e1000.c +++ b/hw/e1000.c @@ -1037,9 +1037,26 @@ e1000_mmio_read(void *opaque, target_phys_addr_t addr, unsigned size) return 0; } +static int e1000_mmio_ref(MemoryRegion *mr) +{ + E1000State *e1000 = container_of(mr, E1000State, mmio); + + object_ref(OBJECT(e1000)); + return 1; +} + +static void e1000_mmio_unref(MemoryRegion *mr) +{ + E1000State *e1000 = container_of(mr, E1000State, mmio); + + object_unref(OBJECT(e1000)); +} + static const MemoryRegionOps e1000_mmio_ops = { .read = e1000_mmio_read, .write = e1000_mmio_write, + .ref = e1000_mmio_ref, + .unref = e1000_mmio_unref, .endianness = DEVICE_LITTLE_ENDIAN, .impl = { .min_access_size = 4, -- 1.7.4.4