VirtualBox

source: vbox/trunk/src/VBox/Main/include/SystemTableBuilder.h

Last change on this file was 108742, checked in by vboxsync, 2 weeks ago

Main: bugref:10877 Added ACPI MADT table entry for the GIC ITS and allow configuring it for the VM from ConsoleImpl.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.1 KB
Line 
1/* $Id: SystemTableBuilder.h 108742 2025-03-26 06:42:04Z 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
41typedef enum SYSTEMTABLETYPE
42{
43 kSystemTableType_Invalid = 0,
44 kSystemTableType_Acpi,
45 kSystemTableType_Fdt
46} SYSTEMTABLETYPE;
47
48class SystemTableBuilder
49{
50public:
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,
64 RTGCPHYS cbMmioIntcReDist, RTGCPHYS GCPhysIntcIts, RTGCPHYS cbMmioIntcIts);
65 virtual int configureClock(void);
66 virtual int configurePcieRootBus(const char *pszVBoxName, uint32_t aPinIrqs[4], RTGCPHYS GCPhysMmioPio, RTGCPHYS GCPhysMmioEcam, size_t cbPciMmioEcam,
67 RTGCPHYS GCPhysPciMmioBase, RTGCPHYS cbPciMmio, RTGCPHYS GCPhysPciMmio32Base, RTGCPHYS cbPciMmio32);
68 virtual int configureTpm2(bool fCrb, RTGCPHYS GCPhysMmioStart, RTGCPHYS cbMmio, uint32_t u32Irq);
69 virtual int configureGpioDevice(const char *pszVBoxName, uint32_t uInstance, RTGCPHYS GCPhysMmio, RTGCPHYS cbMmio, uint32_t u32Irq,
70 uint16_t u16PinShutdown, uint16_t u16PinSuspend);
71
72 virtual int dumpTables(const char *pszFilename);
73};
74
75
76class SystemTableBuilderAcpi: public SystemTableBuilder
77{
78public:
79 SystemTableBuilderAcpi() { };
80 ~SystemTableBuilderAcpi() { };
81
82 int initInstance(void);
83 int finishTables(RTGCPHYS GCPhysTblsStart, RTVFSIOSTREAM hVfsIos, PRTGCPHYS pGCPhysTblRoot, size_t *pcbTblRoot, size_t *pcbTbls);
84
85 int addCpu(uint32_t idCpu);
86 int addMemory(RTGCPHYS GCPhysStart, RTGCPHYS cbMem);
87 int addMmioDeviceNoIrq(const char *pszVBoxName, uint32_t uInstance, RTGCPHYS GCPhysMmio, RTGCPHYS cbMmio);
88 int addMmioDevice(const char *pszVBoxName, uint32_t uInstance, RTGCPHYS GCPhysMmio, RTGCPHYS cbMmio, uint32_t u32Irq);
89 int configureGic(uint32_t cCpus, RTGCPHYS GCPhysIntcDist, RTGCPHYS cbMmioIntcDist, RTGCPHYS GCPhysIntcReDist,
90 RTGCPHYS cbMmioIntcReDist, RTGCPHYS GCPhysIntcIts, RTGCPHYS cbMmioIntcIts);
91 int configureClock(void);
92 int configurePcieRootBus(const char *pszVBoxName, uint32_t aPinIrqs[4], RTGCPHYS GCPhysMmioPio, RTGCPHYS GCPhysMmioEcam, size_t cbPciMmioEcam,
93 RTGCPHYS GCPhysPciMmioBase, RTGCPHYS cbPciMmio, RTGCPHYS GCPhysPciMmio32Base, RTGCPHYS cbPciMmio32);
94 int configureTpm2(bool fCrb, RTGCPHYS GCPhysMmioStart, RTGCPHYS cbMmio, uint32_t u32Irq);
95 int configureGpioDevice(const char *pszVBoxName, uint32_t uInstance, RTGCPHYS GCPhysMmio, RTGCPHYS cbMmio, uint32_t u32Irq,
96 uint16_t u16PinShutdown, uint16_t u16PinSuspend);
97
98 int dumpTables(const char *pszFilename);
99
100private:
101 int buildMadt(RTVFSIOSTREAM hVfsIos, size_t *pcbMadt);
102 int buildMcfg(RTVFSIOSTREAM hVfsIos, size_t *pcbMcfg);
103 int buildGtdt(RTVFSIOSTREAM hVfsIos, size_t *pcbGtdt);
104 int buildFadt(RTVFSIOSTREAM hVfsIos, RTGCPHYS GCPhysXDsdt, size_t *pcbFadt);
105 int buildTpm20(RTVFSIOSTREAM hVfsIos, size_t *pcbTpm20);
106
107 RTACPITBL m_hAcpiDsdt;
108 RTACPIRES m_hAcpiRes;
109
110 uint32_t m_cCpus;
111 RTGCPHYS m_GCPhysIntcDist;
112 RTGCPHYS m_cbMmioIntcDist;
113 RTGCPHYS m_GCPhysIntcReDist;
114 RTGCPHYS m_cbMmioIntcReDist;
115 RTGCPHYS m_GCPhysIntcIts;
116 RTGCPHYS m_cbMmioIntcIts;
117
118 RTGCPHYS m_GCPhysPciMmioEcam;
119 uint8_t m_bPciBusMax;
120
121 bool m_fTpm20;
122 bool m_fCrb;
123 RTGCPHYS m_GCPhysTpm20Mmio;
124};
125
126#endif /* !MAIN_INCLUDED_SystemTableBuilder_h */
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette