1 /* 2 * Memory Device Interface 3 * 4 * Copyright (c) 2018 Red Hat, Inc. 5 * 6 * Authors: 7 * David Hildenbrand <david@redhat.com> 8 * 9 * This work is licensed under the terms of the GNU GPL, version 2 or later. 10 * See the COPYING file in the top-level directory. 11 */ 12 13 #ifndef MEMORY_DEVICE_H 14 #define MEMORY_DEVICE_H 15 16 #include "qom/object.h" 17 #include "hw/qdev.h" 18 19 #define TYPE_MEMORY_DEVICE "memory-device" 20 21 #define MEMORY_DEVICE_CLASS(klass) \ 22 OBJECT_CLASS_CHECK(MemoryDeviceClass, (klass), TYPE_MEMORY_DEVICE) 23 #define MEMORY_DEVICE_GET_CLASS(obj) \ 24 OBJECT_GET_CLASS(MemoryDeviceClass, (obj), TYPE_MEMORY_DEVICE) 25 #define MEMORY_DEVICE(obj) \ 26 INTERFACE_CHECK(MemoryDeviceState, (obj), TYPE_MEMORY_DEVICE) 27 28 typedef struct MemoryDeviceState { 29 Object parent_obj; 30 } MemoryDeviceState; 31 32 typedef struct MemoryDeviceClass { 33 InterfaceClass parent_class; 34 35 uint64_t (*get_addr)(const MemoryDeviceState *md); 36 uint64_t (*get_plugged_size)(const MemoryDeviceState *md); 37 uint64_t (*get_region_size)(const MemoryDeviceState *md); 38 void (*fill_device_info)(const MemoryDeviceState *md, 39 MemoryDeviceInfo *info); 40 } MemoryDeviceClass; 41 42 MemoryDeviceInfoList *qmp_memory_device_list(void); 43 uint64_t get_plugged_memory_size(void); 44 uint64_t memory_device_get_free_addr(MachineState *ms, const uint64_t *hint, 45 uint64_t align, uint64_t size, 46 Error **errp); 47 void memory_device_plug_region(MachineState *ms, MemoryRegion *mr, 48 uint64_t addr); 49 void memory_device_unplug_region(MachineState *ms, MemoryRegion *mr); 50 51 #endif 52