xref: /openbmc/qemu/include/hw/xen/xen-pvh-common.h (revision cb988a10)
1258b2a40SEdgar E. Iglesias /*
2258b2a40SEdgar E. Iglesias  * QEMU Xen PVH machine - common code.
3258b2a40SEdgar E. Iglesias  *
4258b2a40SEdgar E. Iglesias  * Copyright (c) 2024 Advanced Micro Devices, Inc.
5258b2a40SEdgar E. Iglesias  *
6258b2a40SEdgar E. Iglesias  * SPDX-License-Identifier: GPL-2.0-or-later
7258b2a40SEdgar E. Iglesias  */
8258b2a40SEdgar E. Iglesias 
9258b2a40SEdgar E. Iglesias #ifndef XEN_PVH_COMMON_H__
10258b2a40SEdgar E. Iglesias #define XEN_PVH_COMMON_H__
11258b2a40SEdgar E. Iglesias 
12258b2a40SEdgar E. Iglesias #include <assert.h>
13258b2a40SEdgar E. Iglesias #include "hw/sysbus.h"
14258b2a40SEdgar E. Iglesias #include "hw/hw.h"
15258b2a40SEdgar E. Iglesias #include "hw/xen/xen-hvm-common.h"
16258b2a40SEdgar E. Iglesias #include "hw/pci-host/gpex.h"
17258b2a40SEdgar E. Iglesias 
18258b2a40SEdgar E. Iglesias #define TYPE_XEN_PVH_MACHINE MACHINE_TYPE_NAME("xen-pvh-base")
19258b2a40SEdgar E. Iglesias OBJECT_DECLARE_TYPE(XenPVHMachineState, XenPVHMachineClass,
20258b2a40SEdgar E. Iglesias                     XEN_PVH_MACHINE)
21258b2a40SEdgar E. Iglesias 
22258b2a40SEdgar E. Iglesias struct XenPVHMachineClass {
23258b2a40SEdgar E. Iglesias     MachineClass parent;
24258b2a40SEdgar E. Iglesias 
25258b2a40SEdgar E. Iglesias     /* PVH implementation specific init.  */
26258b2a40SEdgar E. Iglesias     void (*init)(MachineState *state);
27258b2a40SEdgar E. Iglesias 
28258b2a40SEdgar E. Iglesias     /*
29f22e598aSEdgar E. Iglesias      * set_pci_intx_irq - Deliver INTX irqs to the guest.
30f22e598aSEdgar E. Iglesias      *
31f22e598aSEdgar E. Iglesias      * @opaque: pointer to XenPVHMachineState.
32f22e598aSEdgar E. Iglesias      * @irq: IRQ after swizzling, between 0-3.
33f22e598aSEdgar E. Iglesias      * @level: IRQ level.
34f22e598aSEdgar E. Iglesias      */
35f22e598aSEdgar E. Iglesias     void (*set_pci_intx_irq)(void *opaque, int irq, int level);
36f22e598aSEdgar E. Iglesias 
37f22e598aSEdgar E. Iglesias     /*
38f22e598aSEdgar E. Iglesias      * set_pci_link_route: - optional implementation call to setup
39f22e598aSEdgar E. Iglesias      * routing between INTX IRQ (0 - 3) and GSI's.
40f22e598aSEdgar E. Iglesias      *
41f22e598aSEdgar E. Iglesias      * @line: line the INTx line (0 => A .. 3 => B)
42f22e598aSEdgar E. Iglesias      * @irq: GSI
43f22e598aSEdgar E. Iglesias      */
44f22e598aSEdgar E. Iglesias     int (*set_pci_link_route)(uint8_t line, uint8_t irq);
45f22e598aSEdgar E. Iglesias 
46*cb988a10SEdgar E. Iglesias     /* Allow implementations to optionally enable buffered ioreqs.  */
47*cb988a10SEdgar E. Iglesias     uint8_t handle_bufioreq;
48*cb988a10SEdgar E. Iglesias 
49f22e598aSEdgar E. Iglesias     /*
50258b2a40SEdgar E. Iglesias      * Each implementation can optionally enable features that it
51258b2a40SEdgar E. Iglesias      * supports and are known to work.
52258b2a40SEdgar E. Iglesias      */
53f22e598aSEdgar E. Iglesias     bool has_pci;
54258b2a40SEdgar E. Iglesias     bool has_tpm;
55258b2a40SEdgar E. Iglesias     bool has_virtio_mmio;
56258b2a40SEdgar E. Iglesias };
57258b2a40SEdgar E. Iglesias 
58258b2a40SEdgar E. Iglesias struct XenPVHMachineState {
59258b2a40SEdgar E. Iglesias     /*< private >*/
60258b2a40SEdgar E. Iglesias     MachineState parent;
61258b2a40SEdgar E. Iglesias 
62258b2a40SEdgar E. Iglesias     XenIOState ioreq;
63258b2a40SEdgar E. Iglesias 
64258b2a40SEdgar E. Iglesias     struct {
65258b2a40SEdgar E. Iglesias         MemoryRegion low;
66258b2a40SEdgar E. Iglesias         MemoryRegion high;
67258b2a40SEdgar E. Iglesias     } ram;
68258b2a40SEdgar E. Iglesias 
69258b2a40SEdgar E. Iglesias     struct {
70f22e598aSEdgar E. Iglesias         GPEXHost gpex;
71f22e598aSEdgar E. Iglesias         MemoryRegion mmio_alias;
72f22e598aSEdgar E. Iglesias         MemoryRegion mmio_high_alias;
73f22e598aSEdgar E. Iglesias     } pci;
74f22e598aSEdgar E. Iglesias 
75f22e598aSEdgar E. Iglesias     struct {
76258b2a40SEdgar E. Iglesias         MemMapEntry ram_low, ram_high;
77258b2a40SEdgar E. Iglesias         MemMapEntry tpm;
78258b2a40SEdgar E. Iglesias 
79258b2a40SEdgar E. Iglesias         /* Virtio-mmio */
80258b2a40SEdgar E. Iglesias         MemMapEntry virtio_mmio;
81258b2a40SEdgar E. Iglesias         uint32_t virtio_mmio_num;
82258b2a40SEdgar E. Iglesias         uint32_t virtio_mmio_irq_base;
83f22e598aSEdgar E. Iglesias 
84f22e598aSEdgar E. Iglesias         /* PCI */
85f22e598aSEdgar E. Iglesias         MemMapEntry pci_ecam, pci_mmio, pci_mmio_high;
86f22e598aSEdgar E. Iglesias         uint32_t pci_intx_irq_base;
87258b2a40SEdgar E. Iglesias     } cfg;
88258b2a40SEdgar E. Iglesias };
89258b2a40SEdgar E. Iglesias 
90258b2a40SEdgar E. Iglesias void xen_pvh_class_setup_common_props(XenPVHMachineClass *xpc);
91258b2a40SEdgar E. Iglesias #endif
92