10d09e41aSPaolo Bonzini /* Declarations for use by board files for creating devices. */ 20d09e41aSPaolo Bonzini 30d09e41aSPaolo Bonzini #ifndef HW_BOARDS_H 40d09e41aSPaolo Bonzini #define HW_BOARDS_H 50d09e41aSPaolo Bonzini 6f1e29879SMarcel Apfelbaum #include "qemu/typedefs.h" 70d09e41aSPaolo Bonzini #include "sysemu/blockdev.h" 8ac2da55eSEduardo Habkost #include "sysemu/accel.h" 90d09e41aSPaolo Bonzini #include "hw/qdev.h" 1036d20cb2SMarcel Apfelbaum #include "qom/object.h" 110d09e41aSPaolo Bonzini 120d09e41aSPaolo Bonzini 133ef96221SMarcel Apfelbaum typedef void QEMUMachineInitFunc(MachineState *ms); 140d09e41aSPaolo Bonzini 150d09e41aSPaolo Bonzini typedef void QEMUMachineResetFunc(void); 160d09e41aSPaolo Bonzini 17b4fc7b43SIgor Mammedov typedef void QEMUMachineHotAddCPUFunc(const int64_t id, Error **errp); 18b4fc7b43SIgor Mammedov 19135a129aSAneesh Kumar K.V typedef int QEMUMachineGetKvmtypeFunc(const char *arg); 20135a129aSAneesh Kumar K.V 21e689f7c6SMarkus Armbruster struct QEMUMachine { 222709f263SLaszlo Ersek const char *family; /* NULL iff @name identifies a standalone machtype */ 230d09e41aSPaolo Bonzini const char *name; 240d09e41aSPaolo Bonzini const char *alias; 250d09e41aSPaolo Bonzini const char *desc; 260d09e41aSPaolo Bonzini QEMUMachineInitFunc *init; 270d09e41aSPaolo Bonzini QEMUMachineResetFunc *reset; 28b4fc7b43SIgor Mammedov QEMUMachineHotAddCPUFunc *hot_add_cpu; 29135a129aSAneesh Kumar K.V QEMUMachineGetKvmtypeFunc *kvm_type; 300d09e41aSPaolo Bonzini BlockInterfaceType block_default_type; 3116026518SJohn Snow int units_per_default_bus; 320d09e41aSPaolo Bonzini int max_cpus; 330d09e41aSPaolo Bonzini unsigned int no_serial:1, 340d09e41aSPaolo Bonzini no_parallel:1, 350d09e41aSPaolo Bonzini use_virtcon:1, 360d09e41aSPaolo Bonzini use_sclp:1, 370d09e41aSPaolo Bonzini no_floppy:1, 380d09e41aSPaolo Bonzini no_cdrom:1, 3933cd52b5SAlexander Graf no_sdcard:1, 4033cd52b5SAlexander Graf has_dynamic_sysbus:1; 410d09e41aSPaolo Bonzini int is_default; 420d09e41aSPaolo Bonzini const char *default_machine_opts; 43c1654732SMarkus Armbruster const char *default_boot_order; 446f00494aSGerd Hoffmann const char *default_display; 450d09e41aSPaolo Bonzini GlobalProperty *compat_props; 460d09e41aSPaolo Bonzini const char *hw_version; 47e689f7c6SMarkus Armbruster }; 480d09e41aSPaolo Bonzini 49dfabb8b9SPaolo Bonzini void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner, 50dfabb8b9SPaolo Bonzini const char *name, 51dfabb8b9SPaolo Bonzini uint64_t ram_size); 52dfabb8b9SPaolo Bonzini 530d09e41aSPaolo Bonzini int qemu_register_machine(QEMUMachine *m); 540d09e41aSPaolo Bonzini 55dfabb8b9SPaolo Bonzini #define TYPE_MACHINE_SUFFIX "-machine" 5636d20cb2SMarcel Apfelbaum #define TYPE_MACHINE "machine" 57c8897e8eSMarcel Apfelbaum #undef MACHINE /* BSD defines it and QEMU does not use it */ 5836d20cb2SMarcel Apfelbaum #define MACHINE(obj) \ 5936d20cb2SMarcel Apfelbaum OBJECT_CHECK(MachineState, (obj), TYPE_MACHINE) 6036d20cb2SMarcel Apfelbaum #define MACHINE_GET_CLASS(obj) \ 6136d20cb2SMarcel Apfelbaum OBJECT_GET_CLASS(MachineClass, (obj), TYPE_MACHINE) 6236d20cb2SMarcel Apfelbaum #define MACHINE_CLASS(klass) \ 6336d20cb2SMarcel Apfelbaum OBJECT_CLASS_CHECK(MachineClass, (klass), TYPE_MACHINE) 6436d20cb2SMarcel Apfelbaum 650056ae24SMarcel Apfelbaum MachineClass *find_default_machine(void); 660056ae24SMarcel Apfelbaum extern MachineState *current_machine; 670056ae24SMarcel Apfelbaum 685e97b623SMarcel Apfelbaum bool machine_usb(MachineState *machine); 698caff636SMarcel Apfelbaum bool machine_iommu(MachineState *machine); 70d8870d02SMarcel Apfelbaum bool machine_kernel_irqchip_allowed(MachineState *machine); 71d8870d02SMarcel Apfelbaum bool machine_kernel_irqchip_required(MachineState *machine); 724689b77bSMarcel Apfelbaum int machine_kvm_shadow_mem(MachineState *machine); 736cabe7faSMarcel Apfelbaum int machine_phandle_start(MachineState *machine); 7447c8ca53SMarcel Apfelbaum bool machine_dump_guest_core(MachineState *machine); 7575cc7f01SMarcel Apfelbaum bool machine_mem_merge(MachineState *machine); 765e97b623SMarcel Apfelbaum 7736d20cb2SMarcel Apfelbaum /** 7836d20cb2SMarcel Apfelbaum * MachineClass: 7936d20cb2SMarcel Apfelbaum * @qemu_machine: #QEMUMachine 80b7454548SIgor Mammedov * @get_hotplug_handler: this function is called during bus-less 81b7454548SIgor Mammedov * device hotplug. If defined it returns pointer to an instance 82b7454548SIgor Mammedov * of HotplugHandler object, which handles hotplug operation 83b7454548SIgor Mammedov * for a given @dev. It may return NULL if @dev doesn't require 84b7454548SIgor Mammedov * any actions to be performed by hotplug handler. 8536d20cb2SMarcel Apfelbaum */ 8636d20cb2SMarcel Apfelbaum struct MachineClass { 8736d20cb2SMarcel Apfelbaum /*< private >*/ 8836d20cb2SMarcel Apfelbaum ObjectClass parent_class; 8936d20cb2SMarcel Apfelbaum /*< public >*/ 9036d20cb2SMarcel Apfelbaum 912709f263SLaszlo Ersek const char *family; /* NULL iff @name identifies a standalone machtype */ 9200b4fbe2SMarcel Apfelbaum const char *name; 9300b4fbe2SMarcel Apfelbaum const char *alias; 9400b4fbe2SMarcel Apfelbaum const char *desc; 9500b4fbe2SMarcel Apfelbaum 963ef96221SMarcel Apfelbaum void (*init)(MachineState *state); 9700b4fbe2SMarcel Apfelbaum void (*reset)(void); 9800b4fbe2SMarcel Apfelbaum void (*hot_add_cpu)(const int64_t id, Error **errp); 9900b4fbe2SMarcel Apfelbaum int (*kvm_type)(const char *arg); 10000b4fbe2SMarcel Apfelbaum 10100b4fbe2SMarcel Apfelbaum BlockInterfaceType block_default_type; 10216026518SJohn Snow int units_per_default_bus; 10300b4fbe2SMarcel Apfelbaum int max_cpus; 10400b4fbe2SMarcel Apfelbaum unsigned int no_serial:1, 10500b4fbe2SMarcel Apfelbaum no_parallel:1, 10600b4fbe2SMarcel Apfelbaum use_virtcon:1, 10700b4fbe2SMarcel Apfelbaum use_sclp:1, 10800b4fbe2SMarcel Apfelbaum no_floppy:1, 10900b4fbe2SMarcel Apfelbaum no_cdrom:1, 11033cd52b5SAlexander Graf no_sdcard:1, 11133cd52b5SAlexander Graf has_dynamic_sysbus:1; 11200b4fbe2SMarcel Apfelbaum int is_default; 11300b4fbe2SMarcel Apfelbaum const char *default_machine_opts; 11400b4fbe2SMarcel Apfelbaum const char *default_boot_order; 1156f00494aSGerd Hoffmann const char *default_display; 11600b4fbe2SMarcel Apfelbaum GlobalProperty *compat_props; 11700b4fbe2SMarcel Apfelbaum const char *hw_version; 118b7454548SIgor Mammedov 119b7454548SIgor Mammedov HotplugHandler *(*get_hotplug_handler)(MachineState *machine, 120b7454548SIgor Mammedov DeviceState *dev); 12136d20cb2SMarcel Apfelbaum }; 12236d20cb2SMarcel Apfelbaum 12336d20cb2SMarcel Apfelbaum /** 12436d20cb2SMarcel Apfelbaum * MachineState: 12536d20cb2SMarcel Apfelbaum */ 12636d20cb2SMarcel Apfelbaum struct MachineState { 12736d20cb2SMarcel Apfelbaum /*< private >*/ 12836d20cb2SMarcel Apfelbaum Object parent_obj; 12933cd52b5SAlexander Graf Notifier sysbus_notifier; 13033cd52b5SAlexander Graf 13136d20cb2SMarcel Apfelbaum /*< public >*/ 13236d20cb2SMarcel Apfelbaum 13336d20cb2SMarcel Apfelbaum char *accel; 134d8870d02SMarcel Apfelbaum bool kernel_irqchip_allowed; 135d8870d02SMarcel Apfelbaum bool kernel_irqchip_required; 13636d20cb2SMarcel Apfelbaum int kvm_shadow_mem; 13736d20cb2SMarcel Apfelbaum char *dtb; 13836d20cb2SMarcel Apfelbaum char *dumpdtb; 13936d20cb2SMarcel Apfelbaum int phandle_start; 14036d20cb2SMarcel Apfelbaum char *dt_compatible; 14136d20cb2SMarcel Apfelbaum bool dump_guest_core; 14236d20cb2SMarcel Apfelbaum bool mem_merge; 14336d20cb2SMarcel Apfelbaum bool usb; 14436d20cb2SMarcel Apfelbaum char *firmware; 145a52a7fdfSLe Tan bool iommu; 146*9850c604SAlexander Graf bool suppress_vmdesc; 14736d20cb2SMarcel Apfelbaum 1483ef96221SMarcel Apfelbaum ram_addr_t ram_size; 149c270fb9eSIgor Mammedov ram_addr_t maxram_size; 150c270fb9eSIgor Mammedov uint64_t ram_slots; 1513ef96221SMarcel Apfelbaum const char *boot_order; 1526b1b1440SMarcel Apfelbaum char *kernel_filename; 1536b1b1440SMarcel Apfelbaum char *kernel_cmdline; 1546b1b1440SMarcel Apfelbaum char *initrd_filename; 1553ef96221SMarcel Apfelbaum const char *cpu_model; 156ac2da55eSEduardo Habkost AccelState *accelerator; 15736d20cb2SMarcel Apfelbaum }; 15836d20cb2SMarcel Apfelbaum 1590d09e41aSPaolo Bonzini #endif 160