VirtualBox

source: vbox/trunk/src/VBox/Runtime/include/internal/acpi.h@ 108059

Last change on this file since 108059 was 108059, checked in by vboxsync, 3 weeks ago

Runtime/RTAcpi*: Updates to the ACPI ASL -> AML compiler, bugref:10733

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.7 KB
Line 
1/* $Id: acpi.h 108059 2025-02-04 13:35:41Z vboxsync $ */
2/** @file
3 * IPRT - Internal RTAcpi header.
4 */
5
6/*
7 * Copyright (C) 2025 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * The contents of this file may alternatively be used under the terms
26 * of the Common Development and Distribution License Version 1.0
27 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28 * in the VirtualBox distribution, in which case the provisions of the
29 * CDDL are applicable instead of those of the GPL.
30 *
31 * You may elect to license modified versions of this file under the
32 * terms and conditions of either the GPL or the CDDL or both.
33 *
34 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35 */
36
37#ifndef IPRT_INCLUDED_INTERNAL_acpi_h
38#define IPRT_INCLUDED_INTERNAL_acpi_h
39#ifndef RT_WITHOUT_PRAGMA_ONCE
40# pragma once
41#endif
42
43#include <iprt/acpi.h>
44#include <iprt/list.h>
45
46RT_C_DECLS_BEGIN
47
48/** Pointer to an ACPI AST node. */
49typedef struct RTACPIASTNODE *PRTACPIASTNODE;
50/** Pointer to a const ACPI AST node. */
51typedef const struct RTACPIASTNODE *PCRTACPIASTNODE;
52
53/**
54 * AST node argument type.
55 */
56typedef enum RTACPIASTARGTYPE
57{
58 kAcpiAstArgType_Invalid = 0,
59 kAcpiAstArgType_AstNode,
60 kAcpiAstArgType_NameString,
61 kAcpiAstArgType_Bool,
62 kAcpiAstArgType_U8,
63 kAcpiAstArgType_U16,
64 kAcpiAstArgType_U32,
65 kAcpiAstArgType_U64,
66 kAcpiAstArgType_ObjType,
67 kAcpiAstArgType_RegionSpace,
68 kAcpiAstArgType_32Bit_Hack = 0x7fffffff
69} RTACPIASTARGTYPE;
70
71
72/**
73 * An AST node argument
74 */
75typedef struct RTACPIASTARG
76{
77 /** Argument type. */
78 RTACPIASTARGTYPE enmType;
79 /** Type dependent data. */
80 union
81 {
82 uintptr_t uPtrInternal;
83 PCRTACPIASTNODE pAstNd;
84 const char *pszNameString;
85 bool f;
86 uint8_t u8;
87 uint16_t u16;
88 uint32_t u32;
89 uint64_t u64;
90 RTACPIOBJTYPE enmObjType;
91 RTACPIOPREGIONSPACE enmRegionSpace;
92 } u;
93} RTACPIASTARG;
94/** Pointer to an AST node argument. */
95typedef RTACPIASTARG *PRTACPIASTARG;
96/** Pointer to a const AST node argument. */
97typedef const RTACPIASTARG *PCRTACPIASTARG;
98
99
100/**
101 * The ACPI AST node op.
102 */
103typedef enum RTACPIASTNODEOP
104{
105 kAcpiAstNodeOp_Invalid = 0,
106 kAcpiAstNodeOp_Identifier,
107 kAcpiAstNodeOp_StringLiteral,
108 kAcpiAstNodeOp_Number,
109 kAcpiAstNodeOp_Scope,
110 kAcpiAstNodeOp_Processor,
111 kAcpiAstNodeOp_External,
112 kAcpiAstNodeOp_Method,
113 kAcpiAstNodeOp_Device,
114 kAcpiAstNodeOp_If,
115 kAcpiAstNodeOp_Else,
116 kAcpiAstNodeOp_LAnd,
117 kAcpiAstNodeOp_LEqual,
118 kAcpiAstNodeOp_LGreater,
119 kAcpiAstNodeOp_LGreaterEqual,
120 kAcpiAstNodeOp_LLess,
121 kAcpiAstNodeOp_LLessEqual,
122 kAcpiAstNodeOp_LNot,
123 kAcpiAstNodeOp_LNotEqual,
124 kAcpiAstNodeOp_Zero,
125 kAcpiAstNodeOp_One,
126 kAcpiAstNodeOp_Ones,
127 kAcpiAstNodeOp_Return,
128 kAcpiAstNodeOp_Unicode,
129 kAcpiAstNodeOp_OperationRegion,
130 kAcpiAstNodeOp_32Bit_Hack = 0x7fffffff
131} RTACPIASTNODEOP;
132
133
134/**
135 * The core ACPI AST node.
136 */
137typedef struct RTACPIASTNODE
138{
139 /** List node. */
140 RTLISTNODE NdAst;
141 /** The AML op defining the node. */
142 RTACPIASTNODEOP enmOp;
143 /** Some additional flags. */
144 uint32_t fFlags;
145 /** Operation dependent data. */
146 union
147 {
148 /** List of other AST nodes for the opened scope if indicated by the AST flags (RTACPIASTNODE). */
149 RTLISTANCHOR LstScopeNodes;
150 /** Pointer to the identifier if an identifier node. */
151 const char *pszIde;
152 /** Pointer to the string literal if a string literal node. */
153 const char *pszStrLit;
154 /** A number */
155 uint64_t u64;
156 };
157 /** Number of "arguments" for the opcode following (for example Scope(), Method(), If(), etc., i.e. anything requiring () after the keyword ). */
158 uint8_t cArgs;
159 /** Padding */
160 uint8_t abRsvd[2];
161 /** The AST node arguments - variable in size. */
162 RTACPIASTARG aArgs[1];
163} RTACPIASTNODE;
164
165/** Default flags. */
166#define RTACPI_AST_NODE_F_DEFAULT 0
167/** The AST node opens a new scope. */
168#define RTACPI_AST_NODE_F_NEW_SCOPE RT_BIT_32(0)
169
170
171/**
172 * Allocates a new ACPI AST node initialized with the given properties.
173 *
174 * @returns Pointer to the new ACPI AST node or NULL if out of memory.
175 * @param enmOp The operation of the AST node.
176 * @param fFlags Flags for this node.
177 * @param cArgs Number of arguments to allocate.
178 */
179DECLHIDDEN(PRTACPIASTNODE) rtAcpiAstNodeAlloc(RTACPIASTNODEOP enmOp, uint32_t fFlags, uint8_t cArgs);
180
181
182/**
183 * Frees the given AST node and all children nodes linked to this one.
184 *
185 * @param pAstNd The AST node to free.
186 */
187DECLHIDDEN(void) rtAcpiAstNodeFree(PRTACPIASTNODE pAstNd);
188
189
190/**
191 * Dumps the given AST node and everything it references to the given ACPI table.
192 *
193 * @returns IPRT status code.
194 * @param pAstNd The AST node to dump.
195 * @param hAcpiTbl The ACPI table to dump to.
196 */
197DECLHIDDEN(int) rtAcpiAstDumpToTbl(PCRTACPIASTNODE pAstNd, RTACPITBL hAcpiTbl);
198
199
200/**
201 * Worker for decompiling AML bytecode to the ASL source language.
202 *
203 * @returns IPRT status code.
204 * @param hVfsIosOut The VFS I/O stream handle to output the result to.
205 * @param hVfsIosIn The VFS I/O stream handle to read the ACPI table from.
206 * @param pErrInfo Where to return additional error information.
207 */
208DECLHIDDEN(int) rtAcpiTblConvertFromAmlToAsl(RTVFSIOSTREAM hVfsIosOut, RTVFSIOSTREAM hVfsIosIn, PRTERRINFO pErrInfo);
209
210
211/**
212 * Worker for compiling ASL to the AML bytecode.
213 *
214 * @returns IPRT status code.
215 * @param hVfsIosOut The VFS I/O stream handle to output the result to.
216 * @param hVfsIosIn The VFS I/O stream handle to read the ACPI table from.
217 * @param pErrInfo Where to return additional error information.
218 */
219DECLHIDDEN(int) rtAcpiTblConvertFromAslToAml(RTVFSIOSTREAM hVfsIosOut, RTVFSIOSTREAM hVfsIosIn, PRTERRINFO pErrInfo);
220
221
222RT_C_DECLS_END
223
224#endif /* !IPRT_INCLUDED_INTERNAL_acpi_h */
225
Note: See TracBrowser for help on using the repository browser.

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