xref: /openbmc/qemu/include/hw/i386/microvm.h (revision 354908ce)
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 
28 /* Platform virtio definitions */
29 #define VIRTIO_MMIO_BASE      0xfeb00000
30 #define VIRTIO_IRQ_BASE       5
31 #define VIRTIO_NUM_TRANSPORTS 8
32 #define VIRTIO_CMDLINE_MAXLEN 64
33 
34 /* Machine type options */
35 #define MICROVM_MACHINE_PIT                 "pit"
36 #define MICROVM_MACHINE_PIC                 "pic"
37 #define MICROVM_MACHINE_RTC                 "rtc"
38 #define MICROVM_MACHINE_ISA_SERIAL          "isa-serial"
39 #define MICROVM_MACHINE_OPTION_ROMS         "x-option-roms"
40 #define MICROVM_MACHINE_AUTO_KERNEL_CMDLINE "auto-kernel-cmdline"
41 
42 typedef struct {
43     X86MachineClass parent;
44     HotplugHandler *(*orig_hotplug_handler)(MachineState *machine,
45                                            DeviceState *dev);
46 } MicrovmMachineClass;
47 
48 typedef struct {
49     X86MachineState parent;
50 
51     /* Machine type options */
52     OnOffAuto pic;
53     OnOffAuto pit;
54     OnOffAuto rtc;
55     bool isa_serial;
56     bool option_roms;
57     bool auto_kernel_cmdline;
58 
59     /* Machine state */
60     bool kernel_cmdline_fixed;
61 } MicrovmMachineState;
62 
63 #define TYPE_MICROVM_MACHINE   MACHINE_TYPE_NAME("microvm")
64 #define MICROVM_MACHINE(obj) \
65     OBJECT_CHECK(MicrovmMachineState, (obj), TYPE_MICROVM_MACHINE)
66 #define MICROVM_MACHINE_GET_CLASS(obj) \
67     OBJECT_GET_CLASS(MicrovmMachineClass, obj, TYPE_MICROVM_MACHINE)
68 #define MICROVM_MACHINE_CLASS(class) \
69     OBJECT_CLASS_CHECK(MicrovmMachineClass, class, TYPE_MICROVM_MACHINE)
70 
71 #endif
72