net: cadence_gem: Fix debug statements
[qemu/ar7.git] / include / hw / mem / memory-device.h
blob04476acb8fa60b218e8f0016319fabfd6cc82a0f
1 /*
2 * Memory Device Interface
4 * Copyright (c) 2018 Red Hat, Inc.
6 * Authors:
7 * David Hildenbrand <david@redhat.com>
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.
13 #ifndef MEMORY_DEVICE_H
14 #define MEMORY_DEVICE_H
16 #include "hw/qdev-core.h"
17 #include "qapi/qapi-types-misc.h"
18 #include "qom/object.h"
20 #define TYPE_MEMORY_DEVICE "memory-device"
22 #define MEMORY_DEVICE_CLASS(klass) \
23 OBJECT_CLASS_CHECK(MemoryDeviceClass, (klass), TYPE_MEMORY_DEVICE)
24 #define MEMORY_DEVICE_GET_CLASS(obj) \
25 OBJECT_GET_CLASS(MemoryDeviceClass, (obj), TYPE_MEMORY_DEVICE)
26 #define MEMORY_DEVICE(obj) \
27 INTERFACE_CHECK(MemoryDeviceState, (obj), TYPE_MEMORY_DEVICE)
29 typedef struct MemoryDeviceState MemoryDeviceState;
31 /**
32 * MemoryDeviceClass:
34 * All memory devices need to implement TYPE_MEMORY_DEVICE as an interface.
36 * A memory device is a device that owns a memory region which is
37 * mapped into guest physical address space at a certain address. The
38 * address in guest physical memory can either be specified explicitly
39 * or get assigned automatically.
41 * Conceptually, memory devices only span one memory region. If multiple
42 * successive memory regions are used, a covering memory region has to
43 * be provided. Scattered memory regions are not supported for single
44 * devices.
46 typedef struct MemoryDeviceClass {
47 /* private */
48 InterfaceClass parent_class;
51 * Return the address of the memory device in guest physical memory.
53 * Called when (un)plugging a memory device or when iterating over
54 * all memory devices mapped into guest physical address space.
56 * If "0" is returned, no address has been specified by the user and
57 * no address has been assigned to this memory device yet.
59 uint64_t (*get_addr)(const MemoryDeviceState *md);
62 * Set the address of the memory device in guest physical memory.
64 * Called when plugging the memory device to configure the determined
65 * address in guest physical memory.
67 void (*set_addr)(MemoryDeviceState *md, uint64_t addr, Error **errp);
70 * Return the amount of memory provided by the memory device currently
71 * usable ("plugged") by the VM.
73 * Called when calculating the total amount of ram available to the
74 * VM (e.g. to report memory stats to the user).
76 * This is helpful for devices that dynamically manage the amount of
77 * memory accessible by the guest via the reserved memory region. For
78 * most devices, this corresponds to the size of the memory region.
80 uint64_t (*get_plugged_size)(const MemoryDeviceState *md, Error **errp);
83 * Return the memory region of the memory device.
85 * Called when (un)plugging the memory device, to (un)map the
86 * memory region in guest physical memory, but also to detect the
87 * required alignment during address assignment or when the size of the
88 * memory region is required.
90 MemoryRegion *(*get_memory_region)(MemoryDeviceState *md, Error **errp);
93 * Translate the memory device into #MemoryDeviceInfo.
95 void (*fill_device_info)(const MemoryDeviceState *md,
96 MemoryDeviceInfo *info);
97 } MemoryDeviceClass;
99 MemoryDeviceInfoList *qmp_memory_device_list(void);
100 uint64_t get_plugged_memory_size(void);
101 void memory_device_pre_plug(MemoryDeviceState *md, MachineState *ms,
102 const uint64_t *legacy_align, Error **errp);
103 void memory_device_plug(MemoryDeviceState *md, MachineState *ms);
104 void memory_device_unplug(MemoryDeviceState *md, MachineState *ms);
105 uint64_t memory_device_get_region_size(const MemoryDeviceState *md,
106 Error **errp);
108 #endif