xref: /openbmc/qemu/include/hw/i386/microvm.h (revision 5de5b99b)
1 /*
2  * Copyright (c) 2018 Intel Corporation
3  * Copyright (c) 2019 Red Hat, Inc.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms and conditions of the GNU General Public License,
7  * version 2 or later, as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef HW_I386_MICROVM_H
19 #define HW_I386_MICROVM_H
20 
21 #include "qemu-common.h"
22 #include "exec/hwaddr.h"
23 #include "qemu/notify.h"
24 
25 #include "hw/boards.h"
26 #include "hw/i386/x86.h"
27 #include "hw/acpi/acpi_dev_interface.h"
28 #include "qom/object.h"
29 
30 /* Platform virtio definitions */
31 #define VIRTIO_MMIO_BASE      0xfeb00000
32 #define VIRTIO_NUM_TRANSPORTS 8
33 #define VIRTIO_CMDLINE_MAXLEN 64
34 
35 #define GED_MMIO_BASE         0xfea00000
36 #define GED_MMIO_BASE_MEMHP   (GED_MMIO_BASE + 0x100)
37 #define GED_MMIO_BASE_REGS    (GED_MMIO_BASE + 0x200)
38 #define GED_MMIO_IRQ          9
39 
40 /* Machine type options */
41 #define MICROVM_MACHINE_PIT                 "pit"
42 #define MICROVM_MACHINE_PIC                 "pic"
43 #define MICROVM_MACHINE_RTC                 "rtc"
44 #define MICROVM_MACHINE_ISA_SERIAL          "isa-serial"
45 #define MICROVM_MACHINE_OPTION_ROMS         "x-option-roms"
46 #define MICROVM_MACHINE_AUTO_KERNEL_CMDLINE "auto-kernel-cmdline"
47 
48 struct MicrovmMachineClass {
49     X86MachineClass parent;
50     HotplugHandler *(*orig_hotplug_handler)(MachineState *machine,
51                                            DeviceState *dev);
52 };
53 typedef struct MicrovmMachineClass MicrovmMachineClass;
54 
55 struct MicrovmMachineState {
56     X86MachineState parent;
57 
58     /* Machine type options */
59     OnOffAuto pic;
60     OnOffAuto pit;
61     OnOffAuto rtc;
62     bool isa_serial;
63     bool option_roms;
64     bool auto_kernel_cmdline;
65 
66     /* Machine state */
67     uint32_t virtio_irq_base;
68     bool kernel_cmdline_fixed;
69     Notifier machine_done;
70     Notifier powerdown_req;
71 };
72 typedef struct MicrovmMachineState MicrovmMachineState;
73 
74 #define TYPE_MICROVM_MACHINE   MACHINE_TYPE_NAME("microvm")
75 DECLARE_OBJ_CHECKERS(MicrovmMachineState, MicrovmMachineClass,
76                      MICROVM_MACHINE, TYPE_MICROVM_MACHINE)
77 
78 #endif
79