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