xref: /openbmc/qemu/include/hw/boards.h (revision c84a8f01)
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 {
220d09e41aSPaolo Bonzini     const char *name;
230d09e41aSPaolo Bonzini     const char *desc;
240d09e41aSPaolo Bonzini     QEMUMachineInitFunc *init;
25135a129aSAneesh Kumar K.V     QEMUMachineGetKvmtypeFunc *kvm_type;
260d09e41aSPaolo Bonzini     BlockInterfaceType block_default_type;
270d09e41aSPaolo Bonzini     int max_cpus;
28d48f4fa6SEduardo Habkost     unsigned int
2933cd52b5SAlexander Graf         no_sdcard:1,
3033cd52b5SAlexander Graf         has_dynamic_sysbus:1;
310d09e41aSPaolo Bonzini     int is_default;
320d09e41aSPaolo Bonzini     const char *default_machine_opts;
33c1654732SMarkus Armbruster     const char *default_boot_order;
34e689f7c6SMarkus Armbruster };
350d09e41aSPaolo Bonzini 
36dfabb8b9SPaolo Bonzini void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner,
37dfabb8b9SPaolo Bonzini                                           const char *name,
38dfabb8b9SPaolo Bonzini                                           uint64_t ram_size);
39dfabb8b9SPaolo Bonzini 
400d09e41aSPaolo Bonzini int qemu_register_machine(QEMUMachine *m);
410d09e41aSPaolo Bonzini 
42dfabb8b9SPaolo Bonzini #define TYPE_MACHINE_SUFFIX "-machine"
43*c84a8f01SEduardo Habkost 
44*c84a8f01SEduardo Habkost /* Machine class name that needs to be used for class-name-based machine
45*c84a8f01SEduardo Habkost  * type lookup to work.
46*c84a8f01SEduardo Habkost  */
47*c84a8f01SEduardo Habkost #define MACHINE_TYPE_NAME(machinename) (machinename TYPE_MACHINE_SUFFIX)
48*c84a8f01SEduardo Habkost 
4936d20cb2SMarcel Apfelbaum #define TYPE_MACHINE "machine"
50c8897e8eSMarcel Apfelbaum #undef MACHINE  /* BSD defines it and QEMU does not use it */
5136d20cb2SMarcel Apfelbaum #define MACHINE(obj) \
5236d20cb2SMarcel Apfelbaum     OBJECT_CHECK(MachineState, (obj), TYPE_MACHINE)
5336d20cb2SMarcel Apfelbaum #define MACHINE_GET_CLASS(obj) \
5436d20cb2SMarcel Apfelbaum     OBJECT_GET_CLASS(MachineClass, (obj), TYPE_MACHINE)
5536d20cb2SMarcel Apfelbaum #define MACHINE_CLASS(klass) \
5636d20cb2SMarcel Apfelbaum     OBJECT_CLASS_CHECK(MachineClass, (klass), TYPE_MACHINE)
5736d20cb2SMarcel Apfelbaum 
580056ae24SMarcel Apfelbaum MachineClass *find_default_machine(void);
590056ae24SMarcel Apfelbaum extern MachineState *current_machine;
600056ae24SMarcel Apfelbaum 
615e97b623SMarcel Apfelbaum bool machine_usb(MachineState *machine);
628caff636SMarcel Apfelbaum bool machine_iommu(MachineState *machine);
63d8870d02SMarcel Apfelbaum bool machine_kernel_irqchip_allowed(MachineState *machine);
64d8870d02SMarcel Apfelbaum bool machine_kernel_irqchip_required(MachineState *machine);
654689b77bSMarcel Apfelbaum int machine_kvm_shadow_mem(MachineState *machine);
666cabe7faSMarcel Apfelbaum int machine_phandle_start(MachineState *machine);
6747c8ca53SMarcel Apfelbaum bool machine_dump_guest_core(MachineState *machine);
6875cc7f01SMarcel Apfelbaum bool machine_mem_merge(MachineState *machine);
695e97b623SMarcel Apfelbaum 
7036d20cb2SMarcel Apfelbaum /**
7136d20cb2SMarcel Apfelbaum  * MachineClass:
7236d20cb2SMarcel Apfelbaum  * @qemu_machine: #QEMUMachine
73b7454548SIgor Mammedov  * @get_hotplug_handler: this function is called during bus-less
74b7454548SIgor Mammedov  *    device hotplug. If defined it returns pointer to an instance
75b7454548SIgor Mammedov  *    of HotplugHandler object, which handles hotplug operation
76b7454548SIgor Mammedov  *    for a given @dev. It may return NULL if @dev doesn't require
77b7454548SIgor Mammedov  *    any actions to be performed by hotplug handler.
7857924bcdSIgor Mammedov  * @cpu_index_to_socket_id:
7957924bcdSIgor Mammedov  *    used to provide @cpu_index to socket number mapping, allowing
8057924bcdSIgor Mammedov  *    a machine to group CPU threads belonging to the same socket/package
8157924bcdSIgor Mammedov  *    Returns: socket number given cpu_index belongs to.
8236d20cb2SMarcel Apfelbaum  */
8336d20cb2SMarcel Apfelbaum struct MachineClass {
8436d20cb2SMarcel Apfelbaum     /*< private >*/
8536d20cb2SMarcel Apfelbaum     ObjectClass parent_class;
8636d20cb2SMarcel Apfelbaum     /*< public >*/
8736d20cb2SMarcel Apfelbaum 
882709f263SLaszlo Ersek     const char *family; /* NULL iff @name identifies a standalone machtype */
8900b4fbe2SMarcel Apfelbaum     const char *name;
9000b4fbe2SMarcel Apfelbaum     const char *alias;
9100b4fbe2SMarcel Apfelbaum     const char *desc;
9200b4fbe2SMarcel Apfelbaum 
933ef96221SMarcel Apfelbaum     void (*init)(MachineState *state);
9400b4fbe2SMarcel Apfelbaum     void (*reset)(void);
9500b4fbe2SMarcel Apfelbaum     void (*hot_add_cpu)(const int64_t id, Error **errp);
9600b4fbe2SMarcel Apfelbaum     int (*kvm_type)(const char *arg);
9700b4fbe2SMarcel Apfelbaum 
9800b4fbe2SMarcel Apfelbaum     BlockInterfaceType block_default_type;
9916026518SJohn Snow     int units_per_default_bus;
10000b4fbe2SMarcel Apfelbaum     int max_cpus;
10100b4fbe2SMarcel Apfelbaum     unsigned int no_serial:1,
10200b4fbe2SMarcel Apfelbaum         no_parallel:1,
10300b4fbe2SMarcel Apfelbaum         use_virtcon:1,
10400b4fbe2SMarcel Apfelbaum         use_sclp:1,
10500b4fbe2SMarcel Apfelbaum         no_floppy:1,
10600b4fbe2SMarcel Apfelbaum         no_cdrom:1,
10733cd52b5SAlexander Graf         no_sdcard:1,
10892055797SPaulo Alcantara         has_dynamic_sysbus:1,
109e4024630SLaurent Vivier         no_tco:1,
110e4024630SLaurent Vivier         pci_allow_0_address:1;
11100b4fbe2SMarcel Apfelbaum     int is_default;
11200b4fbe2SMarcel Apfelbaum     const char *default_machine_opts;
11300b4fbe2SMarcel Apfelbaum     const char *default_boot_order;
1146f00494aSGerd Hoffmann     const char *default_display;
11500b4fbe2SMarcel Apfelbaum     GlobalProperty *compat_props;
11600b4fbe2SMarcel Apfelbaum     const char *hw_version;
117076b35b5SNikunj A Dadhania     ram_addr_t default_ram_size;
118b7454548SIgor Mammedov 
119b7454548SIgor Mammedov     HotplugHandler *(*get_hotplug_handler)(MachineState *machine,
120b7454548SIgor Mammedov                                            DeviceState *dev);
12157924bcdSIgor Mammedov     unsigned (*cpu_index_to_socket_id)(unsigned cpu_index);
12236d20cb2SMarcel Apfelbaum };
12336d20cb2SMarcel Apfelbaum 
12436d20cb2SMarcel Apfelbaum /**
12536d20cb2SMarcel Apfelbaum  * MachineState:
12636d20cb2SMarcel Apfelbaum  */
12736d20cb2SMarcel Apfelbaum struct MachineState {
12836d20cb2SMarcel Apfelbaum     /*< private >*/
12936d20cb2SMarcel Apfelbaum     Object parent_obj;
13033cd52b5SAlexander Graf     Notifier sysbus_notifier;
13133cd52b5SAlexander Graf 
13236d20cb2SMarcel Apfelbaum     /*< public >*/
13336d20cb2SMarcel Apfelbaum 
13436d20cb2SMarcel Apfelbaum     char *accel;
135d8870d02SMarcel Apfelbaum     bool kernel_irqchip_allowed;
136d8870d02SMarcel Apfelbaum     bool kernel_irqchip_required;
13736d20cb2SMarcel Apfelbaum     int kvm_shadow_mem;
13836d20cb2SMarcel Apfelbaum     char *dtb;
13936d20cb2SMarcel Apfelbaum     char *dumpdtb;
14036d20cb2SMarcel Apfelbaum     int phandle_start;
14136d20cb2SMarcel Apfelbaum     char *dt_compatible;
14236d20cb2SMarcel Apfelbaum     bool dump_guest_core;
14336d20cb2SMarcel Apfelbaum     bool mem_merge;
14436d20cb2SMarcel Apfelbaum     bool usb;
145c6e76503SPaolo Bonzini     bool usb_disabled;
14679814179STiejun Chen     bool igd_gfx_passthru;
14736d20cb2SMarcel Apfelbaum     char *firmware;
148a52a7fdfSLe Tan     bool iommu;
1499850c604SAlexander Graf     bool suppress_vmdesc;
15036d20cb2SMarcel Apfelbaum 
1513ef96221SMarcel Apfelbaum     ram_addr_t ram_size;
152c270fb9eSIgor Mammedov     ram_addr_t maxram_size;
153c270fb9eSIgor Mammedov     uint64_t   ram_slots;
1543ef96221SMarcel Apfelbaum     const char *boot_order;
1556b1b1440SMarcel Apfelbaum     char *kernel_filename;
1566b1b1440SMarcel Apfelbaum     char *kernel_cmdline;
1576b1b1440SMarcel Apfelbaum     char *initrd_filename;
1583ef96221SMarcel Apfelbaum     const char *cpu_model;
159ac2da55eSEduardo Habkost     AccelState *accelerator;
16036d20cb2SMarcel Apfelbaum };
16136d20cb2SMarcel Apfelbaum 
1620d09e41aSPaolo Bonzini #endif
163