1 | /** @file
|
---|
2 | * IPRT - Advanced Configuration and Power Interface (ACPI) Table generation API.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2024 Oracle and/or its affiliates.
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox base platform packages, as
|
---|
9 | * available from https://www.virtualbox.org.
|
---|
10 | *
|
---|
11 | * This program is free software; you can redistribute it and/or
|
---|
12 | * modify it under the terms of the GNU General Public License
|
---|
13 | * as published by the Free Software Foundation, in version 3 of the
|
---|
14 | * License.
|
---|
15 | *
|
---|
16 | * This program is distributed in the hope that it will be useful, but
|
---|
17 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
19 | * General Public License for more details.
|
---|
20 | *
|
---|
21 | * You should have received a copy of the GNU General Public License
|
---|
22 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
23 | *
|
---|
24 | * The contents of this file may alternatively be used under the terms
|
---|
25 | * of the Common Development and Distribution License Version 1.0
|
---|
26 | * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
27 | * in the VirtualBox distribution, in which case the provisions of the
|
---|
28 | * CDDL are applicable instead of those of the GPL.
|
---|
29 | *
|
---|
30 | * You may elect to license modified versions of this file under the
|
---|
31 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
32 | *
|
---|
33 | * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
34 | */
|
---|
35 |
|
---|
36 | #ifndef IPRT_INCLUDED_acpi_h
|
---|
37 | #define IPRT_INCLUDED_acpi_h
|
---|
38 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
39 | # pragma once
|
---|
40 | #endif
|
---|
41 |
|
---|
42 | #include <iprt/cdefs.h>
|
---|
43 | #include <iprt/types.h>
|
---|
44 | #include <iprt/vfs.h>
|
---|
45 |
|
---|
46 | #include <iprt/formats/acpi-tables.h>
|
---|
47 |
|
---|
48 |
|
---|
49 | RT_C_DECLS_BEGIN
|
---|
50 |
|
---|
51 | /** @defgroup grp_rt_acpi RTAcpi - Advanced Configuration and Power Interface (ACPI) Table generation API.
|
---|
52 | * @ingroup grp_rt
|
---|
53 | * @{
|
---|
54 | */
|
---|
55 |
|
---|
56 | #ifdef IN_RING3
|
---|
57 |
|
---|
58 |
|
---|
59 | /**
|
---|
60 | * Regenerates the ACPI checksum for the given data.
|
---|
61 | *
|
---|
62 | * @returns The checksum for the given data.
|
---|
63 | * @param pvData The data to check sum.
|
---|
64 | * @param cbData Number of bytes to check sum.
|
---|
65 | */
|
---|
66 | RTDECL(uint8_t) RTAcpiChecksumGenerate(const void *pvData, size_t cbData);
|
---|
67 |
|
---|
68 |
|
---|
69 | /**
|
---|
70 | * Generates and writes the table header checksum for the given ACPI table.
|
---|
71 | *
|
---|
72 | * @param pTbl Pointer to the ACPI table to set the checksum for.
|
---|
73 | * @param cbTbl Size of the table in bytes, including the ACPI table header.
|
---|
74 | */
|
---|
75 | RTDECL(void) RTAcpiTblHdrChecksumGenerate(PACPITBLHDR pTbl, size_t cbTbl);
|
---|
76 |
|
---|
77 |
|
---|
78 | /**
|
---|
79 | * Creates a new empty ACPI table.
|
---|
80 | *
|
---|
81 | * @returns IPRT status code.
|
---|
82 | * @param phAcpiTbl Where to store the ACPI table handle on success.
|
---|
83 | * @param u32TblSig The signature of the table to use.
|
---|
84 | * @param bRevision The revision of the table.
|
---|
85 | * @param pszOemId The OEM supplied string identifiying the OEM, maximum of 6 characters.
|
---|
86 | * @param pszOemTblId The OEM supplied string identifiying the OEM table, maximum of 8 characters.
|
---|
87 | * @param u32OemRevision The OEM supplied revision number.
|
---|
88 | * @param pszCreatorId Vendor ID of the utility that created the table, maximum of 4 characters.
|
---|
89 | * @param u32CreatorRevision Revision of the utility that created the table.
|
---|
90 | */
|
---|
91 | RTDECL(int) RTAcpiTblCreate(PRTACPITBL phAcpiTbl, uint32_t u32TblSig, uint8_t bRevision, const char *pszOemId,
|
---|
92 | const char *pszOemTblId, uint32_t u32OemRevision, const char *pszCreatorId,
|
---|
93 | uint32_t u32CreatorRevision);
|
---|
94 |
|
---|
95 |
|
---|
96 | /**
|
---|
97 | * Destroys the given ACPI table, freeing all resources.
|
---|
98 | *
|
---|
99 | * @param hAcpiTbl The ACPI table handle to destroy.
|
---|
100 | */
|
---|
101 | RTDECL(void) RTAcpiTblDestroy(RTACPITBL hAcpiTbl);
|
---|
102 |
|
---|
103 |
|
---|
104 | /**
|
---|
105 | * Finalizes the given ACPI table, setting the header and generating checksums.
|
---|
106 | *
|
---|
107 | * @returns IPRT status code.
|
---|
108 | * @param hAcpiTbl The ACPI table handle to finalize.
|
---|
109 | *
|
---|
110 | * @note Nothing can be added to the table after this was called.
|
---|
111 | */
|
---|
112 | RTDECL(int) RTAcpiTblFinalize(RTACPITBL hAcpiTbl);
|
---|
113 |
|
---|
114 |
|
---|
115 | /**
|
---|
116 | * Returns the size of the given ACPI table.
|
---|
117 | *
|
---|
118 | * @returns Size of the given ACPI table in bytes, 0 on error.
|
---|
119 | * @param hAcpiTbl The ACPI table handle.
|
---|
120 | *
|
---|
121 | * @note This can only be called after RTAcpiTblFinalize() was called successfully.
|
---|
122 | */
|
---|
123 | RTDECL(uint32_t) RTAcpiTblGetSize(RTACPITBL hAcpiTbl);
|
---|
124 |
|
---|
125 |
|
---|
126 | /**
|
---|
127 | * Dumps the given ACPI table to the given VFS I/O stream.
|
---|
128 | *
|
---|
129 | * @returns IPRT status code.
|
---|
130 | * @param hAcpiTbl The ACPI table handle.
|
---|
131 | * @param hVfsIos The VFS I/O stream handle to dump the table to.
|
---|
132 | */
|
---|
133 | RTDECL(int) RTAcpiTblDumpToVfsIoStrm(RTACPITBL hAcpiTbl, RTVFSIOSTREAM hVfsIos);
|
---|
134 |
|
---|
135 |
|
---|
136 | /**
|
---|
137 | * Dumps the given ACPI table to the given file.
|
---|
138 | *
|
---|
139 | * @returns IPRT status code.
|
---|
140 | * @param hAcpiTbl The ACPI table handle.
|
---|
141 | * @param pszFilename The file path to dump the table to.
|
---|
142 | */
|
---|
143 | RTDECL(int) RTAcpiTblDumpToFile(RTACPITBL hAcpiTbl, const char *pszFilename);
|
---|
144 |
|
---|
145 |
|
---|
146 | /**
|
---|
147 | * Starts a new DefScope object.
|
---|
148 | *
|
---|
149 | * @returns IPRT status code.
|
---|
150 | * @param hAcpiTbl The ACPI table handle.
|
---|
151 | * @param pszName Name of the scope, can have a root (\) specifier optionally.
|
---|
152 | */
|
---|
153 | RTDECL(int) RTAcpiTblScopeStart(RTACPITBL hAcpiTbl, const char *pszName);
|
---|
154 |
|
---|
155 |
|
---|
156 | /**
|
---|
157 | * Finalizes the current scope object, nothing can be added to the scope afterwards.
|
---|
158 | *
|
---|
159 | * @returns IPRT status code.
|
---|
160 | * @param hAcpiTbl The ACPI table handle.
|
---|
161 | */
|
---|
162 | RTDECL(int) RTAcpiTblScopeFinalize(RTACPITBL hAcpiTbl);
|
---|
163 |
|
---|
164 |
|
---|
165 | /**
|
---|
166 | * Starts a new DefPackage object.
|
---|
167 | *
|
---|
168 | * @returns IPRT status code.
|
---|
169 | * @param hAcpiTbl The ACPI table handle.
|
---|
170 | * @param cElements Number of element which will be inside the package,
|
---|
171 | * only supports up to 255 elements, use DefVarPackage if more is required.
|
---|
172 | */
|
---|
173 | RTDECL(int) RTAcpiTblPackageStart(RTACPITBL hAcpiTbl, uint8_t cElements);
|
---|
174 |
|
---|
175 |
|
---|
176 | /**
|
---|
177 | * Finalizes the current DefPackage object, and return to the enclosing object's scope.
|
---|
178 | *
|
---|
179 | * @returns IPRT status code.
|
---|
180 | * @param hAcpiTbl The ACPI table handle.
|
---|
181 | */
|
---|
182 | RTDECL(int) RTAcpiTblPackageFinalize(RTACPITBL hAcpiTbl);
|
---|
183 |
|
---|
184 |
|
---|
185 | /**
|
---|
186 | * Starts a new device object for the given ACPI table in the current scope.
|
---|
187 | *
|
---|
188 | * @returns IPRT status code.
|
---|
189 | * @param hAcpiTbl The ACPI table handle.
|
---|
190 | * @param pszName Name of the device object, must be <= 4 characters long.
|
---|
191 | */
|
---|
192 | RTDECL(int) RTAcpiTblDeviceStart(RTACPITBL hAcpiTbl, const char *pszName);
|
---|
193 |
|
---|
194 |
|
---|
195 | /**
|
---|
196 | * Starts a new device object for the given ACPI table in the current scope.
|
---|
197 | *
|
---|
198 | * @returns IPRT status code.
|
---|
199 | * @param hAcpiTbl The ACPI table handle.
|
---|
200 | * @param pszNameFmt The name of the device as a format string.
|
---|
201 | * @param ... The format arguments.
|
---|
202 | */
|
---|
203 | RTDECL(int) RTAcpiTblDeviceStartF(RTACPITBL hAcpiTbl, const char *pszNameFmt, ...) RT_IPRT_FORMAT_ATTR(2, 3);
|
---|
204 |
|
---|
205 |
|
---|
206 | /**
|
---|
207 | * Starts a new device object for the given ACPI table in the current scope.
|
---|
208 | *
|
---|
209 | * @returns IPRT status code.
|
---|
210 | * @param hAcpiTbl The ACPI table handle.
|
---|
211 | * @param pszNameFmt The name of the device as a format string.
|
---|
212 | * @param va The format arguments.
|
---|
213 | */
|
---|
214 | RTDECL(int) RTAcpiTblDeviceStartV(RTACPITBL hAcpiTbl, const char *pszNameFmt, va_list va) RT_IPRT_FORMAT_ATTR(2, 0);
|
---|
215 |
|
---|
216 |
|
---|
217 | /**
|
---|
218 | * Finalizes the current scope object, nothing can be added to the scope afterwards.
|
---|
219 | *
|
---|
220 | * @returns IPRT status code.
|
---|
221 | * @param hAcpiTbl The ACPI table handle.
|
---|
222 | */
|
---|
223 | RTDECL(int) RTAcpiTblDeviceFinalize(RTACPITBL hAcpiTbl);
|
---|
224 |
|
---|
225 |
|
---|
226 | /**
|
---|
227 | * Starts a new method object for the given ACPI table in the current scope.
|
---|
228 | *
|
---|
229 | * @returns IPRT status code.
|
---|
230 | * @param hAcpiTbl The ACPI table handle.
|
---|
231 | * @param pszName The method name.
|
---|
232 | * @param fFlags AML method flags, see RTACPI_METHOD_F_XXX.
|
---|
233 | * @param cArgs Number of arguments this method takes.
|
---|
234 | * @param uSyncLvl The sync level.
|
---|
235 | */
|
---|
236 | RTDECL(int) RTAcpiTblMethodStart(RTACPITBL hAcpiTbl, const char *pszName, uint8_t cArgs, uint32_t fFlags, uint8_t uSyncLvl);
|
---|
237 |
|
---|
238 |
|
---|
239 | /** ACPI method is not serialized. */
|
---|
240 | #define RTACPI_METHOD_F_NOT_SERIALIZED 0
|
---|
241 | /** ACPI method call needs to be serialized in the ACPI interpreter. */
|
---|
242 | #define RTACPI_METHOD_F_SERIALIZED RT_BIT_32(0)
|
---|
243 |
|
---|
244 |
|
---|
245 | /**
|
---|
246 | * Finalizes the current method object, nothing can be added to the method afterwards.
|
---|
247 | *
|
---|
248 | * @returns IPRT status code.
|
---|
249 | * @param hAcpiTbl The ACPI table handle.
|
---|
250 | */
|
---|
251 | RTDECL(int) RTAcpiTblMethodFinalize(RTACPITBL hAcpiTbl);
|
---|
252 |
|
---|
253 |
|
---|
254 | /**
|
---|
255 | * Appends a new DefName object (only the NameOp NameString part, DataRefObject is left for the caller
|
---|
256 | * to append).
|
---|
257 | *
|
---|
258 | * @returns IPRT status code.
|
---|
259 | * @param hAcpiTbl The ACPI table handle.
|
---|
260 | * @param pszName The name to append.
|
---|
261 | */
|
---|
262 | RTDECL(int) RTAcpiTblNameAppend(RTACPITBL hAcpiTbl, const char *pszName);
|
---|
263 |
|
---|
264 |
|
---|
265 | /**
|
---|
266 | * Appends a new String object.
|
---|
267 | *
|
---|
268 | * @returns IPRT status code.
|
---|
269 | * @param hAcpiTbl The ACPI table handle.
|
---|
270 | * @param psz The string to append.
|
---|
271 | */
|
---|
272 | RTDECL(int) RTAcpiTblStringAppend(RTACPITBL hAcpiTbl, const char *psz);
|
---|
273 |
|
---|
274 |
|
---|
275 | /**
|
---|
276 | * Appends a new integer object (depending on the value ZeroOp, OneOp,
|
---|
277 | * BytePrefix, WordPrefix, DWordPrefix or QWordPrefix is used).
|
---|
278 | *
|
---|
279 | * @returns IPRT status code.
|
---|
280 | * @param hAcpiTbl The ACPI table handle.
|
---|
281 | * @param u64 The 64-bit value to append.
|
---|
282 | */
|
---|
283 | RTDECL(int) RTAcpiTblIntegerAppend(RTACPITBL hAcpiTbl, uint64_t u64);
|
---|
284 |
|
---|
285 |
|
---|
286 | /**
|
---|
287 | * Appends a new DefBuffer object under the current scope.
|
---|
288 | *
|
---|
289 | * @returns IPRT status code.
|
---|
290 | * @param hAcpiTbl The ACPI table handle.
|
---|
291 | * @param pvBuf The buffer data.
|
---|
292 | * @param cbBuf Size of the buffer in bytes.
|
---|
293 | */
|
---|
294 | RTDECL(int) RTAcpiTblBufferAppend(RTACPITBL hAcpiTbl, const void *pvBuf, size_t cbBuf);
|
---|
295 |
|
---|
296 |
|
---|
297 | /**
|
---|
298 | * Appends the given resource as a DefBuffer under the current scope.
|
---|
299 | *
|
---|
300 | * @returns IPRT status code.
|
---|
301 | * @param hAcpiTbl The ACPI table handle.
|
---|
302 | * @param hAcpiRes The ACPI resource handle.
|
---|
303 | */
|
---|
304 | RTDECL(int) RTAcpiTblResourceAppend(RTACPITBL hAcpiTbl, RTACPIRES hAcpiRes);
|
---|
305 |
|
---|
306 |
|
---|
307 | /**
|
---|
308 | * List of statements.
|
---|
309 | */
|
---|
310 | typedef enum RTACPISTMT
|
---|
311 | {
|
---|
312 | /** Invalid statement. */
|
---|
313 | kAcpiStmt_Invalid = 0,
|
---|
314 | /** Return statement. */
|
---|
315 | kAcpiStmt_Return,
|
---|
316 | /** Breakpoint statement. */
|
---|
317 | kAcpiStmt_Breakpoint,
|
---|
318 | /** No operation statement. */
|
---|
319 | kAcpiStmt_Nop,
|
---|
320 | /** Break statement. */
|
---|
321 | kAcpiStmt_Break,
|
---|
322 | /** Continue statement. */
|
---|
323 | kAcpiStmt_Continue
|
---|
324 | } RTACPISTMT;
|
---|
325 |
|
---|
326 |
|
---|
327 | /**
|
---|
328 | * Appends the given simple statement to the given ACPI table in the current scope.
|
---|
329 | *
|
---|
330 | * @returns IPRT status code.
|
---|
331 | * @param hAcpiTbl The ACPI table handle.
|
---|
332 | * @param enmStmt The statement to add.
|
---|
333 | */
|
---|
334 | RTDECL(int) RTAcpiTblStmtSimpleAppend(RTACPITBL hAcpiTbl, RTACPISTMT enmStmt);
|
---|
335 |
|
---|
336 |
|
---|
337 | /** @name ACPI resource builder related API.
|
---|
338 | * @{ */
|
---|
339 |
|
---|
340 | /**
|
---|
341 | * Creates a new empty resource template.
|
---|
342 | *
|
---|
343 | * @returns IPRT status code.
|
---|
344 | * @param phAcpiRes Where to store the handle to the ACPI resource on success.
|
---|
345 | */
|
---|
346 | RTDECL(int) RTAcpiResourceCreate(PRTACPIRES phAcpiRes);
|
---|
347 |
|
---|
348 |
|
---|
349 | /**
|
---|
350 | * Destroys the given ACPI resource, freeing all allocated resources.
|
---|
351 | *
|
---|
352 | * @param hAcpiRes The ACPI resource handle to destroy.
|
---|
353 | */
|
---|
354 | RTDECL(void) RTAcpiResourceDestroy(RTACPIRES hAcpiRes);
|
---|
355 |
|
---|
356 |
|
---|
357 | /**
|
---|
358 | * Resets the given ACPI resource handle to create a new empty template.
|
---|
359 | *
|
---|
360 | * @param hAcpiRes The ACPI resource handle.
|
---|
361 | */
|
---|
362 | RTDECL(void) RTAcpiResourceReset(RTACPIRES hAcpiRes);
|
---|
363 |
|
---|
364 |
|
---|
365 | /**
|
---|
366 | * Seals the given ACPI resource against further changes and adds any
|
---|
367 | * missing data required to complete the resource buffer.
|
---|
368 | *
|
---|
369 | * @returns IPRT status code.
|
---|
370 | * @param hAcpiRes The ACPI resource handle.
|
---|
371 | *
|
---|
372 | * @note After a call to this method completed successfully it is not possible
|
---|
373 | * to add new resources until RTAcpiResourceReset() was called.
|
---|
374 | */
|
---|
375 | RTDECL(int) RTAcpiResourceSeal(RTACPIRES hAcpiRes);
|
---|
376 |
|
---|
377 |
|
---|
378 | /**
|
---|
379 | * Queries the pointer to the buffer holding the encoded data.
|
---|
380 | *
|
---|
381 | * @returns IPRT status code.
|
---|
382 | * @param hAcpiRes The ACPI resource handle.
|
---|
383 | * @param ppvRes Where to store the pointer to the buffer holding the encoded resource template on success.
|
---|
384 | * @param pcbRes Where to store the size of the encoded data in bytes on success.
|
---|
385 | *
|
---|
386 | * @note The ACPI resource must be successfully sealed with RTAcpiResourceSeal() for this function to succeed.
|
---|
387 | * Also the buffer pointer will only be valid until a call to any other RTAcpiResource* method.
|
---|
388 | */
|
---|
389 | RTDECL(int) RTAcpiResourceQueryBuffer(RTACPIRES hAcpiRes, const void **ppvRes, size_t *pcbRes);
|
---|
390 |
|
---|
391 |
|
---|
392 | /**
|
---|
393 | * Adds a fixed memory range with the given start address and size to the given ACPI resource.
|
---|
394 | *
|
---|
395 | * @returns IPRT status code.
|
---|
396 | * @param hAcpiRes The ACPI resource handle.
|
---|
397 | * @param u32AddrBase The base address to encode.
|
---|
398 | * @param cbRange The range length in bytes to encode.
|
---|
399 | * @param fRw Flag whether this address range is read-write or read-only.
|
---|
400 | */
|
---|
401 | RTDECL(int) RTAcpiResourceAdd32BitFixedMemoryRange(RTACPIRES hAcpiRes, uint32_t u32AddrBase, uint32_t cbRange,
|
---|
402 | bool fRw);
|
---|
403 |
|
---|
404 |
|
---|
405 | /**
|
---|
406 | * Adds an extended interrupt descriptor with the given configuration to the given ACPI resource.
|
---|
407 | *
|
---|
408 | * @returns IPRT status code.
|
---|
409 | * @param hAcpiRes The ACPI resource handle.
|
---|
410 | * @param fConsumer Flag whether the entity this resource is assigned to consumes the interrupt (true) or produces it (false).
|
---|
411 | * @param fEdgeTriggered Flag whether the interrupt is edged (true) or level (false) triggered.
|
---|
412 | * @param fActiveLow Flag whether the interrupt polarity is active low (true) or active high (false).
|
---|
413 | * @param fShared Flag whether the interrupt is shared between different entities (true) or exclusive to the assigned entity (false).
|
---|
414 | * @param fWakeCapable Flag whether the interrupt can wake the system (true) or not (false).
|
---|
415 | * @param cIntrs Number of interrupts following.
|
---|
416 | * @param pau32Intrs Pointer to the array of interrupt numbers.
|
---|
417 | */
|
---|
418 | RTDECL(int) RTAcpiResourceAddExtendedInterrupt(RTACPIRES hAcpiRes, bool fConsumer, bool fEdgeTriggered, bool fActiveLow, bool fShared,
|
---|
419 | bool fWakeCapable, uint8_t cIntrs, uint32_t *pau32Intrs);
|
---|
420 |
|
---|
421 |
|
---|
422 | /** @name Generic address space flags.
|
---|
423 | * @{ */
|
---|
424 | #define RTACPI_RESOURCE_ADDR_RANGE_F_DECODE_TYPE_SUB RT_BIT_32(0)
|
---|
425 | #define RTACPI_RESOURCE_ADDR_RANGE_F_DECODE_TYPE_POS 0
|
---|
426 |
|
---|
427 | #define RTACPI_RESOURCE_ADDR_RANGE_F_MIN_ADDR_FIXED RT_BIT_32(1)
|
---|
428 | #define RTACPI_RESOURCE_ADDR_RANGE_F_MIN_ADDR_CHANGEABLE 0
|
---|
429 |
|
---|
430 | #define RTACPI_RESOURCE_ADDR_RANGE_F_MAX_ADDR_FIXED RT_BIT_32(2)
|
---|
431 | #define RTACPI_RESOURCE_ADDR_RANGE_F_MAX_ADDR_CHANGEABLE 0
|
---|
432 |
|
---|
433 | #define RTACPI_RESOURCE_ADDR_RANGE_F_VALID_MASK UINT32_C(0x00000007)
|
---|
434 | /** @} */
|
---|
435 |
|
---|
436 | /**
|
---|
437 | * Memory range cacheability
|
---|
438 | */
|
---|
439 | typedef enum RTACPIRESMEMRANGECACHEABILITY
|
---|
440 | {
|
---|
441 | /** Usual invalid value. */
|
---|
442 | kAcpiResMemRangeCacheability_Invalid = 0,
|
---|
443 | /** Memory range is non cacheable (like MMIO, etc.). */
|
---|
444 | kAcpiResMemRangeCacheability_NonCacheable,
|
---|
445 | /** Memory is cacheable. */
|
---|
446 | kAcpiResMemRangeCacheability_Cacheable,
|
---|
447 | /** Memory is cacheable and supports write comining. */
|
---|
448 | kAcpiResMemRangeCacheability_CacheableWriteCombining,
|
---|
449 | /** Memory is cacheable and supports prefetching. */
|
---|
450 | kAcpiResMemRangeCacheability_CacheablePrefetchable,
|
---|
451 | /** 32-bit blow up hack. */
|
---|
452 | kAcpiResMemRangeCacheability_32BitHack = 0x7fffffff
|
---|
453 | } RTACPIRESMEMRANGECACHEABILITY;
|
---|
454 |
|
---|
455 |
|
---|
456 | /**
|
---|
457 | * Memory attribute.
|
---|
458 | */
|
---|
459 | typedef enum RTACPIRESMEMRANGETYPE
|
---|
460 | {
|
---|
461 | /** Invalid memory range type. */
|
---|
462 | kAcpiResMemType_Invalid = 0,
|
---|
463 | /** Memory range is actual memory. */
|
---|
464 | kAcpiResMemType_Memory,
|
---|
465 | /** Memory range is reserved. */
|
---|
466 | kAcpiResMemType_Reserved,
|
---|
467 | /** Memory range is reserved to ACPI. */
|
---|
468 | kAcpiResMemType_Acpi,
|
---|
469 | /** Memory range is no volatile storage. */
|
---|
470 | kAcpiResMemType_Nvs,
|
---|
471 | /** 32-bit blow up hack. */
|
---|
472 | kAcpiResMemType_32BitHack = 0x7fffffff
|
---|
473 | } RTACPIRESMEMRANGETYPE;
|
---|
474 |
|
---|
475 |
|
---|
476 | /**
|
---|
477 | * Adds a quad word (64-bit) memory range to the given ACPI resource.
|
---|
478 | *
|
---|
479 | * @returns IPRT status code.
|
---|
480 | * @param hAcpiRes The ACPI resource handle.
|
---|
481 | * @param enmCacheability The cacheability of the memory range.
|
---|
482 | * @param enmType Memory range type.
|
---|
483 | * @param fRw Flag whether the memory range is read/write (true) or readonly (false).
|
---|
484 | * @param fAddrSpace Additional address space flags (combination of RTACPI_RESOURCE_ADDR_RANGE_F_XXX).
|
---|
485 | * @param u64AddrMin The start address of the memory range.
|
---|
486 | * @param u64AddrMax Last valid address of the range.
|
---|
487 | * @param u64OffTrans Translation offset being applied to the address (for a PCIe bridge or IOMMU for example).
|
---|
488 | * @param u64Granularity The access granularity of the range in bytes.
|
---|
489 | * @param u64Length Length of the memory range in bytes.
|
---|
490 | */
|
---|
491 | RTDECL(int) RTAcpiResourceAddQWordMemoryRange(RTACPIRES hAcpiRes, RTACPIRESMEMRANGECACHEABILITY enmCacheability,
|
---|
492 | RTACPIRESMEMRANGETYPE enmType, bool fRw, uint32_t fAddrSpace,
|
---|
493 | uint64_t u64AddrMin, uint64_t u64AddrMax, uint64_t u64OffTrans,
|
---|
494 | uint64_t u64Granularity, uint64_t u64Length);
|
---|
495 |
|
---|
496 |
|
---|
497 | /**
|
---|
498 | * Adds a double word (32-bit) memory range to the given ACPI resource.
|
---|
499 | *
|
---|
500 | * @returns IPRT status code.
|
---|
501 | * @param hAcpiRes The ACPI resource handle.
|
---|
502 | * @param enmCacheability The cacheability of the memory range.
|
---|
503 | * @param enmType Memory range type.
|
---|
504 | * @param fRw Flag whether the memory range is read/write (true) or readonly (false).
|
---|
505 | * @param fAddrSpace Additional address space flags (combination of RTACPI_RESOURCE_ADDR_RANGE_F_XXX).
|
---|
506 | * @param u32AddrMin The start address of the memory range.
|
---|
507 | * @param u32AddrMax Last valid address of the range.
|
---|
508 | * @param u32OffTrans Translation offset being applied to the address (for a PCIe bridge or IOMMU for example).
|
---|
509 | * @param u32Granularity The access granularity of the range in bytes.
|
---|
510 | * @param u32Length Length of the memory range in bytes.
|
---|
511 | */
|
---|
512 | RTDECL(int) RTAcpiResourceAddDWordMemoryRange(RTACPIRES hAcpiRes, RTACPIRESMEMRANGECACHEABILITY enmCacheability,
|
---|
513 | RTACPIRESMEMRANGETYPE enmType, bool fRw, uint32_t fAddrSpace,
|
---|
514 | uint32_t u32AddrMin, uint32_t u32AddrMax, uint32_t u32OffTrans,
|
---|
515 | uint32_t u32Granularity, uint32_t u32Length);
|
---|
516 |
|
---|
517 |
|
---|
518 | /**
|
---|
519 | * I/O range coverage.
|
---|
520 | */
|
---|
521 | typedef enum RTACPIRESIORANGE
|
---|
522 | {
|
---|
523 | /** Invalid range. */
|
---|
524 | kAcpiResIoRange_Invalid = 0,
|
---|
525 | /** Range covers only non ISA I/O ports. */
|
---|
526 | kAcpiResIoRange_NonIsaOnly,
|
---|
527 | /** Range covers only ISA I/O ports. */
|
---|
528 | kAcpiResIoRange_IsaOnly,
|
---|
529 | /** Range covers the whole I/O port range. */
|
---|
530 | kAcpiResIoRange_Whole,
|
---|
531 | /** 32-bit blow up hack. */
|
---|
532 | kAcpiResIoRange_32BitHack = 0x7fffffff
|
---|
533 | } RTACPIRESIORANGE;
|
---|
534 |
|
---|
535 |
|
---|
536 | /**
|
---|
537 | * I/O range type.
|
---|
538 | */
|
---|
539 | typedef enum RTACPIRESIORANGETYPE
|
---|
540 | {
|
---|
541 | /** Invalid value. */
|
---|
542 | kAcpiResIoRangeType_Invalid = 0,
|
---|
543 | /** Resource is I/O on the primary and secondary side of the bridge. */
|
---|
544 | kAcpiResIoRangeType_Static,
|
---|
545 | /** Resource is memory on the primary and I/O on the secondary side of the bridge,
|
---|
546 | * primary side memory address for a given I/O port is calculated with
|
---|
547 | * address = (((Port & 0xfffc) << 10) || (Port & 0xfff)) + AddrMin. */
|
---|
548 | kAcpiResIoRangeType_Translation_Sparse,
|
---|
549 | /** Resource is memory on the primary and I/O on the secondary side of the bridge,
|
---|
550 | * primary side memory address for a given I/O port is calculated with
|
---|
551 | * address = AddrMin + Port. */
|
---|
552 | kAcpiResIoRangeType_Translation_Dense,
|
---|
553 | /** 32-bit blowup hack. */
|
---|
554 | kAcpiResIoRangeType_32BitHack = 0x7fffffff
|
---|
555 | } RTACPIRESIORANGETYPE;
|
---|
556 |
|
---|
557 |
|
---|
558 | /**
|
---|
559 | * Adds a quad word (64-bit) I/O range to the given ACPI resource.
|
---|
560 | *
|
---|
561 | * @returns IPRT status code.
|
---|
562 | * @param hAcpiRes The ACPI resource handle.
|
---|
563 | * @param enmIoType The I/O range type.
|
---|
564 | * @param enmIoRange The I/O range coverage.
|
---|
565 | * @param fAddrSpace Additional address space flags (combination of RTACPI_RESOURCE_ADDR_RANGE_F_XXX).
|
---|
566 | * @param u64AddrMin The start address of the memory range.
|
---|
567 | * @param u64AddrMax Last valid address of the range.
|
---|
568 | * @param u64OffTrans Translation offset being applied to the address (for a PCIe bridge or IOMMU for example).
|
---|
569 | * @param u64Granularity The access granularity of the range in bytes.
|
---|
570 | * @param u64Length Length of the memory range in bytes.
|
---|
571 | */
|
---|
572 | RTDECL(int) RTAcpiResourceAddQWordIoRange(RTACPIRES hAcpiRes, RTACPIRESIORANGETYPE enmIoType, RTACPIRESIORANGE enmIoRange,
|
---|
573 | uint32_t fAddrSpace, uint64_t u64AddrMin, uint64_t u64AddrMax, uint64_t u64OffTrans,
|
---|
574 | uint64_t u64Granularity, uint64_t u64Length);
|
---|
575 |
|
---|
576 |
|
---|
577 | /**
|
---|
578 | * Adds a word (16-bit) bus number to the given ACPI resource.
|
---|
579 | *
|
---|
580 | * @returns IPRT status code.
|
---|
581 | * @param hAcpiRes The ACPI resource handle.
|
---|
582 | * @param fAddrSpace Additional address space flags (combination of RTACPI_RESOURCE_ADDR_RANGE_F_XXX).
|
---|
583 | * @param u16BusMin Starting bus number.
|
---|
584 | * @param u16BusMax Last valid bus number.
|
---|
585 | * @param u16OffTrans Translation offset being applied to the bus number.
|
---|
586 | * @param u16Granularity The access granularity of the bus number.
|
---|
587 | * @param u16Length Length of the bus range.
|
---|
588 | */
|
---|
589 | RTDECL(int) RTAcpiResourceAddWordBusNumber(RTACPIRES hAcpiRes, uint32_t fAddrSpace, uint16_t u16BusMin, uint16_t u16BusMax,
|
---|
590 | uint16_t u16OffTrans, uint16_t u16Granularity, uint16_t u16Length);
|
---|
591 |
|
---|
592 | /** @} */
|
---|
593 |
|
---|
594 | #endif /* IN_RING3 */
|
---|
595 |
|
---|
596 | /** @} */
|
---|
597 |
|
---|
598 | RT_C_DECLS_END
|
---|
599 |
|
---|
600 | #endif /* !IPRT_INCLUDED_acpi_h */
|
---|
601 |
|
---|