xref: /openbmc/qemu/include/hw/boards.h (revision a52a7fdf)
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"
80d09e41aSPaolo Bonzini #include "hw/qdev.h"
936d20cb2SMarcel Apfelbaum #include "qom/object.h"
100d09e41aSPaolo Bonzini 
110d09e41aSPaolo Bonzini 
123ef96221SMarcel Apfelbaum typedef struct MachineState MachineState;
133ef96221SMarcel Apfelbaum 
143ef96221SMarcel Apfelbaum typedef void QEMUMachineInitFunc(MachineState *ms);
150d09e41aSPaolo Bonzini 
160d09e41aSPaolo Bonzini typedef void QEMUMachineResetFunc(void);
170d09e41aSPaolo Bonzini 
18b4fc7b43SIgor Mammedov typedef void QEMUMachineHotAddCPUFunc(const int64_t id, Error **errp);
19b4fc7b43SIgor Mammedov 
20135a129aSAneesh Kumar K.V typedef int QEMUMachineGetKvmtypeFunc(const char *arg);
21135a129aSAneesh Kumar K.V 
22e689f7c6SMarkus Armbruster struct QEMUMachine {
230d09e41aSPaolo Bonzini     const char *name;
240d09e41aSPaolo Bonzini     const char *alias;
250d09e41aSPaolo Bonzini     const char *desc;
260d09e41aSPaolo Bonzini     QEMUMachineInitFunc *init;
270d09e41aSPaolo Bonzini     QEMUMachineResetFunc *reset;
28b4fc7b43SIgor Mammedov     QEMUMachineHotAddCPUFunc *hot_add_cpu;
29135a129aSAneesh Kumar K.V     QEMUMachineGetKvmtypeFunc *kvm_type;
300d09e41aSPaolo Bonzini     BlockInterfaceType block_default_type;
310d09e41aSPaolo Bonzini     int max_cpus;
320d09e41aSPaolo Bonzini     unsigned int no_serial:1,
330d09e41aSPaolo Bonzini         no_parallel:1,
340d09e41aSPaolo Bonzini         use_virtcon:1,
350d09e41aSPaolo Bonzini         use_sclp:1,
360d09e41aSPaolo Bonzini         no_floppy:1,
370d09e41aSPaolo Bonzini         no_cdrom:1,
380d09e41aSPaolo Bonzini         no_sdcard:1;
390d09e41aSPaolo Bonzini     int is_default;
400d09e41aSPaolo Bonzini     const char *default_machine_opts;
41c1654732SMarkus Armbruster     const char *default_boot_order;
420d09e41aSPaolo Bonzini     GlobalProperty *compat_props;
430d09e41aSPaolo Bonzini     const char *hw_version;
44e689f7c6SMarkus Armbruster };
450d09e41aSPaolo Bonzini 
46dfabb8b9SPaolo Bonzini void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner,
47dfabb8b9SPaolo Bonzini                                           const char *name,
48dfabb8b9SPaolo Bonzini                                           uint64_t ram_size);
49dfabb8b9SPaolo Bonzini 
500d09e41aSPaolo Bonzini int qemu_register_machine(QEMUMachine *m);
510d09e41aSPaolo Bonzini 
52dfabb8b9SPaolo Bonzini #define TYPE_MACHINE_SUFFIX "-machine"
5336d20cb2SMarcel Apfelbaum #define TYPE_MACHINE "machine"
54c8897e8eSMarcel Apfelbaum #undef MACHINE  /* BSD defines it and QEMU does not use it */
5536d20cb2SMarcel Apfelbaum #define MACHINE(obj) \
5636d20cb2SMarcel Apfelbaum     OBJECT_CHECK(MachineState, (obj), TYPE_MACHINE)
5736d20cb2SMarcel Apfelbaum #define MACHINE_GET_CLASS(obj) \
5836d20cb2SMarcel Apfelbaum     OBJECT_GET_CLASS(MachineClass, (obj), TYPE_MACHINE)
5936d20cb2SMarcel Apfelbaum #define MACHINE_CLASS(klass) \
6036d20cb2SMarcel Apfelbaum     OBJECT_CLASS_CHECK(MachineClass, (klass), TYPE_MACHINE)
6136d20cb2SMarcel Apfelbaum 
620056ae24SMarcel Apfelbaum MachineClass *find_default_machine(void);
630056ae24SMarcel Apfelbaum extern MachineState *current_machine;
640056ae24SMarcel Apfelbaum 
6536d20cb2SMarcel Apfelbaum /**
6636d20cb2SMarcel Apfelbaum  * MachineClass:
6736d20cb2SMarcel Apfelbaum  * @qemu_machine: #QEMUMachine
68b7454548SIgor Mammedov  * @get_hotplug_handler: this function is called during bus-less
69b7454548SIgor Mammedov  *    device hotplug. If defined it returns pointer to an instance
70b7454548SIgor Mammedov  *    of HotplugHandler object, which handles hotplug operation
71b7454548SIgor Mammedov  *    for a given @dev. It may return NULL if @dev doesn't require
72b7454548SIgor Mammedov  *    any actions to be performed by hotplug handler.
7336d20cb2SMarcel Apfelbaum  */
7436d20cb2SMarcel Apfelbaum struct MachineClass {
7536d20cb2SMarcel Apfelbaum     /*< private >*/
7636d20cb2SMarcel Apfelbaum     ObjectClass parent_class;
7736d20cb2SMarcel Apfelbaum     /*< public >*/
7836d20cb2SMarcel Apfelbaum 
7900b4fbe2SMarcel Apfelbaum     const char *name;
8000b4fbe2SMarcel Apfelbaum     const char *alias;
8100b4fbe2SMarcel Apfelbaum     const char *desc;
8200b4fbe2SMarcel Apfelbaum 
833ef96221SMarcel Apfelbaum     void (*init)(MachineState *state);
8400b4fbe2SMarcel Apfelbaum     void (*reset)(void);
8500b4fbe2SMarcel Apfelbaum     void (*hot_add_cpu)(const int64_t id, Error **errp);
8600b4fbe2SMarcel Apfelbaum     int (*kvm_type)(const char *arg);
8700b4fbe2SMarcel Apfelbaum 
8800b4fbe2SMarcel Apfelbaum     BlockInterfaceType block_default_type;
8900b4fbe2SMarcel Apfelbaum     int max_cpus;
9000b4fbe2SMarcel Apfelbaum     unsigned int no_serial:1,
9100b4fbe2SMarcel Apfelbaum         no_parallel:1,
9200b4fbe2SMarcel Apfelbaum         use_virtcon:1,
9300b4fbe2SMarcel Apfelbaum         use_sclp:1,
9400b4fbe2SMarcel Apfelbaum         no_floppy:1,
9500b4fbe2SMarcel Apfelbaum         no_cdrom:1,
9600b4fbe2SMarcel Apfelbaum         no_sdcard:1;
9700b4fbe2SMarcel Apfelbaum     int is_default;
9800b4fbe2SMarcel Apfelbaum     const char *default_machine_opts;
9900b4fbe2SMarcel Apfelbaum     const char *default_boot_order;
10000b4fbe2SMarcel Apfelbaum     GlobalProperty *compat_props;
10100b4fbe2SMarcel Apfelbaum     const char *hw_version;
102b7454548SIgor Mammedov 
103b7454548SIgor Mammedov     HotplugHandler *(*get_hotplug_handler)(MachineState *machine,
104b7454548SIgor Mammedov                                            DeviceState *dev);
10536d20cb2SMarcel Apfelbaum };
10636d20cb2SMarcel Apfelbaum 
10736d20cb2SMarcel Apfelbaum /**
10836d20cb2SMarcel Apfelbaum  * MachineState:
10936d20cb2SMarcel Apfelbaum  */
11036d20cb2SMarcel Apfelbaum struct MachineState {
11136d20cb2SMarcel Apfelbaum     /*< private >*/
11236d20cb2SMarcel Apfelbaum     Object parent_obj;
11336d20cb2SMarcel Apfelbaum     /*< public >*/
11436d20cb2SMarcel Apfelbaum 
11536d20cb2SMarcel Apfelbaum     char *accel;
11636d20cb2SMarcel Apfelbaum     bool kernel_irqchip;
11736d20cb2SMarcel Apfelbaum     int kvm_shadow_mem;
11836d20cb2SMarcel Apfelbaum     char *dtb;
11936d20cb2SMarcel Apfelbaum     char *dumpdtb;
12036d20cb2SMarcel Apfelbaum     int phandle_start;
12136d20cb2SMarcel Apfelbaum     char *dt_compatible;
12236d20cb2SMarcel Apfelbaum     bool dump_guest_core;
12336d20cb2SMarcel Apfelbaum     bool mem_merge;
12436d20cb2SMarcel Apfelbaum     bool usb;
12536d20cb2SMarcel Apfelbaum     char *firmware;
126*a52a7fdfSLe Tan     bool iommu;
12736d20cb2SMarcel Apfelbaum 
1283ef96221SMarcel Apfelbaum     ram_addr_t ram_size;
129c270fb9eSIgor Mammedov     ram_addr_t maxram_size;
130c270fb9eSIgor Mammedov     uint64_t   ram_slots;
1313ef96221SMarcel Apfelbaum     const char *boot_order;
1326b1b1440SMarcel Apfelbaum     char *kernel_filename;
1336b1b1440SMarcel Apfelbaum     char *kernel_cmdline;
1346b1b1440SMarcel Apfelbaum     char *initrd_filename;
1353ef96221SMarcel Apfelbaum     const char *cpu_model;
13636d20cb2SMarcel Apfelbaum };
13736d20cb2SMarcel Apfelbaum 
1380d09e41aSPaolo Bonzini #endif
139