VirtualBox

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

Last change on this file since 108195 was 108184, checked in by vboxsync, 3 months ago

Runtime/RTAcpi*: Parser updates, the code is now able to parse vbox.dsl successfully and generate an AST, bugref:10733

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 50.0 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.215389.xyz.
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 * ACPI table type.
60 */
61typedef enum RTACPITBLTYPE
62{
63 /** The invalid output type. */
64 RTACPITBLTYPE_INVALID = 0,
65 /** Type is an UTF-8 ASL source. */
66 RTACPITBLTYPE_ASL,
67 /** Type is the AML bytecode. */
68 RTACPITBLTYPE_AML,
69 /** Usual 32-bit hack. */
70 RTACPITBLTYPE_32BIT_HACK = 0x7fffffff
71} RTACPITBLTYPE;
72
73
74/**
75 * Regenerates the ACPI checksum for the given data.
76 *
77 * @returns The checksum for the given data.
78 * @param pvData The data to check sum.
79 * @param cbData Number of bytes to check sum.
80 */
81RTDECL(uint8_t) RTAcpiChecksumGenerate(const void *pvData, size_t cbData);
82
83
84/**
85 * Generates and writes the table header checksum for the given ACPI table.
86 *
87 * @param pTbl Pointer to the ACPI table to set the checksum for.
88 * @param cbTbl Size of the table in bytes, including the ACPI table header.
89 */
90RTDECL(void) RTAcpiTblHdrChecksumGenerate(PACPITBLHDR pTbl, size_t cbTbl);
91
92
93/**
94 * Creates an ACPI table from the given VFS file.
95 *
96 * @returns IPRT status code.
97 * @param phAcpiTbl Where to store the ACPI table handle on success.
98 * @param hVfsIos The VFS I/O stream handle to read the ACPI table from.
99 * @param enmInType The input type of the ACPI table.
100 * @param pErrInfo Where to return additional error information.
101 */
102RTDECL(int) RTAcpiTblCreateFromVfsIoStrm(PRTACPITBL phAcpiTbl, RTVFSIOSTREAM hVfsIos, RTACPITBLTYPE enmInType, PRTERRINFO pErrInfo);
103
104
105/**
106 * Converts a given ACPI table input stream to the given output type.
107 *
108 * @returns IPRT status code.
109 * @param hVfsIosOut The VFS I/O stream handle to output the result to.
110 * @param enmOutType The output type.
111 * @param hVfsIosIn The VFS I/O stream handle to read the ACPI table from.
112 * @param enmInType The input type of the ACPI table.
113 * @param pErrInfo Where to return additional error information.
114 */
115RTDECL(int) RTAcpiTblConvertFromVfsIoStrm(RTVFSIOSTREAM hVfsIosOut, RTACPITBLTYPE enmOutType,
116 RTVFSIOSTREAM hVfsIosIn, RTACPITBLTYPE enmInType, PRTERRINFO pErrInfo);
117
118
119/**
120 * Creates an ACPI table from the given filename.
121 *
122 * @returns IPRT status code.
123 * @param phAcpiTbl Where to store the ACPI table handle on success.
124 * @param pszFilename The filename to read the ACPI table from.
125 * @param enmInType The input type of the ACPI table.
126 * @param pErrInfo Where to return additional error information.
127 */
128RTDECL(int) RTAcpiTblCreateFromFile(PRTACPITBL phAcpiTbl, const char *pszFilename, RTACPITBLTYPE enmInType, PRTERRINFO pErrInfo);
129
130
131/**
132 * Creates a new empty ACPI table.
133 *
134 * @returns IPRT status code.
135 * @param phAcpiTbl Where to store the ACPI table handle on success.
136 * @param u32TblSig The signature of the table to use.
137 * @param bRevision The revision of the table.
138 * @param pszOemId The OEM supplied string identifiying the OEM, maximum of 6 characters.
139 * @param pszOemTblId The OEM supplied string identifiying the OEM table, maximum of 8 characters.
140 * @param u32OemRevision The OEM supplied revision number.
141 * @param pszCreatorId Vendor ID of the utility that created the table, maximum of 4 characters.
142 * @param u32CreatorRevision Revision of the utility that created the table.
143 */
144RTDECL(int) RTAcpiTblCreate(PRTACPITBL phAcpiTbl, uint32_t u32TblSig, uint8_t bRevision, const char *pszOemId,
145 const char *pszOemTblId, uint32_t u32OemRevision, const char *pszCreatorId,
146 uint32_t u32CreatorRevision);
147
148
149/**
150 * Destroys the given ACPI table, freeing all resources.
151 *
152 * @param hAcpiTbl The ACPI table handle to destroy.
153 */
154RTDECL(void) RTAcpiTblDestroy(RTACPITBL hAcpiTbl);
155
156
157/**
158 * Finalizes the given ACPI table, setting the header and generating checksums.
159 *
160 * @returns IPRT status code.
161 * @param hAcpiTbl The ACPI table handle to finalize.
162 *
163 * @note Nothing can be added to the table after this was called.
164 */
165RTDECL(int) RTAcpiTblFinalize(RTACPITBL hAcpiTbl);
166
167
168/**
169 * Returns the size of the given ACPI table.
170 *
171 * @returns Size of the given ACPI table in bytes, 0 on error.
172 * @param hAcpiTbl The ACPI table handle.
173 *
174 * @note This can only be called after RTAcpiTblFinalize() was called successfully.
175 */
176RTDECL(uint32_t) RTAcpiTblGetSize(RTACPITBL hAcpiTbl);
177
178
179/**
180 * Dumps the given ACPI table to the given VFS I/O stream.
181 *
182 * @returns IPRT status code.
183 * @param hAcpiTbl The ACPI table handle.
184 * @param enmOutType The output type.
185 * @param hVfsIos The VFS I/O stream handle to dump the table to.
186 */
187RTDECL(int) RTAcpiTblDumpToVfsIoStrm(RTACPITBL hAcpiTbl, RTACPITBLTYPE enmOutType, RTVFSIOSTREAM hVfsIos);
188
189
190/**
191 * Dumps the given ACPI table to the given file.
192 *
193 * @returns IPRT status code.
194 * @param hAcpiTbl The ACPI table handle.
195 * @param enmOutType The output type.
196 * @param pszFilename The file path to dump the table to.
197 */
198RTDECL(int) RTAcpiTblDumpToFile(RTACPITBL hAcpiTbl, RTACPITBLTYPE enmOutType, const char *pszFilename);
199
200
201/**
202 * Dumps the given ACPI table to a memory buffer allocated with RTMemAlloc() and returns the pointer
203 * to the allocated memory.
204 *
205 * @returns IPRT status code.
206 * @param hAcpiTbl The ACPI table handle.
207 * @param enmOutType The output type.
208 * @param ppbAcpiTbl Where to store the pointer to the ACPI table on success.
209 * @param pcbAcpiTbl Where to store the size of the ACPI table in bytes on success.
210 *
211 * @note The caller has to free the buffer with RTMemFree().
212 */
213RTDECL(int) RTAcpiTblDumpToBufferA(RTACPITBL hAcpiTbl, RTACPITBLTYPE enmOutType, uint8_t **ppbAcpiTbl, size_t *pcbAcpiTbl);
214
215
216/**
217 * Starts a new DefScope object.
218 *
219 * @returns IPRT status code.
220 * @param hAcpiTbl The ACPI table handle.
221 * @param pszName Name of the scope, can have a root (\) specifier optionally.
222 */
223RTDECL(int) RTAcpiTblScopeStart(RTACPITBL hAcpiTbl, const char *pszName);
224
225
226/**
227 * Finalizes the current scope object, nothing can be added to the scope afterwards.
228 *
229 * @returns IPRT status code.
230 * @param hAcpiTbl The ACPI table handle.
231 */
232RTDECL(int) RTAcpiTblScopeFinalize(RTACPITBL hAcpiTbl);
233
234
235/**
236 * Starts a new DefPackage object.
237 *
238 * @returns IPRT status code.
239 * @param hAcpiTbl The ACPI table handle.
240 * @param cElements Number of element which will be inside the package,
241 * only supports up to 255 elements, use DefVarPackage if more is required.
242 */
243RTDECL(int) RTAcpiTblPackageStart(RTACPITBL hAcpiTbl, uint8_t cElements);
244
245
246/**
247 * Finalizes the current DefPackage object, and return to the enclosing object's scope.
248 *
249 * @returns IPRT status code.
250 * @param hAcpiTbl The ACPI table handle.
251 */
252RTDECL(int) RTAcpiTblPackageFinalize(RTACPITBL hAcpiTbl);
253
254
255/**
256 * Starts a new device object for the given ACPI table in the current scope.
257 *
258 * @returns IPRT status code.
259 * @param hAcpiTbl The ACPI table handle.
260 * @param pszName Name of the device object, must be <= 4 characters long.
261 */
262RTDECL(int) RTAcpiTblDeviceStart(RTACPITBL hAcpiTbl, const char *pszName);
263
264
265/**
266 * Starts a new device object for the given ACPI table in the current scope.
267 *
268 * @returns IPRT status code.
269 * @param hAcpiTbl The ACPI table handle.
270 * @param pszNameFmt The name of the device as a format string.
271 * @param ... The format arguments.
272 */
273RTDECL(int) RTAcpiTblDeviceStartF(RTACPITBL hAcpiTbl, const char *pszNameFmt, ...) RT_IPRT_FORMAT_ATTR(2, 3);
274
275
276/**
277 * Starts a new device object for the given ACPI table in the current scope.
278 *
279 * @returns IPRT status code.
280 * @param hAcpiTbl The ACPI table handle.
281 * @param pszNameFmt The name of the device as a format string.
282 * @param va The format arguments.
283 */
284RTDECL(int) RTAcpiTblDeviceStartV(RTACPITBL hAcpiTbl, const char *pszNameFmt, va_list va) RT_IPRT_FORMAT_ATTR(2, 0);
285
286
287/**
288 * Finalizes the current scope object, nothing can be added to the scope afterwards.
289 *
290 * @returns IPRT status code.
291 * @param hAcpiTbl The ACPI table handle.
292 */
293RTDECL(int) RTAcpiTblDeviceFinalize(RTACPITBL hAcpiTbl);
294
295
296/**
297 * Starts a new processor object for the given ACPI table in the current scope.
298 *
299 * @returns IPRT status code.
300 * @param hAcpiTbl The ACPI table handle.
301 * @param pszName Name of the device object, must be <= 4 characters long.
302 * @param bProcId The processor ID.
303 * @param u32PBlkAddr Address of the processor register block.
304 * @param cbPBlk Size of the processor register block in bytes.
305 */
306RTDECL(int) RTAcpiTblProcessorStart(RTACPITBL hAcpiTbl, const char *pszName, uint8_t bProcId, uint32_t u32PBlkAddr,
307 uint8_t cbPBlk);
308
309
310/**
311 * Starts a new processor object for the given ACPI table in the current scope.
312 *
313 * @returns IPRT status code.
314 * @param hAcpiTbl The ACPI table handle.
315 * @param bProcId The processor ID.
316 * @param u32PBlkAddr Address of the processor register block.
317 * @param cbPBlk Size of the processor register block in bytes.
318 * @param pszNameFmt The name of the device as a format string.
319 * @param ... The format arguments.
320 */
321RTDECL(int) RTAcpiTblProcessorStartF(RTACPITBL hAcpiTbl, uint8_t bProcId, uint32_t u32PBlkAddr, uint8_t cbPBlk,
322 const char *pszNameFmt, ...) RT_IPRT_FORMAT_ATTR(5, 6);
323
324
325/**
326 * Starts a new processor object for the given ACPI table in the current scope.
327 *
328 * @returns IPRT status code.
329 * @param hAcpiTbl The ACPI table handle.
330 * @param bProcId The processor ID.
331 * @param u32PBlkAddr Address of the processor register block.
332 * @param cbPBlk Size of the processor register block in bytes.
333 * @param pszNameFmt The name of the device as a format string.
334 * @param va The format arguments.
335 */
336RTDECL(int) RTAcpiTblProcessorStartV(RTACPITBL hAcpiTbl, uint8_t bProcId, uint32_t u32PBlkAddr, uint8_t cbPBlk,
337 const char *pszNameFmt, va_list va) RT_IPRT_FORMAT_ATTR(5, 0);
338
339
340/**
341 * Finalizes the current scope object, nothing can be added to the scope afterwards.
342 *
343 * @returns IPRT status code.
344 * @param hAcpiTbl The ACPI table handle.
345 */
346RTDECL(int) RTAcpiTblProcessorFinalize(RTACPITBL hAcpiTbl);
347
348
349/**
350 * Starts a new method object for the given ACPI table in the current scope.
351 *
352 * @returns IPRT status code.
353 * @param hAcpiTbl The ACPI table handle.
354 * @param pszName The method name.
355 * @param fFlags AML method flags, see RTACPI_METHOD_F_XXX.
356 * @param cArgs Number of arguments this method takes.
357 * @param uSyncLvl The sync level.
358 */
359RTDECL(int) RTAcpiTblMethodStart(RTACPITBL hAcpiTbl, const char *pszName, uint8_t cArgs, uint32_t fFlags, uint8_t uSyncLvl);
360
361
362/** ACPI method is not serialized. */
363#define RTACPI_METHOD_F_NOT_SERIALIZED 0
364/** ACPI method call needs to be serialized in the ACPI interpreter. */
365#define RTACPI_METHOD_F_SERIALIZED RT_BIT_32(0)
366
367
368/**
369 * Finalizes the current method object, nothing can be added to the method afterwards.
370 *
371 * @returns IPRT status code.
372 * @param hAcpiTbl The ACPI table handle.
373 */
374RTDECL(int) RTAcpiTblMethodFinalize(RTACPITBL hAcpiTbl);
375
376
377/**
378 * Appends a new DefName object (only the NameOp NameString part, DataRefObject is left for the caller
379 * to append).
380 *
381 * @returns IPRT status code.
382 * @param hAcpiTbl The ACPI table handle.
383 * @param pszName The name to append.
384 */
385RTDECL(int) RTAcpiTblNameAppend(RTACPITBL hAcpiTbl, const char *pszName);
386
387
388/**
389 * Appends a new NullName object.
390 *
391 * @returns IPRT status code.
392 * @param hAcpiTbl The ACPI table handle.
393 */
394RTDECL(int) RTAcpiTblNullNameAppend(RTACPITBL hAcpiTbl);
395
396
397/**
398 * Appends a new NameString object.
399 *
400 * @returns IPRT status code.
401 * @param hAcpiTbl The ACPI table handle.
402 * @param pszName The name to append.
403 */
404RTDECL(int) RTAcpiTblNameStringAppend(RTACPITBL hAcpiTbl, const char *pszName);
405
406
407/**
408 * Appends a new String object - format string variant.
409 *
410 * @returns IPRT status code.
411 * @param hAcpiTbl The ACPI table handle.
412 * @param pszNameFmt The format string to build the name string from.
413 * @param ... Arguments for the format string.
414 */
415RTDECL(int) RTAcpiTblNameStringAppendF(RTACPITBL hAcpiTbl, const char *pszNameFmt, ...) RT_IPRT_FORMAT_ATTR(2, 3);
416
417
418/**
419 * Appends a new String object - format string variant.
420 *
421 * @returns IPRT status code.
422 * @param hAcpiTbl The ACPI table handle.
423 * @param pszNameFmt The format string to build the name string from.
424 * @param va The format arguments.
425 */
426RTDECL(int) RTAcpiTblNameStringAppendV(RTACPITBL hAcpiTbl, const char *pszNameFmt, va_list va) RT_IPRT_FORMAT_ATTR(2, 0);
427
428
429/**
430 * Appends a new String object.
431 *
432 * @returns IPRT status code.
433 * @param hAcpiTbl The ACPI table handle.
434 * @param psz The string to append.
435 */
436RTDECL(int) RTAcpiTblStringAppend(RTACPITBL hAcpiTbl, const char *psz);
437
438
439/**
440 * Appends a new String object - format string variant.
441 *
442 * @returns IPRT status code.
443 * @param hAcpiTbl The ACPI table handle.
444 * @param pszFmt The format string to build the string from.
445 * @param ... Arguments for the format string.
446 */
447RTDECL(int) RTAcpiTblStringAppendF(RTACPITBL hAcpiTbl, const char *pszFmt, ...) RT_IPRT_FORMAT_ATTR(2, 3);
448
449
450/**
451 * Appends a new String object - format string variant.
452 *
453 * @returns IPRT status code.
454 * @param hAcpiTbl The ACPI table handle.
455 * @param pszFmt The format string to build the string from.
456 * @param va The format arguments.
457 */
458RTDECL(int) RTAcpiTblStringAppendV(RTACPITBL hAcpiTbl, const char *pszFmt, va_list va) RT_IPRT_FORMAT_ATTR(2, 0);
459
460
461/**
462 * Appends a given UTF-8 string as UTF-16 using a buffer object (Unicode() equivalent).
463 *
464 * @returns IPRT status code.
465 * @param hAcpiTbl The ACPI table handle.
466 * @param psz The string to append.
467 */
468RTDECL(int) RTAcpiTblStringAppendAsUtf16(RTACPITBL hAcpiTbl, const char *psz);
469
470
471/**
472 * Appends a new integer object (depending on the value ZeroOp, OneOp,
473 * BytePrefix, WordPrefix, DWordPrefix or QWordPrefix is used).
474 *
475 * @returns IPRT status code.
476 * @param hAcpiTbl The ACPI table handle.
477 * @param u64 The 64-bit value to append.
478 */
479RTDECL(int) RTAcpiTblIntegerAppend(RTACPITBL hAcpiTbl, uint64_t u64);
480
481
482/**
483 * Appends a new DefBuffer object under the current scope.
484 *
485 * @returns IPRT status code.
486 * @param hAcpiTbl The ACPI table handle.
487 * @param pvBuf The buffer data.
488 * @param cbBuf Size of the buffer in bytes.
489 */
490RTDECL(int) RTAcpiTblBufferAppend(RTACPITBL hAcpiTbl, const void *pvBuf, size_t cbBuf);
491
492
493/**
494 * Appends the given resource as a DefBuffer under the current scope.
495 *
496 * @returns IPRT status code.
497 * @param hAcpiTbl The ACPI table handle.
498 * @param hAcpiRes The ACPI resource handle.
499 */
500RTDECL(int) RTAcpiTblResourceAppend(RTACPITBL hAcpiTbl, RTACPIRES hAcpiRes);
501
502
503/**
504 * List of statements.
505 */
506typedef enum RTACPISTMT
507{
508 /** Invalid statement. */
509 kAcpiStmt_Invalid = 0,
510 /** Return statement. */
511 kAcpiStmt_Return,
512 /** Breakpoint statement. */
513 kAcpiStmt_Breakpoint,
514 /** No operation statement. */
515 kAcpiStmt_Nop,
516 /** Break statement. */
517 kAcpiStmt_Break,
518 /** Continue statement. */
519 kAcpiStmt_Continue,
520 /** Add(Operand, Operand, Target) statement. */
521 kAcpiStmt_Add,
522 /** Subtract(Operand, Operand, Target) statement. */
523 kAcpiStmt_Subtract,
524 /** Multiply(Operand, Operand, Target) statement. */
525 kAcpiStmt_Multiply,
526 /** And(Operand, Operand, Target) statement. */
527 kAcpiStmt_And,
528 /** Nand(Operand, Operand, Target) statement. */
529 kAcpiStmt_Nand,
530 /** Or(Operand, Operand, Target) statement. */
531 kAcpiStmt_Or,
532 /** Xor(Operand, Operand, Target) statement. */
533 kAcpiStmt_Xor,
534 /** ShiftLeft(Operand, Operand, Target) statement. */
535 kAcpiStmt_ShiftLeft,
536 /** ShiftRight(Operand, Operand, Target) statement. */
537 kAcpiStmt_ShiftRight,
538 /** Not(Operand, Target) statement. */
539 kAcpiStmt_Not,
540 /** Store(TermArg, Supername) statement. */
541 kAcpiStmt_Store,
542 /** Index(BuffPkgStrObj, IndexValue, Target) statement. */
543 kAcpiStmt_Index,
544 /** DerefOf(ObjReference) statement. */
545 kAcpiStmt_DerefOf,
546 /** Store(SuperName, TermArg => Integer) statement. */
547 kAcpiStmt_Notify,
548 /** SizeOf(SuperName) statement. */
549 kAcpiStmt_SizeOf,
550 /** Increment(TermArg) statement. */
551 kAcpiStmt_Increment,
552 /** Decrement(TermArg) statement. */
553 kAcpiStmt_Decrement,
554 /** CondRefOf(TermArg, Target) statement. */
555 kAcpiStmt_CondRefOf
556} RTACPISTMT;
557
558
559/**
560 * Appends the given simple statement to the given ACPI table in the current scope.
561 *
562 * @returns IPRT status code.
563 * @param hAcpiTbl The ACPI table handle.
564 * @param enmStmt The statement to add.
565 */
566RTDECL(int) RTAcpiTblStmtSimpleAppend(RTACPITBL hAcpiTbl, RTACPISTMT enmStmt);
567
568
569/**
570 * Starts a new If statement operation.
571 *
572 * @returns IPRT status code.
573 * @param hAcpiTbl The ACPI table handle.
574 */
575RTDECL(int) RTAcpiTblIfStart(RTACPITBL hAcpiTbl);
576
577
578/**
579 * Finalizes the current If statement operation.
580 *
581 * @returns IPRT status code.
582 * @param hAcpiTbl The ACPI table handle.
583 */
584RTDECL(int) RTAcpiTblIfFinalize(RTACPITBL hAcpiTbl);
585
586
587/**
588 * Starts a new Else operation (only valid if currently inside an If oepration).
589 *
590 * @returns IPRT status code.
591 * @param hAcpiTbl The ACPI table handle.
592 */
593RTDECL(int) RTAcpiTblElseStart(RTACPITBL hAcpiTbl);
594
595
596/**
597 * Finalizes the current Else statement operation.
598 *
599 * @returns IPRT status code.
600 * @param hAcpiTbl The ACPI table handle.
601 */
602RTDECL(int) RTAcpiTblElseFinalize(RTACPITBL hAcpiTbl);
603
604
605/**
606 * Starts a new While statement operation.
607 *
608 * @returns IPRT status code.
609 * @param hAcpiTbl The ACPI table handle.
610 */
611RTDECL(int) RTAcpiTblWhileStart(RTACPITBL hAcpiTbl);
612
613
614/**
615 * Finalizes the current While statement operation.
616 *
617 * @returns IPRT status code.
618 * @param hAcpiTbl The ACPI table handle.
619 */
620RTDECL(int) RTAcpiTblWhileFinalize(RTACPITBL hAcpiTbl);
621
622
623/**
624 * List of binary operations.
625 */
626typedef enum RTACPIBINARYOP
627{
628 /** Invalid binary operation. */
629 kAcpiBinaryOp_Invalid = 0,
630 /** LAnd(Operand, Operand). */
631 kAcpiBinaryOp_LAnd,
632 /** LEqual(Operand, Operand). */
633 kAcpiBinaryOp_LEqual,
634 /** LGreater(Operand, Operand). */
635 kAcpiBinaryOp_LGreater,
636 /** LGreaterEqual(Operand, Operand). */
637 kAcpiBinaryOp_LGreaterEqual,
638 /** LLess(Operand, Operand). */
639 kAcpiBinaryOp_LLess,
640 /** LLessEqual(Operand, Operand). */
641 kAcpiBinaryOp_LLessEqual,
642 /** LNotEqual(Operand, Operand). */
643 kAcpiBinaryOp_LNotEqual
644} RTACPIBINARYOP;
645
646
647/**
648 * Appends the given binary operand.
649 *
650 * @returns IPRT status code.
651 * @param hAcpiTbl The ACPI table handle.
652 * @param enmBinaryOp The binary operation to append.
653 */
654RTDECL(int) RTAcpiTblBinaryOpAppend(RTACPITBL hAcpiTbl, RTACPIBINARYOP enmBinaryOp);
655
656
657/**
658 * Appends the given Arg<idArg> operand.
659 *
660 * @returns IPRT status code.
661 * @param hAcpiTbl The ACPI table handle.
662 * @param idArg The argument ID to append [0..6].
663 */
664RTDECL(int) RTAcpiTblArgOpAppend(RTACPITBL hAcpiTbl, uint8_t idArg);
665
666
667/**
668 * Appends the given Local<idLocal> operand.
669 *
670 * @returns IPRT status code.
671 * @param hAcpiTbl The ACPI table handle.
672 * @param idLocal The local ID to append [0..7].
673 */
674RTDECL(int) RTAcpiTblLocalOpAppend(RTACPITBL hAcpiTbl, uint8_t idLocal);
675
676
677/**
678 * Appends the given UUID as a buffer object.
679 *
680 * @returns IPRT status code.
681 * @param hAcpiTbl The ACPI table handle.
682 * @param pUuid The UUID to append.
683 */
684RTDECL(int) RTAcpiTblUuidAppend(RTACPITBL hAcpiTbl, PCRTUUID pUuid);
685
686
687/**
688 * Appends the given UUID string as a UUID buffer object.
689 *
690 * @returns IPRT status code.
691 * @param hAcpiTbl The ACPI table handle.
692 * @param pszUuid The UUID string to append as a buffer.
693 */
694RTDECL(int) RTAcpiTblUuidAppendFromStr(RTACPITBL hAcpiTbl, const char *pszUuid);
695
696
697/**
698 * Known operation region space types.
699 */
700typedef enum RTACPIOPREGIONSPACE
701{
702 /** Invalid region space type. */
703 kAcpiOperationRegionSpace_Invalid = 0,
704 /** Region is in system memory space. */
705 kAcpiOperationRegionSpace_SystemMemory,
706 /** Region is in system I/O space. */
707 kAcpiOperationRegionSpace_SystemIo,
708 /** Region is in PCI config space. */
709 kAcpiOperationRegionSpace_PciConfig,
710 /** Region is in embedded control space. */
711 kAcpiOperationRegionSpace_EmbeddedControl,
712 /** Region is in SMBUS space. */
713 kAcpiOperationRegionSpace_SmBus,
714 /** Region is in system CMOS space. */
715 kAcpiOperationRegionSpace_SystemCmos,
716 /** Region is a PCI bar target. */
717 kAcpiOperationRegionSpace_PciBarTarget,
718 /** Region is in IPMI space. */
719 kAcpiOperationRegionSpace_Ipmi,
720 /** Region is in GPIO space. */
721 kAcpiOperationRegionSpace_Gpio,
722 /** Region is in generic serial bus space. */
723 kAcpiOperationRegionSpace_GenericSerialBus,
724 /** Region is in platform communications channel (PCC) space. */
725 kAcpiOperationRegionSpace_Pcc,
726 /** 32bit hack. */
727 kAcpiOperationRegionSpace_32bit_Hack = 0x7fffffff
728} RTACPIOPREGIONSPACE;
729
730
731/**
732 * Appends a new OperationRegion() to the given ACPI table - extended version.
733 *
734 * @returns IPRT status code.
735 * @param hAcpiTbl The ACPI table handle.
736 * @param pszName The name of the operation region.
737 * @param enmSpace The operation region space type.
738 *
739 * @note This doesn't encode the region offset and size arguments but leaves it up to the caller
740 * to be able to encode complex stuff.
741 */
742RTDECL(int) RTAcpiTblOpRegionAppendEx(RTACPITBL hAcpiTbl, const char *pszName, RTACPIOPREGIONSPACE enmSpace);
743
744
745/**
746 * Appends a new OperationRegion() to the given ACPI table.
747 *
748 * @returns IPRT status code.
749 * @param hAcpiTbl The ACPI table handle.
750 * @param pszName The name of the operation region.
751 * @param enmSpace The operation region space type.
752 * @param offRegion Offset of the region.
753 * @param cbRegion Size of the region in bytes.
754 */
755RTDECL(int) RTAcpiTblOpRegionAppend(RTACPITBL hAcpiTbl, const char *pszName, RTACPIOPREGIONSPACE enmSpace,
756 uint64_t offRegion, uint64_t cbRegion);
757
758
759/**
760 * Field access type.
761 */
762typedef enum RTACPIFIELDACC
763{
764 /** Invalid access type. */
765 kAcpiFieldAcc_Invalid = 0,
766 /** Any access width is okay. */
767 kAcpiFieldAcc_Any,
768 /** Byte (8-bit) access. */
769 kAcpiFieldAcc_Byte,
770 /** Word (16-bit) access. */
771 kAcpiFieldAcc_Word,
772 /** Double word (32-bit) access. */
773 kAcpiFieldAcc_DWord,
774 /** Quad word (64-bit) access. */
775 kAcpiFieldAcc_QWord,
776 /** Buffer like access. */
777 kAcpiFieldAcc_Buffer
778} RTACPIFIELDACC;
779
780
781/**
782 * Field update rule.
783 */
784typedef enum RTACPIFIELDUPDATE
785{
786 /** Invalid upadte rule. */
787 kAcpiFieldUpdate_Invalid = 0,
788 /** Preserve content not being accessed. */
789 kAcpiFieldUpdate_Preserve,
790 /** Write as ones. */
791 kAcpiFieldUpdate_WriteAsOnes,
792 /** Write as zeroes. */
793 kAcpiFieldUpdate_WriteAsZeroes
794} RTACPIFIELDUPDATE;
795
796
797/**
798 * Field entry.
799 */
800typedef struct RTACPIFIELDENTRY
801{
802 /** The field name - NULL means the NullName. */
803 const char *pszName;
804 /** Number of bits of the field. */
805 uint64_t cBits;
806} RTACPIFIELDENTRY;
807/** Pointer to a field entry. */
808typedef RTACPIFIELDENTRY *PRTACPIFIELDENTRY;
809/** Pointer to a const field entry. */
810typedef const RTACPIFIELDENTRY *PCRTACPIFIELDENTRY;
811
812
813/**
814 * Appends a new field descriptor to the given ACPI table.
815 *
816 * @returns IPRT status code.
817 * @param hAcpiTbl The ACPI table handle.
818 * @param pszNameRef The region/buffer the field describes.
819 * @param enmAcc The access type,
820 * @param fLock Flag whether access must happen under a lock.
821 * @param enmUpdate The update rule.
822 * @param paFields Pointer to the field descriptors.
823 * @param cFields Number of entries in the array.
824 */
825RTDECL(int) RTAcpiTblFieldAppend(RTACPITBL hAcpiTbl, const char *pszNameRef, RTACPIFIELDACC enmAcc,
826 bool fLock, RTACPIFIELDUPDATE enmUpdate, PCRTACPIFIELDENTRY paFields,
827 uint32_t cFields);
828
829
830/**
831 * Object type.
832 */
833typedef enum RTACPIOBJTYPE
834{
835 /** Invalid object type. */
836 kAcpiObjType_Invalid = 0,
837 /** Unknown object - UnknownObj */
838 kAcpiObjType_Unknown,
839 /** Integer object - IntObj */
840 kAcpiObjType_Int,
841 /** String object - StrObj */
842 kAcpiObjType_Str,
843 /** Buffer object - BuffObj */
844 kAcpiObjType_Buff,
845 /** Package object - PkgObj */
846 kAcpiObjType_Pkg,
847 /** Field unit object - FieldUnitObj */
848 kAcpiObjType_FieldUnit,
849 /** Device object - DeviceObj */
850 kAcpiObjType_Device,
851 /** Event object - EventObj */
852 kAcpiObjType_Event,
853 /** Method object - MethodObj */
854 kAcpiObjType_Method,
855 /** Mutex object - MutexObj */
856 kAcpiObjType_MutexObj,
857 /** OpRegion object - OpRegionObj */
858 kAcpiObjType_OpRegion,
859 /** Power resource object - PowerResObj */
860 kAcpiObjType_PowerRes,
861 /** Thermal zone object - ThermalZoneObj */
862 kAcpiObjType_ThermalZone,
863 /** Buffer field object - BuffFieldObj */
864 kAcpiObjType_BuffField,
865 /** Processor object - ProcessorObj */
866 kAcpiObjType_Processor
867} RTACPIOBJTYPE;
868
869
870/**
871 * Appends a new External declaration to the given ACPI table.
872 *
873 * @returns IPRT status code.
874 * @param hAcpiTbl The ACPI table handle.
875 * @param pszName The name stirng of the external object.
876 * @param enmObjType The object type.
877 * @param cArgs Number of arguments for the object (mostly method), valid is [0..7].
878 */
879RTDECL(int) RTAcpiTblExternalAppend(RTACPITBL hAcpiTbl, const char *pszName, RTACPIOBJTYPE enmObjType, uint8_t cArgs);
880
881
882/** @name ACPI resource builder related API.
883 * @{ */
884
885/**
886 * Creates a new empty resource template.
887 *
888 * @returns IPRT status code.
889 * @param phAcpiRes Where to store the handle to the ACPI resource on success.
890 */
891RTDECL(int) RTAcpiResourceCreate(PRTACPIRES phAcpiRes);
892
893
894/**
895 * Destroys the given ACPI resource, freeing all allocated resources.
896 *
897 * @param hAcpiRes The ACPI resource handle to destroy.
898 */
899RTDECL(void) RTAcpiResourceDestroy(RTACPIRES hAcpiRes);
900
901
902/**
903 * Resets the given ACPI resource handle to create a new empty template.
904 *
905 * @param hAcpiRes The ACPI resource handle.
906 */
907RTDECL(void) RTAcpiResourceReset(RTACPIRES hAcpiRes);
908
909
910/**
911 * Returns the offset where the next resource added to the template would be.
912 *
913 * @returns Offset into the resource buffer where the next resource will be appended
914 * @retval UINT32_MAX if the handle is invalid or the resource is in an error state.
915 * @param hAcpiRes The ACPI resource handle.
916 */
917RTDECL(uint32_t) RTAcpiResourceGetOffset(RTACPIRES hAcpiRes);
918
919
920/**
921 * Seals the given ACPI resource against further changes and adds any
922 * missing data required to complete the resource buffer.
923 *
924 * @returns IPRT status code.
925 * @param hAcpiRes The ACPI resource handle.
926 *
927 * @note After a call to this method completed successfully it is not possible
928 * to add new resources until RTAcpiResourceReset() was called.
929 */
930RTDECL(int) RTAcpiResourceSeal(RTACPIRES hAcpiRes);
931
932
933/**
934 * Queries the pointer to the buffer holding the encoded data.
935 *
936 * @returns IPRT status code.
937 * @param hAcpiRes The ACPI resource handle.
938 * @param ppvRes Where to store the pointer to the buffer holding the encoded resource template on success.
939 * @param pcbRes Where to store the size of the encoded data in bytes on success.
940 *
941 * @note The ACPI resource must be successfully sealed with RTAcpiResourceSeal() for this function to succeed.
942 * Also the buffer pointer will only be valid until a call to any other RTAcpiResource* method.
943 */
944RTDECL(int) RTAcpiResourceQueryBuffer(RTACPIRES hAcpiRes, const void **ppvRes, size_t *pcbRes);
945
946
947/**
948 * Adds a fixed memory range with the given start address and size to the given ACPI resource.
949 *
950 * @returns IPRT status code.
951 * @param hAcpiRes The ACPI resource handle.
952 * @param u32AddrBase The base address to encode.
953 * @param cbRange The range length in bytes to encode.
954 * @param fRw Flag whether this address range is read-write or read-only.
955 */
956RTDECL(int) RTAcpiResourceAdd32BitFixedMemoryRange(RTACPIRES hAcpiRes, uint32_t u32AddrBase, uint32_t cbRange,
957 bool fRw);
958
959
960/**
961 * Adds an extended interrupt descriptor with the given configuration to the given ACPI resource.
962 *
963 * @returns IPRT status code.
964 * @param hAcpiRes The ACPI resource handle.
965 * @param fConsumer Flag whether the entity this resource is assigned to consumes the interrupt (true) or produces it (false).
966 * @param fEdgeTriggered Flag whether the interrupt is edged (true) or level (false) triggered.
967 * @param fActiveLow Flag whether the interrupt polarity is active low (true) or active high (false).
968 * @param fShared Flag whether the interrupt is shared between different entities (true) or exclusive to the assigned entity (false).
969 * @param fWakeCapable Flag whether the interrupt can wake the system (true) or not (false).
970 * @param cIntrs Number of interrupts following.
971 * @param pau32Intrs Pointer to the array of interrupt numbers.
972 */
973RTDECL(int) RTAcpiResourceAddExtendedInterrupt(RTACPIRES hAcpiRes, bool fConsumer, bool fEdgeTriggered, bool fActiveLow, bool fShared,
974 bool fWakeCapable, uint8_t cIntrs, uint32_t *pau32Intrs);
975
976
977/** @name Generic address space flags.
978 * @{ */
979#define RTACPI_RESOURCE_ADDR_RANGE_F_DECODE_TYPE_SUB RT_BIT_32(0)
980#define RTACPI_RESOURCE_ADDR_RANGE_F_DECODE_TYPE_POS 0
981
982#define RTACPI_RESOURCE_ADDR_RANGE_F_MIN_ADDR_FIXED RT_BIT_32(1)
983#define RTACPI_RESOURCE_ADDR_RANGE_F_MIN_ADDR_CHANGEABLE 0
984
985#define RTACPI_RESOURCE_ADDR_RANGE_F_MAX_ADDR_FIXED RT_BIT_32(2)
986#define RTACPI_RESOURCE_ADDR_RANGE_F_MAX_ADDR_CHANGEABLE 0
987
988#define RTACPI_RESOURCE_ADDR_RANGE_F_PRODUCER RT_BIT_32(3)
989#define RTACPI_RESOURCE_ADDR_RANGE_F_CONSUMER 0
990
991#define RTACPI_RESOURCE_ADDR_RANGE_F_VALID_MASK UINT32_C(0x0000000f)
992/** @} */
993
994/**
995 * Memory range cacheability
996 */
997typedef enum RTACPIRESMEMRANGECACHEABILITY
998{
999 /** Usual invalid value. */
1000 kAcpiResMemRangeCacheability_Invalid = 0,
1001 /** Memory range is non cacheable (like MMIO, etc.). */
1002 kAcpiResMemRangeCacheability_NonCacheable,
1003 /** Memory is cacheable. */
1004 kAcpiResMemRangeCacheability_Cacheable,
1005 /** Memory is cacheable and supports write combining. */
1006 kAcpiResMemRangeCacheability_CacheableWriteCombining,
1007 /** Memory is cacheable and supports prefetching. */
1008 kAcpiResMemRangeCacheability_CacheablePrefetchable,
1009 /** 32-bit blow up hack. */
1010 kAcpiResMemRangeCacheability_32BitHack = 0x7fffffff
1011} RTACPIRESMEMRANGECACHEABILITY;
1012
1013
1014/**
1015 * Memory attribute.
1016 */
1017typedef enum RTACPIRESMEMRANGETYPE
1018{
1019 /** Invalid memory range type. */
1020 kAcpiResMemType_Invalid = 0,
1021 /** Memory range is actual memory. */
1022 kAcpiResMemType_Memory,
1023 /** Memory range is reserved. */
1024 kAcpiResMemType_Reserved,
1025 /** Memory range is reserved to ACPI. */
1026 kAcpiResMemType_Acpi,
1027 /** Memory range is no volatile storage. */
1028 kAcpiResMemType_Nvs,
1029 /** 32-bit blow up hack. */
1030 kAcpiResMemType_32BitHack = 0x7fffffff
1031} RTACPIRESMEMRANGETYPE;
1032
1033
1034/**
1035 * Adds a quad word (64-bit) memory range to the given ACPI resource.
1036 *
1037 * @returns IPRT status code.
1038 * @param hAcpiRes The ACPI resource handle.
1039 * @param enmCacheability The cacheability of the memory range.
1040 * @param enmType Memory range type.
1041 * @param fRw Flag whether the memory range is read/write (true) or readonly (false).
1042 * @param fAddrSpace Additional address space flags (combination of RTACPI_RESOURCE_ADDR_RANGE_F_XXX).
1043 * @param u64AddrMin The start address of the memory range.
1044 * @param u64AddrMax Last valid address of the range.
1045 * @param u64OffTrans Translation offset being applied to the address (for a PCIe bridge or IOMMU for example).
1046 * @param u64Granularity The access granularity of the range in bytes.
1047 * @param u64Length Length of the memory range in bytes.
1048 */
1049RTDECL(int) RTAcpiResourceAddQWordMemoryRange(RTACPIRES hAcpiRes, RTACPIRESMEMRANGECACHEABILITY enmCacheability,
1050 RTACPIRESMEMRANGETYPE enmType, bool fRw, uint32_t fAddrSpace,
1051 uint64_t u64AddrMin, uint64_t u64AddrMax, uint64_t u64OffTrans,
1052 uint64_t u64Granularity, uint64_t u64Length);
1053
1054
1055/**
1056 * Adds a quad word (64-bit) memory range to the given ACPI resource - extended version.
1057 *
1058 * @returns IPRT status code.
1059 * @param hAcpiRes The ACPI resource handle.
1060 * @param enmCacheability The cacheability of the memory range.
1061 * @param enmType Memory range type.
1062 * @param fRw Flag whether the memory range is read/write (true) or readonly (false).
1063 * @param fStatic Flag whether the translation type is static (true) or translation (false).
1064 * @param fAddrSpace Additional address space flags (combination of RTACPI_RESOURCE_ADDR_RANGE_F_XXX).
1065 * @param u64AddrMin The start address of the memory range.
1066 * @param u64AddrMax Last valid address of the range.
1067 * @param u64OffTrans Translation offset being applied to the address (for a PCIe bridge or IOMMU for example).
1068 * @param u64Granularity The access granularity of the range in bytes.
1069 * @param u64Length Length of the memory range in bytes.
1070 * @param pszRsrcSrc Name of the device object that produces the the descriptor consumed by the device, optional.
1071 * NULL means the device consumes the resource out of a global pool.
1072 * @param bRsrcIndex Index into the resource descriptor this device consumes from. Ignored if pszRsrcSrc is NULL.
1073 */
1074RTDECL(int) RTAcpiResourceAddQWordMemoryRangeEx(RTACPIRES hAcpiRes, RTACPIRESMEMRANGECACHEABILITY enmCacheability,
1075 RTACPIRESMEMRANGETYPE enmType, bool fRw, bool fStatic, uint32_t fAddrSpace,
1076 uint64_t u64AddrMin, uint64_t u64AddrMax, uint64_t u64OffTrans,
1077 uint64_t u64Granularity, uint64_t u64Length,
1078 const char *pszRsrcSrc, uint8_t bRsrcIndex);
1079
1080
1081/**
1082 * Adds a double word (32-bit) memory range to the given ACPI resource.
1083 *
1084 * @returns IPRT status code.
1085 * @param hAcpiRes The ACPI resource handle.
1086 * @param enmCacheability The cacheability of the memory range.
1087 * @param enmType Memory range type.
1088 * @param fRw Flag whether the memory range is read/write (true) or readonly (false).
1089 * @param fAddrSpace Additional address space flags (combination of RTACPI_RESOURCE_ADDR_RANGE_F_XXX).
1090 * @param u32AddrMin The start address of the memory range.
1091 * @param u32AddrMax Last valid address of the range.
1092 * @param u32OffTrans Translation offset being applied to the address (for a PCIe bridge or IOMMU for example).
1093 * @param u32Granularity The access granularity of the range in bytes.
1094 * @param u32Length Length of the memory range in bytes.
1095 */
1096RTDECL(int) RTAcpiResourceAddDWordMemoryRange(RTACPIRES hAcpiRes, RTACPIRESMEMRANGECACHEABILITY enmCacheability,
1097 RTACPIRESMEMRANGETYPE enmType, bool fRw, uint32_t fAddrSpace,
1098 uint32_t u32AddrMin, uint32_t u32AddrMax, uint32_t u32OffTrans,
1099 uint32_t u32Granularity, uint32_t u32Length);
1100
1101
1102/**
1103 * Adds a double word (32-bit) memory range to the given ACPI resource - extended version.
1104 *
1105 * @returns IPRT status code.
1106 * @param hAcpiRes The ACPI resource handle.
1107 * @param enmCacheability The cacheability of the memory range.
1108 * @param enmType Memory range type.
1109 * @param fRw Flag whether the memory range is read/write (true) or readonly (false).
1110 * @param fStatic Flag whether the translation type is static (true) or translation (false).
1111 * @param fAddrSpace Additional address space flags (combination of RTACPI_RESOURCE_ADDR_RANGE_F_XXX).
1112 * @param u32AddrMin The start address of the memory range.
1113 * @param u32AddrMax Last valid address of the range.
1114 * @param u32OffTrans Translation offset being applied to the address (for a PCIe bridge or IOMMU for example).
1115 * @param u32Granularity The access granularity of the range in bytes.
1116 * @param u32Length Length of the memory range in bytes.
1117 * @param pszRsrcSrc Name of the device object that produces the the descriptor consumed by the device, optional.
1118 * NULL means the device consumes the resource out of a global pool.
1119 * @param bRsrcIndex Index into the resource descriptor this device consumes from. Ignored if pszRsrcSrc is NULL.
1120 */
1121RTDECL(int) RTAcpiResourceAddDWordMemoryRangeEx(RTACPIRES hAcpiRes, RTACPIRESMEMRANGECACHEABILITY enmCacheability,
1122 RTACPIRESMEMRANGETYPE enmType, bool fRw, bool fStatic, uint32_t fAddrSpace,
1123 uint32_t u32AddrMin, uint32_t u32AddrMax, uint32_t u32OffTrans,
1124 uint32_t u32Granularity, uint32_t u32Length,
1125 const char *pszRsrcSrc, uint8_t bRsrcIndex);
1126
1127
1128/**
1129 * I/O range coverage.
1130 */
1131typedef enum RTACPIRESIORANGE
1132{
1133 /** Invalid range. */
1134 kAcpiResIoRange_Invalid = 0,
1135 /** Range covers only non ISA I/O ports. */
1136 kAcpiResIoRange_NonIsaOnly,
1137 /** Range covers only ISA I/O ports. */
1138 kAcpiResIoRange_IsaOnly,
1139 /** Range covers the whole I/O port range. */
1140 kAcpiResIoRange_Whole,
1141 /** 32-bit blow up hack. */
1142 kAcpiResIoRange_32BitHack = 0x7fffffff
1143} RTACPIRESIORANGE;
1144
1145
1146/**
1147 * I/O range type.
1148 */
1149typedef enum RTACPIRESIORANGETYPE
1150{
1151 /** Invalid value. */
1152 kAcpiResIoRangeType_Invalid = 0,
1153 /** Resource is I/O on the primary and secondary side of the bridge. */
1154 kAcpiResIoRangeType_Static,
1155 /** Resource is memory on the primary and I/O on the secondary side of the bridge,
1156 * primary side memory address for a given I/O port is calculated with
1157 * address = (((Port & 0xfffc) << 10) || (Port & 0xfff)) + AddrMin. */
1158 kAcpiResIoRangeType_Translation_Sparse,
1159 /** Resource is memory on the primary and I/O on the secondary side of the bridge,
1160 * primary side memory address for a given I/O port is calculated with
1161 * address = AddrMin + Port. */
1162 kAcpiResIoRangeType_Translation_Dense,
1163 /** 32-bit blowup hack. */
1164 kAcpiResIoRangeType_32BitHack = 0x7fffffff
1165} RTACPIRESIORANGETYPE;
1166
1167
1168/**
1169 * Adds a quad word (64-bit) I/O range to the given ACPI resource.
1170 *
1171 * @returns IPRT status code.
1172 * @param hAcpiRes The ACPI resource handle.
1173 * @param enmIoType The I/O range type.
1174 * @param enmIoRange The I/O range coverage.
1175 * @param fAddrSpace Additional address space flags (combination of RTACPI_RESOURCE_ADDR_RANGE_F_XXX).
1176 * @param u64AddrMin The start address of the memory range.
1177 * @param u64AddrMax Last valid address of the range.
1178 * @param u64OffTrans Translation offset being applied to the address (for a PCIe bridge or IOMMU for example).
1179 * @param u64Granularity The access granularity of the range in bytes.
1180 * @param u64Length Length of the memory range in bytes.
1181 */
1182RTDECL(int) RTAcpiResourceAddQWordIoRange(RTACPIRES hAcpiRes, RTACPIRESIORANGETYPE enmIoType, RTACPIRESIORANGE enmIoRange,
1183 uint32_t fAddrSpace, uint64_t u64AddrMin, uint64_t u64AddrMax, uint64_t u64OffTrans,
1184 uint64_t u64Granularity, uint64_t u64Length);
1185
1186
1187/**
1188 * Adds a word (16-bit) I/O range to the given ACPI resource - extended version.
1189 *
1190 * @returns IPRT status code.
1191 * @param hAcpiRes The ACPI resource handle.
1192 * @param enmIoType The I/O range type.
1193 * @param enmIoRange The I/O range coverage.
1194 * @param fAddrSpace Additional address space flags (combination of RTACPI_RESOURCE_ADDR_RANGE_F_XXX).
1195 * @param u16AddrMin The start address of the memory range.
1196 * @param u16AddrMax Last valid address of the range.
1197 * @param u16OffTrans Translation offset being applied to the address (for a PCIe bridge or IOMMU for example).
1198 * @param u16Granularity The access granularity of the range in bytes.
1199 * @param u16Length Length of the memory range in bytes.
1200 * @param pszRsrcSrc Name of the device object that produces the the descriptor consumed by the device, optional.
1201 * NULL means the device consumes the resource out of a global pool.
1202 * @param bRsrcIndex Index into the resource descriptor this device consumes from. Ignored if pszRsrcSrc is NULL.
1203 */
1204RTDECL(int) RTAcpiResourceAddWordIoRangeEx(RTACPIRES hAcpiRes, RTACPIRESIORANGETYPE enmIoType, RTACPIRESIORANGE enmIoRange,
1205 uint32_t fAddrSpace, uint16_t u16AddrMin, uint16_t u16AddrMax, uint64_t u16OffTrans,
1206 uint16_t u16Granularity, uint16_t u16Length, const char *pszRsrcSrc, uint8_t bRsrcIndex);
1207
1208
1209/**
1210 * Adds a word (16-bit) bus number to the given ACPI resource.
1211 *
1212 * @returns IPRT status code.
1213 * @param hAcpiRes The ACPI resource handle.
1214 * @param fAddrSpace Additional address space flags (combination of RTACPI_RESOURCE_ADDR_RANGE_F_XXX).
1215 * @param u16BusMin Starting bus number.
1216 * @param u16BusMax Last valid bus number.
1217 * @param u16OffTrans Translation offset being applied to the bus number.
1218 * @param u16Granularity The access granularity of the bus number.
1219 * @param u16Length Length of the bus range.
1220 */
1221RTDECL(int) RTAcpiResourceAddWordBusNumber(RTACPIRES hAcpiRes, uint32_t fAddrSpace, uint16_t u16BusMin, uint16_t u16BusMax,
1222 uint16_t u16OffTrans, uint16_t u16Granularity, uint16_t u16Length);
1223
1224
1225/**
1226 * Adds a word (16-bit) bus number to the given ACPI resource - extended version.
1227 *
1228 * @returns IPRT status code.
1229 * @param hAcpiRes The ACPI resource handle.
1230 * @param fAddrSpace Additional address space flags (combination of RTACPI_RESOURCE_ADDR_RANGE_F_XXX).
1231 * @param u16BusMin Starting bus number.
1232 * @param u16BusMax Last valid bus number.
1233 * @param u16OffTrans Translation offset being applied to the bus number.
1234 * @param u16Granularity The access granularity of the bus number.
1235 * @param u16Length Length of the bus range.
1236 * @param pszRsrcSrc Name of the device object that produces the the descriptor consumed by the device, optional.
1237 * NULL means the device consumes the resource out of a global pool.
1238 * @param bRsrcIndex Index into the resource descriptor this device consumes from. Ignored if pszRsrcSrc is NULL.
1239 */
1240RTDECL(int) RTAcpiResourceAddWordBusNumberEx(RTACPIRES hAcpiRes, uint32_t fAddrSpace, uint16_t u16BusMin, uint16_t u16BusMax,
1241 uint16_t u16OffTrans, uint16_t u16Granularity, uint16_t u16Length,
1242 const char *pszRsrcSrc, uint8_t bRsrcIndex);
1243
1244
1245/**
1246 * I/O decode type.
1247 */
1248typedef enum RTACPIRESIODECODETYPE
1249{
1250 /** Invalid value. */
1251 kAcpiResIoDecodeType_Invalid = 0,
1252 /** 10-bit decoding. */
1253 kAcpiResIoDecodeType_Decode10,
1254 /** 16-bit decoding. */
1255 kAcpiResIoDecodeType_Decode16,
1256 /** 32-bit blowup hack. */
1257 kAcpiResIoDecodeType_32BitHack = 0x7fffffff
1258} RTACPIRESIODECODETYPE;
1259
1260
1261/**
1262 * Adds an I/O port descriptor to the given ACPI resource.
1263 *
1264 * @returns IPRT status code.
1265 * @param hAcpiRes The ACPI resource handle.
1266 * @param enmDecode The decoding type of the range.
1267 * @param u16AddrMin Minimum base I/O address the range might be configured for.
1268 * @param u16AddrMax Maximum base I/O address the range might be configured for.
1269 * @param u8AddrAlignment Alignment of the minimum base address.
1270 * @param u8RangeLength Number of contiguous I/O ports requested.
1271 */
1272RTDECL(int) RTAcpiResourceAddIo(RTACPIRES hAcpiRes, RTACPIRESIODECODETYPE enmDecode, uint16_t u16AddrMin, uint16_t u16AddrMax,
1273 uint8_t u8AddrAlignment, uint8_t u8RangeLength);
1274
1275
1276/**
1277 * Adds an IRQ descriptor with the given configuration to the given ACPI resource.
1278 *
1279 * @returns IPRT status code.
1280 * @param hAcpiRes The ACPI resource handle.
1281 * @param fEdgeTriggered Flag whether the interrupt is edged (true) or level (false) triggered.
1282 * @param fActiveLow Flag whether the interrupt polarity is active low (true) or active high (false).
1283 * @param fShared Flag whether the interrupt is shared between different entities (true) or exclusive to the assigned entity (false).
1284 * @param fWakeCapable Flag whether the interrupt can wake the system (true) or not (false).
1285 * @param bmIntrs Bitmap of interrupts (0..15) requested.
1286 */
1287RTDECL(int) RTAcpiResourceAddIrq(RTACPIRES hAcpiRes, bool fEdgeTriggered, bool fActiveLow, bool fShared,
1288 bool fWakeCapable, uint16_t bmIntrs);
1289
1290
1291/**
1292 * DMA channel speed.
1293 */
1294typedef enum RTACPIRESDMACHANSPEED
1295{
1296 /** Invalid value. */
1297 kAcpiResDmaChanSpeed_Invalid = 0,
1298 /** Compatibility mode. */
1299 kAcpiResDmaChanSpeed_Compatibility,
1300 /** Type A DMA as described in EISA. */
1301 kAcpiResDmaChanSpeed_TypeA,
1302 /** Type B DMA. */
1303 kAcpiResDmaChanSpeed_TypeB,
1304 /** Type F. */
1305 kAcpiResDmaChanSpeed_TypeF,
1306 /** 32-bit blowup hack. */
1307 kAcpiResDmaChanSpeed_32BitHack = 0x7fffffff
1308} RTACPIRESDMACHANSPEED;
1309
1310
1311/**
1312 * DMA transfer type.
1313 */
1314typedef enum RTACPIRESDMATRANSFERTYPE
1315{
1316 /** Invalid value. */
1317 kAcpiResDmaTransferType_Invalid = 0,
1318 /** 8bit only. */
1319 kAcpiResDmaTransferType_8Bit,
1320 /** 8-bit and 16-bit. */
1321 kAcpiResDmaTransferType_8Bit_16Bit,
1322 /** 16-bit only. */
1323 kAcpiResDmaTransferType_16Bit,
1324 /** 32-bit blowup hack. */
1325 kAcpiResDmaTransferType_32BitHack = 0x7fffffff
1326} RTACPIRESDMATRANSFERTYPE;
1327
1328
1329/**
1330 * Adds a DMA descriptor with the given configuration to the given ACPI resource.
1331 *
1332 * @returns IPRT status code.
1333 * @param hAcpiRes The ACPI resource handle.
1334 * @param enmChanSpeed The DMA channel speed.
1335 * @param fBusMaster Flag whether the device is a bus master.
1336 * @param enmTransferType DMA transfer type preference.
1337 * @param bmChannels Bitmap of DMA channels (0..7) requested.
1338 */
1339RTDECL(int) RTAcpiResourceAddDma(RTACPIRES hAcpiRes, RTACPIRESDMACHANSPEED enmChanSpeed, bool fBusMaster,
1340 RTACPIRESDMATRANSFERTYPE enmTransferType, uint8_t bmChannels);
1341
1342/** @} */
1343
1344#endif /* IN_RING3 */
1345
1346/** @} */
1347
1348RT_C_DECLS_END
1349
1350#endif /* !IPRT_INCLUDED_acpi_h */
1351
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