xref: /openbmc/qemu/include/hw/boards.h (revision a719a27c)
1 /* Declarations for use by board files for creating devices.  */
2 
3 #ifndef HW_BOARDS_H
4 #define HW_BOARDS_H
5 
6 #include "qemu/typedefs.h"
7 #include "sysemu/blockdev.h"
8 #include "hw/qdev.h"
9 #include "qom/object.h"
10 
11 typedef struct QEMUMachineInitArgs {
12     const MachineClass *machine;
13     ram_addr_t ram_size;
14     const char *boot_order;
15     const char *kernel_filename;
16     const char *kernel_cmdline;
17     const char *initrd_filename;
18     const char *cpu_model;
19 } QEMUMachineInitArgs;
20 
21 typedef void QEMUMachineInitFunc(QEMUMachineInitArgs *args);
22 
23 typedef void QEMUMachineResetFunc(void);
24 
25 typedef void QEMUMachineHotAddCPUFunc(const int64_t id, Error **errp);
26 
27 typedef int QEMUMachineGetKvmtypeFunc(const char *arg);
28 
29 struct QEMUMachine {
30     const char *name;
31     const char *alias;
32     const char *desc;
33     QEMUMachineInitFunc *init;
34     QEMUMachineResetFunc *reset;
35     QEMUMachineHotAddCPUFunc *hot_add_cpu;
36     QEMUMachineGetKvmtypeFunc *kvm_type;
37     BlockInterfaceType block_default_type;
38     int max_cpus;
39     unsigned int no_serial:1,
40         no_parallel:1,
41         use_virtcon:1,
42         use_sclp:1,
43         no_floppy:1,
44         no_cdrom:1,
45         no_sdcard:1;
46     int is_default;
47     const char *default_machine_opts;
48     const char *default_boot_order;
49     GlobalProperty *compat_props;
50     const char *hw_version;
51 };
52 
53 #define TYPE_MACHINE_SUFFIX "-machine"
54 int qemu_register_machine(QEMUMachine *m);
55 
56 #define TYPE_MACHINE "machine"
57 #undef MACHINE  /* BSD defines it and QEMU does not use it */
58 #define MACHINE(obj) \
59     OBJECT_CHECK(MachineState, (obj), TYPE_MACHINE)
60 #define MACHINE_GET_CLASS(obj) \
61     OBJECT_GET_CLASS(MachineClass, (obj), TYPE_MACHINE)
62 #define MACHINE_CLASS(klass) \
63     OBJECT_CLASS_CHECK(MachineClass, (klass), TYPE_MACHINE)
64 
65 typedef struct MachineState MachineState;
66 
67 MachineClass *find_default_machine(void);
68 extern MachineState *current_machine;
69 
70 /**
71  * MachineClass:
72  * @qemu_machine: #QEMUMachine
73  */
74 struct MachineClass {
75     /*< private >*/
76     ObjectClass parent_class;
77     /*< public >*/
78 
79     const char *name;
80     const char *alias;
81     const char *desc;
82 
83     void (*init)(QEMUMachineInitArgs *args);
84     void (*reset)(void);
85     void (*hot_add_cpu)(const int64_t id, Error **errp);
86     int (*kvm_type)(const char *arg);
87 
88     BlockInterfaceType block_default_type;
89     int max_cpus;
90     unsigned int no_serial:1,
91         no_parallel:1,
92         use_virtcon:1,
93         use_sclp:1,
94         no_floppy:1,
95         no_cdrom:1,
96         no_sdcard:1;
97     int is_default;
98     const char *default_machine_opts;
99     const char *default_boot_order;
100     GlobalProperty *compat_props;
101     const char *hw_version;
102 };
103 
104 /**
105  * MachineState:
106  */
107 struct MachineState {
108     /*< private >*/
109     Object parent_obj;
110     /*< public >*/
111 
112     char *accel;
113     bool kernel_irqchip;
114     int kvm_shadow_mem;
115     char *kernel;
116     char *initrd;
117     char *append;
118     char *dtb;
119     char *dumpdtb;
120     int phandle_start;
121     char *dt_compatible;
122     bool dump_guest_core;
123     bool mem_merge;
124     bool usb;
125     char *firmware;
126 
127     QEMUMachineInitArgs init_args;
128 };
129 
130 #endif
131