From patchwork Wed Dec 14 16:20:34 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 131440 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8C4B91007D6 for ; Thu, 15 Dec 2011 03:21:50 +1100 (EST) Received: from localhost ([::1]:38365 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RaraS-0006eG-MG for incoming@patchwork.ozlabs.org; Wed, 14 Dec 2011 11:21:44 -0500 Received: from eggs.gnu.org ([140.186.70.92]:59812) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RarZZ-0003qL-IH for qemu-devel@nongnu.org; Wed, 14 Dec 2011 11:20:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RarZT-0003zV-HI for qemu-devel@nongnu.org; Wed, 14 Dec 2011 11:20:49 -0500 Received: from cpe-70-123-132-139.austin.res.rr.com ([70.123.132.139]:40091 helo=localhost6.localdomain6) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RarZT-0003zH-At for qemu-devel@nongnu.org; Wed, 14 Dec 2011 11:20:43 -0500 Received: from localhost6.localdomain6 (localhost.localdomain [127.0.0.1]) by localhost6.localdomain6 (8.14.4/8.14.4/Debian-2ubuntu1) with ESMTP id pBEGKfjC016943; Wed, 14 Dec 2011 10:20:41 -0600 Received: (from anthony@localhost) by localhost6.localdomain6 (8.14.4/8.14.4/Submit) id pBEGKeWs016942; Wed, 14 Dec 2011 10:20:40 -0600 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Wed, 14 Dec 2011 10:20:34 -0600 Message-Id: <1323879637-16901-2-git-send-email-aliguori@us.ibm.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1323879637-16901-1-git-send-email-aliguori@us.ibm.com> References: <1323879637-16901-1-git-send-email-aliguori@us.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 70.123.132.139 Cc: Anthony Liguori , Avi Kivity Subject: [Qemu-devel] [PATCH 1/4] memory: make memory API parsable by gtkdoc-scan X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org GTK/glib uses a convenient of: typedef struct _CamelCase CamelCase; The reason that they use a separate struct name is that in C++, the struct namespace not a separate namespace from the type namespace. This is actually a reasonable policy for QEMU to adopt as we eventually start exporting C libraries that may be consumed by C++ programs. I think the use of _ does not violate the C specification as the struct namespace is not the same as the type namespace which is what the C spec refers to if I understand it correctly. Additionally, gtkdoc-scan cannot handle nested structs so remove those from the memory API. Signed-off-by: Anthony Liguori --- ioport.h | 14 ++++---- memory.c | 6 ++-- memory.h | 99 +++++++++++++++++++++++++++++++++---------------------------- 3 files changed, 64 insertions(+), 55 deletions(-) diff --git a/ioport.h b/ioport.h index ae3e9da..99345d8 100644 --- a/ioport.h +++ b/ioport.h @@ -52,24 +52,24 @@ uint8_t cpu_inb(pio_addr_t addr); uint16_t cpu_inw(pio_addr_t addr); uint32_t cpu_inl(pio_addr_t addr); -struct MemoryRegion; -struct MemoryRegionPortio; +struct _MemoryRegion; +struct _MemoryRegionPortio; typedef struct PortioList { - const struct MemoryRegionPortio *ports; - struct MemoryRegion *address_space; + const struct _MemoryRegionPortio *ports; + struct _MemoryRegion *address_space; unsigned nr; - struct MemoryRegion **regions; + struct _MemoryRegion **regions; void *opaque; const char *name; } PortioList; void portio_list_init(PortioList *piolist, - const struct MemoryRegionPortio *callbacks, + const struct _MemoryRegionPortio *callbacks, void *opaque, const char *name); void portio_list_destroy(PortioList *piolist); void portio_list_add(PortioList *piolist, - struct MemoryRegion *address_space, + struct _MemoryRegion *address_space, uint32_t addr); void portio_list_del(PortioList *piolist); diff --git a/memory.c b/memory.c index adfdf14..76a7ae6 100644 --- a/memory.c +++ b/memory.c @@ -72,12 +72,12 @@ static AddrRange addrrange_intersection(AddrRange r1, AddrRange r2) return addrrange_make(start, int128_sub(end, start)); } -struct CoalescedMemoryRange { +struct _CoalescedMemoryRange { AddrRange addr; - QTAILQ_ENTRY(CoalescedMemoryRange) link; + QTAILQ_ENTRY(_CoalescedMemoryRange) link; }; -struct MemoryRegionIoeventfd { +struct _MemoryRegionIoeventfd { AddrRange addr; bool match_data; uint64_t data; diff --git a/memory.h b/memory.h index beae127..3aa8404 100644 --- a/memory.h +++ b/memory.h @@ -26,10 +26,12 @@ #include "ioport.h" #include "int128.h" -typedef struct MemoryRegionOps MemoryRegionOps; -typedef struct MemoryRegion MemoryRegion; -typedef struct MemoryRegionPortio MemoryRegionPortio; -typedef struct MemoryRegionMmio MemoryRegionMmio; +typedef struct _MemoryRegionOps MemoryRegionOps; +typedef struct _MemoryRegion MemoryRegion; +typedef struct _MemoryRegionPortio MemoryRegionPortio; +typedef struct _MemoryRegionMmio MemoryRegionMmio; +typedef struct _MemoryRegionGuestConstraints MemoryRegionGuestConstraints; +typedef struct _MemoryRegionInternalConstraints MemoryRegionInternalConstraints; /* Must match *_DIRTY_FLAGS in cpu-all.h. To be replaced with dynamic * registration. @@ -38,15 +40,51 @@ typedef struct MemoryRegionMmio MemoryRegionMmio; #define DIRTY_MEMORY_CODE 1 #define DIRTY_MEMORY_MIGRATION 3 -struct MemoryRegionMmio { +struct _MemoryRegionMmio { CPUReadMemoryFunc *read[3]; CPUWriteMemoryFunc *write[3]; }; +struct _MemoryRegionGuestConstraints +{ + /* If nonzero, specify bounds on access sizes beyond which a machine + * check is thrown. + */ + unsigned min_access_size; + unsigned max_access_size; + /* If true, unaligned accesses are supported. Otherwise unaligned + * accesses throw machine checks. + */ + bool unaligned; + /* + * If present, and returns #false, the transaction is not accepted + * by the device (and results in machine dependent behaviour such + * as a machine check exception). + */ + bool (*accepts)(void *opaque, target_phys_addr_t addr, + unsigned size, bool is_write); +}; + +struct _MemoryRegionInternalConstraints +{ + /* If nonzero, specifies the minimum size implemented. Smaller sizes + * will be rounded upwards and a partial result will be returned. + */ + unsigned min_access_size; + /* If nonzero, specifies the maximum size implemented. Larger sizes + * will be done as a series of accesses with smaller sizes. + */ + unsigned max_access_size; + /* If true, unaligned accesses are supported. Otherwise all accesses + * are converted to (possibly multiple) naturally aligned accesses. + */ + bool unaligned; +}; + /* * Memory region callbacks */ -struct MemoryRegionOps { +struct _MemoryRegionOps { /* Read from the memory region. @addr is relative to @mr; @size is * in bytes. */ uint64_t (*read)(void *opaque, @@ -61,39 +99,10 @@ struct MemoryRegionOps { enum device_endian endianness; /* Guest-visible constraints: */ - struct { - /* If nonzero, specify bounds on access sizes beyond which a machine - * check is thrown. - */ - unsigned min_access_size; - unsigned max_access_size; - /* If true, unaligned accesses are supported. Otherwise unaligned - * accesses throw machine checks. - */ - bool unaligned; - /* - * If present, and returns #false, the transaction is not accepted - * by the device (and results in machine dependent behaviour such - * as a machine check exception). - */ - bool (*accepts)(void *opaque, target_phys_addr_t addr, - unsigned size, bool is_write); - } valid; + MemoryRegionGuestConstraints valid; + /* Internal implementation constraints: */ - struct { - /* If nonzero, specifies the minimum size implemented. Smaller sizes - * will be rounded upwards and a partial result will be returned. - */ - unsigned min_access_size; - /* If nonzero, specifies the maximum size implemented. Larger sizes - * will be done as a series of accesses with smaller sizes. - */ - unsigned max_access_size; - /* If true, unaligned accesses are supported. Otherwise all accesses - * are converted to (possibly multiple) naturally aligned accesses. - */ - bool unaligned; - } impl; + MemoryRegionInternalConstraints impl; /* If .read and .write are not present, old_portio may be used for * backwards compatibility with old portio registration @@ -105,10 +114,10 @@ struct MemoryRegionOps { const MemoryRegionMmio old_mmio; }; -typedef struct CoalescedMemoryRange CoalescedMemoryRange; -typedef struct MemoryRegionIoeventfd MemoryRegionIoeventfd; +typedef struct _CoalescedMemoryRange CoalescedMemoryRange; +typedef struct _MemoryRegionIoeventfd MemoryRegionIoeventfd; -struct MemoryRegion { +struct _MemoryRegion { /* All fields are private - violators will be prosecuted */ const MemoryRegionOps *ops; void *opaque; @@ -127,16 +136,16 @@ struct MemoryRegion { target_phys_addr_t alias_offset; unsigned priority; bool may_overlap; - QTAILQ_HEAD(subregions, MemoryRegion) subregions; - QTAILQ_ENTRY(MemoryRegion) subregions_link; - QTAILQ_HEAD(coalesced_ranges, CoalescedMemoryRange) coalesced; + QTAILQ_HEAD(subregions, _MemoryRegion) subregions; + QTAILQ_ENTRY(_MemoryRegion) subregions_link; + QTAILQ_HEAD(coalesced_ranges, _CoalescedMemoryRange) coalesced; const char *name; uint8_t dirty_log_mask; unsigned ioeventfd_nb; MemoryRegionIoeventfd *ioeventfds; }; -struct MemoryRegionPortio { +struct _MemoryRegionPortio { uint32_t offset; uint32_t len; unsigned size;