VirtualBox

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

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

Runtime/RTAcpi*: Support generating AML for more statements found in vbox.dsl, bugref:10733 [build fixes]

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 52.9 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 pszNameRef The region/buffer the field describes.
898 * @param enmAcc The access type,
899 * @param fLock Flag whether access must happen under a lock.
900 * @param enmUpdate The update rule.
901 * @param paFields Pointer to the field descriptors.
902 * @param cFields Number of entries in the array.
903 */
904RTDECL(int) RTAcpiTblIndexFieldAppend(RTACPITBL hAcpiTbl, const char *pszNameIndex, const char *pszNameData,
905 RTACPIFIELDACC enmAcc, bool fLock, RTACPIFIELDUPDATE enmUpdate,
906 PCRTACPIFIELDENTRY paFields, uint32_t cFields);
907
908
909/**
910 * Object type.
911 */
912typedef enum RTACPIOBJTYPE
913{
914 /** Invalid object type. */
915 kAcpiObjType_Invalid = 0,
916 /** Unknown object - UnknownObj */
917 kAcpiObjType_Unknown,
918 /** Integer object - IntObj */
919 kAcpiObjType_Int,
920 /** String object - StrObj */
921 kAcpiObjType_Str,
922 /** Buffer object - BuffObj */
923 kAcpiObjType_Buff,
924 /** Package object - PkgObj */
925 kAcpiObjType_Pkg,
926 /** Field unit object - FieldUnitObj */
927 kAcpiObjType_FieldUnit,
928 /** Device object - DeviceObj */
929 kAcpiObjType_Device,
930 /** Event object - EventObj */
931 kAcpiObjType_Event,
932 /** Method object - MethodObj */
933 kAcpiObjType_Method,
934 /** Mutex object - MutexObj */
935 kAcpiObjType_MutexObj,
936 /** OpRegion object - OpRegionObj */
937 kAcpiObjType_OpRegion,
938 /** Power resource object - PowerResObj */
939 kAcpiObjType_PowerRes,
940 /** Thermal zone object - ThermalZoneObj */
941 kAcpiObjType_ThermalZone,
942 /** Buffer field object - BuffFieldObj */
943 kAcpiObjType_BuffField,
944 /** Processor object - ProcessorObj */
945 kAcpiObjType_Processor
946} RTACPIOBJTYPE;
947
948
949/**
950 * Appends a new External declaration to the given ACPI table.
951 *
952 * @returns IPRT status code.
953 * @param hAcpiTbl The ACPI table handle.
954 * @param pszName The name stirng of the external object.
955 * @param enmObjType The object type.
956 * @param cArgs Number of arguments for the object (mostly method), valid is [0..7].
957 */
958RTDECL(int) RTAcpiTblExternalAppend(RTACPITBL hAcpiTbl, const char *pszName, RTACPIOBJTYPE enmObjType, uint8_t cArgs);
959
960
961/** @name ACPI resource builder related API.
962 * @{ */
963
964/**
965 * Creates a new empty resource template.
966 *
967 * @returns IPRT status code.
968 * @param phAcpiRes Where to store the handle to the ACPI resource on success.
969 */
970RTDECL(int) RTAcpiResourceCreate(PRTACPIRES phAcpiRes);
971
972
973/**
974 * Destroys the given ACPI resource, freeing all allocated resources.
975 *
976 * @param hAcpiRes The ACPI resource handle to destroy.
977 */
978RTDECL(void) RTAcpiResourceDestroy(RTACPIRES hAcpiRes);
979
980
981/**
982 * Resets the given ACPI resource handle to create a new empty template.
983 *
984 * @param hAcpiRes The ACPI resource handle.
985 */
986RTDECL(void) RTAcpiResourceReset(RTACPIRES hAcpiRes);
987
988
989/**
990 * Returns the offset where the next resource added to the template would be.
991 *
992 * @returns Offset into the resource buffer where the next resource will be appended
993 * @retval UINT32_MAX if the handle is invalid or the resource is in an error state.
994 * @param hAcpiRes The ACPI resource handle.
995 */
996RTDECL(uint32_t) RTAcpiResourceGetOffset(RTACPIRES hAcpiRes);
997
998
999/**
1000 * Seals the given ACPI resource against further changes and adds any
1001 * missing data required to complete the resource buffer.
1002 *
1003 * @returns IPRT status code.
1004 * @param hAcpiRes The ACPI resource handle.
1005 *
1006 * @note After a call to this method completed successfully it is not possible
1007 * to add new resources until RTAcpiResourceReset() was called.
1008 */
1009RTDECL(int) RTAcpiResourceSeal(RTACPIRES hAcpiRes);
1010
1011
1012/**
1013 * Queries the pointer to the buffer holding the encoded data.
1014 *
1015 * @returns IPRT status code.
1016 * @param hAcpiRes The ACPI resource handle.
1017 * @param ppvRes Where to store the pointer to the buffer holding the encoded resource template on success.
1018 * @param pcbRes Where to store the size of the encoded data in bytes on success.
1019 *
1020 * @note The ACPI resource must be successfully sealed with RTAcpiResourceSeal() for this function to succeed.
1021 * Also the buffer pointer will only be valid until a call to any other RTAcpiResource* method.
1022 */
1023RTDECL(int) RTAcpiResourceQueryBuffer(RTACPIRES hAcpiRes, const void **ppvRes, size_t *pcbRes);
1024
1025
1026/**
1027 * Adds a fixed memory range with the given start address and size to the given ACPI resource.
1028 *
1029 * @returns IPRT status code.
1030 * @param hAcpiRes The ACPI resource handle.
1031 * @param u32AddrBase The base address to encode.
1032 * @param cbRange The range length in bytes to encode.
1033 * @param fRw Flag whether this address range is read-write or read-only.
1034 */
1035RTDECL(int) RTAcpiResourceAdd32BitFixedMemoryRange(RTACPIRES hAcpiRes, uint32_t u32AddrBase, uint32_t cbRange,
1036 bool fRw);
1037
1038
1039/**
1040 * Adds an extended interrupt descriptor with the given configuration to the given ACPI resource.
1041 *
1042 * @returns IPRT status code.
1043 * @param hAcpiRes The ACPI resource handle.
1044 * @param fConsumer Flag whether the entity this resource is assigned to consumes the interrupt (true) or produces it (false).
1045 * @param fEdgeTriggered Flag whether the interrupt is edged (true) or level (false) triggered.
1046 * @param fActiveLow Flag whether the interrupt polarity is active low (true) or active high (false).
1047 * @param fShared Flag whether the interrupt is shared between different entities (true) or exclusive to the assigned entity (false).
1048 * @param fWakeCapable Flag whether the interrupt can wake the system (true) or not (false).
1049 * @param cIntrs Number of interrupts following.
1050 * @param pau32Intrs Pointer to the array of interrupt numbers.
1051 */
1052RTDECL(int) RTAcpiResourceAddExtendedInterrupt(RTACPIRES hAcpiRes, bool fConsumer, bool fEdgeTriggered, bool fActiveLow, bool fShared,
1053 bool fWakeCapable, uint8_t cIntrs, uint32_t *pau32Intrs);
1054
1055
1056/** @name Generic address space flags.
1057 * @{ */
1058#define RTACPI_RESOURCE_ADDR_RANGE_F_DECODE_TYPE_SUB RT_BIT_32(0)
1059#define RTACPI_RESOURCE_ADDR_RANGE_F_DECODE_TYPE_POS 0
1060
1061#define RTACPI_RESOURCE_ADDR_RANGE_F_MIN_ADDR_FIXED RT_BIT_32(1)
1062#define RTACPI_RESOURCE_ADDR_RANGE_F_MIN_ADDR_CHANGEABLE 0
1063
1064#define RTACPI_RESOURCE_ADDR_RANGE_F_MAX_ADDR_FIXED RT_BIT_32(2)
1065#define RTACPI_RESOURCE_ADDR_RANGE_F_MAX_ADDR_CHANGEABLE 0
1066
1067#define RTACPI_RESOURCE_ADDR_RANGE_F_PRODUCER RT_BIT_32(3)
1068#define RTACPI_RESOURCE_ADDR_RANGE_F_CONSUMER 0
1069
1070#define RTACPI_RESOURCE_ADDR_RANGE_F_VALID_MASK UINT32_C(0x0000000f)
1071/** @} */
1072
1073/**
1074 * Memory range cacheability
1075 */
1076typedef enum RTACPIRESMEMRANGECACHEABILITY
1077{
1078 /** Usual invalid value. */
1079 kAcpiResMemRangeCacheability_Invalid = 0,
1080 /** Memory range is non cacheable (like MMIO, etc.). */
1081 kAcpiResMemRangeCacheability_NonCacheable,
1082 /** Memory is cacheable. */
1083 kAcpiResMemRangeCacheability_Cacheable,
1084 /** Memory is cacheable and supports write combining. */
1085 kAcpiResMemRangeCacheability_CacheableWriteCombining,
1086 /** Memory is cacheable and supports prefetching. */
1087 kAcpiResMemRangeCacheability_CacheablePrefetchable,
1088 /** 32-bit blow up hack. */
1089 kAcpiResMemRangeCacheability_32BitHack = 0x7fffffff
1090} RTACPIRESMEMRANGECACHEABILITY;
1091
1092
1093/**
1094 * Memory attribute.
1095 */
1096typedef enum RTACPIRESMEMRANGETYPE
1097{
1098 /** Invalid memory range type. */
1099 kAcpiResMemType_Invalid = 0,
1100 /** Memory range is actual memory. */
1101 kAcpiResMemType_Memory,
1102 /** Memory range is reserved. */
1103 kAcpiResMemType_Reserved,
1104 /** Memory range is reserved to ACPI. */
1105 kAcpiResMemType_Acpi,
1106 /** Memory range is no volatile storage. */
1107 kAcpiResMemType_Nvs,
1108 /** 32-bit blow up hack. */
1109 kAcpiResMemType_32BitHack = 0x7fffffff
1110} RTACPIRESMEMRANGETYPE;
1111
1112
1113/**
1114 * Adds a quad word (64-bit) memory range to the given ACPI resource.
1115 *
1116 * @returns IPRT status code.
1117 * @param hAcpiRes The ACPI resource handle.
1118 * @param enmCacheability The cacheability of the memory range.
1119 * @param enmType Memory range type.
1120 * @param fRw Flag whether the memory range is read/write (true) or readonly (false).
1121 * @param fAddrSpace Additional address space flags (combination of RTACPI_RESOURCE_ADDR_RANGE_F_XXX).
1122 * @param u64AddrMin The start address of the memory range.
1123 * @param u64AddrMax Last valid address of the range.
1124 * @param u64OffTrans Translation offset being applied to the address (for a PCIe bridge or IOMMU for example).
1125 * @param u64Granularity The access granularity of the range in bytes.
1126 * @param u64Length Length of the memory range in bytes.
1127 */
1128RTDECL(int) RTAcpiResourceAddQWordMemoryRange(RTACPIRES hAcpiRes, RTACPIRESMEMRANGECACHEABILITY enmCacheability,
1129 RTACPIRESMEMRANGETYPE enmType, bool fRw, uint32_t fAddrSpace,
1130 uint64_t u64AddrMin, uint64_t u64AddrMax, uint64_t u64OffTrans,
1131 uint64_t u64Granularity, uint64_t u64Length);
1132
1133
1134/**
1135 * Adds a quad word (64-bit) memory range to the given ACPI resource - extended version.
1136 *
1137 * @returns IPRT status code.
1138 * @param hAcpiRes The ACPI resource handle.
1139 * @param enmCacheability The cacheability of the memory range.
1140 * @param enmType Memory range type.
1141 * @param fRw Flag whether the memory range is read/write (true) or readonly (false).
1142 * @param fStatic Flag whether the translation type is static (true) or translation (false).
1143 * @param fAddrSpace Additional address space flags (combination of RTACPI_RESOURCE_ADDR_RANGE_F_XXX).
1144 * @param u64AddrMin The start address of the memory range.
1145 * @param u64AddrMax Last valid address of the range.
1146 * @param u64OffTrans Translation offset being applied to the address (for a PCIe bridge or IOMMU for example).
1147 * @param u64Granularity The access granularity of the range in bytes.
1148 * @param u64Length Length of the memory range in bytes.
1149 * @param pszRsrcSrc Name of the device object that produces the the descriptor consumed by the device, optional.
1150 * NULL means the device consumes the resource out of a global pool.
1151 * @param bRsrcIndex Index into the resource descriptor this device consumes from. Ignored if pszRsrcSrc is NULL.
1152 */
1153RTDECL(int) RTAcpiResourceAddQWordMemoryRangeEx(RTACPIRES hAcpiRes, RTACPIRESMEMRANGECACHEABILITY enmCacheability,
1154 RTACPIRESMEMRANGETYPE enmType, bool fRw, bool fStatic, uint32_t fAddrSpace,
1155 uint64_t u64AddrMin, uint64_t u64AddrMax, uint64_t u64OffTrans,
1156 uint64_t u64Granularity, uint64_t u64Length,
1157 const char *pszRsrcSrc, uint8_t bRsrcIndex);
1158
1159
1160/**
1161 * Adds a double word (32-bit) memory range to the given ACPI resource.
1162 *
1163 * @returns IPRT status code.
1164 * @param hAcpiRes The ACPI resource handle.
1165 * @param enmCacheability The cacheability of the memory range.
1166 * @param enmType Memory range type.
1167 * @param fRw Flag whether the memory range is read/write (true) or readonly (false).
1168 * @param fAddrSpace Additional address space flags (combination of RTACPI_RESOURCE_ADDR_RANGE_F_XXX).
1169 * @param u32AddrMin The start address of the memory range.
1170 * @param u32AddrMax Last valid address of the range.
1171 * @param u32OffTrans Translation offset being applied to the address (for a PCIe bridge or IOMMU for example).
1172 * @param u32Granularity The access granularity of the range in bytes.
1173 * @param u32Length Length of the memory range in bytes.
1174 */
1175RTDECL(int) RTAcpiResourceAddDWordMemoryRange(RTACPIRES hAcpiRes, RTACPIRESMEMRANGECACHEABILITY enmCacheability,
1176 RTACPIRESMEMRANGETYPE enmType, bool fRw, uint32_t fAddrSpace,
1177 uint32_t u32AddrMin, uint32_t u32AddrMax, uint32_t u32OffTrans,
1178 uint32_t u32Granularity, uint32_t u32Length);
1179
1180
1181/**
1182 * Adds a double word (32-bit) memory range to the given ACPI resource - extended version.
1183 *
1184 * @returns IPRT status code.
1185 * @param hAcpiRes The ACPI resource handle.
1186 * @param enmCacheability The cacheability of the memory range.
1187 * @param enmType Memory range type.
1188 * @param fRw Flag whether the memory range is read/write (true) or readonly (false).
1189 * @param fStatic Flag whether the translation type is static (true) or translation (false).
1190 * @param fAddrSpace Additional address space flags (combination of RTACPI_RESOURCE_ADDR_RANGE_F_XXX).
1191 * @param u32AddrMin The start address of the memory range.
1192 * @param u32AddrMax Last valid address of the range.
1193 * @param u32OffTrans Translation offset being applied to the address (for a PCIe bridge or IOMMU for example).
1194 * @param u32Granularity The access granularity of the range in bytes.
1195 * @param u32Length Length of the memory range in bytes.
1196 * @param pszRsrcSrc Name of the device object that produces the the descriptor consumed by the device, optional.
1197 * NULL means the device consumes the resource out of a global pool.
1198 * @param bRsrcIndex Index into the resource descriptor this device consumes from. Ignored if pszRsrcSrc is NULL.
1199 */
1200RTDECL(int) RTAcpiResourceAddDWordMemoryRangeEx(RTACPIRES hAcpiRes, RTACPIRESMEMRANGECACHEABILITY enmCacheability,
1201 RTACPIRESMEMRANGETYPE enmType, bool fRw, bool fStatic, uint32_t fAddrSpace,
1202 uint32_t u32AddrMin, uint32_t u32AddrMax, uint32_t u32OffTrans,
1203 uint32_t u32Granularity, uint32_t u32Length,
1204 const char *pszRsrcSrc, uint8_t bRsrcIndex);
1205
1206
1207/**
1208 * I/O range coverage.
1209 */
1210typedef enum RTACPIRESIORANGE
1211{
1212 /** Invalid range. */
1213 kAcpiResIoRange_Invalid = 0,
1214 /** Range covers only non ISA I/O ports. */
1215 kAcpiResIoRange_NonIsaOnly,
1216 /** Range covers only ISA I/O ports. */
1217 kAcpiResIoRange_IsaOnly,
1218 /** Range covers the whole I/O port range. */
1219 kAcpiResIoRange_Whole,
1220 /** 32-bit blow up hack. */
1221 kAcpiResIoRange_32BitHack = 0x7fffffff
1222} RTACPIRESIORANGE;
1223
1224
1225/**
1226 * I/O range type.
1227 */
1228typedef enum RTACPIRESIORANGETYPE
1229{
1230 /** Invalid value. */
1231 kAcpiResIoRangeType_Invalid = 0,
1232 /** Resource is I/O on the primary and secondary side of the bridge. */
1233 kAcpiResIoRangeType_Static,
1234 /** Resource is memory on the primary and I/O on the secondary side of the bridge,
1235 * primary side memory address for a given I/O port is calculated with
1236 * address = (((Port & 0xfffc) << 10) || (Port & 0xfff)) + AddrMin. */
1237 kAcpiResIoRangeType_Translation_Sparse,
1238 /** Resource is memory on the primary and I/O on the secondary side of the bridge,
1239 * primary side memory address for a given I/O port is calculated with
1240 * address = AddrMin + Port. */
1241 kAcpiResIoRangeType_Translation_Dense,
1242 /** 32-bit blowup hack. */
1243 kAcpiResIoRangeType_32BitHack = 0x7fffffff
1244} RTACPIRESIORANGETYPE;
1245
1246
1247/**
1248 * Adds a quad word (64-bit) I/O range to the given ACPI resource.
1249 *
1250 * @returns IPRT status code.
1251 * @param hAcpiRes The ACPI resource handle.
1252 * @param enmIoType The I/O range type.
1253 * @param enmIoRange The I/O range coverage.
1254 * @param fAddrSpace Additional address space flags (combination of RTACPI_RESOURCE_ADDR_RANGE_F_XXX).
1255 * @param u64AddrMin The start address of the memory range.
1256 * @param u64AddrMax Last valid address of the range.
1257 * @param u64OffTrans Translation offset being applied to the address (for a PCIe bridge or IOMMU for example).
1258 * @param u64Granularity The access granularity of the range in bytes.
1259 * @param u64Length Length of the memory range in bytes.
1260 */
1261RTDECL(int) RTAcpiResourceAddQWordIoRange(RTACPIRES hAcpiRes, RTACPIRESIORANGETYPE enmIoType, RTACPIRESIORANGE enmIoRange,
1262 uint32_t fAddrSpace, uint64_t u64AddrMin, uint64_t u64AddrMax, uint64_t u64OffTrans,
1263 uint64_t u64Granularity, uint64_t u64Length);
1264
1265
1266/**
1267 * Adds a word (16-bit) I/O range to the given ACPI resource - extended version.
1268 *
1269 * @returns IPRT status code.
1270 * @param hAcpiRes The ACPI resource handle.
1271 * @param enmIoType The I/O range type.
1272 * @param enmIoRange The I/O range coverage.
1273 * @param fAddrSpace Additional address space flags (combination of RTACPI_RESOURCE_ADDR_RANGE_F_XXX).
1274 * @param u16AddrMin The start address of the memory range.
1275 * @param u16AddrMax Last valid address of the range.
1276 * @param u16OffTrans Translation offset being applied to the address (for a PCIe bridge or IOMMU for example).
1277 * @param u16Granularity The access granularity of the range in bytes.
1278 * @param u16Length Length of the memory range in bytes.
1279 * @param pszRsrcSrc Name of the device object that produces the the descriptor consumed by the device, optional.
1280 * NULL means the device consumes the resource out of a global pool.
1281 * @param bRsrcIndex Index into the resource descriptor this device consumes from. Ignored if pszRsrcSrc is NULL.
1282 */
1283RTDECL(int) RTAcpiResourceAddWordIoRangeEx(RTACPIRES hAcpiRes, RTACPIRESIORANGETYPE enmIoType, RTACPIRESIORANGE enmIoRange,
1284 uint32_t fAddrSpace, uint16_t u16AddrMin, uint16_t u16AddrMax, uint64_t u16OffTrans,
1285 uint16_t u16Granularity, uint16_t u16Length, const char *pszRsrcSrc, uint8_t bRsrcIndex);
1286
1287
1288/**
1289 * Adds a word (16-bit) bus number to the given ACPI resource.
1290 *
1291 * @returns IPRT status code.
1292 * @param hAcpiRes The ACPI resource handle.
1293 * @param fAddrSpace Additional address space flags (combination of RTACPI_RESOURCE_ADDR_RANGE_F_XXX).
1294 * @param u16BusMin Starting bus number.
1295 * @param u16BusMax Last valid bus number.
1296 * @param u16OffTrans Translation offset being applied to the bus number.
1297 * @param u16Granularity The access granularity of the bus number.
1298 * @param u16Length Length of the bus range.
1299 */
1300RTDECL(int) RTAcpiResourceAddWordBusNumber(RTACPIRES hAcpiRes, uint32_t fAddrSpace, uint16_t u16BusMin, uint16_t u16BusMax,
1301 uint16_t u16OffTrans, uint16_t u16Granularity, uint16_t u16Length);
1302
1303
1304/**
1305 * Adds a word (16-bit) bus number to the given ACPI resource - extended version.
1306 *
1307 * @returns IPRT status code.
1308 * @param hAcpiRes The ACPI resource handle.
1309 * @param fAddrSpace Additional address space flags (combination of RTACPI_RESOURCE_ADDR_RANGE_F_XXX).
1310 * @param u16BusMin Starting bus number.
1311 * @param u16BusMax Last valid bus number.
1312 * @param u16OffTrans Translation offset being applied to the bus number.
1313 * @param u16Granularity The access granularity of the bus number.
1314 * @param u16Length Length of the bus range.
1315 * @param pszRsrcSrc Name of the device object that produces the the descriptor consumed by the device, optional.
1316 * NULL means the device consumes the resource out of a global pool.
1317 * @param bRsrcIndex Index into the resource descriptor this device consumes from. Ignored if pszRsrcSrc is NULL.
1318 */
1319RTDECL(int) RTAcpiResourceAddWordBusNumberEx(RTACPIRES hAcpiRes, uint32_t fAddrSpace, uint16_t u16BusMin, uint16_t u16BusMax,
1320 uint16_t u16OffTrans, uint16_t u16Granularity, uint16_t u16Length,
1321 const char *pszRsrcSrc, uint8_t bRsrcIndex);
1322
1323
1324/**
1325 * I/O decode type.
1326 */
1327typedef enum RTACPIRESIODECODETYPE
1328{
1329 /** Invalid value. */
1330 kAcpiResIoDecodeType_Invalid = 0,
1331 /** 10-bit decoding. */
1332 kAcpiResIoDecodeType_Decode10,
1333 /** 16-bit decoding. */
1334 kAcpiResIoDecodeType_Decode16,
1335 /** 32-bit blowup hack. */
1336 kAcpiResIoDecodeType_32BitHack = 0x7fffffff
1337} RTACPIRESIODECODETYPE;
1338
1339
1340/**
1341 * Adds an I/O port descriptor to the given ACPI resource.
1342 *
1343 * @returns IPRT status code.
1344 * @param hAcpiRes The ACPI resource handle.
1345 * @param enmDecode The decoding type of the range.
1346 * @param u16AddrMin Minimum base I/O address the range might be configured for.
1347 * @param u16AddrMax Maximum base I/O address the range might be configured for.
1348 * @param u8AddrAlignment Alignment of the minimum base address.
1349 * @param u8RangeLength Number of contiguous I/O ports requested.
1350 */
1351RTDECL(int) RTAcpiResourceAddIo(RTACPIRES hAcpiRes, RTACPIRESIODECODETYPE enmDecode, uint16_t u16AddrMin, uint16_t u16AddrMax,
1352 uint8_t u8AddrAlignment, uint8_t u8RangeLength);
1353
1354
1355/**
1356 * Adds an IRQ descriptor with the given configuration to the given ACPI resource.
1357 *
1358 * @returns IPRT status code.
1359 * @param hAcpiRes The ACPI resource handle.
1360 * @param fEdgeTriggered Flag whether the interrupt is edged (true) or level (false) triggered.
1361 * @param fActiveLow Flag whether the interrupt polarity is active low (true) or active high (false).
1362 * @param fShared Flag whether the interrupt is shared between different entities (true) or exclusive to the assigned entity (false).
1363 * @param fWakeCapable Flag whether the interrupt can wake the system (true) or not (false).
1364 * @param bmIntrs Bitmap of interrupts (0..15) requested.
1365 */
1366RTDECL(int) RTAcpiResourceAddIrq(RTACPIRES hAcpiRes, bool fEdgeTriggered, bool fActiveLow, bool fShared,
1367 bool fWakeCapable, uint16_t bmIntrs);
1368
1369
1370/**
1371 * DMA channel speed.
1372 */
1373typedef enum RTACPIRESDMACHANSPEED
1374{
1375 /** Invalid value. */
1376 kAcpiResDmaChanSpeed_Invalid = 0,
1377 /** Compatibility mode. */
1378 kAcpiResDmaChanSpeed_Compatibility,
1379 /** Type A DMA as described in EISA. */
1380 kAcpiResDmaChanSpeed_TypeA,
1381 /** Type B DMA. */
1382 kAcpiResDmaChanSpeed_TypeB,
1383 /** Type F. */
1384 kAcpiResDmaChanSpeed_TypeF,
1385 /** 32-bit blowup hack. */
1386 kAcpiResDmaChanSpeed_32BitHack = 0x7fffffff
1387} RTACPIRESDMACHANSPEED;
1388
1389
1390/**
1391 * DMA transfer type.
1392 */
1393typedef enum RTACPIRESDMATRANSFERTYPE
1394{
1395 /** Invalid value. */
1396 kAcpiResDmaTransferType_Invalid = 0,
1397 /** 8bit only. */
1398 kAcpiResDmaTransferType_8Bit,
1399 /** 8-bit and 16-bit. */
1400 kAcpiResDmaTransferType_8Bit_16Bit,
1401 /** 16-bit only. */
1402 kAcpiResDmaTransferType_16Bit,
1403 /** 32-bit blowup hack. */
1404 kAcpiResDmaTransferType_32BitHack = 0x7fffffff
1405} RTACPIRESDMATRANSFERTYPE;
1406
1407
1408/**
1409 * Adds a DMA descriptor with the given configuration to the given ACPI resource.
1410 *
1411 * @returns IPRT status code.
1412 * @param hAcpiRes The ACPI resource handle.
1413 * @param enmChanSpeed The DMA channel speed.
1414 * @param fBusMaster Flag whether the device is a bus master.
1415 * @param enmTransferType DMA transfer type preference.
1416 * @param bmChannels Bitmap of DMA channels (0..7) requested.
1417 */
1418RTDECL(int) RTAcpiResourceAddDma(RTACPIRES hAcpiRes, RTACPIRESDMACHANSPEED enmChanSpeed, bool fBusMaster,
1419 RTACPIRESDMATRANSFERTYPE enmTransferType, uint8_t bmChannels);
1420
1421/** @} */
1422
1423#endif /* IN_RING3 */
1424
1425/** @} */
1426
1427RT_C_DECLS_END
1428
1429#endif /* !IPRT_INCLUDED_acpi_h */
1430
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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