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