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" 11*3811ef14SIgor Mammedov #include "qom/cpu.h" 120d09e41aSPaolo Bonzini 13dfabb8b9SPaolo Bonzini void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner, 14dfabb8b9SPaolo Bonzini const char *name, 15dfabb8b9SPaolo Bonzini uint64_t ram_size); 16dfabb8b9SPaolo Bonzini 17dfabb8b9SPaolo Bonzini #define TYPE_MACHINE_SUFFIX "-machine" 18c84a8f01SEduardo Habkost 19c84a8f01SEduardo Habkost /* Machine class name that needs to be used for class-name-based machine 20c84a8f01SEduardo Habkost * type lookup to work. 21c84a8f01SEduardo Habkost */ 22c84a8f01SEduardo Habkost #define MACHINE_TYPE_NAME(machinename) (machinename TYPE_MACHINE_SUFFIX) 23c84a8f01SEduardo Habkost 2436d20cb2SMarcel Apfelbaum #define TYPE_MACHINE "machine" 25c8897e8eSMarcel Apfelbaum #undef MACHINE /* BSD defines it and QEMU does not use it */ 2636d20cb2SMarcel Apfelbaum #define MACHINE(obj) \ 2736d20cb2SMarcel Apfelbaum OBJECT_CHECK(MachineState, (obj), TYPE_MACHINE) 2836d20cb2SMarcel Apfelbaum #define MACHINE_GET_CLASS(obj) \ 2936d20cb2SMarcel Apfelbaum OBJECT_GET_CLASS(MachineClass, (obj), TYPE_MACHINE) 3036d20cb2SMarcel Apfelbaum #define MACHINE_CLASS(klass) \ 3136d20cb2SMarcel Apfelbaum OBJECT_CLASS_CHECK(MachineClass, (klass), TYPE_MACHINE) 3236d20cb2SMarcel Apfelbaum 330056ae24SMarcel Apfelbaum MachineClass *find_default_machine(void); 340056ae24SMarcel Apfelbaum extern MachineState *current_machine; 350056ae24SMarcel Apfelbaum 365e97b623SMarcel Apfelbaum bool machine_usb(MachineState *machine); 37d8870d02SMarcel Apfelbaum bool machine_kernel_irqchip_allowed(MachineState *machine); 38d8870d02SMarcel Apfelbaum bool machine_kernel_irqchip_required(MachineState *machine); 3932c18a2dSMatt Gingell bool machine_kernel_irqchip_split(MachineState *machine); 404689b77bSMarcel Apfelbaum int machine_kvm_shadow_mem(MachineState *machine); 416cabe7faSMarcel Apfelbaum int machine_phandle_start(MachineState *machine); 4247c8ca53SMarcel Apfelbaum bool machine_dump_guest_core(MachineState *machine); 4375cc7f01SMarcel Apfelbaum bool machine_mem_merge(MachineState *machine); 445e97b623SMarcel Apfelbaum 4536d20cb2SMarcel Apfelbaum /** 46*3811ef14SIgor Mammedov * CPUArchId: 47*3811ef14SIgor Mammedov * @arch_id - architecture-dependent CPU ID of present or possible CPU 48*3811ef14SIgor Mammedov * @cpu - pointer to corresponding CPU object if it's present on NULL otherwise 49*3811ef14SIgor Mammedov */ 50*3811ef14SIgor Mammedov typedef struct { 51*3811ef14SIgor Mammedov uint64_t arch_id; 52*3811ef14SIgor Mammedov struct CPUState *cpu; 53*3811ef14SIgor Mammedov } CPUArchId; 54*3811ef14SIgor Mammedov 55*3811ef14SIgor Mammedov /** 56*3811ef14SIgor Mammedov * CPUArchIdList: 57*3811ef14SIgor Mammedov * @len - number of @CPUArchId items in @cpus array 58*3811ef14SIgor Mammedov * @cpus - array of present or possible CPUs for current machine configuration 59*3811ef14SIgor Mammedov */ 60*3811ef14SIgor Mammedov typedef struct { 61*3811ef14SIgor Mammedov int len; 62*3811ef14SIgor Mammedov CPUArchId cpus[0]; 63*3811ef14SIgor Mammedov } CPUArchIdList; 64*3811ef14SIgor Mammedov 65*3811ef14SIgor Mammedov /** 6636d20cb2SMarcel Apfelbaum * MachineClass: 67b7454548SIgor Mammedov * @get_hotplug_handler: this function is called during bus-less 68b7454548SIgor Mammedov * device hotplug. If defined it returns pointer to an instance 69b7454548SIgor Mammedov * of HotplugHandler object, which handles hotplug operation 70b7454548SIgor Mammedov * for a given @dev. It may return NULL if @dev doesn't require 71b7454548SIgor Mammedov * any actions to be performed by hotplug handler. 7257924bcdSIgor Mammedov * @cpu_index_to_socket_id: 7357924bcdSIgor Mammedov * used to provide @cpu_index to socket number mapping, allowing 7457924bcdSIgor Mammedov * a machine to group CPU threads belonging to the same socket/package 7557924bcdSIgor Mammedov * Returns: socket number given cpu_index belongs to. 76fac862ffSEduardo Habkost * @hw_version: 77fac862ffSEduardo Habkost * Value of QEMU_VERSION when the machine was added to QEMU. 78fac862ffSEduardo Habkost * Set only by old machines because they need to keep 79fac862ffSEduardo Habkost * compatibility on code that exposed QEMU_VERSION to guests in 80fac862ffSEduardo Habkost * the past (and now use qemu_hw_version()). 81*3811ef14SIgor Mammedov * @possible_cpu_arch_ids: 82*3811ef14SIgor Mammedov * Returns an array of @CPUArchId architecture-dependent CPU IDs 83*3811ef14SIgor Mammedov * which includes CPU IDs for present and possible to hotplug CPUs. 84*3811ef14SIgor Mammedov * Caller is responsible for freeing returned list. 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, 11192055797SPaulo Alcantara has_dynamic_sysbus:1, 112e4024630SLaurent Vivier pci_allow_0_address:1; 11300b4fbe2SMarcel Apfelbaum int is_default; 11400b4fbe2SMarcel Apfelbaum const char *default_machine_opts; 11500b4fbe2SMarcel Apfelbaum const char *default_boot_order; 1166f00494aSGerd Hoffmann const char *default_display; 11700b4fbe2SMarcel Apfelbaum GlobalProperty *compat_props; 11800b4fbe2SMarcel Apfelbaum const char *hw_version; 119076b35b5SNikunj A Dadhania ram_addr_t default_ram_size; 12071ae9e94SEduardo Habkost bool option_rom_has_mr; 12171ae9e94SEduardo Habkost bool rom_file_has_mr; 122b7454548SIgor Mammedov 123b7454548SIgor Mammedov HotplugHandler *(*get_hotplug_handler)(MachineState *machine, 124b7454548SIgor Mammedov DeviceState *dev); 12557924bcdSIgor Mammedov unsigned (*cpu_index_to_socket_id)(unsigned cpu_index); 126*3811ef14SIgor Mammedov CPUArchIdList *(*possible_cpu_arch_ids)(MachineState *machine); 12736d20cb2SMarcel Apfelbaum }; 12836d20cb2SMarcel Apfelbaum 12936d20cb2SMarcel Apfelbaum /** 13036d20cb2SMarcel Apfelbaum * MachineState: 13136d20cb2SMarcel Apfelbaum */ 13236d20cb2SMarcel Apfelbaum struct MachineState { 13336d20cb2SMarcel Apfelbaum /*< private >*/ 13436d20cb2SMarcel Apfelbaum Object parent_obj; 13533cd52b5SAlexander Graf Notifier sysbus_notifier; 13633cd52b5SAlexander Graf 13736d20cb2SMarcel Apfelbaum /*< public >*/ 13836d20cb2SMarcel Apfelbaum 13936d20cb2SMarcel Apfelbaum char *accel; 140d8870d02SMarcel Apfelbaum bool kernel_irqchip_allowed; 141d8870d02SMarcel Apfelbaum bool kernel_irqchip_required; 14232c18a2dSMatt Gingell bool kernel_irqchip_split; 14336d20cb2SMarcel Apfelbaum int kvm_shadow_mem; 14436d20cb2SMarcel Apfelbaum char *dtb; 14536d20cb2SMarcel Apfelbaum char *dumpdtb; 14636d20cb2SMarcel Apfelbaum int phandle_start; 14736d20cb2SMarcel Apfelbaum char *dt_compatible; 14836d20cb2SMarcel Apfelbaum bool dump_guest_core; 14936d20cb2SMarcel Apfelbaum bool mem_merge; 15036d20cb2SMarcel Apfelbaum bool usb; 151c6e76503SPaolo Bonzini bool usb_disabled; 15279814179STiejun Chen bool igd_gfx_passthru; 15336d20cb2SMarcel Apfelbaum char *firmware; 154a52a7fdfSLe Tan bool iommu; 1559850c604SAlexander Graf bool suppress_vmdesc; 156902c053dSGreg Kurz bool enforce_config_section; 15736d20cb2SMarcel Apfelbaum 1583ef96221SMarcel Apfelbaum ram_addr_t ram_size; 159c270fb9eSIgor Mammedov ram_addr_t maxram_size; 160c270fb9eSIgor Mammedov uint64_t ram_slots; 1613ef96221SMarcel Apfelbaum const char *boot_order; 1626b1b1440SMarcel Apfelbaum char *kernel_filename; 1636b1b1440SMarcel Apfelbaum char *kernel_cmdline; 1646b1b1440SMarcel Apfelbaum char *initrd_filename; 1653ef96221SMarcel Apfelbaum const char *cpu_model; 166ac2da55eSEduardo Habkost AccelState *accelerator; 16736d20cb2SMarcel Apfelbaum }; 16836d20cb2SMarcel Apfelbaum 169ed0b6de3SEduardo Habkost #define DEFINE_MACHINE(namestr, machine_initfn) \ 170ed0b6de3SEduardo Habkost static void machine_initfn##_class_init(ObjectClass *oc, void *data) \ 171ed0b6de3SEduardo Habkost { \ 172ed0b6de3SEduardo Habkost MachineClass *mc = MACHINE_CLASS(oc); \ 173ed0b6de3SEduardo Habkost machine_initfn(mc); \ 174ed0b6de3SEduardo Habkost } \ 175ed0b6de3SEduardo Habkost static const TypeInfo machine_initfn##_typeinfo = { \ 176ed0b6de3SEduardo Habkost .name = MACHINE_TYPE_NAME(namestr), \ 177ed0b6de3SEduardo Habkost .parent = TYPE_MACHINE, \ 178ed0b6de3SEduardo Habkost .class_init = machine_initfn##_class_init, \ 179ed0b6de3SEduardo Habkost }; \ 180ed0b6de3SEduardo Habkost static void machine_initfn##_register_types(void) \ 181ed0b6de3SEduardo Habkost { \ 182ed0b6de3SEduardo Habkost type_register_static(&machine_initfn##_typeinfo); \ 183ed0b6de3SEduardo Habkost } \ 184ed0b6de3SEduardo Habkost machine_init(machine_initfn##_register_types) 185ed0b6de3SEduardo Habkost 186877f8931SDavid Gibson #define SET_MACHINE_COMPAT(m, COMPAT) \ 187877f8931SDavid Gibson do { \ 188877f8931SDavid Gibson static GlobalProperty props[] = { \ 189877f8931SDavid Gibson COMPAT \ 190877f8931SDavid Gibson { /* end of list */ } \ 191877f8931SDavid Gibson }; \ 192877f8931SDavid Gibson (m)->compat_props = props; \ 193877f8931SDavid Gibson } while (0) 194877f8931SDavid Gibson 1950d09e41aSPaolo Bonzini #endif 196