xref: /openbmc/qemu/include/hw/i386/x86.h (revision 4b9fa0b4)
1 /*
2  * Copyright (c) 2019 Red Hat, Inc.
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms and conditions of the GNU General Public License,
6  * version 2 or later, as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
11  * more details.
12  *
13  * You should have received a copy of the GNU General Public License along with
14  * this program.  If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 #ifndef HW_I386_X86_H
18 #define HW_I386_X86_H
19 
20 #include "qemu-common.h"
21 #include "exec/hwaddr.h"
22 #include "qemu/notify.h"
23 
24 #include "hw/boards.h"
25 #include "hw/nmi.h"
26 
27 typedef struct {
28     /*< private >*/
29     MachineClass parent;
30 
31     /*< public >*/
32 
33     /* Enables contiguous-apic-ID mode */
34     bool compat_apic_id_mode;
35 } X86MachineClass;
36 
37 typedef struct {
38     /*< private >*/
39     MachineState parent;
40 
41     /*< public >*/
42 
43     /* Pointers to devices and objects: */
44     ISADevice *rtc;
45     FWCfgState *fw_cfg;
46     qemu_irq *gsi;
47     GMappedFile *initrd_mapped_file;
48 
49     /* Configuration options: */
50     uint64_t max_ram_below_4g;
51 
52     /* RAM information (sizes, addresses, configuration): */
53     ram_addr_t below_4g_mem_size, above_4g_mem_size;
54 
55     /* CPU and apic information: */
56     bool apic_xrupt_override;
57     unsigned apic_id_limit;
58     uint16_t boot_cpus;
59     unsigned smp_dies;
60 
61     /*
62      * Address space used by IOAPIC device. All IOAPIC interrupts
63      * will be translated to MSI messages in the address space.
64      */
65     AddressSpace *ioapic_as;
66 } X86MachineState;
67 
68 #define X86_MACHINE_MAX_RAM_BELOW_4G "max-ram-below-4g"
69 
70 #define TYPE_X86_MACHINE   MACHINE_TYPE_NAME("x86")
71 #define X86_MACHINE(obj) \
72     OBJECT_CHECK(X86MachineState, (obj), TYPE_X86_MACHINE)
73 #define X86_MACHINE_GET_CLASS(obj) \
74     OBJECT_GET_CLASS(X86MachineClass, obj, TYPE_X86_MACHINE)
75 #define X86_MACHINE_CLASS(class) \
76     OBJECT_CLASS_CHECK(X86MachineClass, class, TYPE_X86_MACHINE)
77 
78 uint32_t x86_cpu_apic_id_from_index(X86MachineState *pcms,
79                                     unsigned int cpu_index);
80 
81 void x86_cpu_new(X86MachineState *pcms, int64_t apic_id, Error **errp);
82 void x86_cpus_init(X86MachineState *pcms, int default_cpu_version);
83 CpuInstanceProperties x86_cpu_index_to_props(MachineState *ms,
84                                              unsigned cpu_index);
85 int64_t x86_get_default_cpu_node_id(const MachineState *ms, int idx);
86 const CPUArchIdList *x86_possible_cpu_arch_ids(MachineState *ms);
87 
88 void x86_bios_rom_init(MemoryRegion *rom_memory, bool isapc_ram_fw);
89 
90 void x86_load_linux(X86MachineState *x86ms,
91                     FWCfgState *fw_cfg,
92                     int acpi_data_size,
93                     bool pvh_enabled,
94                     bool linuxboot_dma_enabled);
95 
96 #endif
97