VirtualBox

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

最後變更 在這個檔案是 108231,由 vboxsync 提交於 4 週 前

include/iprt/acpi.h: Doxygen fix, bugref:10733

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 53.0 KB
 
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.alldomusa.eu.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 * 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 buffer object for the given ACPI table in the current scope.
351 *
352 * @returns IPRT status code.
353 * @param hAcpiTbl The ACPI table handle.
354 */
355RTDECL(int) RTAcpiTblBufferStart(RTACPITBL hAcpiTbl);
356
357
358/**
359 * Finalizes the current buffer object, nothing can be added to the scope afterwards.
360 *
361 * @returns IPRT status code.
362 * @param hAcpiTbl The ACPI table handle.
363 */
364RTDECL(int) RTAcpiTblBufferFinalize(RTACPITBL hAcpiTbl);
365
366
367/**
368 * Appends data to the current raw buffer object (needs to be called between RTAcpiTblBufferStart() and RTAcpiTblBufferFinalize()).
369 *
370 * @returns IPRT status code.
371 * @param hAcpiTbl The ACPI table handle.
372 * @param pvBuf The data to append.
373 * @param cbBuf Size of the buffer in bytes.
374 */
375RTDECL(int) RTAcpiTblBufferAppendRawData(RTACPITBL hAcpiTbl, const void *pvBuf, size_t cbBuf);
376
377
378/**
379 * Starts a new method object for the given ACPI table in the current scope.
380 *
381 * @returns IPRT status code.
382 * @param hAcpiTbl The ACPI table handle.
383 * @param pszName The method name.
384 * @param fFlags AML method flags, see RTACPI_METHOD_F_XXX.
385 * @param cArgs Number of arguments this method takes.
386 * @param uSyncLvl The sync level.
387 */
388RTDECL(int) RTAcpiTblMethodStart(RTACPITBL hAcpiTbl, const char *pszName, uint8_t cArgs, uint32_t fFlags, uint8_t uSyncLvl);
389
390
391/** ACPI method is not serialized. */
392#define RTACPI_METHOD_F_NOT_SERIALIZED 0
393/** ACPI method call needs to be serialized in the ACPI interpreter. */
394#define RTACPI_METHOD_F_SERIALIZED RT_BIT_32(0)
395
396
397/**
398 * Finalizes the current method object, nothing can be added to the method afterwards.
399 *
400 * @returns IPRT status code.
401 * @param hAcpiTbl The ACPI table handle.
402 */
403RTDECL(int) RTAcpiTblMethodFinalize(RTACPITBL hAcpiTbl);
404
405
406/**
407 * Appends a new DefName object (only the NameOp NameString part, DataRefObject is left for the caller
408 * to append).
409 *
410 * @returns IPRT status code.
411 * @param hAcpiTbl The ACPI table handle.
412 * @param pszName The name to append.
413 */
414RTDECL(int) RTAcpiTblNameAppend(RTACPITBL hAcpiTbl, const char *pszName);
415
416
417/**
418 * Appends a new NullName object.
419 *
420 * @returns IPRT status code.
421 * @param hAcpiTbl The ACPI table handle.
422 */
423RTDECL(int) RTAcpiTblNullNameAppend(RTACPITBL hAcpiTbl);
424
425
426/**
427 * Appends a new NameString object.
428 *
429 * @returns IPRT status code.
430 * @param hAcpiTbl The ACPI table handle.
431 * @param pszName The name to append.
432 */
433RTDECL(int) RTAcpiTblNameStringAppend(RTACPITBL hAcpiTbl, const char *pszName);
434
435
436/**
437 * Appends a new String object - format string variant.
438 *
439 * @returns IPRT status code.
440 * @param hAcpiTbl The ACPI table handle.
441 * @param pszNameFmt The format string to build the name string from.
442 * @param ... Arguments for the format string.
443 */
444RTDECL(int) RTAcpiTblNameStringAppendF(RTACPITBL hAcpiTbl, const char *pszNameFmt, ...) RT_IPRT_FORMAT_ATTR(2, 3);
445
446
447/**
448 * Appends a new String object - format string variant.
449 *
450 * @returns IPRT status code.
451 * @param hAcpiTbl The ACPI table handle.
452 * @param pszNameFmt The format string to build the name string from.
453 * @param va The format arguments.
454 */
455RTDECL(int) RTAcpiTblNameStringAppendV(RTACPITBL hAcpiTbl, const char *pszNameFmt, va_list va) RT_IPRT_FORMAT_ATTR(2, 0);
456
457
458/**
459 * Appends a new String object.
460 *
461 * @returns IPRT status code.
462 * @param hAcpiTbl The ACPI table handle.
463 * @param psz The string to append.
464 */
465RTDECL(int) RTAcpiTblStringAppend(RTACPITBL hAcpiTbl, const char *psz);
466
467
468/**
469 * Appends a new String object - format string variant.
470 *
471 * @returns IPRT status code.
472 * @param hAcpiTbl The ACPI table handle.
473 * @param pszFmt The format string to build the string from.
474 * @param ... Arguments for the format string.
475 */
476RTDECL(int) RTAcpiTblStringAppendF(RTACPITBL hAcpiTbl, const char *pszFmt, ...) RT_IPRT_FORMAT_ATTR(2, 3);
477
478
479/**
480 * Appends a new String object - format string variant.
481 *
482 * @returns IPRT status code.
483 * @param hAcpiTbl The ACPI table handle.
484 * @param pszFmt The format string to build the string from.
485 * @param va The format arguments.
486 */
487RTDECL(int) RTAcpiTblStringAppendV(RTACPITBL hAcpiTbl, const char *pszFmt, va_list va) RT_IPRT_FORMAT_ATTR(2, 0);
488
489
490/**
491 * Appends a given UTF-8 string as UTF-16 using a buffer object (Unicode() equivalent).
492 *
493 * @returns IPRT status code.
494 * @param hAcpiTbl The ACPI table handle.
495 * @param psz The string to append.
496 */
497RTDECL(int) RTAcpiTblStringAppendAsUtf16(RTACPITBL hAcpiTbl, const char *psz);
498
499
500/**
501 * Appends a new integer object (depending on the value ZeroOp, OneOp,
502 * BytePrefix, WordPrefix, DWordPrefix or QWordPrefix is used).
503 *
504 * @returns IPRT status code.
505 * @param hAcpiTbl The ACPI table handle.
506 * @param u64 The 64-bit value to append.
507 */
508RTDECL(int) RTAcpiTblIntegerAppend(RTACPITBL hAcpiTbl, uint64_t u64);
509
510
511/**
512 * Appends a new DefBuffer object under the current scope.
513 *
514 * @returns IPRT status code.
515 * @param hAcpiTbl The ACPI table handle.
516 * @param pvBuf The buffer data.
517 * @param cbBuf Size of the buffer in bytes.
518 */
519RTDECL(int) RTAcpiTblBufferAppend(RTACPITBL hAcpiTbl, const void *pvBuf, size_t cbBuf);
520
521
522/**
523 * Appends the given resource as a DefBuffer under the current scope.
524 *
525 * @returns IPRT status code.
526 * @param hAcpiTbl The ACPI table handle.
527 * @param hAcpiRes The ACPI resource handle.
528 */
529RTDECL(int) RTAcpiTblResourceAppend(RTACPITBL hAcpiTbl, RTACPIRES hAcpiRes);
530
531
532/**
533 * List of statements.
534 */
535typedef enum RTACPISTMT
536{
537 /** Invalid statement. */
538 kAcpiStmt_Invalid = 0,
539 /** Ones statement. */
540 kAcpiStmt_Ones,
541 /** Return statement. */
542 kAcpiStmt_Return,
543 /** Breakpoint statement. */
544 kAcpiStmt_Breakpoint,
545 /** No operation statement. */
546 kAcpiStmt_Nop,
547 /** Break statement. */
548 kAcpiStmt_Break,
549 /** Continue statement. */
550 kAcpiStmt_Continue,
551 /** Add(Operand, Operand, Target) statement. */
552 kAcpiStmt_Add,
553 /** Subtract(Operand, Operand, Target) statement. */
554 kAcpiStmt_Subtract,
555 /** Multiply(Operand, Operand, Target) statement. */
556 kAcpiStmt_Multiply,
557 /** And(Operand, Operand, Target) statement. */
558 kAcpiStmt_And,
559 /** Nand(Operand, Operand, Target) statement. */
560 kAcpiStmt_Nand,
561 /** Or(Operand, Operand, Target) statement. */
562 kAcpiStmt_Or,
563 /** Xor(Operand, Operand, Target) statement. */
564 kAcpiStmt_Xor,
565 /** ShiftLeft(Operand, Operand, Target) statement. */
566 kAcpiStmt_ShiftLeft,
567 /** ShiftRight(Operand, Operand, Target) statement. */
568 kAcpiStmt_ShiftRight,
569 /** Not(Operand, Target) statement. */
570 kAcpiStmt_Not,
571 /** Store(TermArg, Supername) statement. */
572 kAcpiStmt_Store,
573 /** Index(BuffPkgStrObj, IndexValue, Target) statement. */
574 kAcpiStmt_Index,
575 /** DerefOf(ObjReference) statement. */
576 kAcpiStmt_DerefOf,
577 /** Store(SuperName, TermArg => Integer) statement. */
578 kAcpiStmt_Notify,
579 /** SizeOf(SuperName) statement. */
580 kAcpiStmt_SizeOf,
581 /** Increment(TermArg) statement. */
582 kAcpiStmt_Increment,
583 /** Decrement(TermArg) statement. */
584 kAcpiStmt_Decrement,
585 /** CondRefOf(TermArg, Target) statement. */
586 kAcpiStmt_CondRefOf,
587 /** LNot(Source) statement. */
588 kAcpiStmt_LNot,
589 /** CreateBitField(SourceBuff, BitIndex, NameString) statement. */
590 kAcpiStmt_CreateBitField,
591 /** CreateByteField(SourceBuff, ByteIndex, NameString) statement. */
592 kAcpiStmt_CreateByteField,
593 /** CreateWordField(SourceBuff, ByteIndex, NameString) statement. */
594 kAcpiStmt_CreateWordField,
595 /** CreateDWordField(SourceBuff, ByteIndex, NameString) statement. */
596 kAcpiStmt_CreateDWordField,
597 /** CreateQWordField(SourceBuff, ByteIndex, NameString) statement. */
598 kAcpiStmt_CreateQWordField,
599 /** ConcatenateResTemplate(Source1, Source2, Result) statement. */
600 kAcpiStmt_ConcatenateResTemplate,
601 /** FindSetLeftBit(Source, Result) statement. */
602 kAcpiStmt_FindSetLeftBit,
603 /** FindSetRightBit(Source, Result) statement. */
604 kAcpiStmt_FindSetRightBit
605} RTACPISTMT;
606
607
608/**
609 * Appends the given simple statement to the given ACPI table in the current scope.
610 *
611 * @returns IPRT status code.
612 * @param hAcpiTbl The ACPI table handle.
613 * @param enmStmt The statement to add.
614 */
615RTDECL(int) RTAcpiTblStmtSimpleAppend(RTACPITBL hAcpiTbl, RTACPISTMT enmStmt);
616
617
618/**
619 * Starts a new If statement operation.
620 *
621 * @returns IPRT status code.
622 * @param hAcpiTbl The ACPI table handle.
623 */
624RTDECL(int) RTAcpiTblIfStart(RTACPITBL hAcpiTbl);
625
626
627/**
628 * Finalizes the current If statement operation.
629 *
630 * @returns IPRT status code.
631 * @param hAcpiTbl The ACPI table handle.
632 */
633RTDECL(int) RTAcpiTblIfFinalize(RTACPITBL hAcpiTbl);
634
635
636/**
637 * Starts a new Else operation (only valid if currently inside an If oepration).
638 *
639 * @returns IPRT status code.
640 * @param hAcpiTbl The ACPI table handle.
641 */
642RTDECL(int) RTAcpiTblElseStart(RTACPITBL hAcpiTbl);
643
644
645/**
646 * Finalizes the current Else statement operation.
647 *
648 * @returns IPRT status code.
649 * @param hAcpiTbl The ACPI table handle.
650 */
651RTDECL(int) RTAcpiTblElseFinalize(RTACPITBL hAcpiTbl);
652
653
654/**
655 * Starts a new While statement operation.
656 *
657 * @returns IPRT status code.
658 * @param hAcpiTbl The ACPI table handle.
659 */
660RTDECL(int) RTAcpiTblWhileStart(RTACPITBL hAcpiTbl);
661
662
663/**
664 * Finalizes the current While statement operation.
665 *
666 * @returns IPRT status code.
667 * @param hAcpiTbl The ACPI table handle.
668 */
669RTDECL(int) RTAcpiTblWhileFinalize(RTACPITBL hAcpiTbl);
670
671
672/**
673 * List of binary operations.
674 */
675typedef enum RTACPIBINARYOP
676{
677 /** Invalid binary operation. */
678 kAcpiBinaryOp_Invalid = 0,
679 /** LAnd(Operand, Operand). */
680 kAcpiBinaryOp_LAnd,
681 /** LOr(Operand, Operand). */
682 kAcpiBinaryOp_LOr,
683 /** LEqual(Operand, Operand). */
684 kAcpiBinaryOp_LEqual,
685 /** LGreater(Operand, Operand). */
686 kAcpiBinaryOp_LGreater,
687 /** LGreaterEqual(Operand, Operand). */
688 kAcpiBinaryOp_LGreaterEqual,
689 /** LLess(Operand, Operand). */
690 kAcpiBinaryOp_LLess,
691 /** LLessEqual(Operand, Operand). */
692 kAcpiBinaryOp_LLessEqual,
693 /** LNotEqual(Operand, Operand). */
694 kAcpiBinaryOp_LNotEqual
695} RTACPIBINARYOP;
696
697
698/**
699 * Appends the given binary operand.
700 *
701 * @returns IPRT status code.
702 * @param hAcpiTbl The ACPI table handle.
703 * @param enmBinaryOp The binary operation to append.
704 */
705RTDECL(int) RTAcpiTblBinaryOpAppend(RTACPITBL hAcpiTbl, RTACPIBINARYOP enmBinaryOp);
706
707
708/**
709 * Appends the given Arg<idArg> operand.
710 *
711 * @returns IPRT status code.
712 * @param hAcpiTbl The ACPI table handle.
713 * @param idArg The argument ID to append [0..6].
714 */
715RTDECL(int) RTAcpiTblArgOpAppend(RTACPITBL hAcpiTbl, uint8_t idArg);
716
717
718/**
719 * Appends the given Local<idLocal> operand.
720 *
721 * @returns IPRT status code.
722 * @param hAcpiTbl The ACPI table handle.
723 * @param idLocal The local ID to append [0..7].
724 */
725RTDECL(int) RTAcpiTblLocalOpAppend(RTACPITBL hAcpiTbl, uint8_t idLocal);
726
727
728/**
729 * Appends the given UUID as a buffer object.
730 *
731 * @returns IPRT status code.
732 * @param hAcpiTbl The ACPI table handle.
733 * @param pUuid The UUID to append.
734 */
735RTDECL(int) RTAcpiTblUuidAppend(RTACPITBL hAcpiTbl, PCRTUUID pUuid);
736
737
738/**
739 * Appends the given UUID string as a UUID buffer object.
740 *
741 * @returns IPRT status code.
742 * @param hAcpiTbl The ACPI table handle.
743 * @param pszUuid The UUID string to append as a buffer.
744 */
745RTDECL(int) RTAcpiTblUuidAppendFromStr(RTACPITBL hAcpiTbl, const char *pszUuid);
746
747
748/**
749 * Appends the given 7 character EISA ID string as the corresponding 4-byte
750 * integer.
751 *
752 * @returns IPRT status code.
753 * @param hAcpiTbl The ACPI table handle.
754 * @param pszEisaId The EISA ID to append.
755 */
756RTDECL(int) RTAcpiTblEisaIdAppend(RTACPITBL hAcpiTbl, const char *pszEisaId);
757
758
759/**
760 * Known operation region space types.
761 */
762typedef enum RTACPIOPREGIONSPACE
763{
764 /** Invalid region space type. */
765 kAcpiOperationRegionSpace_Invalid = 0,
766 /** Region is in system memory space. */
767 kAcpiOperationRegionSpace_SystemMemory,
768 /** Region is in system I/O space. */
769 kAcpiOperationRegionSpace_SystemIo,
770 /** Region is in PCI config space. */
771 kAcpiOperationRegionSpace_PciConfig,
772 /** Region is in embedded control space. */
773 kAcpiOperationRegionSpace_EmbeddedControl,
774 /** Region is in SMBUS space. */
775 kAcpiOperationRegionSpace_SmBus,
776 /** Region is in system CMOS space. */
777 kAcpiOperationRegionSpace_SystemCmos,
778 /** Region is a PCI bar target. */
779 kAcpiOperationRegionSpace_PciBarTarget,
780 /** Region is in IPMI space. */
781 kAcpiOperationRegionSpace_Ipmi,
782 /** Region is in GPIO space. */
783 kAcpiOperationRegionSpace_Gpio,
784 /** Region is in generic serial bus space. */
785 kAcpiOperationRegionSpace_GenericSerialBus,
786 /** Region is in platform communications channel (PCC) space. */
787 kAcpiOperationRegionSpace_Pcc,
788 /** 32bit hack. */
789 kAcpiOperationRegionSpace_32bit_Hack = 0x7fffffff
790} RTACPIOPREGIONSPACE;
791
792
793/**
794 * Appends a new OperationRegion() to the given ACPI table - extended version.
795 *
796 * @returns IPRT status code.
797 * @param hAcpiTbl The ACPI table handle.
798 * @param pszName The name of the operation region.
799 * @param enmSpace The operation region space type.
800 *
801 * @note This doesn't encode the region offset and size arguments but leaves it up to the caller
802 * to be able to encode complex stuff.
803 */
804RTDECL(int) RTAcpiTblOpRegionAppendEx(RTACPITBL hAcpiTbl, const char *pszName, RTACPIOPREGIONSPACE enmSpace);
805
806
807/**
808 * Appends a new OperationRegion() to the given ACPI table.
809 *
810 * @returns IPRT status code.
811 * @param hAcpiTbl The ACPI table handle.
812 * @param pszName The name of the operation region.
813 * @param enmSpace The operation region space type.
814 * @param offRegion Offset of the region.
815 * @param cbRegion Size of the region in bytes.
816 */
817RTDECL(int) RTAcpiTblOpRegionAppend(RTACPITBL hAcpiTbl, const char *pszName, RTACPIOPREGIONSPACE enmSpace,
818 uint64_t offRegion, uint64_t cbRegion);
819
820
821/**
822 * Field access type.
823 */
824typedef enum RTACPIFIELDACC
825{
826 /** Invalid access type. */
827 kAcpiFieldAcc_Invalid = 0,
828 /** Any access width is okay. */
829 kAcpiFieldAcc_Any,
830 /** Byte (8-bit) access. */
831 kAcpiFieldAcc_Byte,
832 /** Word (16-bit) access. */
833 kAcpiFieldAcc_Word,
834 /** Double word (32-bit) access. */
835 kAcpiFieldAcc_DWord,
836 /** Quad word (64-bit) access. */
837 kAcpiFieldAcc_QWord,
838 /** Buffer like access. */
839 kAcpiFieldAcc_Buffer
840} RTACPIFIELDACC;
841
842
843/**
844 * Field update rule.
845 */
846typedef enum RTACPIFIELDUPDATE
847{
848 /** Invalid upadte rule. */
849 kAcpiFieldUpdate_Invalid = 0,
850 /** Preserve content not being accessed. */
851 kAcpiFieldUpdate_Preserve,
852 /** Write as ones. */
853 kAcpiFieldUpdate_WriteAsOnes,
854 /** Write as zeroes. */
855 kAcpiFieldUpdate_WriteAsZeroes
856} RTACPIFIELDUPDATE;
857
858
859/**
860 * Field entry.
861 */
862typedef struct RTACPIFIELDENTRY
863{
864 /** The field name - NULL means the NullName. */
865 const char *pszName;
866 /** Number of bits of the field. */
867 uint64_t cBits;
868} RTACPIFIELDENTRY;
869/** Pointer to a field entry. */
870typedef RTACPIFIELDENTRY *PRTACPIFIELDENTRY;
871/** Pointer to a const field entry. */
872typedef const RTACPIFIELDENTRY *PCRTACPIFIELDENTRY;
873
874
875/**
876 * Appends a new field descriptor to the given ACPI table.
877 *
878 * @returns IPRT status code.
879 * @param hAcpiTbl The ACPI table handle.
880 * @param pszNameRef The region/buffer the field describes.
881 * @param enmAcc The access type,
882 * @param fLock Flag whether access must happen under a lock.
883 * @param enmUpdate The update rule.
884 * @param paFields Pointer to the field descriptors.
885 * @param cFields Number of entries in the array.
886 */
887RTDECL(int) RTAcpiTblFieldAppend(RTACPITBL hAcpiTbl, const char *pszNameRef, RTACPIFIELDACC enmAcc,
888 bool fLock, RTACPIFIELDUPDATE enmUpdate, PCRTACPIFIELDENTRY paFields,
889 uint32_t cFields);
890
891
892/**
893 * Appends a new index field descriptor to the given ACPI table.
894 *
895 * @returns IPRT status code.
896 * @param hAcpiTbl The ACPI table handle.
897 * @param pszNameIndex The index object.
898 * @param pszNameData The data object.
899 * @param enmAcc The access type,
900 * @param fLock Flag whether access must happen under a lock.
901 * @param enmUpdate The update rule.
902 * @param paFields Pointer to the field descriptors.
903 * @param cFields Number of entries in the array.
904 */
905RTDECL(int) RTAcpiTblIndexFieldAppend(RTACPITBL hAcpiTbl, const char *pszNameIndex, const char *pszNameData,
906 RTACPIFIELDACC enmAcc, bool fLock, RTACPIFIELDUPDATE enmUpdate,
907 PCRTACPIFIELDENTRY paFields, uint32_t cFields);
908
909
910/**
911 * Object type.
912 */
913typedef enum RTACPIOBJTYPE
914{
915 /** Invalid object type. */
916 kAcpiObjType_Invalid = 0,
917 /** Unknown object - UnknownObj */
918 kAcpiObjType_Unknown,
919 /** Integer object - IntObj */
920 kAcpiObjType_Int,
921 /** String object - StrObj */
922 kAcpiObjType_Str,
923 /** Buffer object - BuffObj */
924 kAcpiObjType_Buff,
925 /** Package object - PkgObj */
926 kAcpiObjType_Pkg,
927 /** Field unit object - FieldUnitObj */
928 kAcpiObjType_FieldUnit,
929 /** Device object - DeviceObj */
930 kAcpiObjType_Device,
931 /** Event object - EventObj */
932 kAcpiObjType_Event,
933 /** Method object - MethodObj */
934 kAcpiObjType_Method,
935 /** Mutex object - MutexObj */
936 kAcpiObjType_MutexObj,
937 /** OpRegion object - OpRegionObj */
938 kAcpiObjType_OpRegion,
939 /** Power resource object - PowerResObj */
940 kAcpiObjType_PowerRes,
941 /** Thermal zone object - ThermalZoneObj */
942 kAcpiObjType_ThermalZone,
943 /** Buffer field object - BuffFieldObj */
944 kAcpiObjType_BuffField,
945 /** Processor object - ProcessorObj */
946 kAcpiObjType_Processor
947} RTACPIOBJTYPE;
948
949
950/**
951 * Appends a new External declaration to the given ACPI table.
952 *
953 * @returns IPRT status code.
954 * @param hAcpiTbl The ACPI table handle.
955 * @param pszName The name stirng of the external object.
956 * @param enmObjType The object type.
957 * @param cArgs Number of arguments for the object (mostly method), valid is [0..7].
958 */
959RTDECL(int) RTAcpiTblExternalAppend(RTACPITBL hAcpiTbl, const char *pszName, RTACPIOBJTYPE enmObjType, uint8_t cArgs);
960
961
962/** @name ACPI resource builder related API.
963 * @{ */
964
965/**
966 * Creates a new empty resource template.
967 *
968 * @returns IPRT status code.
969 * @param phAcpiRes Where to store the handle to the ACPI resource on success.
970 */
971RTDECL(int) RTAcpiResourceCreate(PRTACPIRES phAcpiRes);
972
973
974/**
975 * Destroys the given ACPI resource, freeing all allocated resources.
976 *
977 * @param hAcpiRes The ACPI resource handle to destroy.
978 */
979RTDECL(void) RTAcpiResourceDestroy(RTACPIRES hAcpiRes);
980
981
982/**
983 * Resets the given ACPI resource handle to create a new empty template.
984 *
985 * @param hAcpiRes The ACPI resource handle.
986 */
987RTDECL(void) RTAcpiResourceReset(RTACPIRES hAcpiRes);
988
989
990/**
991 * Returns the offset where the next resource added to the template would be.
992 *
993 * @returns Offset into the resource buffer where the next resource will be appended
994 * @retval UINT32_MAX if the handle is invalid or the resource is in an error state.
995 * @param hAcpiRes The ACPI resource handle.
996 */
997RTDECL(uint32_t) RTAcpiResourceGetOffset(RTACPIRES hAcpiRes);
998
999
1000/**
1001 * Seals the given ACPI resource against further changes and adds any
1002 * missing data required to complete the resource buffer.
1003 *
1004 * @returns IPRT status code.
1005 * @param hAcpiRes The ACPI resource handle.
1006 *
1007 * @note After a call to this method completed successfully it is not possible
1008 * to add new resources until RTAcpiResourceReset() was called.
1009 */
1010RTDECL(int) RTAcpiResourceSeal(RTACPIRES hAcpiRes);
1011
1012
1013/**
1014 * Queries the pointer to the buffer holding the encoded data.
1015 *
1016 * @returns IPRT status code.
1017 * @param hAcpiRes The ACPI resource handle.
1018 * @param ppvRes Where to store the pointer to the buffer holding the encoded resource template on success.
1019 * @param pcbRes Where to store the size of the encoded data in bytes on success.
1020 *
1021 * @note The ACPI resource must be successfully sealed with RTAcpiResourceSeal() for this function to succeed.
1022 * Also the buffer pointer will only be valid until a call to any other RTAcpiResource* method.
1023 */
1024RTDECL(int) RTAcpiResourceQueryBuffer(RTACPIRES hAcpiRes, const void **ppvRes, size_t *pcbRes);
1025
1026
1027/**
1028 * Adds a fixed memory range with the given start address and size to the given ACPI resource.
1029 *
1030 * @returns IPRT status code.
1031 * @param hAcpiRes The ACPI resource handle.
1032 * @param u32AddrBase The base address to encode.
1033 * @param cbRange The range length in bytes to encode.
1034 * @param fRw Flag whether this address range is read-write or read-only.
1035 */
1036RTDECL(int) RTAcpiResourceAdd32BitFixedMemoryRange(RTACPIRES hAcpiRes, uint32_t u32AddrBase, uint32_t cbRange,
1037 bool fRw);
1038
1039
1040/**
1041 * Adds an extended interrupt descriptor with the given configuration to the given ACPI resource.
1042 *
1043 * @returns IPRT status code.
1044 * @param hAcpiRes The ACPI resource handle.
1045 * @param fConsumer Flag whether the entity this resource is assigned to consumes the interrupt (true) or produces it (false).
1046 * @param fEdgeTriggered Flag whether the interrupt is edged (true) or level (false) triggered.
1047 * @param fActiveLow Flag whether the interrupt polarity is active low (true) or active high (false).
1048 * @param fShared Flag whether the interrupt is shared between different entities (true) or exclusive to the assigned entity (false).
1049 * @param fWakeCapable Flag whether the interrupt can wake the system (true) or not (false).
1050 * @param cIntrs Number of interrupts following.
1051 * @param pau32Intrs Pointer to the array of interrupt numbers.
1052 */
1053RTDECL(int) RTAcpiResourceAddExtendedInterrupt(RTACPIRES hAcpiRes, bool fConsumer, bool fEdgeTriggered, bool fActiveLow, bool fShared,
1054 bool fWakeCapable, uint8_t cIntrs, uint32_t *pau32Intrs);
1055
1056
1057/** @name Generic address space flags.
1058 * @{ */
1059#define RTACPI_RESOURCE_ADDR_RANGE_F_DECODE_TYPE_SUB RT_BIT_32(0)
1060#define RTACPI_RESOURCE_ADDR_RANGE_F_DECODE_TYPE_POS 0
1061
1062#define RTACPI_RESOURCE_ADDR_RANGE_F_MIN_ADDR_FIXED RT_BIT_32(1)
1063#define RTACPI_RESOURCE_ADDR_RANGE_F_MIN_ADDR_CHANGEABLE 0
1064
1065#define RTACPI_RESOURCE_ADDR_RANGE_F_MAX_ADDR_FIXED RT_BIT_32(2)
1066#define RTACPI_RESOURCE_ADDR_RANGE_F_MAX_ADDR_CHANGEABLE 0
1067
1068#define RTACPI_RESOURCE_ADDR_RANGE_F_PRODUCER RT_BIT_32(3)
1069#define RTACPI_RESOURCE_ADDR_RANGE_F_CONSUMER 0
1070
1071#define RTACPI_RESOURCE_ADDR_RANGE_F_VALID_MASK UINT32_C(0x0000000f)
1072/** @} */
1073
1074/**
1075 * Memory range cacheability
1076 */
1077typedef enum RTACPIRESMEMRANGECACHEABILITY
1078{
1079 /** Usual invalid value. */
1080 kAcpiResMemRangeCacheability_Invalid = 0,
1081 /** Memory range is non cacheable (like MMIO, etc.). */
1082 kAcpiResMemRangeCacheability_NonCacheable,
1083 /** Memory is cacheable. */
1084 kAcpiResMemRangeCacheability_Cacheable,
1085 /** Memory is cacheable and supports write combining. */
1086 kAcpiResMemRangeCacheability_CacheableWriteCombining,
1087 /** Memory is cacheable and supports prefetching. */
1088 kAcpiResMemRangeCacheability_CacheablePrefetchable,
1089 /** 32-bit blow up hack. */
1090 kAcpiResMemRangeCacheability_32BitHack = 0x7fffffff
1091} RTACPIRESMEMRANGECACHEABILITY;
1092
1093
1094/**
1095 * Memory attribute.
1096 */
1097typedef enum RTACPIRESMEMRANGETYPE
1098{
1099 /** Invalid memory range type. */
1100 kAcpiResMemType_Invalid = 0,
1101 /** Memory range is actual memory. */
1102 kAcpiResMemType_Memory,
1103 /** Memory range is reserved. */
1104 kAcpiResMemType_Reserved,
1105 /** Memory range is reserved to ACPI. */
1106 kAcpiResMemType_Acpi,
1107 /** Memory range is no volatile storage. */
1108 kAcpiResMemType_Nvs,
1109 /** 32-bit blow up hack. */
1110 kAcpiResMemType_32BitHack = 0x7fffffff
1111} RTACPIRESMEMRANGETYPE;
1112
1113
1114/**
1115 * Adds a quad word (64-bit) memory range to the given ACPI resource.
1116 *
1117 * @returns IPRT status code.
1118 * @param hAcpiRes The ACPI resource handle.
1119 * @param enmCacheability The cacheability of the memory range.
1120 * @param enmType Memory range type.
1121 * @param fRw Flag whether the memory range is read/write (true) or readonly (false).
1122 * @param fAddrSpace Additional address space flags (combination of RTACPI_RESOURCE_ADDR_RANGE_F_XXX).
1123 * @param u64AddrMin The start address of the memory range.
1124 * @param u64AddrMax Last valid address of the range.
1125 * @param u64OffTrans Translation offset being applied to the address (for a PCIe bridge or IOMMU for example).
1126 * @param u64Granularity The access granularity of the range in bytes.
1127 * @param u64Length Length of the memory range in bytes.
1128 */
1129RTDECL(int) RTAcpiResourceAddQWordMemoryRange(RTACPIRES hAcpiRes, RTACPIRESMEMRANGECACHEABILITY enmCacheability,
1130 RTACPIRESMEMRANGETYPE enmType, bool fRw, uint32_t fAddrSpace,
1131 uint64_t u64AddrMin, uint64_t u64AddrMax, uint64_t u64OffTrans,
1132 uint64_t u64Granularity, uint64_t u64Length);
1133
1134
1135/**
1136 * Adds a quad word (64-bit) memory range to the given ACPI resource - extended version.
1137 *
1138 * @returns IPRT status code.
1139 * @param hAcpiRes The ACPI resource handle.
1140 * @param enmCacheability The cacheability of the memory range.
1141 * @param enmType Memory range type.
1142 * @param fRw Flag whether the memory range is read/write (true) or readonly (false).
1143 * @param fStatic Flag whether the translation type is static (true) or translation (false).
1144 * @param fAddrSpace Additional address space flags (combination of RTACPI_RESOURCE_ADDR_RANGE_F_XXX).
1145 * @param u64AddrMin The start address of the memory range.
1146 * @param u64AddrMax Last valid address of the range.
1147 * @param u64OffTrans Translation offset being applied to the address (for a PCIe bridge or IOMMU for example).
1148 * @param u64Granularity The access granularity of the range in bytes.
1149 * @param u64Length Length of the memory range in bytes.
1150 * @param pszRsrcSrc Name of the device object that produces the the descriptor consumed by the device, optional.
1151 * NULL means the device consumes the resource out of a global pool.
1152 * @param bRsrcIndex Index into the resource descriptor this device consumes from. Ignored if pszRsrcSrc is NULL.
1153 */
1154RTDECL(int) RTAcpiResourceAddQWordMemoryRangeEx(RTACPIRES hAcpiRes, RTACPIRESMEMRANGECACHEABILITY enmCacheability,
1155 RTACPIRESMEMRANGETYPE enmType, bool fRw, bool fStatic, uint32_t fAddrSpace,
1156 uint64_t u64AddrMin, uint64_t u64AddrMax, uint64_t u64OffTrans,
1157 uint64_t u64Granularity, uint64_t u64Length,
1158 const char *pszRsrcSrc, uint8_t bRsrcIndex);
1159
1160
1161/**
1162 * Adds a double word (32-bit) memory range to the given ACPI resource.
1163 *
1164 * @returns IPRT status code.
1165 * @param hAcpiRes The ACPI resource handle.
1166 * @param enmCacheability The cacheability of the memory range.
1167 * @param enmType Memory range type.
1168 * @param fRw Flag whether the memory range is read/write (true) or readonly (false).
1169 * @param fAddrSpace Additional address space flags (combination of RTACPI_RESOURCE_ADDR_RANGE_F_XXX).
1170 * @param u32AddrMin The start address of the memory range.
1171 * @param u32AddrMax Last valid address of the range.
1172 * @param u32OffTrans Translation offset being applied to the address (for a PCIe bridge or IOMMU for example).
1173 * @param u32Granularity The access granularity of the range in bytes.
1174 * @param u32Length Length of the memory range in bytes.
1175 */
1176RTDECL(int) RTAcpiResourceAddDWordMemoryRange(RTACPIRES hAcpiRes, RTACPIRESMEMRANGECACHEABILITY enmCacheability,
1177 RTACPIRESMEMRANGETYPE enmType, bool fRw, uint32_t fAddrSpace,
1178 uint32_t u32AddrMin, uint32_t u32AddrMax, uint32_t u32OffTrans,
1179 uint32_t u32Granularity, uint32_t u32Length);
1180
1181
1182/**
1183 * Adds a double word (32-bit) memory range to the given ACPI resource - extended version.
1184 *
1185 * @returns IPRT status code.
1186 * @param hAcpiRes The ACPI resource handle.
1187 * @param enmCacheability The cacheability of the memory range.
1188 * @param enmType Memory range type.
1189 * @param fRw Flag whether the memory range is read/write (true) or readonly (false).
1190 * @param fStatic Flag whether the translation type is static (true) or translation (false).
1191 * @param fAddrSpace Additional address space flags (combination of RTACPI_RESOURCE_ADDR_RANGE_F_XXX).
1192 * @param u32AddrMin The start address of the memory range.
1193 * @param u32AddrMax Last valid address of the range.
1194 * @param u32OffTrans Translation offset being applied to the address (for a PCIe bridge or IOMMU for example).
1195 * @param u32Granularity The access granularity of the range in bytes.
1196 * @param u32Length Length of the memory range in bytes.
1197 * @param pszRsrcSrc Name of the device object that produces the the descriptor consumed by the device, optional.
1198 * NULL means the device consumes the resource out of a global pool.
1199 * @param bRsrcIndex Index into the resource descriptor this device consumes from. Ignored if pszRsrcSrc is NULL.
1200 */
1201RTDECL(int) RTAcpiResourceAddDWordMemoryRangeEx(RTACPIRES hAcpiRes, RTACPIRESMEMRANGECACHEABILITY enmCacheability,
1202 RTACPIRESMEMRANGETYPE enmType, bool fRw, bool fStatic, uint32_t fAddrSpace,
1203 uint32_t u32AddrMin, uint32_t u32AddrMax, uint32_t u32OffTrans,
1204 uint32_t u32Granularity, uint32_t u32Length,
1205 const char *pszRsrcSrc, uint8_t bRsrcIndex);
1206
1207
1208/**
1209 * I/O range coverage.
1210 */
1211typedef enum RTACPIRESIORANGE
1212{
1213 /** Invalid range. */
1214 kAcpiResIoRange_Invalid = 0,
1215 /** Range covers only non ISA I/O ports. */
1216 kAcpiResIoRange_NonIsaOnly,
1217 /** Range covers only ISA I/O ports. */
1218 kAcpiResIoRange_IsaOnly,
1219 /** Range covers the whole I/O port range. */
1220 kAcpiResIoRange_Whole,
1221 /** 32-bit blow up hack. */
1222 kAcpiResIoRange_32BitHack = 0x7fffffff
1223} RTACPIRESIORANGE;
1224
1225
1226/**
1227 * I/O range type.
1228 */
1229typedef enum RTACPIRESIORANGETYPE
1230{
1231 /** Invalid value. */
1232 kAcpiResIoRangeType_Invalid = 0,
1233 /** Resource is I/O on the primary and secondary side of the bridge. */
1234 kAcpiResIoRangeType_Static,
1235 /** Resource is memory on the primary and I/O on the secondary side of the bridge,
1236 * primary side memory address for a given I/O port is calculated with
1237 * address = (((Port & 0xfffc) << 10) || (Port & 0xfff)) + AddrMin. */
1238 kAcpiResIoRangeType_Translation_Sparse,
1239 /** Resource is memory on the primary and I/O on the secondary side of the bridge,
1240 * primary side memory address for a given I/O port is calculated with
1241 * address = AddrMin + Port. */
1242 kAcpiResIoRangeType_Translation_Dense,
1243 /** 32-bit blowup hack. */
1244 kAcpiResIoRangeType_32BitHack = 0x7fffffff
1245} RTACPIRESIORANGETYPE;
1246
1247
1248/**
1249 * Adds a quad word (64-bit) I/O range to the given ACPI resource.
1250 *
1251 * @returns IPRT status code.
1252 * @param hAcpiRes The ACPI resource handle.
1253 * @param enmIoType The I/O range type.
1254 * @param enmIoRange The I/O range coverage.
1255 * @param fAddrSpace Additional address space flags (combination of RTACPI_RESOURCE_ADDR_RANGE_F_XXX).
1256 * @param u64AddrMin The start address of the memory range.
1257 * @param u64AddrMax Last valid address of the range.
1258 * @param u64OffTrans Translation offset being applied to the address (for a PCIe bridge or IOMMU for example).
1259 * @param u64Granularity The access granularity of the range in bytes.
1260 * @param u64Length Length of the memory range in bytes.
1261 */
1262RTDECL(int) RTAcpiResourceAddQWordIoRange(RTACPIRES hAcpiRes, RTACPIRESIORANGETYPE enmIoType, RTACPIRESIORANGE enmIoRange,
1263 uint32_t fAddrSpace, uint64_t u64AddrMin, uint64_t u64AddrMax, uint64_t u64OffTrans,
1264 uint64_t u64Granularity, uint64_t u64Length);
1265
1266
1267/**
1268 * Adds a word (16-bit) I/O range to the given ACPI resource - extended version.
1269 *
1270 * @returns IPRT status code.
1271 * @param hAcpiRes The ACPI resource handle.
1272 * @param enmIoType The I/O range type.
1273 * @param enmIoRange The I/O range coverage.
1274 * @param fAddrSpace Additional address space flags (combination of RTACPI_RESOURCE_ADDR_RANGE_F_XXX).
1275 * @param u16AddrMin The start address of the memory range.
1276 * @param u16AddrMax Last valid address of the range.
1277 * @param u16OffTrans Translation offset being applied to the address (for a PCIe bridge or IOMMU for example).
1278 * @param u16Granularity The access granularity of the range in bytes.
1279 * @param u16Length Length of the memory range in bytes.
1280 * @param pszRsrcSrc Name of the device object that produces the the descriptor consumed by the device, optional.
1281 * NULL means the device consumes the resource out of a global pool.
1282 * @param bRsrcIndex Index into the resource descriptor this device consumes from. Ignored if pszRsrcSrc is NULL.
1283 */
1284RTDECL(int) RTAcpiResourceAddWordIoRangeEx(RTACPIRES hAcpiRes, RTACPIRESIORANGETYPE enmIoType, RTACPIRESIORANGE enmIoRange,
1285 uint32_t fAddrSpace, uint16_t u16AddrMin, uint16_t u16AddrMax, uint64_t u16OffTrans,
1286 uint16_t u16Granularity, uint16_t u16Length, const char *pszRsrcSrc, uint8_t bRsrcIndex);
1287
1288
1289/**
1290 * Adds a word (16-bit) bus number to the given ACPI resource.
1291 *
1292 * @returns IPRT status code.
1293 * @param hAcpiRes The ACPI resource handle.
1294 * @param fAddrSpace Additional address space flags (combination of RTACPI_RESOURCE_ADDR_RANGE_F_XXX).
1295 * @param u16BusMin Starting bus number.
1296 * @param u16BusMax Last valid bus number.
1297 * @param u16OffTrans Translation offset being applied to the bus number.
1298 * @param u16Granularity The access granularity of the bus number.
1299 * @param u16Length Length of the bus range.
1300 */
1301RTDECL(int) RTAcpiResourceAddWordBusNumber(RTACPIRES hAcpiRes, uint32_t fAddrSpace, uint16_t u16BusMin, uint16_t u16BusMax,
1302 uint16_t u16OffTrans, uint16_t u16Granularity, uint16_t u16Length);
1303
1304
1305/**
1306 * Adds a word (16-bit) bus number to the given ACPI resource - extended version.
1307 *
1308 * @returns IPRT status code.
1309 * @param hAcpiRes The ACPI resource handle.
1310 * @param fAddrSpace Additional address space flags (combination of RTACPI_RESOURCE_ADDR_RANGE_F_XXX).
1311 * @param u16BusMin Starting bus number.
1312 * @param u16BusMax Last valid bus number.
1313 * @param u16OffTrans Translation offset being applied to the bus number.
1314 * @param u16Granularity The access granularity of the bus number.
1315 * @param u16Length Length of the bus range.
1316 * @param pszRsrcSrc Name of the device object that produces the the descriptor consumed by the device, optional.
1317 * NULL means the device consumes the resource out of a global pool.
1318 * @param bRsrcIndex Index into the resource descriptor this device consumes from. Ignored if pszRsrcSrc is NULL.
1319 */
1320RTDECL(int) RTAcpiResourceAddWordBusNumberEx(RTACPIRES hAcpiRes, uint32_t fAddrSpace, uint16_t u16BusMin, uint16_t u16BusMax,
1321 uint16_t u16OffTrans, uint16_t u16Granularity, uint16_t u16Length,
1322 const char *pszRsrcSrc, uint8_t bRsrcIndex);
1323
1324
1325/**
1326 * I/O decode type.
1327 */
1328typedef enum RTACPIRESIODECODETYPE
1329{
1330 /** Invalid value. */
1331 kAcpiResIoDecodeType_Invalid = 0,
1332 /** 10-bit decoding. */
1333 kAcpiResIoDecodeType_Decode10,
1334 /** 16-bit decoding. */
1335 kAcpiResIoDecodeType_Decode16,
1336 /** 32-bit blowup hack. */
1337 kAcpiResIoDecodeType_32BitHack = 0x7fffffff
1338} RTACPIRESIODECODETYPE;
1339
1340
1341/**
1342 * Adds an I/O port descriptor to the given ACPI resource.
1343 *
1344 * @returns IPRT status code.
1345 * @param hAcpiRes The ACPI resource handle.
1346 * @param enmDecode The decoding type of the range.
1347 * @param u16AddrMin Minimum base I/O address the range might be configured for.
1348 * @param u16AddrMax Maximum base I/O address the range might be configured for.
1349 * @param u8AddrAlignment Alignment of the minimum base address.
1350 * @param u8RangeLength Number of contiguous I/O ports requested.
1351 */
1352RTDECL(int) RTAcpiResourceAddIo(RTACPIRES hAcpiRes, RTACPIRESIODECODETYPE enmDecode, uint16_t u16AddrMin, uint16_t u16AddrMax,
1353 uint8_t u8AddrAlignment, uint8_t u8RangeLength);
1354
1355
1356/**
1357 * Adds an IRQ descriptor with the given configuration to the given ACPI resource.
1358 *
1359 * @returns IPRT status code.
1360 * @param hAcpiRes The ACPI resource handle.
1361 * @param fEdgeTriggered Flag whether the interrupt is edged (true) or level (false) triggered.
1362 * @param fActiveLow Flag whether the interrupt polarity is active low (true) or active high (false).
1363 * @param fShared Flag whether the interrupt is shared between different entities (true) or exclusive to the assigned entity (false).
1364 * @param fWakeCapable Flag whether the interrupt can wake the system (true) or not (false).
1365 * @param bmIntrs Bitmap of interrupts (0..15) requested.
1366 */
1367RTDECL(int) RTAcpiResourceAddIrq(RTACPIRES hAcpiRes, bool fEdgeTriggered, bool fActiveLow, bool fShared,
1368 bool fWakeCapable, uint16_t bmIntrs);
1369
1370
1371/**
1372 * DMA channel speed.
1373 */
1374typedef enum RTACPIRESDMACHANSPEED
1375{
1376 /** Invalid value. */
1377 kAcpiResDmaChanSpeed_Invalid = 0,
1378 /** Compatibility mode. */
1379 kAcpiResDmaChanSpeed_Compatibility,
1380 /** Type A DMA as described in EISA. */
1381 kAcpiResDmaChanSpeed_TypeA,
1382 /** Type B DMA. */
1383 kAcpiResDmaChanSpeed_TypeB,
1384 /** Type F. */
1385 kAcpiResDmaChanSpeed_TypeF,
1386 /** 32-bit blowup hack. */
1387 kAcpiResDmaChanSpeed_32BitHack = 0x7fffffff
1388} RTACPIRESDMACHANSPEED;
1389
1390
1391/**
1392 * DMA transfer type.
1393 */
1394typedef enum RTACPIRESDMATRANSFERTYPE
1395{
1396 /** Invalid value. */
1397 kAcpiResDmaTransferType_Invalid = 0,
1398 /** 8bit only. */
1399 kAcpiResDmaTransferType_8Bit,
1400 /** 8-bit and 16-bit. */
1401 kAcpiResDmaTransferType_8Bit_16Bit,
1402 /** 16-bit only. */
1403 kAcpiResDmaTransferType_16Bit,
1404 /** 32-bit blowup hack. */
1405 kAcpiResDmaTransferType_32BitHack = 0x7fffffff
1406} RTACPIRESDMATRANSFERTYPE;
1407
1408
1409/**
1410 * Adds a DMA descriptor with the given configuration to the given ACPI resource.
1411 *
1412 * @returns IPRT status code.
1413 * @param hAcpiRes The ACPI resource handle.
1414 * @param enmChanSpeed The DMA channel speed.
1415 * @param fBusMaster Flag whether the device is a bus master.
1416 * @param enmTransferType DMA transfer type preference.
1417 * @param bmChannels Bitmap of DMA channels (0..7) requested.
1418 */
1419RTDECL(int) RTAcpiResourceAddDma(RTACPIRES hAcpiRes, RTACPIRESDMACHANSPEED enmChanSpeed, bool fBusMaster,
1420 RTACPIRESDMATRANSFERTYPE enmTransferType, uint8_t bmChannels);
1421
1422/** @} */
1423
1424#endif /* IN_RING3 */
1425
1426/** @} */
1427
1428RT_C_DECLS_END
1429
1430#endif /* !IPRT_INCLUDED_acpi_h */
1431
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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