xref: /openbmc/qemu/include/hw/boards.h (revision 228aa992)
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 *family; /* NULL iff @name identifies a standalone machtype */
23     const char *name;
24     const char *alias;
25     const char *desc;
26     QEMUMachineInitFunc *init;
27     QEMUMachineResetFunc *reset;
28     QEMUMachineHotAddCPUFunc *hot_add_cpu;
29     QEMUMachineGetKvmtypeFunc *kvm_type;
30     BlockInterfaceType block_default_type;
31     int units_per_default_bus;
32     int max_cpus;
33     unsigned int no_serial:1,
34         no_parallel:1,
35         use_virtcon:1,
36         use_sclp:1,
37         no_floppy:1,
38         no_cdrom:1,
39         no_sdcard:1;
40     int is_default;
41     const char *default_machine_opts;
42     const char *default_boot_order;
43     const char *default_display;
44     GlobalProperty *compat_props;
45     const char *hw_version;
46 };
47 
48 void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner,
49                                           const char *name,
50                                           uint64_t ram_size);
51 
52 int qemu_register_machine(QEMUMachine *m);
53 
54 #define TYPE_MACHINE_SUFFIX "-machine"
55 #define TYPE_MACHINE "machine"
56 #undef MACHINE  /* BSD defines it and QEMU does not use it */
57 #define MACHINE(obj) \
58     OBJECT_CHECK(MachineState, (obj), TYPE_MACHINE)
59 #define MACHINE_GET_CLASS(obj) \
60     OBJECT_GET_CLASS(MachineClass, (obj), TYPE_MACHINE)
61 #define MACHINE_CLASS(klass) \
62     OBJECT_CLASS_CHECK(MachineClass, (klass), TYPE_MACHINE)
63 
64 MachineClass *find_default_machine(void);
65 extern MachineState *current_machine;
66 
67 /**
68  * MachineClass:
69  * @qemu_machine: #QEMUMachine
70  * @get_hotplug_handler: this function is called during bus-less
71  *    device hotplug. If defined it returns pointer to an instance
72  *    of HotplugHandler object, which handles hotplug operation
73  *    for a given @dev. It may return NULL if @dev doesn't require
74  *    any actions to be performed by hotplug handler.
75  */
76 struct MachineClass {
77     /*< private >*/
78     ObjectClass parent_class;
79     /*< public >*/
80 
81     const char *family; /* NULL iff @name identifies a standalone machtype */
82     const char *name;
83     const char *alias;
84     const char *desc;
85 
86     void (*init)(MachineState *state);
87     void (*reset)(void);
88     void (*hot_add_cpu)(const int64_t id, Error **errp);
89     int (*kvm_type)(const char *arg);
90 
91     BlockInterfaceType block_default_type;
92     int units_per_default_bus;
93     int max_cpus;
94     unsigned int no_serial:1,
95         no_parallel:1,
96         use_virtcon:1,
97         use_sclp:1,
98         no_floppy:1,
99         no_cdrom:1,
100         no_sdcard:1;
101     int is_default;
102     const char *default_machine_opts;
103     const char *default_boot_order;
104     const char *default_display;
105     GlobalProperty *compat_props;
106     const char *hw_version;
107 
108     HotplugHandler *(*get_hotplug_handler)(MachineState *machine,
109                                            DeviceState *dev);
110 };
111 
112 /**
113  * MachineState:
114  */
115 struct MachineState {
116     /*< private >*/
117     Object parent_obj;
118     /*< public >*/
119 
120     char *accel;
121     bool kernel_irqchip;
122     int kvm_shadow_mem;
123     char *dtb;
124     char *dumpdtb;
125     int phandle_start;
126     char *dt_compatible;
127     bool dump_guest_core;
128     bool mem_merge;
129     bool usb;
130     char *firmware;
131     bool iommu;
132 
133     ram_addr_t ram_size;
134     ram_addr_t maxram_size;
135     uint64_t   ram_slots;
136     const char *boot_order;
137     char *kernel_filename;
138     char *kernel_cmdline;
139     char *initrd_filename;
140     const char *cpu_model;
141     AccelState *accelerator;
142 };
143 
144 #endif
145