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); 3937662d85SXiaoyao Li bool machine_require_guest_memfd(MachineState *machine); 40f2d672c2SIgor Mammedov HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine); 417c88e65dSIgor Mammedov void machine_set_cpu_numa_node(MachineState *machine, 427c88e65dSIgor Mammedov const CpuInstanceProperties *props, 437c88e65dSIgor Mammedov Error **errp); 443e2f1498SPhilippe Mathieu-Daudé void machine_parse_smp_config(MachineState *ms, 453e2f1498SPhilippe Mathieu-Daudé const SMPConfiguration *config, Error **errp); 46a1d027beSZhao Liu unsigned int machine_topo_get_cores_per_socket(const MachineState *ms); 47a1d027beSZhao Liu unsigned int machine_topo_get_threads_per_socket(const MachineState *ms); 48cc0afd8aSDavid Hildenbrand void machine_memory_devices_init(MachineState *ms, hwaddr base, uint64_t size); 495e97b623SMarcel Apfelbaum 50387c0e8bSPeter Maydell /** 51387c0e8bSPeter Maydell * machine_class_allow_dynamic_sysbus_dev: Add type to list of valid devices 52387c0e8bSPeter Maydell * @mc: Machine class 53387c0e8bSPeter Maydell * @type: type to allow (should be a subtype of TYPE_SYS_BUS_DEVICE) 54387c0e8bSPeter Maydell * 55387c0e8bSPeter Maydell * Add the QOM type @type to the list of devices of which are subtypes 56387c0e8bSPeter Maydell * of TYPE_SYS_BUS_DEVICE but which are still permitted to be dynamically 57387c0e8bSPeter Maydell * created (eg by the user on the command line with -device). 58387c0e8bSPeter Maydell * By default if the user tries to create any devices on the command line 59387c0e8bSPeter Maydell * that are subtypes of TYPE_SYS_BUS_DEVICE they will get an error message; 60387c0e8bSPeter Maydell * for the special cases which are permitted for this machine model, the 61387c0e8bSPeter Maydell * machine model class init code must call this function to add them 62387c0e8bSPeter Maydell * to the list of specifically permitted devices. 63387c0e8bSPeter Maydell */ 640bd1909dSEduardo Habkost void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *type); 65387c0e8bSPeter Maydell 660fb124dbSPeter Maydell /** 67b5fdf410SDamien Hedde * device_type_is_dynamic_sysbus: Check if type is an allowed sysbus device 68b5fdf410SDamien Hedde * type for the machine class. 69b5fdf410SDamien Hedde * @mc: Machine class 70b5fdf410SDamien Hedde * @type: type to check (should be a subtype of TYPE_SYS_BUS_DEVICE) 71b5fdf410SDamien Hedde * 72b5fdf410SDamien Hedde * Returns: true if @type is a type in the machine's list of 73b5fdf410SDamien Hedde * dynamically pluggable sysbus devices; otherwise false. 74b5fdf410SDamien Hedde * 75b5fdf410SDamien Hedde * Check if the QOM type @type is in the list of allowed sysbus device 76b5fdf410SDamien Hedde * types (see machine_class_allowed_dynamic_sysbus_dev()). 77b5fdf410SDamien Hedde * Note that if @type has a parent type in the list, it is allowed too. 78b5fdf410SDamien Hedde */ 79b5fdf410SDamien Hedde bool device_type_is_dynamic_sysbus(MachineClass *mc, const char *type); 80b5fdf410SDamien Hedde 81b5fdf410SDamien Hedde /** 820fb124dbSPeter Maydell * device_is_dynamic_sysbus: test whether device is a dynamic sysbus device 830fb124dbSPeter Maydell * @mc: Machine class 840fb124dbSPeter Maydell * @dev: device to check 850fb124dbSPeter Maydell * 860fb124dbSPeter Maydell * Returns: true if @dev is a sysbus device on the machine's list 870fb124dbSPeter Maydell * of dynamically pluggable sysbus devices; otherwise false. 880fb124dbSPeter Maydell * 890fb124dbSPeter Maydell * This function checks whether @dev is a valid dynamic sysbus device, 900fb124dbSPeter Maydell * by first confirming that it is a sysbus device and then checking it 910fb124dbSPeter Maydell * against the list of permitted dynamic sysbus devices which has been 920fb124dbSPeter Maydell * set up by the machine using machine_class_allow_dynamic_sysbus_dev(). 930fb124dbSPeter Maydell * 940fb124dbSPeter Maydell * It is valid to call this with something that is not a subclass of 950fb124dbSPeter Maydell * TYPE_SYS_BUS_DEVICE; the function will return false in this case. 960fb124dbSPeter Maydell * This allows hotplug callback functions to be written as: 970fb124dbSPeter Maydell * if (device_is_dynamic_sysbus(mc, dev)) { 980fb124dbSPeter Maydell * handle dynamic sysbus case; 990fb124dbSPeter Maydell * } else if (some other kind of hotplug) { 1000fb124dbSPeter Maydell * handle that; 1010fb124dbSPeter Maydell * } 1020fb124dbSPeter Maydell */ 1030fb124dbSPeter Maydell bool device_is_dynamic_sysbus(MachineClass *mc, DeviceState *dev); 1040fb124dbSPeter Maydell 10582b911aaSIgor Mammedov /* 10682b911aaSIgor Mammedov * Checks that backend isn't used, preps it for exclusive usage and 10782b911aaSIgor Mammedov * returns migratable MemoryRegion provided by backend. 10882b911aaSIgor Mammedov */ 10982b911aaSIgor Mammedov MemoryRegion *machine_consume_memdev(MachineState *machine, 11082b911aaSIgor Mammedov HostMemoryBackend *backend); 1110bd1909dSEduardo Habkost 11236d20cb2SMarcel Apfelbaum /** 1133811ef14SIgor Mammedov * CPUArchId: 1143811ef14SIgor Mammedov * @arch_id - architecture-dependent CPU ID of present or possible CPU 1153811ef14SIgor Mammedov * @cpu - pointer to corresponding CPU object if it's present on NULL otherwise 116d342eb76SIgor Mammedov * @type - QOM class name of possible @cpu object 117c67ae933SIgor Mammedov * @props - CPU object properties, initialized by board 118f2d672c2SIgor Mammedov * #vcpus_count - number of threads provided by @cpu object 1193811ef14SIgor Mammedov */ 120a44432b4SMarkus Armbruster typedef struct CPUArchId { 1213811ef14SIgor Mammedov uint64_t arch_id; 122f2d672c2SIgor Mammedov int64_t vcpus_count; 123c67ae933SIgor Mammedov CpuInstanceProperties props; 12497e03106SPhilippe Mathieu-Daudé CPUState *cpu; 125d342eb76SIgor Mammedov const char *type; 1263811ef14SIgor Mammedov } CPUArchId; 1273811ef14SIgor Mammedov 1283811ef14SIgor Mammedov /** 1293811ef14SIgor Mammedov * CPUArchIdList: 1303811ef14SIgor Mammedov * @len - number of @CPUArchId items in @cpus array 1313811ef14SIgor Mammedov * @cpus - array of present or possible CPUs for current machine configuration 1323811ef14SIgor Mammedov */ 1333811ef14SIgor Mammedov typedef struct { 1343811ef14SIgor Mammedov int len; 135880a7817SPhilippe Mathieu-Daudé CPUArchId cpus[]; 1363811ef14SIgor Mammedov } CPUArchIdList; 1373811ef14SIgor Mammedov 1383811ef14SIgor Mammedov /** 139e4a97a89SYanan Wang * SMPCompatProps: 1402b526199SYanan Wang * @prefer_sockets - whether sockets are preferred over cores in smp parsing 141e4a97a89SYanan Wang * @dies_supported - whether dies are supported by the machine 142864c3b5cSYanan Wang * @clusters_supported - whether clusters are supported by the machine 14397f4effeSYicong Yang * @has_clusters - whether clusters are explicitly specified in the user 14497f4effeSYicong Yang * provided SMP configuration 1455de1aff2SPierre Morel * @books_supported - whether books are supported by the machine 1465de1aff2SPierre Morel * @drawers_supported - whether drawers are supported by the machine 147*dcba73b4SZhao Liu * @modules_supported - whether modules are supported by the machine 148e4a97a89SYanan Wang */ 149e4a97a89SYanan Wang typedef struct { 1502b526199SYanan Wang bool prefer_sockets; 151e4a97a89SYanan Wang bool dies_supported; 152864c3b5cSYanan Wang bool clusters_supported; 15397f4effeSYicong Yang bool has_clusters; 1545de1aff2SPierre Morel bool books_supported; 1555de1aff2SPierre Morel bool drawers_supported; 156*dcba73b4SZhao Liu bool modules_supported; 157e4a97a89SYanan Wang } SMPCompatProps; 158e4a97a89SYanan Wang 159e4a97a89SYanan Wang /** 16036d20cb2SMarcel Apfelbaum * MachineClass: 16108fe6824SThomas Huth * @deprecation_reason: If set, the machine is marked as deprecated. The 16208fe6824SThomas Huth * string should provide some clear information about what to use instead. 16372649619SEmilio G. Cota * @max_cpus: maximum number of CPUs supported. Default: 1 16472649619SEmilio G. Cota * @min_cpus: minimum number of CPUs supported. Default: 1 16572649619SEmilio G. Cota * @default_cpus: number of CPUs instantiated if none are specified. Default: 1 166ea0ac7f6SPhilippe Mathieu-Daudé * @is_default: 167ea0ac7f6SPhilippe Mathieu-Daudé * If true QEMU will use this machine by default if no '-M' option is given. 168b7454548SIgor Mammedov * @get_hotplug_handler: this function is called during bus-less 169b7454548SIgor Mammedov * device hotplug. If defined it returns pointer to an instance 170b7454548SIgor Mammedov * of HotplugHandler object, which handles hotplug operation 171b7454548SIgor Mammedov * for a given @dev. It may return NULL if @dev doesn't require 172b7454548SIgor Mammedov * any actions to be performed by hotplug handler. 173ea089eebSIgor Mammedov * @cpu_index_to_instance_props: 174ea089eebSIgor Mammedov * used to provide @cpu_index to socket/core/thread number mapping, allowing 175a1a62cedSMichael Tokarev * legacy code to perform mapping from cpu_index to topology properties 176ea089eebSIgor Mammedov * Returns: tuple of socket/core/thread ids given cpu_index belongs to. 17757924bcdSIgor Mammedov * used to provide @cpu_index to socket number mapping, allowing 17857924bcdSIgor Mammedov * a machine to group CPU threads belonging to the same socket/package 17957924bcdSIgor Mammedov * Returns: socket number given cpu_index belongs to. 180fac862ffSEduardo Habkost * @hw_version: 181fac862ffSEduardo Habkost * Value of QEMU_VERSION when the machine was added to QEMU. 182fac862ffSEduardo Habkost * Set only by old machines because they need to keep 183fac862ffSEduardo Habkost * compatibility on code that exposed QEMU_VERSION to guests in 184fac862ffSEduardo Habkost * the past (and now use qemu_hw_version()). 1853811ef14SIgor Mammedov * @possible_cpu_arch_ids: 1863811ef14SIgor Mammedov * Returns an array of @CPUArchId architecture-dependent CPU IDs 1873811ef14SIgor Mammedov * which includes CPU IDs for present and possible to hotplug CPUs. 1883811ef14SIgor Mammedov * Caller is responsible for freeing returned list. 18979e07936SIgor Mammedov * @get_default_cpu_node_id: 19079e07936SIgor Mammedov * returns default board specific node_id value for CPU slot specified by 19179e07936SIgor Mammedov * index @idx in @ms->possible_cpus[] 192c5514d0eSIgor Mammedov * @has_hotpluggable_cpus: 193c5514d0eSIgor Mammedov * If true, board supports CPUs creation with -device/device_add. 1946063d4c0SIgor Mammedov * @default_cpu_type: 1956063d4c0SIgor Mammedov * specifies default CPU_TYPE, which will be used for parsing target 1966063d4c0SIgor Mammedov * specific features and for creating CPUs if CPU name wasn't provided 1976063d4c0SIgor Mammedov * explicitly at CLI 19820bccb82SPeter Maydell * @minimum_page_bits: 19920bccb82SPeter Maydell * If non-zero, the board promises never to create a CPU with a page size 20020bccb82SPeter Maydell * smaller than this, so QEMU can use a more efficient larger page 20120bccb82SPeter Maydell * size than the target architecture's minimum. (Attempting to create 20220bccb82SPeter Maydell * such a CPU will fail.) Note that changing this is a migration 20320bccb82SPeter Maydell * compatibility break for the machine. 204ed860129SPeter Maydell * @ignore_memory_transaction_failures: 205ed860129SPeter Maydell * If this is flag is true then the CPU will ignore memory transaction 206ed860129SPeter Maydell * failures which should cause the CPU to take an exception due to an 207ed860129SPeter Maydell * access to an unassigned physical address; the transaction will instead 208ed860129SPeter Maydell * return zero (for a read) or be ignored (for a write). This should be 209ed860129SPeter Maydell * set only by legacy board models which rely on the old RAZ/WI behaviour 210ed860129SPeter Maydell * for handling devices that QEMU does not yet model. New board models 211ed860129SPeter Maydell * should instead use "unimplemented-device" for all memory ranges where 212ed860129SPeter Maydell * the guest will attempt to probe for a device that QEMU doesn't 213ed860129SPeter Maydell * implement and a stub device is required. 214dc0ca80eSEric Auger * @kvm_type: 215dc0ca80eSEric Auger * Return the type of KVM corresponding to the kvm-type string option or 216dc0ca80eSEric Auger * computed based on other criteria such as the host kernel capabilities. 217516fc0a0SAndrew Jones * kvm-type may be NULL if it is not needed. 218cd5ff833SIgor Mammedov * @numa_mem_supported: 219cd5ff833SIgor Mammedov * true if '--numa node.mem' option is supported and false otherwise 220d2321d31SPeter Xu * @hotplug_allowed: 221d2321d31SPeter Xu * If the hook is provided, then it'll be called for each device 222d2321d31SPeter Xu * hotplug to check whether the device hotplug is allowed. Return 223d2321d31SPeter Xu * true to grant allowance or false to reject the hotplug. When 224d2321d31SPeter Xu * false is returned, an error must be set to show the reason of 225d2321d31SPeter Xu * the rejection. If the hook is not provided, all hotplug will be 226d2321d31SPeter Xu * allowed. 227900c0ba3SIgor Mammedov * @default_ram_id: 228a1a62cedSMichael Tokarev * Specifies initial RAM MemoryRegion name to be used for default backend 229900c0ba3SIgor Mammedov * creation if user explicitly hasn't specified backend with "memory-backend" 230900c0ba3SIgor Mammedov * property. 231a1a62cedSMichael Tokarev * It also will be used as a way to option into "-m" option support. 232900c0ba3SIgor Mammedov * If it's not set by board, '-m' will be ignored and generic code will 233900c0ba3SIgor Mammedov * not create default RAM MemoryRegion. 2345c30ef93SChristian Borntraeger * @fixup_ram_size: 2355c30ef93SChristian Borntraeger * Amends user provided ram size (with -m option) using machine 2365c30ef93SChristian Borntraeger * specific algorithm. To be used by old machine types for compat 2375c30ef93SChristian Borntraeger * purposes only. 2385c30ef93SChristian Borntraeger * Applies only to default memory backend, i.e., explicit memory backend 2395c30ef93SChristian Borntraeger * wasn't used. 24036d20cb2SMarcel Apfelbaum */ 24136d20cb2SMarcel Apfelbaum struct MachineClass { 24236d20cb2SMarcel Apfelbaum /*< private >*/ 24336d20cb2SMarcel Apfelbaum ObjectClass parent_class; 24436d20cb2SMarcel Apfelbaum /*< public >*/ 24536d20cb2SMarcel Apfelbaum 2462709f263SLaszlo Ersek const char *family; /* NULL iff @name identifies a standalone machtype */ 2478ea75371SMarc-André Lureau char *name; 24800b4fbe2SMarcel Apfelbaum const char *alias; 24900b4fbe2SMarcel Apfelbaum const char *desc; 25008fe6824SThomas Huth const char *deprecation_reason; 25100b4fbe2SMarcel Apfelbaum 2523ef96221SMarcel Apfelbaum void (*init)(MachineState *state); 2537966d70fSJason A. Donenfeld void (*reset)(MachineState *state, ShutdownCause reason); 2544b5e06c9SNicholas Piggin void (*wakeup)(MachineState *state); 255dc0ca80eSEric Auger int (*kvm_type)(MachineState *machine, const char *arg); 25600b4fbe2SMarcel Apfelbaum 25700b4fbe2SMarcel Apfelbaum BlockInterfaceType block_default_type; 25816026518SJohn Snow int units_per_default_bus; 25900b4fbe2SMarcel Apfelbaum int max_cpus; 26072649619SEmilio G. Cota int min_cpus; 26172649619SEmilio G. Cota int default_cpus; 26200b4fbe2SMarcel Apfelbaum unsigned int no_serial:1, 26300b4fbe2SMarcel Apfelbaum no_parallel:1, 26400b4fbe2SMarcel Apfelbaum no_floppy:1, 26500b4fbe2SMarcel Apfelbaum no_cdrom:1, 26633cd52b5SAlexander Graf no_sdcard:1, 267bab47d9aSGerd Hoffmann pci_allow_0_address:1, 268bab47d9aSGerd Hoffmann legacy_fw_cfg_order:1; 269ea0ac7f6SPhilippe Mathieu-Daudé bool is_default; 27000b4fbe2SMarcel Apfelbaum const char *default_machine_opts; 27100b4fbe2SMarcel Apfelbaum const char *default_boot_order; 2726f00494aSGerd Hoffmann const char *default_display; 27301ecdaa4SThomas Huth const char *default_nic; 274b66bbee3SMarc-André Lureau GPtrArray *compat_props; 27500b4fbe2SMarcel Apfelbaum const char *hw_version; 276076b35b5SNikunj A Dadhania ram_addr_t default_ram_size; 2776063d4c0SIgor Mammedov const char *default_cpu_type; 278b2fc91dbSPeter Xu bool default_kernel_irqchip_split; 27971ae9e94SEduardo Habkost bool option_rom_has_mr; 28071ae9e94SEduardo Habkost bool rom_file_has_mr; 28120bccb82SPeter Maydell int minimum_page_bits; 282c5514d0eSIgor Mammedov bool has_hotpluggable_cpus; 283ed860129SPeter Maydell bool ignore_memory_transaction_failures; 28455641213SLaurent Vivier int numa_mem_align_shift; 285790a4428SGavin Shan const char * const *valid_cpu_types; 2860bd1909dSEduardo Habkost strList *allowed_dynamic_sysbus_devices; 2877b8be49dSDou Liyang bool auto_enable_numa_with_memhp; 288195784a0SDavid Hildenbrand bool auto_enable_numa_with_memdev; 289907aac2fSMark Cave-Ayland bool ignore_boot_device_suffixes; 2907fccf2a0SCorey Minyard bool smbus_no_migration_support; 291f6a0d06bSEric Auger bool nvdimm_supported; 292cd5ff833SIgor Mammedov bool numa_mem_supported; 2930533ef5fSTao Xu bool auto_enable_numa; 294a494fdb7SGavin Shan bool cpu_cluster_has_numa_boundary; 295e4a97a89SYanan Wang SMPCompatProps smp_props; 296900c0ba3SIgor Mammedov const char *default_ram_id; 297b7454548SIgor Mammedov 298b7454548SIgor Mammedov HotplugHandler *(*get_hotplug_handler)(MachineState *machine, 299b7454548SIgor Mammedov DeviceState *dev); 300d2321d31SPeter Xu bool (*hotplug_allowed)(MachineState *state, DeviceState *dev, 301d2321d31SPeter Xu Error **errp); 302ea089eebSIgor Mammedov CpuInstanceProperties (*cpu_index_to_instance_props)(MachineState *machine, 303ea089eebSIgor Mammedov unsigned cpu_index); 30480e5db30SIgor Mammedov const CPUArchIdList *(*possible_cpu_arch_ids)(MachineState *machine); 30579e07936SIgor Mammedov int64_t (*get_default_cpu_node_id)(const MachineState *ms, int idx); 3065c30ef93SChristian Borntraeger ram_addr_t (*fixup_ram_size)(ram_addr_t size); 30736d20cb2SMarcel Apfelbaum }; 30836d20cb2SMarcel Apfelbaum 30936d20cb2SMarcel Apfelbaum /** 310e017da37SDavid Hildenbrand * DeviceMemoryState: 311b0c14ec4SDavid Hildenbrand * @base: address in guest physical address space where the memory 312b0c14ec4SDavid Hildenbrand * address space for memory devices starts 313f9716f4bSDavid Hildenbrand * @mr: memory region container for memory devices 314f9716f4bSDavid Hildenbrand * @as: address space for memory devices 315f9716f4bSDavid Hildenbrand * @listener: memory listener used to track used memslots in the address space 316e919402bSYangming * @dimm_size: the sum of plugged DIMMs' sizes 317ac23dd2fSDavid Hildenbrand * @used_region_size: the part of @mr already used by memory devices 318f9716f4bSDavid Hildenbrand * @required_memslots: the number of memslots required by memory devices 319f9716f4bSDavid Hildenbrand * @used_memslots: the number of memslots currently used by memory devices 320a2335113SDavid Hildenbrand * @memslot_auto_decision_active: whether any plugged memory device 321a2335113SDavid Hildenbrand * automatically decided to use more than 322a2335113SDavid Hildenbrand * one memslot 323b0c14ec4SDavid Hildenbrand */ 324e017da37SDavid Hildenbrand typedef struct DeviceMemoryState { 325b0c14ec4SDavid Hildenbrand hwaddr base; 326b0c14ec4SDavid Hildenbrand MemoryRegion mr; 327f9716f4bSDavid Hildenbrand AddressSpace as; 328f9716f4bSDavid Hildenbrand MemoryListener listener; 329e919402bSYangming uint64_t dimm_size; 330ac23dd2fSDavid Hildenbrand uint64_t used_region_size; 331f9716f4bSDavid Hildenbrand unsigned int required_memslots; 332f9716f4bSDavid Hildenbrand unsigned int used_memslots; 333a2335113SDavid Hildenbrand unsigned int memslot_auto_decision_active; 334e017da37SDavid Hildenbrand } DeviceMemoryState; 335b0c14ec4SDavid Hildenbrand 336b0c14ec4SDavid Hildenbrand /** 337edeeec91SLike Xu * CpuTopology: 338edeeec91SLike Xu * @cpus: the number of present logical processors on the machine 3395de1aff2SPierre Morel * @drawers: the number of drawers on the machine 3405de1aff2SPierre Morel * @books: the number of books in one drawer 3415de1aff2SPierre Morel * @sockets: the number of sockets in one book 342003f230eSYanan Wang * @dies: the number of dies in one socket 343864c3b5cSYanan Wang * @clusters: the number of clusters in one die 344*dcba73b4SZhao Liu * @modules: the number of modules in one cluster 345864c3b5cSYanan Wang * @cores: the number of cores in one cluster 346003f230eSYanan Wang * @threads: the number of threads in one core 347edeeec91SLike Xu * @max_cpus: the maximum number of logical processors on the machine 348edeeec91SLike Xu */ 349edeeec91SLike Xu typedef struct CpuTopology { 350edeeec91SLike Xu unsigned int cpus; 3515de1aff2SPierre Morel unsigned int drawers; 3525de1aff2SPierre Morel unsigned int books; 353003f230eSYanan Wang unsigned int sockets; 35467872eb8SPaolo Bonzini unsigned int dies; 355864c3b5cSYanan Wang unsigned int clusters; 356*dcba73b4SZhao Liu unsigned int modules; 357edeeec91SLike Xu unsigned int cores; 358edeeec91SLike Xu unsigned int threads; 359edeeec91SLike Xu unsigned int max_cpus; 360edeeec91SLike Xu } CpuTopology; 361edeeec91SLike Xu 362edeeec91SLike Xu /** 36336d20cb2SMarcel Apfelbaum * MachineState: 36436d20cb2SMarcel Apfelbaum */ 36536d20cb2SMarcel Apfelbaum struct MachineState { 36636d20cb2SMarcel Apfelbaum /*< private >*/ 36736d20cb2SMarcel Apfelbaum Object parent_obj; 36833cd52b5SAlexander Graf 36936d20cb2SMarcel Apfelbaum /*< public >*/ 37036d20cb2SMarcel Apfelbaum 371a6487d37SAlex Bennée void *fdt; 37236d20cb2SMarcel Apfelbaum char *dtb; 37336d20cb2SMarcel Apfelbaum char *dumpdtb; 37436d20cb2SMarcel Apfelbaum int phandle_start; 37536d20cb2SMarcel Apfelbaum char *dt_compatible; 37636d20cb2SMarcel Apfelbaum bool dump_guest_core; 37736d20cb2SMarcel Apfelbaum bool mem_merge; 37837662d85SXiaoyao Li bool require_guest_memfd; 37936d20cb2SMarcel Apfelbaum bool usb; 380c6e76503SPaolo Bonzini bool usb_disabled; 38136d20cb2SMarcel Apfelbaum char *firmware; 382a52a7fdfSLe Tan bool iommu; 3839850c604SAlexander Graf bool suppress_vmdesc; 384cfc58cf3SEduardo Habkost bool enable_graphics; 385e0292d7cSDavid Gibson ConfidentialGuestSupport *cgs; 38626f88d84SPaolo Bonzini HostMemoryBackend *memdev; 38782b911aaSIgor Mammedov /* 38882b911aaSIgor Mammedov * convenience alias to ram_memdev_id backend memory region 38982b911aaSIgor Mammedov * or to numa container memory region 39082b911aaSIgor Mammedov */ 39182b911aaSIgor Mammedov MemoryRegion *ram; 392e017da37SDavid Hildenbrand DeviceMemoryState *device_memory; 39336d20cb2SMarcel Apfelbaum 3947a2c7da6SMartin Kletzander /* 3957a2c7da6SMartin Kletzander * Included in MachineState for simplicity, but not supported 3967a2c7da6SMartin Kletzander * unless machine_add_audiodev_property is called. Boards 3977a2c7da6SMartin Kletzander * that have embedded audio devices can call it from the 3987a2c7da6SMartin Kletzander * machine init function and forward the property to the device. 3997a2c7da6SMartin Kletzander */ 4007a2c7da6SMartin Kletzander char *audiodev; 4017a2c7da6SMartin Kletzander 4023ef96221SMarcel Apfelbaum ram_addr_t ram_size; 403c270fb9eSIgor Mammedov ram_addr_t maxram_size; 404c270fb9eSIgor Mammedov uint64_t ram_slots; 40597ec4d21SPaolo Bonzini BootConfiguration boot_config; 4066b1b1440SMarcel Apfelbaum char *kernel_filename; 4076b1b1440SMarcel Apfelbaum char *kernel_cmdline; 4086b1b1440SMarcel Apfelbaum char *initrd_filename; 4096063d4c0SIgor Mammedov const char *cpu_type; 410ac2da55eSEduardo Habkost AccelState *accelerator; 41138690a1cSIgor Mammedov CPUArchIdList *possible_cpus; 412edeeec91SLike Xu CpuTopology smp; 413f6a0d06bSEric Auger struct NVDIMMState *nvdimms_state; 414aa570207STao Xu struct NumaState *numa_state; 41536d20cb2SMarcel Apfelbaum }; 41636d20cb2SMarcel Apfelbaum 417ed0b6de3SEduardo Habkost #define DEFINE_MACHINE(namestr, machine_initfn) \ 418ed0b6de3SEduardo Habkost static void machine_initfn##_class_init(ObjectClass *oc, void *data) \ 419ed0b6de3SEduardo Habkost { \ 420ed0b6de3SEduardo Habkost MachineClass *mc = MACHINE_CLASS(oc); \ 421ed0b6de3SEduardo Habkost machine_initfn(mc); \ 422ed0b6de3SEduardo Habkost } \ 423ed0b6de3SEduardo Habkost static const TypeInfo machine_initfn##_typeinfo = { \ 424ed0b6de3SEduardo Habkost .name = MACHINE_TYPE_NAME(namestr), \ 425ed0b6de3SEduardo Habkost .parent = TYPE_MACHINE, \ 426ed0b6de3SEduardo Habkost .class_init = machine_initfn##_class_init, \ 427ed0b6de3SEduardo Habkost }; \ 428ed0b6de3SEduardo Habkost static void machine_initfn##_register_types(void) \ 429ed0b6de3SEduardo Habkost { \ 430ed0b6de3SEduardo Habkost type_register_static(&machine_initfn##_typeinfo); \ 431ed0b6de3SEduardo Habkost } \ 4320e6aac87SEduardo Habkost type_init(machine_initfn##_register_types) 433ed0b6de3SEduardo Habkost 43485fa9acdSPaolo Bonzini extern GlobalProperty hw_compat_9_0[]; 43585fa9acdSPaolo Bonzini extern const size_t hw_compat_9_0_len; 43685fa9acdSPaolo Bonzini 4372b10a676SCornelia Huck extern GlobalProperty hw_compat_8_2[]; 4382b10a676SCornelia Huck extern const size_t hw_compat_8_2_len; 4392b10a676SCornelia Huck 44095f5c89eSCornelia Huck extern GlobalProperty hw_compat_8_1[]; 44195f5c89eSCornelia Huck extern const size_t hw_compat_8_1_len; 44295f5c89eSCornelia Huck 4430259dd3eSCornelia Huck extern GlobalProperty hw_compat_8_0[]; 4440259dd3eSCornelia Huck extern const size_t hw_compat_8_0_len; 4450259dd3eSCornelia Huck 446db723c80SCornelia Huck extern GlobalProperty hw_compat_7_2[]; 447db723c80SCornelia Huck extern const size_t hw_compat_7_2_len; 448db723c80SCornelia Huck 449f514e147SCornelia Huck extern GlobalProperty hw_compat_7_1[]; 450f514e147SCornelia Huck extern const size_t hw_compat_7_1_len; 451f514e147SCornelia Huck 4520ca70366SCornelia Huck extern GlobalProperty hw_compat_7_0[]; 4530ca70366SCornelia Huck extern const size_t hw_compat_7_0_len; 4540ca70366SCornelia Huck 45501854af2SCornelia Huck extern GlobalProperty hw_compat_6_2[]; 45601854af2SCornelia Huck extern const size_t hw_compat_6_2_len; 45701854af2SCornelia Huck 45852e64f5bSYanan Wang extern GlobalProperty hw_compat_6_1[]; 45952e64f5bSYanan Wang extern const size_t hw_compat_6_1_len; 46052e64f5bSYanan Wang 461da7e13c0SCornelia Huck extern GlobalProperty hw_compat_6_0[]; 462da7e13c0SCornelia Huck extern const size_t hw_compat_6_0_len; 463da7e13c0SCornelia Huck 464576a00bdSCornelia Huck extern GlobalProperty hw_compat_5_2[]; 465576a00bdSCornelia Huck extern const size_t hw_compat_5_2_len; 466576a00bdSCornelia Huck 4673ff3c5d3SCornelia Huck extern GlobalProperty hw_compat_5_1[]; 4683ff3c5d3SCornelia Huck extern const size_t hw_compat_5_1_len; 4693ff3c5d3SCornelia Huck 470541aaa1dSCornelia Huck extern GlobalProperty hw_compat_5_0[]; 471541aaa1dSCornelia Huck extern const size_t hw_compat_5_0_len; 472541aaa1dSCornelia Huck 4735f258577SEvgeny Yakovlev extern GlobalProperty hw_compat_4_2[]; 4745f258577SEvgeny Yakovlev extern const size_t hw_compat_4_2_len; 4755f258577SEvgeny Yakovlev 4769aec2e52SCornelia Huck extern GlobalProperty hw_compat_4_1[]; 4779aec2e52SCornelia Huck extern const size_t hw_compat_4_1_len; 4789aec2e52SCornelia Huck 4799bf2650bSCornelia Huck extern GlobalProperty hw_compat_4_0[]; 4809bf2650bSCornelia Huck extern const size_t hw_compat_4_0_len; 4819bf2650bSCornelia Huck 482abd93cc7SMarc-André Lureau extern GlobalProperty hw_compat_3_1[]; 483abd93cc7SMarc-André Lureau extern const size_t hw_compat_3_1_len; 484abd93cc7SMarc-André Lureau 485ddb3235dSMarc-André Lureau extern GlobalProperty hw_compat_3_0[]; 486ddb3235dSMarc-André Lureau extern const size_t hw_compat_3_0_len; 487ddb3235dSMarc-André Lureau 4880d47310bSMarc-André Lureau extern GlobalProperty hw_compat_2_12[]; 4890d47310bSMarc-André Lureau extern const size_t hw_compat_2_12_len; 4900d47310bSMarc-André Lureau 49143df70a9SMarc-André Lureau extern GlobalProperty hw_compat_2_11[]; 49243df70a9SMarc-André Lureau extern const size_t hw_compat_2_11_len; 49343df70a9SMarc-André Lureau 494503224f4SMarc-André Lureau extern GlobalProperty hw_compat_2_10[]; 495503224f4SMarc-André Lureau extern const size_t hw_compat_2_10_len; 496503224f4SMarc-André Lureau 4973e803152SMarc-André Lureau extern GlobalProperty hw_compat_2_9[]; 4983e803152SMarc-André Lureau extern const size_t hw_compat_2_9_len; 4993e803152SMarc-André Lureau 500edc24ccdSMarc-André Lureau extern GlobalProperty hw_compat_2_8[]; 501edc24ccdSMarc-André Lureau extern const size_t hw_compat_2_8_len; 502edc24ccdSMarc-André Lureau 5035a995064SMarc-André Lureau extern GlobalProperty hw_compat_2_7[]; 5045a995064SMarc-André Lureau extern const size_t hw_compat_2_7_len; 5055a995064SMarc-André Lureau 506ff8f261fSMarc-André Lureau extern GlobalProperty hw_compat_2_6[]; 507ff8f261fSMarc-André Lureau extern const size_t hw_compat_2_6_len; 508ff8f261fSMarc-André Lureau 509fe759610SMarc-André Lureau extern GlobalProperty hw_compat_2_5[]; 510fe759610SMarc-André Lureau extern const size_t hw_compat_2_5_len; 511fe759610SMarc-André Lureau 5122f99b9c2SMarc-André Lureau extern GlobalProperty hw_compat_2_4[]; 5132f99b9c2SMarc-André Lureau extern const size_t hw_compat_2_4_len; 5142f99b9c2SMarc-André Lureau 5158995dd90SMarc-André Lureau extern GlobalProperty hw_compat_2_3[]; 5168995dd90SMarc-André Lureau extern const size_t hw_compat_2_3_len; 5178995dd90SMarc-André Lureau 5181c30044eSMarc-André Lureau extern GlobalProperty hw_compat_2_2[]; 5191c30044eSMarc-André Lureau extern const size_t hw_compat_2_2_len; 5201c30044eSMarc-André Lureau 521c4fc5695SMarc-André Lureau extern GlobalProperty hw_compat_2_1[]; 522c4fc5695SMarc-André Lureau extern const size_t hw_compat_2_1_len; 523c4fc5695SMarc-André Lureau 5240d09e41aSPaolo Bonzini #endif 525