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