VirtualBox

source: vbox/trunk/include/iprt/acpi.h

Last change on this file was 107036, checked in by vboxsync, 10 days ago

Runtime/RTAcpi*: Add new methods for adding if else statements, binary operands and referencing arguments, locals and appending UUIDs, bugref:10733

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 24.5 KB
Line 
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
49RT_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 */
66RTDECL(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 */
75RTDECL(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 */
91RTDECL(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 */
101RTDECL(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 */
112RTDECL(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 */
123RTDECL(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 */
133RTDECL(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 */
143RTDECL(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 */
153RTDECL(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 */
162RTDECL(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 */
173RTDECL(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 */
182RTDECL(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 */
192RTDECL(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 */
203RTDECL(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 */
214RTDECL(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 */
223RTDECL(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 */
236RTDECL(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 */
251RTDECL(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 */
262RTDECL(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 */
272RTDECL(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 */
283RTDECL(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 */
294RTDECL(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 */
304RTDECL(int) RTAcpiTblResourceAppend(RTACPITBL hAcpiTbl, RTACPIRES hAcpiRes);
305
306
307/**
308 * List of statements.
309 */
310typedef 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 */
334RTDECL(int) RTAcpiTblStmtSimpleAppend(RTACPITBL hAcpiTbl, RTACPISTMT enmStmt);
335
336
337/**
338 * Starts a new If statement operation.
339 *
340 * @returns IPRT status code.
341 * @param hAcpiTbl The ACPI table handle.
342 */
343RTDECL(int) RTAcpiTblIfStart(RTACPITBL hAcpiTbl);
344
345
346/**
347 * Finalizes the current If statement operation.
348 *
349 * @returns IPRT status code.
350 * @param hAcpiTbl The ACPI table handle.
351 */
352RTDECL(int) RTAcpiTblIfFinalize(RTACPITBL hAcpiTbl);
353
354
355/**
356 * Starts a new Else operation (only valid if currently inside an If oepration).
357 *
358 * @returns IPRT status code.
359 * @param hAcpiTbl The ACPI table handle.
360 */
361RTDECL(int) RTAcpiTblElseStart(RTACPITBL hAcpiTbl);
362
363
364/**
365 * Finalizes the current Else statement operation.
366 *
367 * @returns IPRT status code.
368 * @param hAcpiTbl The ACPI table handle.
369 */
370RTDECL(int) RTAcpiTblElseFinalize(RTACPITBL hAcpiTbl);
371
372
373/**
374 * List of binary operations.
375 */
376typedef enum RTACPIBINARYOP
377{
378 /** Invalid binary operation. */
379 kAcpiBinaryOp_Invalid = 0,
380 /** LAnd(Operand, Operand). */
381 kAcpiBinaryOp_LAnd,
382 /** LEqual(Operand, Operand). */
383 kAcpiBinaryOp_LEqual,
384 /** LGreater(Operand, Operand). */
385 kAcpiBinaryOp_LGreater,
386 /** LGreaterEqual(Operand, Operand). */
387 kAcpiBinaryOp_LGreaterEqual,
388 /** LLess(Operand, Operand). */
389 kAcpiBinaryOp_LLess,
390 /** LLessEqual(Operand, Operand). */
391 kAcpiBinaryOp_LLessEqual,
392 /** LNotEqual(Operand, Operand). */
393 kAcpiBinaryOp_LNotEqual
394} RTACPIBINARYOP;
395
396
397/**
398 * Appends the given binary operand.
399 *
400 * @returns IPRT status code.
401 * @param hAcpiTbl The ACPI table handle.
402 * @param enmBinaryOp The binary operation to append.
403 */
404RTDECL(int) RTAcpiTblBinaryOpAppend(RTACPITBL hAcpiTbl, RTACPIBINARYOP enmBinaryOp);
405
406
407/**
408 * Appends the given Arg<idArg> operand.
409 *
410 * @returns IPRT status code.
411 * @param hAcpiTbl The ACPI table handle.
412 * @param idArg The argument ID to append [0..6].
413 */
414RTDECL(int) RTAcpiTblArgOpAppend(RTACPITBL hAcpiTbl, uint8_t idArg);
415
416
417/**
418 * Appends the given Local<idLocal> operand.
419 *
420 * @returns IPRT status code.
421 * @param hAcpiTbl The ACPI table handle.
422 * @param idLocal The local ID to append [0..7].
423 */
424RTDECL(int) RTAcpiTblLocalOpAppend(RTACPITBL hAcpiTbl, uint8_t idLocal);
425
426
427/**
428 * Appends the given UUID as a buffer object.
429 *
430 * @returns IPRT status code.
431 * @param hAcpiTbl The ACPI table handle.
432 * @param pUuid The UUID to append.
433 */
434RTDECL(int) RTAcpiTblUuidAppend(RTACPITBL hAcpiTbl, PCRTUUID pUuid);
435
436
437/**
438 * Appends the given UUID string as a UUID buffer object.
439 *
440 * @returns IPRT status code.
441 * @param hAcpiTbl The ACPI table handle.
442 * @param pszUuid The UUID string to append as a buffer.
443 */
444RTDECL(int) RTAcpiTblUuidAppendFromStr(RTACPITBL hAcpiTbl, const char *pszUuid);
445
446
447/** @name ACPI resource builder related API.
448 * @{ */
449
450/**
451 * Creates a new empty resource template.
452 *
453 * @returns IPRT status code.
454 * @param phAcpiRes Where to store the handle to the ACPI resource on success.
455 */
456RTDECL(int) RTAcpiResourceCreate(PRTACPIRES phAcpiRes);
457
458
459/**
460 * Destroys the given ACPI resource, freeing all allocated resources.
461 *
462 * @param hAcpiRes The ACPI resource handle to destroy.
463 */
464RTDECL(void) RTAcpiResourceDestroy(RTACPIRES hAcpiRes);
465
466
467/**
468 * Resets the given ACPI resource handle to create a new empty template.
469 *
470 * @param hAcpiRes The ACPI resource handle.
471 */
472RTDECL(void) RTAcpiResourceReset(RTACPIRES hAcpiRes);
473
474
475/**
476 * Seals the given ACPI resource against further changes and adds any
477 * missing data required to complete the resource buffer.
478 *
479 * @returns IPRT status code.
480 * @param hAcpiRes The ACPI resource handle.
481 *
482 * @note After a call to this method completed successfully it is not possible
483 * to add new resources until RTAcpiResourceReset() was called.
484 */
485RTDECL(int) RTAcpiResourceSeal(RTACPIRES hAcpiRes);
486
487
488/**
489 * Queries the pointer to the buffer holding the encoded data.
490 *
491 * @returns IPRT status code.
492 * @param hAcpiRes The ACPI resource handle.
493 * @param ppvRes Where to store the pointer to the buffer holding the encoded resource template on success.
494 * @param pcbRes Where to store the size of the encoded data in bytes on success.
495 *
496 * @note The ACPI resource must be successfully sealed with RTAcpiResourceSeal() for this function to succeed.
497 * Also the buffer pointer will only be valid until a call to any other RTAcpiResource* method.
498 */
499RTDECL(int) RTAcpiResourceQueryBuffer(RTACPIRES hAcpiRes, const void **ppvRes, size_t *pcbRes);
500
501
502/**
503 * Adds a fixed memory range with the given start address and size to the given ACPI resource.
504 *
505 * @returns IPRT status code.
506 * @param hAcpiRes The ACPI resource handle.
507 * @param u32AddrBase The base address to encode.
508 * @param cbRange The range length in bytes to encode.
509 * @param fRw Flag whether this address range is read-write or read-only.
510 */
511RTDECL(int) RTAcpiResourceAdd32BitFixedMemoryRange(RTACPIRES hAcpiRes, uint32_t u32AddrBase, uint32_t cbRange,
512 bool fRw);
513
514
515/**
516 * Adds an extended interrupt descriptor with the given configuration to the given ACPI resource.
517 *
518 * @returns IPRT status code.
519 * @param hAcpiRes The ACPI resource handle.
520 * @param fConsumer Flag whether the entity this resource is assigned to consumes the interrupt (true) or produces it (false).
521 * @param fEdgeTriggered Flag whether the interrupt is edged (true) or level (false) triggered.
522 * @param fActiveLow Flag whether the interrupt polarity is active low (true) or active high (false).
523 * @param fShared Flag whether the interrupt is shared between different entities (true) or exclusive to the assigned entity (false).
524 * @param fWakeCapable Flag whether the interrupt can wake the system (true) or not (false).
525 * @param cIntrs Number of interrupts following.
526 * @param pau32Intrs Pointer to the array of interrupt numbers.
527 */
528RTDECL(int) RTAcpiResourceAddExtendedInterrupt(RTACPIRES hAcpiRes, bool fConsumer, bool fEdgeTriggered, bool fActiveLow, bool fShared,
529 bool fWakeCapable, uint8_t cIntrs, uint32_t *pau32Intrs);
530
531
532/** @name Generic address space flags.
533 * @{ */
534#define RTACPI_RESOURCE_ADDR_RANGE_F_DECODE_TYPE_SUB RT_BIT_32(0)
535#define RTACPI_RESOURCE_ADDR_RANGE_F_DECODE_TYPE_POS 0
536
537#define RTACPI_RESOURCE_ADDR_RANGE_F_MIN_ADDR_FIXED RT_BIT_32(1)
538#define RTACPI_RESOURCE_ADDR_RANGE_F_MIN_ADDR_CHANGEABLE 0
539
540#define RTACPI_RESOURCE_ADDR_RANGE_F_MAX_ADDR_FIXED RT_BIT_32(2)
541#define RTACPI_RESOURCE_ADDR_RANGE_F_MAX_ADDR_CHANGEABLE 0
542
543#define RTACPI_RESOURCE_ADDR_RANGE_F_VALID_MASK UINT32_C(0x00000007)
544/** @} */
545
546/**
547 * Memory range cacheability
548 */
549typedef enum RTACPIRESMEMRANGECACHEABILITY
550{
551 /** Usual invalid value. */
552 kAcpiResMemRangeCacheability_Invalid = 0,
553 /** Memory range is non cacheable (like MMIO, etc.). */
554 kAcpiResMemRangeCacheability_NonCacheable,
555 /** Memory is cacheable. */
556 kAcpiResMemRangeCacheability_Cacheable,
557 /** Memory is cacheable and supports write comining. */
558 kAcpiResMemRangeCacheability_CacheableWriteCombining,
559 /** Memory is cacheable and supports prefetching. */
560 kAcpiResMemRangeCacheability_CacheablePrefetchable,
561 /** 32-bit blow up hack. */
562 kAcpiResMemRangeCacheability_32BitHack = 0x7fffffff
563} RTACPIRESMEMRANGECACHEABILITY;
564
565
566/**
567 * Memory attribute.
568 */
569typedef enum RTACPIRESMEMRANGETYPE
570{
571 /** Invalid memory range type. */
572 kAcpiResMemType_Invalid = 0,
573 /** Memory range is actual memory. */
574 kAcpiResMemType_Memory,
575 /** Memory range is reserved. */
576 kAcpiResMemType_Reserved,
577 /** Memory range is reserved to ACPI. */
578 kAcpiResMemType_Acpi,
579 /** Memory range is no volatile storage. */
580 kAcpiResMemType_Nvs,
581 /** 32-bit blow up hack. */
582 kAcpiResMemType_32BitHack = 0x7fffffff
583} RTACPIRESMEMRANGETYPE;
584
585
586/**
587 * Adds a quad word (64-bit) memory range to the given ACPI resource.
588 *
589 * @returns IPRT status code.
590 * @param hAcpiRes The ACPI resource handle.
591 * @param enmCacheability The cacheability of the memory range.
592 * @param enmType Memory range type.
593 * @param fRw Flag whether the memory range is read/write (true) or readonly (false).
594 * @param fAddrSpace Additional address space flags (combination of RTACPI_RESOURCE_ADDR_RANGE_F_XXX).
595 * @param u64AddrMin The start address of the memory range.
596 * @param u64AddrMax Last valid address of the range.
597 * @param u64OffTrans Translation offset being applied to the address (for a PCIe bridge or IOMMU for example).
598 * @param u64Granularity The access granularity of the range in bytes.
599 * @param u64Length Length of the memory range in bytes.
600 */
601RTDECL(int) RTAcpiResourceAddQWordMemoryRange(RTACPIRES hAcpiRes, RTACPIRESMEMRANGECACHEABILITY enmCacheability,
602 RTACPIRESMEMRANGETYPE enmType, bool fRw, uint32_t fAddrSpace,
603 uint64_t u64AddrMin, uint64_t u64AddrMax, uint64_t u64OffTrans,
604 uint64_t u64Granularity, uint64_t u64Length);
605
606
607/**
608 * Adds a double word (32-bit) memory range to the given ACPI resource.
609 *
610 * @returns IPRT status code.
611 * @param hAcpiRes The ACPI resource handle.
612 * @param enmCacheability The cacheability of the memory range.
613 * @param enmType Memory range type.
614 * @param fRw Flag whether the memory range is read/write (true) or readonly (false).
615 * @param fAddrSpace Additional address space flags (combination of RTACPI_RESOURCE_ADDR_RANGE_F_XXX).
616 * @param u32AddrMin The start address of the memory range.
617 * @param u32AddrMax Last valid address of the range.
618 * @param u32OffTrans Translation offset being applied to the address (for a PCIe bridge or IOMMU for example).
619 * @param u32Granularity The access granularity of the range in bytes.
620 * @param u32Length Length of the memory range in bytes.
621 */
622RTDECL(int) RTAcpiResourceAddDWordMemoryRange(RTACPIRES hAcpiRes, RTACPIRESMEMRANGECACHEABILITY enmCacheability,
623 RTACPIRESMEMRANGETYPE enmType, bool fRw, uint32_t fAddrSpace,
624 uint32_t u32AddrMin, uint32_t u32AddrMax, uint32_t u32OffTrans,
625 uint32_t u32Granularity, uint32_t u32Length);
626
627
628/**
629 * I/O range coverage.
630 */
631typedef enum RTACPIRESIORANGE
632{
633 /** Invalid range. */
634 kAcpiResIoRange_Invalid = 0,
635 /** Range covers only non ISA I/O ports. */
636 kAcpiResIoRange_NonIsaOnly,
637 /** Range covers only ISA I/O ports. */
638 kAcpiResIoRange_IsaOnly,
639 /** Range covers the whole I/O port range. */
640 kAcpiResIoRange_Whole,
641 /** 32-bit blow up hack. */
642 kAcpiResIoRange_32BitHack = 0x7fffffff
643} RTACPIRESIORANGE;
644
645
646/**
647 * I/O range type.
648 */
649typedef enum RTACPIRESIORANGETYPE
650{
651 /** Invalid value. */
652 kAcpiResIoRangeType_Invalid = 0,
653 /** Resource is I/O on the primary and secondary side of the bridge. */
654 kAcpiResIoRangeType_Static,
655 /** Resource is memory on the primary and I/O on the secondary side of the bridge,
656 * primary side memory address for a given I/O port is calculated with
657 * address = (((Port & 0xfffc) << 10) || (Port & 0xfff)) + AddrMin. */
658 kAcpiResIoRangeType_Translation_Sparse,
659 /** Resource is memory on the primary and I/O on the secondary side of the bridge,
660 * primary side memory address for a given I/O port is calculated with
661 * address = AddrMin + Port. */
662 kAcpiResIoRangeType_Translation_Dense,
663 /** 32-bit blowup hack. */
664 kAcpiResIoRangeType_32BitHack = 0x7fffffff
665} RTACPIRESIORANGETYPE;
666
667
668/**
669 * Adds a quad word (64-bit) I/O range to the given ACPI resource.
670 *
671 * @returns IPRT status code.
672 * @param hAcpiRes The ACPI resource handle.
673 * @param enmIoType The I/O range type.
674 * @param enmIoRange The I/O range coverage.
675 * @param fAddrSpace Additional address space flags (combination of RTACPI_RESOURCE_ADDR_RANGE_F_XXX).
676 * @param u64AddrMin The start address of the memory range.
677 * @param u64AddrMax Last valid address of the range.
678 * @param u64OffTrans Translation offset being applied to the address (for a PCIe bridge or IOMMU for example).
679 * @param u64Granularity The access granularity of the range in bytes.
680 * @param u64Length Length of the memory range in bytes.
681 */
682RTDECL(int) RTAcpiResourceAddQWordIoRange(RTACPIRES hAcpiRes, RTACPIRESIORANGETYPE enmIoType, RTACPIRESIORANGE enmIoRange,
683 uint32_t fAddrSpace, uint64_t u64AddrMin, uint64_t u64AddrMax, uint64_t u64OffTrans,
684 uint64_t u64Granularity, uint64_t u64Length);
685
686
687/**
688 * Adds a word (16-bit) bus number to the given ACPI resource.
689 *
690 * @returns IPRT status code.
691 * @param hAcpiRes The ACPI resource handle.
692 * @param fAddrSpace Additional address space flags (combination of RTACPI_RESOURCE_ADDR_RANGE_F_XXX).
693 * @param u16BusMin Starting bus number.
694 * @param u16BusMax Last valid bus number.
695 * @param u16OffTrans Translation offset being applied to the bus number.
696 * @param u16Granularity The access granularity of the bus number.
697 * @param u16Length Length of the bus range.
698 */
699RTDECL(int) RTAcpiResourceAddWordBusNumber(RTACPIRES hAcpiRes, uint32_t fAddrSpace, uint16_t u16BusMin, uint16_t u16BusMax,
700 uint16_t u16OffTrans, uint16_t u16Granularity, uint16_t u16Length);
701
702/** @} */
703
704#endif /* IN_RING3 */
705
706/** @} */
707
708RT_C_DECLS_END
709
710#endif /* !IPRT_INCLUDED_acpi_h */
711
Note: See TracBrowser for help on using the repository browser.

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