]>
Commit | Line | Data |
---|---|---|
87ecb68b PB |
1 | /* Declarations for use by board files for creating devices. */ |
2 | ||
3 | #ifndef HW_BOARDS_H | |
4 | #define HW_BOARDS_H | |
5 | ||
f1e29879 | 6 | #include "qemu/typedefs.h" |
9c17d615 | 7 | #include "sysemu/blockdev.h" |
ac2da55e | 8 | #include "sysemu/accel.h" |
83c9f4ca | 9 | #include "hw/qdev.h" |
36d20cb2 | 10 | #include "qom/object.h" |
3811ef14 | 11 | #include "qom/cpu.h" |
b6b61144 | 12 | |
dfabb8b9 PB |
13 | void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner, |
14 | const char *name, | |
15 | uint64_t ram_size); | |
16 | ||
dfabb8b9 | 17 | #define TYPE_MACHINE_SUFFIX "-machine" |
c84a8f01 EH |
18 | |
19 | /* Machine class name that needs to be used for class-name-based machine | |
20 | * type lookup to work. | |
21 | */ | |
22 | #define MACHINE_TYPE_NAME(machinename) (machinename TYPE_MACHINE_SUFFIX) | |
23 | ||
36d20cb2 | 24 | #define TYPE_MACHINE "machine" |
c8897e8e | 25 | #undef MACHINE /* BSD defines it and QEMU does not use it */ |
36d20cb2 MA |
26 | #define MACHINE(obj) \ |
27 | OBJECT_CHECK(MachineState, (obj), TYPE_MACHINE) | |
28 | #define MACHINE_GET_CLASS(obj) \ | |
29 | OBJECT_GET_CLASS(MachineClass, (obj), TYPE_MACHINE) | |
30 | #define MACHINE_CLASS(klass) \ | |
31 | OBJECT_CLASS_CHECK(MachineClass, (klass), TYPE_MACHINE) | |
32 | ||
0056ae24 MA |
33 | MachineClass *find_default_machine(void); |
34 | extern MachineState *current_machine; | |
35 | ||
5e97b623 | 36 | bool machine_usb(MachineState *machine); |
d8870d02 MA |
37 | bool machine_kernel_irqchip_allowed(MachineState *machine); |
38 | bool machine_kernel_irqchip_required(MachineState *machine); | |
32c18a2d | 39 | bool machine_kernel_irqchip_split(MachineState *machine); |
4689b77b | 40 | int machine_kvm_shadow_mem(MachineState *machine); |
6cabe7fa | 41 | int machine_phandle_start(MachineState *machine); |
47c8ca53 | 42 | bool machine_dump_guest_core(MachineState *machine); |
75cc7f01 | 43 | bool machine_mem_merge(MachineState *machine); |
5e97b623 | 44 | |
3811ef14 IM |
45 | /** |
46 | * CPUArchId: | |
47 | * @arch_id - architecture-dependent CPU ID of present or possible CPU | |
48 | * @cpu - pointer to corresponding CPU object if it's present on NULL otherwise | |
49 | */ | |
50 | typedef struct { | |
51 | uint64_t arch_id; | |
52 | struct CPUState *cpu; | |
53 | } CPUArchId; | |
54 | ||
55 | /** | |
56 | * CPUArchIdList: | |
57 | * @len - number of @CPUArchId items in @cpus array | |
58 | * @cpus - array of present or possible CPUs for current machine configuration | |
59 | */ | |
60 | typedef struct { | |
61 | int len; | |
62 | CPUArchId cpus[0]; | |
63 | } CPUArchIdList; | |
64 | ||
36d20cb2 MA |
65 | /** |
66 | * MachineClass: | |
b7454548 IM |
67 | * @get_hotplug_handler: this function is called during bus-less |
68 | * device hotplug. If defined it returns pointer to an instance | |
69 | * of HotplugHandler object, which handles hotplug operation | |
70 | * for a given @dev. It may return NULL if @dev doesn't require | |
71 | * any actions to be performed by hotplug handler. | |
57924bcd IM |
72 | * @cpu_index_to_socket_id: |
73 | * used to provide @cpu_index to socket number mapping, allowing | |
74 | * a machine to group CPU threads belonging to the same socket/package | |
75 | * Returns: socket number given cpu_index belongs to. | |
fac862ff EH |
76 | * @hw_version: |
77 | * Value of QEMU_VERSION when the machine was added to QEMU. | |
78 | * Set only by old machines because they need to keep | |
79 | * compatibility on code that exposed QEMU_VERSION to guests in | |
80 | * the past (and now use qemu_hw_version()). | |
3811ef14 IM |
81 | * @possible_cpu_arch_ids: |
82 | * Returns an array of @CPUArchId architecture-dependent CPU IDs | |
83 | * which includes CPU IDs for present and possible to hotplug CPUs. | |
84 | * Caller is responsible for freeing returned list. | |
36d20cb2 MA |
85 | */ |
86 | struct MachineClass { | |
87 | /*< private >*/ | |
88 | ObjectClass parent_class; | |
89 | /*< public >*/ | |
90 | ||
2709f263 | 91 | const char *family; /* NULL iff @name identifies a standalone machtype */ |
00b4fbe2 MA |
92 | const char *name; |
93 | const char *alias; | |
94 | const char *desc; | |
95 | ||
3ef96221 | 96 | void (*init)(MachineState *state); |
00b4fbe2 MA |
97 | void (*reset)(void); |
98 | void (*hot_add_cpu)(const int64_t id, Error **errp); | |
99 | int (*kvm_type)(const char *arg); | |
100 | ||
101 | BlockInterfaceType block_default_type; | |
16026518 | 102 | int units_per_default_bus; |
00b4fbe2 MA |
103 | int max_cpus; |
104 | unsigned int no_serial:1, | |
105 | no_parallel:1, | |
106 | use_virtcon:1, | |
107 | use_sclp:1, | |
108 | no_floppy:1, | |
109 | no_cdrom:1, | |
33cd52b5 | 110 | no_sdcard:1, |
92055797 | 111 | has_dynamic_sysbus:1, |
e4024630 | 112 | pci_allow_0_address:1; |
00b4fbe2 MA |
113 | int is_default; |
114 | const char *default_machine_opts; | |
115 | const char *default_boot_order; | |
6f00494a | 116 | const char *default_display; |
00b4fbe2 MA |
117 | GlobalProperty *compat_props; |
118 | const char *hw_version; | |
076b35b5 | 119 | ram_addr_t default_ram_size; |
71ae9e94 EH |
120 | bool option_rom_has_mr; |
121 | bool rom_file_has_mr; | |
b7454548 IM |
122 | |
123 | HotplugHandler *(*get_hotplug_handler)(MachineState *machine, | |
124 | DeviceState *dev); | |
57924bcd | 125 | unsigned (*cpu_index_to_socket_id)(unsigned cpu_index); |
3811ef14 | 126 | CPUArchIdList *(*possible_cpu_arch_ids)(MachineState *machine); |
36d20cb2 MA |
127 | }; |
128 | ||
129 | /** | |
130 | * MachineState: | |
131 | */ | |
132 | struct MachineState { | |
133 | /*< private >*/ | |
134 | Object parent_obj; | |
33cd52b5 AG |
135 | Notifier sysbus_notifier; |
136 | ||
36d20cb2 MA |
137 | /*< public >*/ |
138 | ||
139 | char *accel; | |
d8870d02 MA |
140 | bool kernel_irqchip_allowed; |
141 | bool kernel_irqchip_required; | |
32c18a2d | 142 | bool kernel_irqchip_split; |
36d20cb2 | 143 | int kvm_shadow_mem; |
36d20cb2 MA |
144 | char *dtb; |
145 | char *dumpdtb; | |
146 | int phandle_start; | |
147 | char *dt_compatible; | |
148 | bool dump_guest_core; | |
149 | bool mem_merge; | |
150 | bool usb; | |
c6e76503 | 151 | bool usb_disabled; |
79814179 | 152 | bool igd_gfx_passthru; |
36d20cb2 | 153 | char *firmware; |
a52a7fdf | 154 | bool iommu; |
9850c604 | 155 | bool suppress_vmdesc; |
902c053d | 156 | bool enforce_config_section; |
36d20cb2 | 157 | |
3ef96221 | 158 | ram_addr_t ram_size; |
c270fb9e IM |
159 | ram_addr_t maxram_size; |
160 | uint64_t ram_slots; | |
3ef96221 | 161 | const char *boot_order; |
6b1b1440 MA |
162 | char *kernel_filename; |
163 | char *kernel_cmdline; | |
164 | char *initrd_filename; | |
3ef96221 | 165 | const char *cpu_model; |
ac2da55e | 166 | AccelState *accelerator; |
36d20cb2 MA |
167 | }; |
168 | ||
ed0b6de3 EH |
169 | #define DEFINE_MACHINE(namestr, machine_initfn) \ |
170 | static void machine_initfn##_class_init(ObjectClass *oc, void *data) \ | |
171 | { \ | |
172 | MachineClass *mc = MACHINE_CLASS(oc); \ | |
173 | machine_initfn(mc); \ | |
174 | } \ | |
175 | static const TypeInfo machine_initfn##_typeinfo = { \ | |
176 | .name = MACHINE_TYPE_NAME(namestr), \ | |
177 | .parent = TYPE_MACHINE, \ | |
178 | .class_init = machine_initfn##_class_init, \ | |
179 | }; \ | |
180 | static void machine_initfn##_register_types(void) \ | |
181 | { \ | |
182 | type_register_static(&machine_initfn##_typeinfo); \ | |
183 | } \ | |
0e6aac87 | 184 | type_init(machine_initfn##_register_types) |
ed0b6de3 | 185 | |
877f8931 DG |
186 | #define SET_MACHINE_COMPAT(m, COMPAT) \ |
187 | do { \ | |
188 | static GlobalProperty props[] = { \ | |
189 | COMPAT \ | |
190 | { /* end of list */ } \ | |
191 | }; \ | |
192 | (m)->compat_props = props; \ | |
193 | } while (0) | |
194 | ||
87ecb68b | 195 | #endif |