xref: /openbmc/qemu/include/hw/boards.h (revision dcb3d601115eed77aef543fe3a920adc17544e06)
1 /* Declarations for use by board files for creating devices.  */
2 
3 #ifndef HW_BOARDS_H
4 #define HW_BOARDS_H
5 
6 #include "qemu/typedefs.h"
7 #include "sysemu/blockdev.h"
8 #include "sysemu/accel.h"
9 #include "hw/qdev.h"
10 #include "qom/object.h"
11 
12 
13 typedef void QEMUMachineInitFunc(MachineState *ms);
14 
15 typedef void QEMUMachineResetFunc(void);
16 
17 typedef void QEMUMachineHotAddCPUFunc(const int64_t id, Error **errp);
18 
19 typedef int QEMUMachineGetKvmtypeFunc(const char *arg);
20 
21 struct QEMUMachine {
22     const char *name;
23     const char *desc;
24     QEMUMachineInitFunc *init;
25     QEMUMachineGetKvmtypeFunc *kvm_type;
26     BlockInterfaceType block_default_type;
27     int max_cpus;
28     unsigned int
29         no_sdcard:1,
30         has_dynamic_sysbus:1;
31     int is_default;
32     const char *default_machine_opts;
33     const char *default_boot_order;
34 };
35 
36 void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner,
37                                           const char *name,
38                                           uint64_t ram_size);
39 
40 int qemu_register_machine(QEMUMachine *m);
41 
42 #define TYPE_MACHINE_SUFFIX "-machine"
43 
44 /* Machine class name that needs to be used for class-name-based machine
45  * type lookup to work.
46  */
47 #define MACHINE_TYPE_NAME(machinename) (machinename TYPE_MACHINE_SUFFIX)
48 
49 #define TYPE_MACHINE "machine"
50 #undef MACHINE  /* BSD defines it and QEMU does not use it */
51 #define MACHINE(obj) \
52     OBJECT_CHECK(MachineState, (obj), TYPE_MACHINE)
53 #define MACHINE_GET_CLASS(obj) \
54     OBJECT_GET_CLASS(MachineClass, (obj), TYPE_MACHINE)
55 #define MACHINE_CLASS(klass) \
56     OBJECT_CLASS_CHECK(MachineClass, (klass), TYPE_MACHINE)
57 
58 MachineClass *find_default_machine(void);
59 extern MachineState *current_machine;
60 
61 bool machine_usb(MachineState *machine);
62 bool machine_iommu(MachineState *machine);
63 bool machine_kernel_irqchip_allowed(MachineState *machine);
64 bool machine_kernel_irqchip_required(MachineState *machine);
65 int machine_kvm_shadow_mem(MachineState *machine);
66 int machine_phandle_start(MachineState *machine);
67 bool machine_dump_guest_core(MachineState *machine);
68 bool machine_mem_merge(MachineState *machine);
69 
70 /**
71  * MachineClass:
72  * @qemu_machine: #QEMUMachine
73  * @get_hotplug_handler: this function is called during bus-less
74  *    device hotplug. If defined it returns pointer to an instance
75  *    of HotplugHandler object, which handles hotplug operation
76  *    for a given @dev. It may return NULL if @dev doesn't require
77  *    any actions to be performed by hotplug handler.
78  * @cpu_index_to_socket_id:
79  *    used to provide @cpu_index to socket number mapping, allowing
80  *    a machine to group CPU threads belonging to the same socket/package
81  *    Returns: socket number given cpu_index belongs to.
82  */
83 struct MachineClass {
84     /*< private >*/
85     ObjectClass parent_class;
86     /*< public >*/
87 
88     const char *family; /* NULL iff @name identifies a standalone machtype */
89     const char *name;
90     const char *alias;
91     const char *desc;
92 
93     void (*init)(MachineState *state);
94     void (*reset)(void);
95     void (*hot_add_cpu)(const int64_t id, Error **errp);
96     int (*kvm_type)(const char *arg);
97 
98     BlockInterfaceType block_default_type;
99     int units_per_default_bus;
100     int max_cpus;
101     unsigned int no_serial:1,
102         no_parallel:1,
103         use_virtcon:1,
104         use_sclp:1,
105         no_floppy:1,
106         no_cdrom:1,
107         no_sdcard:1,
108         has_dynamic_sysbus:1,
109         no_tco:1,
110         pci_allow_0_address:1;
111     int is_default;
112     const char *default_machine_opts;
113     const char *default_boot_order;
114     const char *default_display;
115     GlobalProperty *compat_props;
116     const char *hw_version;
117     ram_addr_t default_ram_size;
118 
119     HotplugHandler *(*get_hotplug_handler)(MachineState *machine,
120                                            DeviceState *dev);
121     unsigned (*cpu_index_to_socket_id)(unsigned cpu_index);
122 };
123 
124 /**
125  * MachineState:
126  */
127 struct MachineState {
128     /*< private >*/
129     Object parent_obj;
130     Notifier sysbus_notifier;
131 
132     /*< public >*/
133 
134     char *accel;
135     bool kernel_irqchip_allowed;
136     bool kernel_irqchip_required;
137     int kvm_shadow_mem;
138     char *dtb;
139     char *dumpdtb;
140     int phandle_start;
141     char *dt_compatible;
142     bool dump_guest_core;
143     bool mem_merge;
144     bool usb;
145     bool usb_disabled;
146     bool igd_gfx_passthru;
147     char *firmware;
148     bool iommu;
149     bool suppress_vmdesc;
150 
151     ram_addr_t ram_size;
152     ram_addr_t maxram_size;
153     uint64_t   ram_slots;
154     const char *boot_order;
155     char *kernel_filename;
156     char *kernel_cmdline;
157     char *initrd_filename;
158     const char *cpu_model;
159     AccelState *accelerator;
160 };
161 
162 #endif
163