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
#include "qemu/typedefs.h"
7
#include "sysemu/blockdev.h"
8
#include "sysemu/accel.h"
9
#include "hw/qdev.h"
10
#include "qom/object.h"
11

12

13
typedef void QEMUMachineInitFunc(MachineState *ms);
P
pbrook 已提交
14

15 16
typedef void QEMUMachineResetFunc(void);

17 18
typedef void QEMUMachineHotAddCPUFunc(const int64_t id, Error **errp);

19 20
typedef int QEMUMachineGetKvmtypeFunc(const char *arg);

21
struct QEMUMachine {
P
pbrook 已提交
22 23 24
    const char *name;
    const char *desc;
    QEMUMachineInitFunc *init;
25
    QEMUMachineGetKvmtypeFunc *kvm_type;
26
    BlockInterfaceType block_default_type;
27
    int max_cpus;
28
    unsigned int
29 30
        no_sdcard:1,
        has_dynamic_sysbus:1;
31
    int is_default;
32
    const char *default_machine_opts;
33
    const char *default_boot_order;
34
};
P
pbrook 已提交
35

36 37 38 39
void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner,
                                          const char *name,
                                          uint64_t ram_size);

P
pbrook 已提交
40
int qemu_register_machine(QEMUMachine *m);
41

42
#define TYPE_MACHINE_SUFFIX "-machine"
43
#define TYPE_MACHINE "machine"
44
#undef MACHINE  /* BSD defines it and QEMU does not use it */
45 46 47 48 49 50 51
#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)

52 53 54
MachineClass *find_default_machine(void);
extern MachineState *current_machine;

55
bool machine_usb(MachineState *machine);
56
bool machine_iommu(MachineState *machine);
57 58
bool machine_kernel_irqchip_allowed(MachineState *machine);
bool machine_kernel_irqchip_required(MachineState *machine);
59
int machine_kvm_shadow_mem(MachineState *machine);
60
int machine_phandle_start(MachineState *machine);
61
bool machine_dump_guest_core(MachineState *machine);
62
bool machine_mem_merge(MachineState *machine);
63

64 65 66
/**
 * MachineClass:
 * @qemu_machine: #QEMUMachine
67 68 69 70 71
 * @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.
72 73 74 75
 * @cpu_index_to_socket_id:
 *    used to provide @cpu_index to socket number mapping, allowing
 *    a machine to group CPU threads belonging to the same socket/package
 *    Returns: socket number given cpu_index belongs to.
76 77 78 79 80 81
 */
struct MachineClass {
    /*< private >*/
    ObjectClass parent_class;
    /*< public >*/

82
    const char *family; /* NULL iff @name identifies a standalone machtype */
83 84 85 86
    const char *name;
    const char *alias;
    const char *desc;

87
    void (*init)(MachineState *state);
88 89 90 91 92
    void (*reset)(void);
    void (*hot_add_cpu)(const int64_t id, Error **errp);
    int (*kvm_type)(const char *arg);

    BlockInterfaceType block_default_type;
93
    int units_per_default_bus;
94 95 96 97 98 99 100
    int max_cpus;
    unsigned int no_serial:1,
        no_parallel:1,
        use_virtcon:1,
        use_sclp:1,
        no_floppy:1,
        no_cdrom:1,
101
        no_sdcard:1,
102
        has_dynamic_sysbus:1,
103 104
        no_tco:1,
        pci_allow_0_address:1;
105 106 107
    int is_default;
    const char *default_machine_opts;
    const char *default_boot_order;
108
    const char *default_display;
109 110
    GlobalProperty *compat_props;
    const char *hw_version;
111
    ram_addr_t default_ram_size;
112 113 114

    HotplugHandler *(*get_hotplug_handler)(MachineState *machine,
                                           DeviceState *dev);
115
    unsigned (*cpu_index_to_socket_id)(unsigned cpu_index);
116 117 118 119 120 121 122 123
};

/**
 * MachineState:
 */
struct MachineState {
    /*< private >*/
    Object parent_obj;
124 125
    Notifier sysbus_notifier;

126 127 128
    /*< public >*/

    char *accel;
129 130
    bool kernel_irqchip_allowed;
    bool kernel_irqchip_required;
131 132 133 134 135 136 137 138
    int kvm_shadow_mem;
    char *dtb;
    char *dumpdtb;
    int phandle_start;
    char *dt_compatible;
    bool dump_guest_core;
    bool mem_merge;
    bool usb;
139
    bool usb_disabled;
140
    bool igd_gfx_passthru;
141
    char *firmware;
142
    bool iommu;
143
    bool suppress_vmdesc;
144

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

P
pbrook 已提交
156
#endif