1 | /* $Id: GITSInternal.h 109010 2025-04-17 09:10:49Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * GITS - Generic Interrupt Controller Interrupt Translation Service - Internal.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2025 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 VMM_INCLUDED_SRC_include_GITSInternal_h
|
---|
29 | #define VMM_INCLUDED_SRC_include_GITSInternal_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | #include <iprt/cdefs.h>
|
---|
35 | #include <VBox/types.h>
|
---|
36 | #include <VBox/gic-its.h>
|
---|
37 | #include <VBox/vmm/pdmthread.h>
|
---|
38 | #include <VBox/vmm/stam.h>
|
---|
39 |
|
---|
40 | /** @defgroup grp_gits_int Internal
|
---|
41 | * @ingroup grp_gits
|
---|
42 | * @internal
|
---|
43 | * @{
|
---|
44 | */
|
---|
45 |
|
---|
46 | /** @name GITS Device Table Entry (DTE).
|
---|
47 | * @{ */
|
---|
48 | #define GITS_BF_DTE_ITT_RANGE_SHIFT 0
|
---|
49 | #define GITS_BF_DTE_ITT_RANGE_MASK UINT64_C(0x000000000000000f)
|
---|
50 | #define GITS_BF_DTE_RSVD_11_4_SHIFT 4
|
---|
51 | #define GITS_BF_DTE_RSVD_11_4_MASK UINT64_C(0x0000000000000ff0)
|
---|
52 | #define GITS_BF_DTE_ITT_ADDR_SHIFT 12
|
---|
53 | #define GITS_BF_DTE_ITT_ADDR_MASK UINT64_C(0x000ffffffffff000)
|
---|
54 | #define GITS_BF_DTE_RSVD_62_52_SHIFT 52
|
---|
55 | #define GITS_BF_DTE_RSVD_62_52_MASK UINT64_C(0x7ff0000000000000)
|
---|
56 | #define GITS_BF_DTE_VALID_SHIFT 63
|
---|
57 | #define GITS_BF_DTE_VALID_MASK UINT64_C(0x8000000000000000)
|
---|
58 | RT_BF_ASSERT_COMPILE_CHECKS(GITS_BF_DTE_, UINT64_C(0), UINT64_MAX,
|
---|
59 | (ITT_RANGE, RSVD_11_4, ITT_ADDR, RSVD_62_52, VALID));
|
---|
60 | #define GITS_DTE_VALID_MASK (UINT64_MAX & ~(GITS_BF_DTE_RSVD_11_4_MASK | GITS_BF_DTE_RSVD_62_52_MASK));
|
---|
61 | /** GITS DTE: Size of the DTE in bytes. */
|
---|
62 | #define GITS_DTE_SIZE 8
|
---|
63 | /** @} */
|
---|
64 |
|
---|
65 | /** @name GITS Interrupt Translation Entry (ITE).
|
---|
66 | * @{ */
|
---|
67 | #define GITS_BF_ITE_ICID_SHIFT 0
|
---|
68 | #define GITS_BF_ITE_ICID_MASK UINT32_C(0x000000ff)
|
---|
69 | #define GITS_BF_ITE_INTID_SHIFT 8
|
---|
70 | #define GITS_BF_ITE_INTID_MASK UINT32_C(0x00ffff00)
|
---|
71 | #define GITS_BF_ITE_RSVD_30_24_SHIFT 24
|
---|
72 | #define GITS_BF_ITE_RSVD_30_24_MASK UINT32_C(0x7f000000)
|
---|
73 | #define GITS_BF_ITE_VALID_SHIFT 31
|
---|
74 | #define GITS_BF_ITE_VALID_MASK UINT32_C(0x80000000)
|
---|
75 | RT_BF_ASSERT_COMPILE_CHECKS(GITS_BF_ITE_, UINT32_C(0), UINT32_MAX,
|
---|
76 | (ICID, INTID, RSVD_30_24, VALID));
|
---|
77 | /** GITS ITE: Size of the ITE in bytes. */
|
---|
78 | #define GITS_ITE_SIZE 4
|
---|
79 | /** @} */
|
---|
80 |
|
---|
81 | /** @name GITS Collection Table Entry (CTE).
|
---|
82 | * @{ */
|
---|
83 | #define GITS_BF_CTE_RDBASE_SHIFT 0
|
---|
84 | #define GITS_BF_CTE_RDBASE_MASK UINT32_C(0x0000ffff)
|
---|
85 | #define GITS_BF_CTE_RSVD_30_16_SHIFT 16
|
---|
86 | #define GITS_BF_CTE_RSVD_30_16_MASK UINT32_C(0x7fff0000)
|
---|
87 | #define GITS_BF_CTE_VALID_SHIFT 31
|
---|
88 | #define GITS_BF_CTE_VALID_MASK UINT32_C(0x80000000)
|
---|
89 | RT_BF_ASSERT_COMPILE_CHECKS(GITS_BF_CTE_, UINT32_C(0), UINT32_MAX,
|
---|
90 | (RDBASE, RSVD_30_16, VALID));
|
---|
91 | /** GITS CTE: Size of the CTE in bytes. */
|
---|
92 | #define GITS_CTE_SIZE 4
|
---|
93 | /** @} */
|
---|
94 |
|
---|
95 | /**
|
---|
96 | * GITS error diagnostics.
|
---|
97 | * Sorted alphabetically so it's easier to add and locate items, no other reason.
|
---|
98 | *
|
---|
99 | * @note Members of this enum are used as array indices, so no gaps in enum values
|
---|
100 | * are not allowed. Update g_apszGitsDiagDesc when you modify fields in this
|
---|
101 | * enum.
|
---|
102 | */
|
---|
103 | typedef enum GITSDIAG
|
---|
104 | {
|
---|
105 | /* No error, this must be zero! */
|
---|
106 | kGitsDiag_None = 0,
|
---|
107 |
|
---|
108 | /* Command queue: basic operation errors. */
|
---|
109 | kGitsDiag_CmdQueue_Basic_Unknown_Cmd,
|
---|
110 | kGitsDiag_CmdQueue_Basic_Invalid_PhysAddr,
|
---|
111 |
|
---|
112 | /* Command queue: command errors. */
|
---|
113 | kGitsDiag_CmdQueue_Cmd_Mapc_Icid_Overflow,
|
---|
114 |
|
---|
115 | /* Member for determining array index limit. */
|
---|
116 | kGitsDiag_End,
|
---|
117 |
|
---|
118 | /* Usual 32-bit hack. */
|
---|
119 | kGitsDiag_32Bit_Hack = 0x7fffffff
|
---|
120 | } GITSDIAG;
|
---|
121 | AssertCompileSize(GITSDIAG, 4);
|
---|
122 |
|
---|
123 | /**
|
---|
124 | * The GIC Interrupt Translation Service device state.
|
---|
125 | */
|
---|
126 | typedef struct GITSDEV
|
---|
127 | {
|
---|
128 | /** @name Control registers.
|
---|
129 | * @{ */
|
---|
130 | /** The ITS control register (GITS_CTLR). */
|
---|
131 | uint32_t uCtrlReg;
|
---|
132 | /** Implmentation-specific error diagnostic. */
|
---|
133 | GITSDIAG enmDiag;
|
---|
134 | /** The ITS type register (GITS_TYPER). */
|
---|
135 | RTUINT64U uTypeReg;
|
---|
136 | /** The ITS table descriptor registers (GITS_BASER<n>). */
|
---|
137 | RTUINT64U aItsTableRegs[8];
|
---|
138 | /** The ITS command queue base registers (GITS_CBASER). */
|
---|
139 | RTUINT64U uCmdBaseReg;
|
---|
140 | /** The ITS command read register (GITS_CREADR). */
|
---|
141 | uint32_t uCmdReadReg;
|
---|
142 | /** The ITS command write register (GITS_CWRITER). */
|
---|
143 | uint32_t uCmdWriteReg;
|
---|
144 | /** @} */
|
---|
145 |
|
---|
146 | /** @name Interrupt translation space.
|
---|
147 | * @{ */
|
---|
148 | /** @} */
|
---|
149 |
|
---|
150 | /** @name Command queue.
|
---|
151 | * @{ */
|
---|
152 | /** The command-queue thread. */
|
---|
153 | R3PTRTYPE(PPDMTHREAD) pCmdQueueThread;
|
---|
154 | /** The event semaphore the command-queue thread waits on. */
|
---|
155 | SUPSEMEVENT hEvtCmdQueue;
|
---|
156 | /** Number of errors while processing commands (resets on VM reset). */
|
---|
157 | uint64_t cCmdQueueErrors;
|
---|
158 | /** @} */
|
---|
159 |
|
---|
160 | /** @name Tables.
|
---|
161 | * @{
|
---|
162 | */
|
---|
163 | /** The collection table. */
|
---|
164 | uint32_t auCtes[255];
|
---|
165 | /** Padding. */
|
---|
166 | uint32_t auPadding0;
|
---|
167 | /** @} */
|
---|
168 |
|
---|
169 | /** @name Configurables.
|
---|
170 | * @{ */
|
---|
171 | /** The ITS architecture (GITS_PIDR2.ArchRev). */
|
---|
172 | uint8_t uArchRev;
|
---|
173 | /** Padding. */
|
---|
174 | uint8_t afPadding0[7];
|
---|
175 | /** @} */
|
---|
176 |
|
---|
177 | /** @name Statistics.
|
---|
178 | * @{ */
|
---|
179 | #ifdef VBOX_WITH_STATISTICS
|
---|
180 | STAMCOUNTER StatCmdMapc;
|
---|
181 | STAMCOUNTER StatCmdSync;
|
---|
182 | STAMCOUNTER StatCmdInvall;
|
---|
183 | #endif
|
---|
184 | /** @} */
|
---|
185 | } GITSDEV;
|
---|
186 | /** Pointer to a GITS device. */
|
---|
187 | typedef GITSDEV *PGITSDEV;
|
---|
188 | /** Pointer to a const GITS device. */
|
---|
189 | typedef GITSDEV const *PCGITSDEV;
|
---|
190 | AssertCompileSizeAlignment(GITSDEV, 8);
|
---|
191 | AssertCompileMemberAlignment(GITSDEV, aItsTableRegs, 8);
|
---|
192 | AssertCompileMemberAlignment(GITSDEV, uCmdReadReg, 4);
|
---|
193 | AssertCompileMemberAlignment(GITSDEV, uCmdWriteReg, 4);
|
---|
194 | AssertCompileMemberAlignment(GITSDEV, hEvtCmdQueue, 8);
|
---|
195 | AssertCompileMemberAlignment(GITSDEV, auCtes, 8);
|
---|
196 | AssertCompileMemberAlignment(GITSDEV, uArchRev, 8);
|
---|
197 | AssertCompileMemberSize(GITSDEV, auCtes, RT_ELEMENTS(GITSDEV::auCtes) * GITS_CTE_SIZE);
|
---|
198 |
|
---|
199 | DECL_HIDDEN_CALLBACK(void) gitsInit(PGITSDEV pGitsDev);
|
---|
200 | DECL_HIDDEN_CALLBACK(int) gitsSendMsi(PVMCC pVM, PCIBDF uBusDevFn, PCMSIMSG pMsi, uint32_t uEventId, uint32_t uTagSrc);
|
---|
201 | DECL_HIDDEN_CALLBACK(uint64_t) gitsMmioReadCtrl(PCGITSDEV pGitsDev, uint16_t offReg, unsigned cb);
|
---|
202 | DECL_HIDDEN_CALLBACK(uint64_t) gitsMmioReadTranslate(PCGITSDEV pGitsDev, uint16_t offReg, unsigned cb);
|
---|
203 | DECL_HIDDEN_CALLBACK(void) gitsMmioWriteCtrl(PPDMDEVINS pDevIns, PGITSDEV pGitsDev, uint16_t offReg, uint64_t uValue, unsigned cb);
|
---|
204 | DECL_HIDDEN_CALLBACK(void) gitsMmioWriteTranslate(PGITSDEV pGitsDev, uint16_t offReg, uint64_t uValue, unsigned cb);
|
---|
205 |
|
---|
206 | #ifdef IN_RING3
|
---|
207 | DECL_HIDDEN_CALLBACK(void) gitsR3DbgInfo(PCGITSDEV pGitsDev, PCDBGFINFOHLP pHlp);
|
---|
208 | DECL_HIDDEN_CALLBACK(int) gitsR3CmdQueueProcess(PPDMDEVINS pDevIns, PGITSDEV pGitsDev, void *pvBuf, uint32_t cbBuf);
|
---|
209 | #endif
|
---|
210 |
|
---|
211 | #ifdef LOG_ENABLED
|
---|
212 | DECL_HIDDEN_CALLBACK(const char *) gitsGetCtrlRegDescription(uint16_t offReg);
|
---|
213 | DECL_HIDDEN_CALLBACK(const char *) gitsGetTranslationRegDescription(uint16_t offReg);
|
---|
214 | #endif
|
---|
215 |
|
---|
216 | /** @} */
|
---|
217 |
|
---|
218 | #endif /* !VMM_INCLUDED_SRC_include_GITSInternal_h */
|
---|
219 |
|
---|