boards.h 4.3 KB
Newer Older
P
pbrook 已提交
1 2 3 4 5
/* Declarations for use by board files for creating devices.  */

#ifndef HW_BOARDS_H
#define HW_BOARDS_H

6 7
#if !defined(CONFIG_USER_ONLY)

8
#include "qemu/typedefs.h"
9
#include "sysemu/blockdev.h"
10
#include "sysemu/accel.h"
11
#include "hw/qdev.h"
12
#include "qom/object.h"
13

14

15
typedef void QEMUMachineInitFunc(MachineState *ms);
P
pbrook 已提交
16

17 18
typedef void QEMUMachineResetFunc(void);

19 20
typedef void QEMUMachineHotAddCPUFunc(const int64_t id, Error **errp);

21 22
typedef int QEMUMachineGetKvmtypeFunc(const char *arg);

23
struct QEMUMachine {
24
    const char *family; /* NULL iff @name identifies a standalone machtype */
P
pbrook 已提交
25
    const char *name;
M
Mark McLoughlin 已提交
26
    const char *alias;
P
pbrook 已提交
27 28
    const char *desc;
    QEMUMachineInitFunc *init;
29
    QEMUMachineResetFunc *reset;
30
    QEMUMachineHotAddCPUFunc *hot_add_cpu;
31
    QEMUMachineGetKvmtypeFunc *kvm_type;
32
    BlockInterfaceType block_default_type;
33
    int units_per_default_bus;
34
    int max_cpus;
35
    unsigned int no_serial:1,
36 37
        no_parallel:1,
        use_virtcon:1,
38
        use_sclp:1,
G
Gerd Hoffmann 已提交
39 40
        no_floppy:1,
        no_cdrom:1,
41 42
        no_sdcard:1,
        has_dynamic_sysbus:1;
43
    int is_default;
44
    const char *default_machine_opts;
45
    const char *default_boot_order;
46
    const char *default_display;
47
    GlobalProperty *compat_props;
48
    const char *hw_version;
49
};
P
pbrook 已提交
50

51 52 53 54
void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner,
                                          const char *name,
                                          uint64_t ram_size);

P
pbrook 已提交
55
int qemu_register_machine(QEMUMachine *m);
56

57
#define TYPE_MACHINE_SUFFIX "-machine"
58
#define TYPE_MACHINE "machine"
59
#undef MACHINE  /* BSD defines it and QEMU does not use it */
60 61 62 63 64 65 66
#define MACHINE(obj) \
    OBJECT_CHECK(MachineState, (obj), TYPE_MACHINE)
#define MACHINE_GET_CLASS(obj) \
    OBJECT_GET_CLASS(MachineClass, (obj), TYPE_MACHINE)
#define MACHINE_CLASS(klass) \
    OBJECT_CLASS_CHECK(MachineClass, (klass), TYPE_MACHINE)

67 68 69
MachineClass *find_default_machine(void);
extern MachineState *current_machine;

70
bool machine_usb(MachineState *machine);
71
bool machine_iommu(MachineState *machine);
72 73
bool machine_kernel_irqchip_allowed(MachineState *machine);
bool machine_kernel_irqchip_required(MachineState *machine);
74
int machine_kvm_shadow_mem(MachineState *machine);
75
int machine_phandle_start(MachineState *machine);
76
bool machine_dump_guest_core(MachineState *machine);
77

78 79 80
/**
 * MachineClass:
 * @qemu_machine: #QEMUMachine
81 82 83 84 85
 * @get_hotplug_handler: this function is called during bus-less
 *    device hotplug. If defined it returns pointer to an instance
 *    of HotplugHandler object, which handles hotplug operation
 *    for a given @dev. It may return NULL if @dev doesn't require
 *    any actions to be performed by hotplug handler.
86 87 88 89 90 91
 */
struct MachineClass {
    /*< private >*/
    ObjectClass parent_class;
    /*< public >*/

92
    const char *family; /* NULL iff @name identifies a standalone machtype */
93 94 95 96
    const char *name;
    const char *alias;
    const char *desc;

97
    void (*init)(MachineState *state);
98 99 100 101 102
    void (*reset)(void);
    void (*hot_add_cpu)(const int64_t id, Error **errp);
    int (*kvm_type)(const char *arg);

    BlockInterfaceType block_default_type;
103
    int units_per_default_bus;
104 105 106 107 108 109 110
    int max_cpus;
    unsigned int no_serial:1,
        no_parallel:1,
        use_virtcon:1,
        use_sclp:1,
        no_floppy:1,
        no_cdrom:1,
111 112
        no_sdcard:1,
        has_dynamic_sysbus:1;
113 114 115
    int is_default;
    const char *default_machine_opts;
    const char *default_boot_order;
116
    const char *default_display;
117 118
    GlobalProperty *compat_props;
    const char *hw_version;
119 120 121

    HotplugHandler *(*get_hotplug_handler)(MachineState *machine,
                                           DeviceState *dev);
122 123 124 125 126 127 128 129
};

/**
 * MachineState:
 */
struct MachineState {
    /*< private >*/
    Object parent_obj;
130 131
    Notifier sysbus_notifier;

132 133 134
    /*< public >*/

    char *accel;
135 136
    bool kernel_irqchip_allowed;
    bool kernel_irqchip_required;
137 138 139 140 141 142 143 144 145
    int kvm_shadow_mem;
    char *dtb;
    char *dumpdtb;
    int phandle_start;
    char *dt_compatible;
    bool dump_guest_core;
    bool mem_merge;
    bool usb;
    char *firmware;
146
    bool iommu;
147

148
    ram_addr_t ram_size;
149 150
    ram_addr_t maxram_size;
    uint64_t   ram_slots;
151
    const char *boot_order;
152 153 154
    char *kernel_filename;
    char *kernel_cmdline;
    char *initrd_filename;
155
    const char *cpu_model;
156
    AccelState *accelerator;
157 158
};

P
pbrook 已提交
159
#endif
160 161

#endif