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 60d09e41aSPaolo Bonzini #include "sysemu/blockdev.h" 7ac2da55eSEduardo Habkost #include "sysemu/accel.h" 80d09e41aSPaolo Bonzini #include "hw/qdev.h" 936d20cb2SMarcel Apfelbaum #include "qom/object.h" 103811ef14SIgor Mammedov #include "qom/cpu.h" 110d09e41aSPaolo Bonzini 12dfabb8b9SPaolo Bonzini void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner, 13dfabb8b9SPaolo Bonzini const char *name, 14dfabb8b9SPaolo Bonzini uint64_t ram_size); 15dfabb8b9SPaolo Bonzini 16dfabb8b9SPaolo Bonzini #define TYPE_MACHINE_SUFFIX "-machine" 17c84a8f01SEduardo Habkost 18c84a8f01SEduardo Habkost /* Machine class name that needs to be used for class-name-based machine 19c84a8f01SEduardo Habkost * type lookup to work. 20c84a8f01SEduardo Habkost */ 21c84a8f01SEduardo Habkost #define MACHINE_TYPE_NAME(machinename) (machinename TYPE_MACHINE_SUFFIX) 22c84a8f01SEduardo Habkost 2336d20cb2SMarcel Apfelbaum #define TYPE_MACHINE "machine" 24c8897e8eSMarcel Apfelbaum #undef MACHINE /* BSD defines it and QEMU does not use it */ 2536d20cb2SMarcel Apfelbaum #define MACHINE(obj) \ 2636d20cb2SMarcel Apfelbaum OBJECT_CHECK(MachineState, (obj), TYPE_MACHINE) 2736d20cb2SMarcel Apfelbaum #define MACHINE_GET_CLASS(obj) \ 2836d20cb2SMarcel Apfelbaum OBJECT_GET_CLASS(MachineClass, (obj), TYPE_MACHINE) 2936d20cb2SMarcel Apfelbaum #define MACHINE_CLASS(klass) \ 3036d20cb2SMarcel Apfelbaum OBJECT_CLASS_CHECK(MachineClass, (klass), TYPE_MACHINE) 3136d20cb2SMarcel Apfelbaum 320056ae24SMarcel Apfelbaum MachineClass *find_default_machine(void); 330056ae24SMarcel Apfelbaum extern MachineState *current_machine; 340056ae24SMarcel Apfelbaum 355e97b623SMarcel Apfelbaum bool machine_usb(MachineState *machine); 36d8870d02SMarcel Apfelbaum bool machine_kernel_irqchip_allowed(MachineState *machine); 37d8870d02SMarcel Apfelbaum bool machine_kernel_irqchip_required(MachineState *machine); 3832c18a2dSMatt Gingell bool machine_kernel_irqchip_split(MachineState *machine); 394689b77bSMarcel Apfelbaum int machine_kvm_shadow_mem(MachineState *machine); 406cabe7faSMarcel Apfelbaum int machine_phandle_start(MachineState *machine); 4147c8ca53SMarcel Apfelbaum bool machine_dump_guest_core(MachineState *machine); 4275cc7f01SMarcel Apfelbaum bool machine_mem_merge(MachineState *machine); 4339a3b377SEduardo Habkost void machine_register_compat_props(MachineState *machine); 445e97b623SMarcel Apfelbaum 4536d20cb2SMarcel Apfelbaum /** 463811ef14SIgor Mammedov * CPUArchId: 473811ef14SIgor Mammedov * @arch_id - architecture-dependent CPU ID of present or possible CPU 483811ef14SIgor Mammedov * @cpu - pointer to corresponding CPU object if it's present on NULL otherwise 493811ef14SIgor Mammedov */ 503811ef14SIgor Mammedov typedef struct { 513811ef14SIgor Mammedov uint64_t arch_id; 523811ef14SIgor Mammedov struct CPUState *cpu; 533811ef14SIgor Mammedov } CPUArchId; 543811ef14SIgor Mammedov 553811ef14SIgor Mammedov /** 563811ef14SIgor Mammedov * CPUArchIdList: 573811ef14SIgor Mammedov * @len - number of @CPUArchId items in @cpus array 583811ef14SIgor Mammedov * @cpus - array of present or possible CPUs for current machine configuration 593811ef14SIgor Mammedov */ 603811ef14SIgor Mammedov typedef struct { 613811ef14SIgor Mammedov int len; 623811ef14SIgor Mammedov CPUArchId cpus[0]; 633811ef14SIgor Mammedov } CPUArchIdList; 643811ef14SIgor Mammedov 653811ef14SIgor 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()). 813811ef14SIgor Mammedov * @possible_cpu_arch_ids: 823811ef14SIgor Mammedov * Returns an array of @CPUArchId architecture-dependent CPU IDs 833811ef14SIgor Mammedov * which includes CPU IDs for present and possible to hotplug CPUs. 843811ef14SIgor Mammedov * Caller is responsible for freeing returned list. 85d4633541SIgor Mammedov * @query_hotpluggable_cpus: 86d4633541SIgor Mammedov * Returns a @HotpluggableCPUList, which describes CPUs objects which 87d4633541SIgor Mammedov * could be added with -device/device_add. 88d4633541SIgor Mammedov * Caller is responsible for freeing returned list. 89*20bccb82SPeter Maydell * @minimum_page_bits: 90*20bccb82SPeter Maydell * If non-zero, the board promises never to create a CPU with a page size 91*20bccb82SPeter Maydell * smaller than this, so QEMU can use a more efficient larger page 92*20bccb82SPeter Maydell * size than the target architecture's minimum. (Attempting to create 93*20bccb82SPeter Maydell * such a CPU will fail.) Note that changing this is a migration 94*20bccb82SPeter Maydell * compatibility break for the machine. 9536d20cb2SMarcel Apfelbaum */ 9636d20cb2SMarcel Apfelbaum struct MachineClass { 9736d20cb2SMarcel Apfelbaum /*< private >*/ 9836d20cb2SMarcel Apfelbaum ObjectClass parent_class; 9936d20cb2SMarcel Apfelbaum /*< public >*/ 10036d20cb2SMarcel Apfelbaum 1012709f263SLaszlo Ersek const char *family; /* NULL iff @name identifies a standalone machtype */ 1028ea75371SMarc-André Lureau char *name; 10300b4fbe2SMarcel Apfelbaum const char *alias; 10400b4fbe2SMarcel Apfelbaum const char *desc; 10500b4fbe2SMarcel Apfelbaum 1063ef96221SMarcel Apfelbaum void (*init)(MachineState *state); 10700b4fbe2SMarcel Apfelbaum void (*reset)(void); 10800b4fbe2SMarcel Apfelbaum void (*hot_add_cpu)(const int64_t id, Error **errp); 10900b4fbe2SMarcel Apfelbaum int (*kvm_type)(const char *arg); 11000b4fbe2SMarcel Apfelbaum 11100b4fbe2SMarcel Apfelbaum BlockInterfaceType block_default_type; 11216026518SJohn Snow int units_per_default_bus; 11300b4fbe2SMarcel Apfelbaum int max_cpus; 11400b4fbe2SMarcel Apfelbaum unsigned int no_serial:1, 11500b4fbe2SMarcel Apfelbaum no_parallel:1, 11600b4fbe2SMarcel Apfelbaum use_virtcon:1, 11700b4fbe2SMarcel Apfelbaum use_sclp:1, 11800b4fbe2SMarcel Apfelbaum no_floppy:1, 11900b4fbe2SMarcel Apfelbaum no_cdrom:1, 12033cd52b5SAlexander Graf no_sdcard:1, 12192055797SPaulo Alcantara has_dynamic_sysbus:1, 122bab47d9aSGerd Hoffmann pci_allow_0_address:1, 123bab47d9aSGerd Hoffmann legacy_fw_cfg_order:1; 12400b4fbe2SMarcel Apfelbaum int is_default; 12500b4fbe2SMarcel Apfelbaum const char *default_machine_opts; 12600b4fbe2SMarcel Apfelbaum const char *default_boot_order; 1276f00494aSGerd Hoffmann const char *default_display; 128bacc344cSIgor Mammedov GArray *compat_props; 12900b4fbe2SMarcel Apfelbaum const char *hw_version; 130076b35b5SNikunj A Dadhania ram_addr_t default_ram_size; 13171ae9e94SEduardo Habkost bool option_rom_has_mr; 13271ae9e94SEduardo Habkost bool rom_file_has_mr; 133*20bccb82SPeter Maydell int minimum_page_bits; 134b7454548SIgor Mammedov 135b7454548SIgor Mammedov HotplugHandler *(*get_hotplug_handler)(MachineState *machine, 136b7454548SIgor Mammedov DeviceState *dev); 13757924bcdSIgor Mammedov unsigned (*cpu_index_to_socket_id)(unsigned cpu_index); 1383811ef14SIgor Mammedov CPUArchIdList *(*possible_cpu_arch_ids)(MachineState *machine); 139d4633541SIgor Mammedov HotpluggableCPUList *(*query_hotpluggable_cpus)(MachineState *machine); 14036d20cb2SMarcel Apfelbaum }; 14136d20cb2SMarcel Apfelbaum 14236d20cb2SMarcel Apfelbaum /** 14336d20cb2SMarcel Apfelbaum * MachineState: 14436d20cb2SMarcel Apfelbaum */ 14536d20cb2SMarcel Apfelbaum struct MachineState { 14636d20cb2SMarcel Apfelbaum /*< private >*/ 14736d20cb2SMarcel Apfelbaum Object parent_obj; 14833cd52b5SAlexander Graf Notifier sysbus_notifier; 14933cd52b5SAlexander Graf 15036d20cb2SMarcel Apfelbaum /*< public >*/ 15136d20cb2SMarcel Apfelbaum 15236d20cb2SMarcel Apfelbaum char *accel; 153d8870d02SMarcel Apfelbaum bool kernel_irqchip_allowed; 154d8870d02SMarcel Apfelbaum bool kernel_irqchip_required; 15532c18a2dSMatt Gingell bool kernel_irqchip_split; 15636d20cb2SMarcel Apfelbaum int kvm_shadow_mem; 15736d20cb2SMarcel Apfelbaum char *dtb; 15836d20cb2SMarcel Apfelbaum char *dumpdtb; 15936d20cb2SMarcel Apfelbaum int phandle_start; 16036d20cb2SMarcel Apfelbaum char *dt_compatible; 16136d20cb2SMarcel Apfelbaum bool dump_guest_core; 16236d20cb2SMarcel Apfelbaum bool mem_merge; 16336d20cb2SMarcel Apfelbaum bool usb; 164c6e76503SPaolo Bonzini bool usb_disabled; 16579814179STiejun Chen bool igd_gfx_passthru; 16636d20cb2SMarcel Apfelbaum char *firmware; 167a52a7fdfSLe Tan bool iommu; 1689850c604SAlexander Graf bool suppress_vmdesc; 169902c053dSGreg Kurz bool enforce_config_section; 170cfc58cf3SEduardo Habkost bool enable_graphics; 17136d20cb2SMarcel Apfelbaum 1723ef96221SMarcel Apfelbaum ram_addr_t ram_size; 173c270fb9eSIgor Mammedov ram_addr_t maxram_size; 174c270fb9eSIgor Mammedov uint64_t ram_slots; 1753ef96221SMarcel Apfelbaum const char *boot_order; 1766b1b1440SMarcel Apfelbaum char *kernel_filename; 1776b1b1440SMarcel Apfelbaum char *kernel_cmdline; 1786b1b1440SMarcel Apfelbaum char *initrd_filename; 1793ef96221SMarcel Apfelbaum const char *cpu_model; 180ac2da55eSEduardo Habkost AccelState *accelerator; 18136d20cb2SMarcel Apfelbaum }; 18236d20cb2SMarcel Apfelbaum 183ed0b6de3SEduardo Habkost #define DEFINE_MACHINE(namestr, machine_initfn) \ 184ed0b6de3SEduardo Habkost static void machine_initfn##_class_init(ObjectClass *oc, void *data) \ 185ed0b6de3SEduardo Habkost { \ 186ed0b6de3SEduardo Habkost MachineClass *mc = MACHINE_CLASS(oc); \ 187ed0b6de3SEduardo Habkost machine_initfn(mc); \ 188ed0b6de3SEduardo Habkost } \ 189ed0b6de3SEduardo Habkost static const TypeInfo machine_initfn##_typeinfo = { \ 190ed0b6de3SEduardo Habkost .name = MACHINE_TYPE_NAME(namestr), \ 191ed0b6de3SEduardo Habkost .parent = TYPE_MACHINE, \ 192ed0b6de3SEduardo Habkost .class_init = machine_initfn##_class_init, \ 193ed0b6de3SEduardo Habkost }; \ 194ed0b6de3SEduardo Habkost static void machine_initfn##_register_types(void) \ 195ed0b6de3SEduardo Habkost { \ 196ed0b6de3SEduardo Habkost type_register_static(&machine_initfn##_typeinfo); \ 197ed0b6de3SEduardo Habkost } \ 1980e6aac87SEduardo Habkost type_init(machine_initfn##_register_types) 199ed0b6de3SEduardo Habkost 200877f8931SDavid Gibson #define SET_MACHINE_COMPAT(m, COMPAT) \ 201877f8931SDavid Gibson do { \ 202bacc344cSIgor Mammedov int i; \ 203877f8931SDavid Gibson static GlobalProperty props[] = { \ 204877f8931SDavid Gibson COMPAT \ 205877f8931SDavid Gibson { /* end of list */ } \ 206877f8931SDavid Gibson }; \ 207bacc344cSIgor Mammedov if (!m->compat_props) { \ 208bacc344cSIgor Mammedov m->compat_props = g_array_new(false, false, sizeof(void *)); \ 209bacc344cSIgor Mammedov } \ 210bacc344cSIgor Mammedov for (i = 0; props[i].driver != NULL; i++) { \ 211bacc344cSIgor Mammedov GlobalProperty *prop = &props[i]; \ 212bacc344cSIgor Mammedov g_array_append_val(m->compat_props, prop); \ 213bacc344cSIgor Mammedov } \ 214877f8931SDavid Gibson } while (0) 215877f8931SDavid Gibson 2160d09e41aSPaolo Bonzini #endif 217