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 6d4842052SMarkus Armbruster #include "exec/memory.h" 7aa8b1839SIgor Mammedov #include "sysemu/hostmem.h" 80d09e41aSPaolo Bonzini #include "sysemu/blockdev.h" 98ac25c84SMarkus Armbruster #include "qapi/qapi-types-machine.h" 100b8fa32fSMarkus Armbruster #include "qemu/module.h" 1136d20cb2SMarcel Apfelbaum #include "qom/object.h" 122e5b09fdSMarkus Armbruster #include "hw/core/cpu.h" 130d09e41aSPaolo Bonzini 14dfabb8b9SPaolo Bonzini #define TYPE_MACHINE_SUFFIX "-machine" 15c84a8f01SEduardo Habkost 16c84a8f01SEduardo Habkost /* Machine class name that needs to be used for class-name-based machine 17c84a8f01SEduardo Habkost * type lookup to work. 18c84a8f01SEduardo Habkost */ 19c84a8f01SEduardo Habkost #define MACHINE_TYPE_NAME(machinename) (machinename TYPE_MACHINE_SUFFIX) 20c84a8f01SEduardo Habkost 2136d20cb2SMarcel Apfelbaum #define TYPE_MACHINE "machine" 22c8897e8eSMarcel Apfelbaum #undef MACHINE /* BSD defines it and QEMU does not use it */ 23a489d195SEduardo Habkost OBJECT_DECLARE_TYPE(MachineState, MachineClass, MACHINE) 2436d20cb2SMarcel Apfelbaum 250056ae24SMarcel Apfelbaum extern MachineState *current_machine; 260056ae24SMarcel Apfelbaum 2762b4a227SPhilippe Mathieu-Daudé /** 2862b4a227SPhilippe Mathieu-Daudé * machine_class_default_cpu_type: Return the machine default CPU type. 2962b4a227SPhilippe Mathieu-Daudé * @mc: Machine class 3062b4a227SPhilippe Mathieu-Daudé */ 3162b4a227SPhilippe Mathieu-Daudé const char *machine_class_default_cpu_type(MachineClass *mc); 3262b4a227SPhilippe Mathieu-Daudé 337a2c7da6SMartin Kletzander void machine_add_audiodev_property(MachineClass *mc); 3426f88d84SPaolo Bonzini void machine_run_board_init(MachineState *machine, const char *mem_path, Error **errp); 355e97b623SMarcel Apfelbaum bool machine_usb(MachineState *machine); 366cabe7faSMarcel Apfelbaum int machine_phandle_start(MachineState *machine); 3747c8ca53SMarcel Apfelbaum bool machine_dump_guest_core(MachineState *machine); 3875cc7f01SMarcel Apfelbaum bool machine_mem_merge(MachineState *machine); 39f2d672c2SIgor Mammedov HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine); 407c88e65dSIgor Mammedov void machine_set_cpu_numa_node(MachineState *machine, 417c88e65dSIgor Mammedov const CpuInstanceProperties *props, 427c88e65dSIgor Mammedov Error **errp); 433e2f1498SPhilippe Mathieu-Daudé void machine_parse_smp_config(MachineState *ms, 443e2f1498SPhilippe Mathieu-Daudé const SMPConfiguration *config, Error **errp); 45a1d027beSZhao Liu unsigned int machine_topo_get_cores_per_socket(const MachineState *ms); 46a1d027beSZhao Liu unsigned int machine_topo_get_threads_per_socket(const MachineState *ms); 47cc0afd8aSDavid Hildenbrand void machine_memory_devices_init(MachineState *ms, hwaddr base, uint64_t size); 485e97b623SMarcel Apfelbaum 49387c0e8bSPeter Maydell /** 50387c0e8bSPeter Maydell * machine_class_allow_dynamic_sysbus_dev: Add type to list of valid devices 51387c0e8bSPeter Maydell * @mc: Machine class 52387c0e8bSPeter Maydell * @type: type to allow (should be a subtype of TYPE_SYS_BUS_DEVICE) 53387c0e8bSPeter Maydell * 54387c0e8bSPeter Maydell * Add the QOM type @type to the list of devices of which are subtypes 55387c0e8bSPeter Maydell * of TYPE_SYS_BUS_DEVICE but which are still permitted to be dynamically 56387c0e8bSPeter Maydell * created (eg by the user on the command line with -device). 57387c0e8bSPeter Maydell * By default if the user tries to create any devices on the command line 58387c0e8bSPeter Maydell * that are subtypes of TYPE_SYS_BUS_DEVICE they will get an error message; 59387c0e8bSPeter Maydell * for the special cases which are permitted for this machine model, the 60387c0e8bSPeter Maydell * machine model class init code must call this function to add them 61387c0e8bSPeter Maydell * to the list of specifically permitted devices. 62387c0e8bSPeter Maydell */ 630bd1909dSEduardo Habkost void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *type); 64387c0e8bSPeter Maydell 650fb124dbSPeter Maydell /** 66b5fdf410SDamien Hedde * device_type_is_dynamic_sysbus: Check if type is an allowed sysbus device 67b5fdf410SDamien Hedde * type for the machine class. 68b5fdf410SDamien Hedde * @mc: Machine class 69b5fdf410SDamien Hedde * @type: type to check (should be a subtype of TYPE_SYS_BUS_DEVICE) 70b5fdf410SDamien Hedde * 71b5fdf410SDamien Hedde * Returns: true if @type is a type in the machine's list of 72b5fdf410SDamien Hedde * dynamically pluggable sysbus devices; otherwise false. 73b5fdf410SDamien Hedde * 74b5fdf410SDamien Hedde * Check if the QOM type @type is in the list of allowed sysbus device 75b5fdf410SDamien Hedde * types (see machine_class_allowed_dynamic_sysbus_dev()). 76b5fdf410SDamien Hedde * Note that if @type has a parent type in the list, it is allowed too. 77b5fdf410SDamien Hedde */ 78b5fdf410SDamien Hedde bool device_type_is_dynamic_sysbus(MachineClass *mc, const char *type); 79b5fdf410SDamien Hedde 80b5fdf410SDamien Hedde /** 810fb124dbSPeter Maydell * device_is_dynamic_sysbus: test whether device is a dynamic sysbus device 820fb124dbSPeter Maydell * @mc: Machine class 830fb124dbSPeter Maydell * @dev: device to check 840fb124dbSPeter Maydell * 850fb124dbSPeter Maydell * Returns: true if @dev is a sysbus device on the machine's list 860fb124dbSPeter Maydell * of dynamically pluggable sysbus devices; otherwise false. 870fb124dbSPeter Maydell * 880fb124dbSPeter Maydell * This function checks whether @dev is a valid dynamic sysbus device, 890fb124dbSPeter Maydell * by first confirming that it is a sysbus device and then checking it 900fb124dbSPeter Maydell * against the list of permitted dynamic sysbus devices which has been 910fb124dbSPeter Maydell * set up by the machine using machine_class_allow_dynamic_sysbus_dev(). 920fb124dbSPeter Maydell * 930fb124dbSPeter Maydell * It is valid to call this with something that is not a subclass of 940fb124dbSPeter Maydell * TYPE_SYS_BUS_DEVICE; the function will return false in this case. 950fb124dbSPeter Maydell * This allows hotplug callback functions to be written as: 960fb124dbSPeter Maydell * if (device_is_dynamic_sysbus(mc, dev)) { 970fb124dbSPeter Maydell * handle dynamic sysbus case; 980fb124dbSPeter Maydell * } else if (some other kind of hotplug) { 990fb124dbSPeter Maydell * handle that; 1000fb124dbSPeter Maydell * } 1010fb124dbSPeter Maydell */ 1020fb124dbSPeter Maydell bool device_is_dynamic_sysbus(MachineClass *mc, DeviceState *dev); 1030fb124dbSPeter Maydell 10482b911aaSIgor Mammedov /* 10582b911aaSIgor Mammedov * Checks that backend isn't used, preps it for exclusive usage and 10682b911aaSIgor Mammedov * returns migratable MemoryRegion provided by backend. 10782b911aaSIgor Mammedov */ 10882b911aaSIgor Mammedov MemoryRegion *machine_consume_memdev(MachineState *machine, 10982b911aaSIgor Mammedov HostMemoryBackend *backend); 1100bd1909dSEduardo Habkost 11136d20cb2SMarcel Apfelbaum /** 1123811ef14SIgor Mammedov * CPUArchId: 1133811ef14SIgor Mammedov * @arch_id - architecture-dependent CPU ID of present or possible CPU 1143811ef14SIgor Mammedov * @cpu - pointer to corresponding CPU object if it's present on NULL otherwise 115d342eb76SIgor Mammedov * @type - QOM class name of possible @cpu object 116c67ae933SIgor Mammedov * @props - CPU object properties, initialized by board 117f2d672c2SIgor Mammedov * #vcpus_count - number of threads provided by @cpu object 1183811ef14SIgor Mammedov */ 119a44432b4SMarkus Armbruster typedef struct CPUArchId { 1203811ef14SIgor Mammedov uint64_t arch_id; 121f2d672c2SIgor Mammedov int64_t vcpus_count; 122c67ae933SIgor Mammedov CpuInstanceProperties props; 123*97e03106SPhilippe Mathieu-Daudé CPUState *cpu; 124d342eb76SIgor Mammedov const char *type; 1253811ef14SIgor Mammedov } CPUArchId; 1263811ef14SIgor Mammedov 1273811ef14SIgor Mammedov /** 1283811ef14SIgor Mammedov * CPUArchIdList: 1293811ef14SIgor Mammedov * @len - number of @CPUArchId items in @cpus array 1303811ef14SIgor Mammedov * @cpus - array of present or possible CPUs for current machine configuration 1313811ef14SIgor Mammedov */ 1323811ef14SIgor Mammedov typedef struct { 1333811ef14SIgor Mammedov int len; 134880a7817SPhilippe Mathieu-Daudé CPUArchId cpus[]; 1353811ef14SIgor Mammedov } CPUArchIdList; 1363811ef14SIgor Mammedov 1373811ef14SIgor Mammedov /** 138e4a97a89SYanan Wang * SMPCompatProps: 1392b526199SYanan Wang * @prefer_sockets - whether sockets are preferred over cores in smp parsing 140e4a97a89SYanan Wang * @dies_supported - whether dies are supported by the machine 141864c3b5cSYanan Wang * @clusters_supported - whether clusters are supported by the machine 14297f4effeSYicong Yang * @has_clusters - whether clusters are explicitly specified in the user 14397f4effeSYicong Yang * provided SMP configuration 1445de1aff2SPierre Morel * @books_supported - whether books are supported by the machine 1455de1aff2SPierre Morel * @drawers_supported - whether drawers are supported by the machine 146e4a97a89SYanan Wang */ 147e4a97a89SYanan Wang typedef struct { 1482b526199SYanan Wang bool prefer_sockets; 149e4a97a89SYanan Wang bool dies_supported; 150864c3b5cSYanan Wang bool clusters_supported; 15197f4effeSYicong Yang bool has_clusters; 1525de1aff2SPierre Morel bool books_supported; 1535de1aff2SPierre Morel bool drawers_supported; 154e4a97a89SYanan Wang } SMPCompatProps; 155e4a97a89SYanan Wang 156e4a97a89SYanan Wang /** 15736d20cb2SMarcel Apfelbaum * MachineClass: 15808fe6824SThomas Huth * @deprecation_reason: If set, the machine is marked as deprecated. The 15908fe6824SThomas Huth * string should provide some clear information about what to use instead. 16072649619SEmilio G. Cota * @max_cpus: maximum number of CPUs supported. Default: 1 16172649619SEmilio G. Cota * @min_cpus: minimum number of CPUs supported. Default: 1 16272649619SEmilio G. Cota * @default_cpus: number of CPUs instantiated if none are specified. Default: 1 163ea0ac7f6SPhilippe Mathieu-Daudé * @is_default: 164ea0ac7f6SPhilippe Mathieu-Daudé * If true QEMU will use this machine by default if no '-M' option is given. 165b7454548SIgor Mammedov * @get_hotplug_handler: this function is called during bus-less 166b7454548SIgor Mammedov * device hotplug. If defined it returns pointer to an instance 167b7454548SIgor Mammedov * of HotplugHandler object, which handles hotplug operation 168b7454548SIgor Mammedov * for a given @dev. It may return NULL if @dev doesn't require 169b7454548SIgor Mammedov * any actions to be performed by hotplug handler. 170ea089eebSIgor Mammedov * @cpu_index_to_instance_props: 171ea089eebSIgor Mammedov * used to provide @cpu_index to socket/core/thread number mapping, allowing 172a1a62cedSMichael Tokarev * legacy code to perform mapping from cpu_index to topology properties 173ea089eebSIgor Mammedov * Returns: tuple of socket/core/thread ids given cpu_index belongs to. 17457924bcdSIgor Mammedov * used to provide @cpu_index to socket number mapping, allowing 17557924bcdSIgor Mammedov * a machine to group CPU threads belonging to the same socket/package 17657924bcdSIgor Mammedov * Returns: socket number given cpu_index belongs to. 177fac862ffSEduardo Habkost * @hw_version: 178fac862ffSEduardo Habkost * Value of QEMU_VERSION when the machine was added to QEMU. 179fac862ffSEduardo Habkost * Set only by old machines because they need to keep 180fac862ffSEduardo Habkost * compatibility on code that exposed QEMU_VERSION to guests in 181fac862ffSEduardo Habkost * the past (and now use qemu_hw_version()). 1823811ef14SIgor Mammedov * @possible_cpu_arch_ids: 1833811ef14SIgor Mammedov * Returns an array of @CPUArchId architecture-dependent CPU IDs 1843811ef14SIgor Mammedov * which includes CPU IDs for present and possible to hotplug CPUs. 1853811ef14SIgor Mammedov * Caller is responsible for freeing returned list. 18679e07936SIgor Mammedov * @get_default_cpu_node_id: 18779e07936SIgor Mammedov * returns default board specific node_id value for CPU slot specified by 18879e07936SIgor Mammedov * index @idx in @ms->possible_cpus[] 189c5514d0eSIgor Mammedov * @has_hotpluggable_cpus: 190c5514d0eSIgor Mammedov * If true, board supports CPUs creation with -device/device_add. 1916063d4c0SIgor Mammedov * @default_cpu_type: 1926063d4c0SIgor Mammedov * specifies default CPU_TYPE, which will be used for parsing target 1936063d4c0SIgor Mammedov * specific features and for creating CPUs if CPU name wasn't provided 1946063d4c0SIgor Mammedov * explicitly at CLI 19520bccb82SPeter Maydell * @minimum_page_bits: 19620bccb82SPeter Maydell * If non-zero, the board promises never to create a CPU with a page size 19720bccb82SPeter Maydell * smaller than this, so QEMU can use a more efficient larger page 19820bccb82SPeter Maydell * size than the target architecture's minimum. (Attempting to create 19920bccb82SPeter Maydell * such a CPU will fail.) Note that changing this is a migration 20020bccb82SPeter Maydell * compatibility break for the machine. 201ed860129SPeter Maydell * @ignore_memory_transaction_failures: 202ed860129SPeter Maydell * If this is flag is true then the CPU will ignore memory transaction 203ed860129SPeter Maydell * failures which should cause the CPU to take an exception due to an 204ed860129SPeter Maydell * access to an unassigned physical address; the transaction will instead 205ed860129SPeter Maydell * return zero (for a read) or be ignored (for a write). This should be 206ed860129SPeter Maydell * set only by legacy board models which rely on the old RAZ/WI behaviour 207ed860129SPeter Maydell * for handling devices that QEMU does not yet model. New board models 208ed860129SPeter Maydell * should instead use "unimplemented-device" for all memory ranges where 209ed860129SPeter Maydell * the guest will attempt to probe for a device that QEMU doesn't 210ed860129SPeter Maydell * implement and a stub device is required. 211dc0ca80eSEric Auger * @kvm_type: 212dc0ca80eSEric Auger * Return the type of KVM corresponding to the kvm-type string option or 213dc0ca80eSEric Auger * computed based on other criteria such as the host kernel capabilities. 214516fc0a0SAndrew Jones * kvm-type may be NULL if it is not needed. 215cd5ff833SIgor Mammedov * @numa_mem_supported: 216cd5ff833SIgor Mammedov * true if '--numa node.mem' option is supported and false otherwise 217d2321d31SPeter Xu * @hotplug_allowed: 218d2321d31SPeter Xu * If the hook is provided, then it'll be called for each device 219d2321d31SPeter Xu * hotplug to check whether the device hotplug is allowed. Return 220d2321d31SPeter Xu * true to grant allowance or false to reject the hotplug. When 221d2321d31SPeter Xu * false is returned, an error must be set to show the reason of 222d2321d31SPeter Xu * the rejection. If the hook is not provided, all hotplug will be 223d2321d31SPeter Xu * allowed. 224900c0ba3SIgor Mammedov * @default_ram_id: 225a1a62cedSMichael Tokarev * Specifies initial RAM MemoryRegion name to be used for default backend 226900c0ba3SIgor Mammedov * creation if user explicitly hasn't specified backend with "memory-backend" 227900c0ba3SIgor Mammedov * property. 228a1a62cedSMichael Tokarev * It also will be used as a way to option into "-m" option support. 229900c0ba3SIgor Mammedov * If it's not set by board, '-m' will be ignored and generic code will 230900c0ba3SIgor Mammedov * not create default RAM MemoryRegion. 2315c30ef93SChristian Borntraeger * @fixup_ram_size: 2325c30ef93SChristian Borntraeger * Amends user provided ram size (with -m option) using machine 2335c30ef93SChristian Borntraeger * specific algorithm. To be used by old machine types for compat 2345c30ef93SChristian Borntraeger * purposes only. 2355c30ef93SChristian Borntraeger * Applies only to default memory backend, i.e., explicit memory backend 2365c30ef93SChristian Borntraeger * wasn't used. 23736d20cb2SMarcel Apfelbaum */ 23836d20cb2SMarcel Apfelbaum struct MachineClass { 23936d20cb2SMarcel Apfelbaum /*< private >*/ 24036d20cb2SMarcel Apfelbaum ObjectClass parent_class; 24136d20cb2SMarcel Apfelbaum /*< public >*/ 24236d20cb2SMarcel Apfelbaum 2432709f263SLaszlo Ersek const char *family; /* NULL iff @name identifies a standalone machtype */ 2448ea75371SMarc-André Lureau char *name; 24500b4fbe2SMarcel Apfelbaum const char *alias; 24600b4fbe2SMarcel Apfelbaum const char *desc; 24708fe6824SThomas Huth const char *deprecation_reason; 24800b4fbe2SMarcel Apfelbaum 2493ef96221SMarcel Apfelbaum void (*init)(MachineState *state); 2507966d70fSJason A. Donenfeld void (*reset)(MachineState *state, ShutdownCause reason); 2514b5e06c9SNicholas Piggin void (*wakeup)(MachineState *state); 252dc0ca80eSEric Auger int (*kvm_type)(MachineState *machine, const char *arg); 25300b4fbe2SMarcel Apfelbaum 25400b4fbe2SMarcel Apfelbaum BlockInterfaceType block_default_type; 25516026518SJohn Snow int units_per_default_bus; 25600b4fbe2SMarcel Apfelbaum int max_cpus; 25772649619SEmilio G. Cota int min_cpus; 25872649619SEmilio G. Cota int default_cpus; 25900b4fbe2SMarcel Apfelbaum unsigned int no_serial:1, 26000b4fbe2SMarcel Apfelbaum no_parallel:1, 26100b4fbe2SMarcel Apfelbaum no_floppy:1, 26200b4fbe2SMarcel Apfelbaum no_cdrom:1, 26333cd52b5SAlexander Graf no_sdcard:1, 264bab47d9aSGerd Hoffmann pci_allow_0_address:1, 265bab47d9aSGerd Hoffmann legacy_fw_cfg_order:1; 266ea0ac7f6SPhilippe Mathieu-Daudé bool is_default; 26700b4fbe2SMarcel Apfelbaum const char *default_machine_opts; 26800b4fbe2SMarcel Apfelbaum const char *default_boot_order; 2696f00494aSGerd Hoffmann const char *default_display; 27001ecdaa4SThomas Huth const char *default_nic; 271b66bbee3SMarc-André Lureau GPtrArray *compat_props; 27200b4fbe2SMarcel Apfelbaum const char *hw_version; 273076b35b5SNikunj A Dadhania ram_addr_t default_ram_size; 2746063d4c0SIgor Mammedov const char *default_cpu_type; 275b2fc91dbSPeter Xu bool default_kernel_irqchip_split; 27671ae9e94SEduardo Habkost bool option_rom_has_mr; 27771ae9e94SEduardo Habkost bool rom_file_has_mr; 27820bccb82SPeter Maydell int minimum_page_bits; 279c5514d0eSIgor Mammedov bool has_hotpluggable_cpus; 280ed860129SPeter Maydell bool ignore_memory_transaction_failures; 28155641213SLaurent Vivier int numa_mem_align_shift; 282790a4428SGavin Shan const char * const *valid_cpu_types; 2830bd1909dSEduardo Habkost strList *allowed_dynamic_sysbus_devices; 2847b8be49dSDou Liyang bool auto_enable_numa_with_memhp; 285195784a0SDavid Hildenbrand bool auto_enable_numa_with_memdev; 286907aac2fSMark Cave-Ayland bool ignore_boot_device_suffixes; 2877fccf2a0SCorey Minyard bool smbus_no_migration_support; 288f6a0d06bSEric Auger bool nvdimm_supported; 289cd5ff833SIgor Mammedov bool numa_mem_supported; 2900533ef5fSTao Xu bool auto_enable_numa; 291a494fdb7SGavin Shan bool cpu_cluster_has_numa_boundary; 292e4a97a89SYanan Wang SMPCompatProps smp_props; 293900c0ba3SIgor Mammedov const char *default_ram_id; 294b7454548SIgor Mammedov 295b7454548SIgor Mammedov HotplugHandler *(*get_hotplug_handler)(MachineState *machine, 296b7454548SIgor Mammedov DeviceState *dev); 297d2321d31SPeter Xu bool (*hotplug_allowed)(MachineState *state, DeviceState *dev, 298d2321d31SPeter Xu Error **errp); 299ea089eebSIgor Mammedov CpuInstanceProperties (*cpu_index_to_instance_props)(MachineState *machine, 300ea089eebSIgor Mammedov unsigned cpu_index); 30180e5db30SIgor Mammedov const CPUArchIdList *(*possible_cpu_arch_ids)(MachineState *machine); 30279e07936SIgor Mammedov int64_t (*get_default_cpu_node_id)(const MachineState *ms, int idx); 3035c30ef93SChristian Borntraeger ram_addr_t (*fixup_ram_size)(ram_addr_t size); 30436d20cb2SMarcel Apfelbaum }; 30536d20cb2SMarcel Apfelbaum 30636d20cb2SMarcel Apfelbaum /** 307e017da37SDavid Hildenbrand * DeviceMemoryState: 308b0c14ec4SDavid Hildenbrand * @base: address in guest physical address space where the memory 309b0c14ec4SDavid Hildenbrand * address space for memory devices starts 310f9716f4bSDavid Hildenbrand * @mr: memory region container for memory devices 311f9716f4bSDavid Hildenbrand * @as: address space for memory devices 312f9716f4bSDavid Hildenbrand * @listener: memory listener used to track used memslots in the address space 313e919402bSYangming * @dimm_size: the sum of plugged DIMMs' sizes 314ac23dd2fSDavid Hildenbrand * @used_region_size: the part of @mr already used by memory devices 315f9716f4bSDavid Hildenbrand * @required_memslots: the number of memslots required by memory devices 316f9716f4bSDavid Hildenbrand * @used_memslots: the number of memslots currently used by memory devices 317a2335113SDavid Hildenbrand * @memslot_auto_decision_active: whether any plugged memory device 318a2335113SDavid Hildenbrand * automatically decided to use more than 319a2335113SDavid Hildenbrand * one memslot 320b0c14ec4SDavid Hildenbrand */ 321e017da37SDavid Hildenbrand typedef struct DeviceMemoryState { 322b0c14ec4SDavid Hildenbrand hwaddr base; 323b0c14ec4SDavid Hildenbrand MemoryRegion mr; 324f9716f4bSDavid Hildenbrand AddressSpace as; 325f9716f4bSDavid Hildenbrand MemoryListener listener; 326e919402bSYangming uint64_t dimm_size; 327ac23dd2fSDavid Hildenbrand uint64_t used_region_size; 328f9716f4bSDavid Hildenbrand unsigned int required_memslots; 329f9716f4bSDavid Hildenbrand unsigned int used_memslots; 330a2335113SDavid Hildenbrand unsigned int memslot_auto_decision_active; 331e017da37SDavid Hildenbrand } DeviceMemoryState; 332b0c14ec4SDavid Hildenbrand 333b0c14ec4SDavid Hildenbrand /** 334edeeec91SLike Xu * CpuTopology: 335edeeec91SLike Xu * @cpus: the number of present logical processors on the machine 3365de1aff2SPierre Morel * @drawers: the number of drawers on the machine 3375de1aff2SPierre Morel * @books: the number of books in one drawer 3385de1aff2SPierre Morel * @sockets: the number of sockets in one book 339003f230eSYanan Wang * @dies: the number of dies in one socket 340864c3b5cSYanan Wang * @clusters: the number of clusters in one die 341864c3b5cSYanan Wang * @cores: the number of cores in one cluster 342003f230eSYanan Wang * @threads: the number of threads in one core 343edeeec91SLike Xu * @max_cpus: the maximum number of logical processors on the machine 344edeeec91SLike Xu */ 345edeeec91SLike Xu typedef struct CpuTopology { 346edeeec91SLike Xu unsigned int cpus; 3475de1aff2SPierre Morel unsigned int drawers; 3485de1aff2SPierre Morel unsigned int books; 349003f230eSYanan Wang unsigned int sockets; 35067872eb8SPaolo Bonzini unsigned int dies; 351864c3b5cSYanan Wang unsigned int clusters; 352edeeec91SLike Xu unsigned int cores; 353edeeec91SLike Xu unsigned int threads; 354edeeec91SLike Xu unsigned int max_cpus; 355edeeec91SLike Xu } CpuTopology; 356edeeec91SLike Xu 357edeeec91SLike Xu /** 35836d20cb2SMarcel Apfelbaum * MachineState: 35936d20cb2SMarcel Apfelbaum */ 36036d20cb2SMarcel Apfelbaum struct MachineState { 36136d20cb2SMarcel Apfelbaum /*< private >*/ 36236d20cb2SMarcel Apfelbaum Object parent_obj; 36333cd52b5SAlexander Graf 36436d20cb2SMarcel Apfelbaum /*< public >*/ 36536d20cb2SMarcel Apfelbaum 366a6487d37SAlex Bennée void *fdt; 36736d20cb2SMarcel Apfelbaum char *dtb; 36836d20cb2SMarcel Apfelbaum char *dumpdtb; 36936d20cb2SMarcel Apfelbaum int phandle_start; 37036d20cb2SMarcel Apfelbaum char *dt_compatible; 37136d20cb2SMarcel Apfelbaum bool dump_guest_core; 37236d20cb2SMarcel Apfelbaum bool mem_merge; 37336d20cb2SMarcel Apfelbaum bool usb; 374c6e76503SPaolo Bonzini bool usb_disabled; 37536d20cb2SMarcel Apfelbaum char *firmware; 376a52a7fdfSLe Tan bool iommu; 3779850c604SAlexander Graf bool suppress_vmdesc; 378cfc58cf3SEduardo Habkost bool enable_graphics; 379e0292d7cSDavid Gibson ConfidentialGuestSupport *cgs; 38026f88d84SPaolo Bonzini HostMemoryBackend *memdev; 38182b911aaSIgor Mammedov /* 38282b911aaSIgor Mammedov * convenience alias to ram_memdev_id backend memory region 38382b911aaSIgor Mammedov * or to numa container memory region 38482b911aaSIgor Mammedov */ 38582b911aaSIgor Mammedov MemoryRegion *ram; 386e017da37SDavid Hildenbrand DeviceMemoryState *device_memory; 38736d20cb2SMarcel Apfelbaum 3887a2c7da6SMartin Kletzander /* 3897a2c7da6SMartin Kletzander * Included in MachineState for simplicity, but not supported 3907a2c7da6SMartin Kletzander * unless machine_add_audiodev_property is called. Boards 3917a2c7da6SMartin Kletzander * that have embedded audio devices can call it from the 3927a2c7da6SMartin Kletzander * machine init function and forward the property to the device. 3937a2c7da6SMartin Kletzander */ 3947a2c7da6SMartin Kletzander char *audiodev; 3957a2c7da6SMartin Kletzander 3963ef96221SMarcel Apfelbaum ram_addr_t ram_size; 397c270fb9eSIgor Mammedov ram_addr_t maxram_size; 398c270fb9eSIgor Mammedov uint64_t ram_slots; 39997ec4d21SPaolo Bonzini BootConfiguration boot_config; 4006b1b1440SMarcel Apfelbaum char *kernel_filename; 4016b1b1440SMarcel Apfelbaum char *kernel_cmdline; 4026b1b1440SMarcel Apfelbaum char *initrd_filename; 4036063d4c0SIgor Mammedov const char *cpu_type; 404ac2da55eSEduardo Habkost AccelState *accelerator; 40538690a1cSIgor Mammedov CPUArchIdList *possible_cpus; 406edeeec91SLike Xu CpuTopology smp; 407f6a0d06bSEric Auger struct NVDIMMState *nvdimms_state; 408aa570207STao Xu struct NumaState *numa_state; 40936d20cb2SMarcel Apfelbaum }; 41036d20cb2SMarcel Apfelbaum 411ed0b6de3SEduardo Habkost #define DEFINE_MACHINE(namestr, machine_initfn) \ 412ed0b6de3SEduardo Habkost static void machine_initfn##_class_init(ObjectClass *oc, void *data) \ 413ed0b6de3SEduardo Habkost { \ 414ed0b6de3SEduardo Habkost MachineClass *mc = MACHINE_CLASS(oc); \ 415ed0b6de3SEduardo Habkost machine_initfn(mc); \ 416ed0b6de3SEduardo Habkost } \ 417ed0b6de3SEduardo Habkost static const TypeInfo machine_initfn##_typeinfo = { \ 418ed0b6de3SEduardo Habkost .name = MACHINE_TYPE_NAME(namestr), \ 419ed0b6de3SEduardo Habkost .parent = TYPE_MACHINE, \ 420ed0b6de3SEduardo Habkost .class_init = machine_initfn##_class_init, \ 421ed0b6de3SEduardo Habkost }; \ 422ed0b6de3SEduardo Habkost static void machine_initfn##_register_types(void) \ 423ed0b6de3SEduardo Habkost { \ 424ed0b6de3SEduardo Habkost type_register_static(&machine_initfn##_typeinfo); \ 425ed0b6de3SEduardo Habkost } \ 4260e6aac87SEduardo Habkost type_init(machine_initfn##_register_types) 427ed0b6de3SEduardo Habkost 4282b10a676SCornelia Huck extern GlobalProperty hw_compat_8_2[]; 4292b10a676SCornelia Huck extern const size_t hw_compat_8_2_len; 4302b10a676SCornelia Huck 43195f5c89eSCornelia Huck extern GlobalProperty hw_compat_8_1[]; 43295f5c89eSCornelia Huck extern const size_t hw_compat_8_1_len; 43395f5c89eSCornelia Huck 4340259dd3eSCornelia Huck extern GlobalProperty hw_compat_8_0[]; 4350259dd3eSCornelia Huck extern const size_t hw_compat_8_0_len; 4360259dd3eSCornelia Huck 437db723c80SCornelia Huck extern GlobalProperty hw_compat_7_2[]; 438db723c80SCornelia Huck extern const size_t hw_compat_7_2_len; 439db723c80SCornelia Huck 440f514e147SCornelia Huck extern GlobalProperty hw_compat_7_1[]; 441f514e147SCornelia Huck extern const size_t hw_compat_7_1_len; 442f514e147SCornelia Huck 4430ca70366SCornelia Huck extern GlobalProperty hw_compat_7_0[]; 4440ca70366SCornelia Huck extern const size_t hw_compat_7_0_len; 4450ca70366SCornelia Huck 44601854af2SCornelia Huck extern GlobalProperty hw_compat_6_2[]; 44701854af2SCornelia Huck extern const size_t hw_compat_6_2_len; 44801854af2SCornelia Huck 44952e64f5bSYanan Wang extern GlobalProperty hw_compat_6_1[]; 45052e64f5bSYanan Wang extern const size_t hw_compat_6_1_len; 45152e64f5bSYanan Wang 452da7e13c0SCornelia Huck extern GlobalProperty hw_compat_6_0[]; 453da7e13c0SCornelia Huck extern const size_t hw_compat_6_0_len; 454da7e13c0SCornelia Huck 455576a00bdSCornelia Huck extern GlobalProperty hw_compat_5_2[]; 456576a00bdSCornelia Huck extern const size_t hw_compat_5_2_len; 457576a00bdSCornelia Huck 4583ff3c5d3SCornelia Huck extern GlobalProperty hw_compat_5_1[]; 4593ff3c5d3SCornelia Huck extern const size_t hw_compat_5_1_len; 4603ff3c5d3SCornelia Huck 461541aaa1dSCornelia Huck extern GlobalProperty hw_compat_5_0[]; 462541aaa1dSCornelia Huck extern const size_t hw_compat_5_0_len; 463541aaa1dSCornelia Huck 4645f258577SEvgeny Yakovlev extern GlobalProperty hw_compat_4_2[]; 4655f258577SEvgeny Yakovlev extern const size_t hw_compat_4_2_len; 4665f258577SEvgeny Yakovlev 4679aec2e52SCornelia Huck extern GlobalProperty hw_compat_4_1[]; 4689aec2e52SCornelia Huck extern const size_t hw_compat_4_1_len; 4699aec2e52SCornelia Huck 4709bf2650bSCornelia Huck extern GlobalProperty hw_compat_4_0[]; 4719bf2650bSCornelia Huck extern const size_t hw_compat_4_0_len; 4729bf2650bSCornelia Huck 473abd93cc7SMarc-André Lureau extern GlobalProperty hw_compat_3_1[]; 474abd93cc7SMarc-André Lureau extern const size_t hw_compat_3_1_len; 475abd93cc7SMarc-André Lureau 476ddb3235dSMarc-André Lureau extern GlobalProperty hw_compat_3_0[]; 477ddb3235dSMarc-André Lureau extern const size_t hw_compat_3_0_len; 478ddb3235dSMarc-André Lureau 4790d47310bSMarc-André Lureau extern GlobalProperty hw_compat_2_12[]; 4800d47310bSMarc-André Lureau extern const size_t hw_compat_2_12_len; 4810d47310bSMarc-André Lureau 48243df70a9SMarc-André Lureau extern GlobalProperty hw_compat_2_11[]; 48343df70a9SMarc-André Lureau extern const size_t hw_compat_2_11_len; 48443df70a9SMarc-André Lureau 485503224f4SMarc-André Lureau extern GlobalProperty hw_compat_2_10[]; 486503224f4SMarc-André Lureau extern const size_t hw_compat_2_10_len; 487503224f4SMarc-André Lureau 4883e803152SMarc-André Lureau extern GlobalProperty hw_compat_2_9[]; 4893e803152SMarc-André Lureau extern const size_t hw_compat_2_9_len; 4903e803152SMarc-André Lureau 491edc24ccdSMarc-André Lureau extern GlobalProperty hw_compat_2_8[]; 492edc24ccdSMarc-André Lureau extern const size_t hw_compat_2_8_len; 493edc24ccdSMarc-André Lureau 4945a995064SMarc-André Lureau extern GlobalProperty hw_compat_2_7[]; 4955a995064SMarc-André Lureau extern const size_t hw_compat_2_7_len; 4965a995064SMarc-André Lureau 497ff8f261fSMarc-André Lureau extern GlobalProperty hw_compat_2_6[]; 498ff8f261fSMarc-André Lureau extern const size_t hw_compat_2_6_len; 499ff8f261fSMarc-André Lureau 500fe759610SMarc-André Lureau extern GlobalProperty hw_compat_2_5[]; 501fe759610SMarc-André Lureau extern const size_t hw_compat_2_5_len; 502fe759610SMarc-André Lureau 5032f99b9c2SMarc-André Lureau extern GlobalProperty hw_compat_2_4[]; 5042f99b9c2SMarc-André Lureau extern const size_t hw_compat_2_4_len; 5052f99b9c2SMarc-André Lureau 5068995dd90SMarc-André Lureau extern GlobalProperty hw_compat_2_3[]; 5078995dd90SMarc-André Lureau extern const size_t hw_compat_2_3_len; 5088995dd90SMarc-André Lureau 5091c30044eSMarc-André Lureau extern GlobalProperty hw_compat_2_2[]; 5101c30044eSMarc-André Lureau extern const size_t hw_compat_2_2_len; 5111c30044eSMarc-André Lureau 512c4fc5695SMarc-André Lureau extern GlobalProperty hw_compat_2_1[]; 513c4fc5695SMarc-André Lureau extern const size_t hw_compat_2_1_len; 514c4fc5695SMarc-André Lureau 5150d09e41aSPaolo Bonzini #endif 516