1 | /* $Id: SystemTableBuilder.h 106356 2024-10-16 11:44:53Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBox system tables builder.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2024 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 | #ifndef MAIN_INCLUDED_SystemTableBuilder_h
|
---|
29 | #define MAIN_INCLUDED_SystemTableBuilder_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | #include <iprt/types.h>
|
---|
35 | #include <iprt/acpi.h>
|
---|
36 | #include <iprt/vfs.h>
|
---|
37 |
|
---|
38 | #include <iprt/formats/acpi-tables.h>
|
---|
39 |
|
---|
40 |
|
---|
41 | typedef enum SYSTEMTABLETYPE
|
---|
42 | {
|
---|
43 | kSystemTableType_Invalid = 0,
|
---|
44 | kSystemTableType_Acpi,
|
---|
45 | kSystemTableType_Fdt
|
---|
46 | } SYSTEMTABLETYPE;
|
---|
47 |
|
---|
48 | class SystemTableBuilder
|
---|
49 | {
|
---|
50 | public:
|
---|
51 | static SystemTableBuilder *createInstance(SYSTEMTABLETYPE enmTableType);
|
---|
52 |
|
---|
53 | virtual ~SystemTableBuilder() { };
|
---|
54 | SystemTableBuilder() { };
|
---|
55 |
|
---|
56 | virtual int initInstance(void);
|
---|
57 | virtual int finishTables(RTGCPHYS GCPhysTblsStart, RTVFSIOSTREAM hVfsIos, PRTGCPHYS pGCPhysTblRoot, size_t *pcbTblRoot, size_t *pcbTbls);
|
---|
58 |
|
---|
59 | virtual int addCpu(uint32_t idCpu);
|
---|
60 | virtual int addMemory(RTGCPHYS GCPhysStart, RTGCPHYS cbMem);
|
---|
61 | virtual int addMmioDeviceNoIrq(const char *pszVBoxName, uint32_t uInstance, RTGCPHYS GCPhysMmio, RTGCPHYS cbMmio);
|
---|
62 | virtual int addMmioDevice(const char *pszVBoxName, uint32_t uInstance, RTGCPHYS GCPhysMmio, RTGCPHYS cbMmio, uint32_t u32Irq);
|
---|
63 | virtual int configureGic(uint32_t cCpus, RTGCPHYS GCPhysIntcDist, RTGCPHYS cbMmioIntcDist, RTGCPHYS GCPhysIntcReDist, RTGCPHYS cbMmioIntcReDist);
|
---|
64 | virtual int configureClock(void);
|
---|
65 | virtual int configurePcieRootBus(const char *pszVBoxName, uint32_t aPinIrqs[4], RTGCPHYS GCPhysMmioPio, RTGCPHYS GCPhysMmioEcam, size_t cbPciMmioEcam,
|
---|
66 | RTGCPHYS GCPhysPciMmioBase, RTGCPHYS cbPciMmio, RTGCPHYS GCPhysPciMmio32Base, RTGCPHYS cbPciMmio32);
|
---|
67 | virtual int configureTpm2(bool fCrb, RTGCPHYS GCPhysMmioStart, RTGCPHYS cbMmio, uint32_t u32Irq);
|
---|
68 |
|
---|
69 |
|
---|
70 | virtual int dumpTables(const char *pszFilename);
|
---|
71 | };
|
---|
72 |
|
---|
73 |
|
---|
74 | class SystemTableBuilderAcpi: public SystemTableBuilder
|
---|
75 | {
|
---|
76 | public:
|
---|
77 | SystemTableBuilderAcpi() { };
|
---|
78 | ~SystemTableBuilderAcpi() { };
|
---|
79 |
|
---|
80 | int initInstance(void);
|
---|
81 | int finishTables(RTGCPHYS GCPhysTblsStart, RTVFSIOSTREAM hVfsIos, PRTGCPHYS pGCPhysTblRoot, size_t *pcbTblRoot, size_t *pcbTbls);
|
---|
82 |
|
---|
83 | int addCpu(uint32_t idCpu);
|
---|
84 | int addMemory(RTGCPHYS GCPhysStart, RTGCPHYS cbMem);
|
---|
85 | int addMmioDeviceNoIrq(const char *pszVBoxName, uint32_t uInstance, RTGCPHYS GCPhysMmio, RTGCPHYS cbMmio);
|
---|
86 | int addMmioDevice(const char *pszVBoxName, uint32_t uInstance, RTGCPHYS GCPhysMmio, RTGCPHYS cbMmio, uint32_t u32Irq);
|
---|
87 | int configureGic(uint32_t cCpus, RTGCPHYS GCPhysIntcDist, RTGCPHYS cbMmioIntcDist, RTGCPHYS GCPhysIntcReDist, RTGCPHYS cbMmioIntcReDist);
|
---|
88 | int configureClock(void);
|
---|
89 | int configurePcieRootBus(const char *pszVBoxName, uint32_t aPinIrqs[4], RTGCPHYS GCPhysMmioPio, RTGCPHYS GCPhysMmioEcam, size_t cbPciMmioEcam,
|
---|
90 | RTGCPHYS GCPhysPciMmioBase, RTGCPHYS cbPciMmio, RTGCPHYS GCPhysPciMmio32Base, RTGCPHYS cbPciMmio32);
|
---|
91 | int configureTpm2(bool fCrb, RTGCPHYS GCPhysMmioStart, RTGCPHYS cbMmio, uint32_t u32Irq);
|
---|
92 |
|
---|
93 | int dumpTables(const char *pszFilename);
|
---|
94 |
|
---|
95 | private:
|
---|
96 | int buildMadt(RTVFSIOSTREAM hVfsIos, size_t *pcbMadt);
|
---|
97 | int buildMcfg(RTVFSIOSTREAM hVfsIos, size_t *pcbMcfg);
|
---|
98 | int buildGtdt(RTVFSIOSTREAM hVfsIos, size_t *pcbGtdt);
|
---|
99 | int buildFadt(RTVFSIOSTREAM hVfsIos, RTGCPHYS GCPhysXDsdt, size_t *pcbFadt);
|
---|
100 | int buildTpm20(RTVFSIOSTREAM hVfsIos, size_t *pcbTpm20);
|
---|
101 |
|
---|
102 | RTACPITBL m_hAcpiDsdt;
|
---|
103 | RTACPIRES m_hAcpiRes;
|
---|
104 |
|
---|
105 | uint32_t m_cCpus;
|
---|
106 | RTGCPHYS m_GCPhysIntcDist;
|
---|
107 | RTGCPHYS m_cbMmioIntcDist;
|
---|
108 | RTGCPHYS m_GCPhysIntcReDist;
|
---|
109 | RTGCPHYS m_cbMmioIntcReDist;
|
---|
110 |
|
---|
111 | RTGCPHYS m_GCPhysPciMmioEcam;
|
---|
112 |
|
---|
113 | bool m_fTpm20;
|
---|
114 | bool m_fCrb;
|
---|
115 | RTGCPHYS m_GCPhysTpm20Mmio;
|
---|
116 | };
|
---|
117 |
|
---|
118 | #endif /* !MAIN_INCLUDED_SystemTableBuilder_h */
|
---|