From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49492) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fJE4z-0002oW-PK for qemu-devel@nongnu.org; Thu, 17 May 2018 04:16:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fJE4t-00030l-T9 for qemu-devel@nongnu.org; Thu, 17 May 2018 04:16:05 -0400 From: David Hildenbrand Date: Thu, 17 May 2018 10:15:23 +0200 Message-Id: <20180517081527.14410-11-david@redhat.com> In-Reply-To: <20180517081527.14410-1-david@redhat.com> References: <20180517081527.14410-1-david@redhat.com> Subject: [Qemu-devel] [PATCH v4 10/14] memory-device: new functions to handle plug/unplug List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-s390x@nongnu.org, "Michael S . Tsirkin" , Igor Mammedov , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , David Gibson , Markus Armbruster , qemu-ppc@nongnu.org, Pankaj Gupta , Alexander Graf , Cornelia Huck , Christian Borntraeger , Luiz Capitulino , David Hildenbrand We will need a handful of new functions: - set_addr(): To set the calculated address - get_memory_region(): To add it to the memory region container - get_addr(): If the device has any specific alignment requirements Using these and the existing functions, we can properly plug/unplug memory devices. Signed-off-by: David Hildenbrand --- include/hw/mem/memory-device.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/hw/mem/memory-device.h b/include/hw/mem/memory-device.h index 2853b084b5..62d906be50 100644 --- a/include/hw/mem/memory-device.h +++ b/include/hw/mem/memory-device.h @@ -29,14 +29,24 @@ typedef struct MemoryDeviceState { Object parent_obj; } MemoryDeviceState; +/* + * MemoryDeviceClass functions should only be called on realized + * MemoryDevice instances. + */ typedef struct MemoryDeviceClass { InterfaceClass parent_class; + /* required functions that have to be implemented */ uint64_t (*get_addr)(const MemoryDeviceState *md); + void (*set_addr)(MemoryDeviceState *md, uint64_t addr); + MemoryRegion *(*get_memory_region)(MemoryDeviceState *md); uint64_t (*get_plugged_size)(const MemoryDeviceState *md); uint64_t (*get_region_size)(const MemoryDeviceState *md); void (*fill_device_info)(const MemoryDeviceState *md, MemoryDeviceInfo *info); + + /* optional functions that can be implemented */ + uint64_t (*get_align)(const MemoryDeviceState *md); } MemoryDeviceClass; MemoryDeviceInfoList *qmp_memory_device_list(void); -- 2.14.3