VirtualBox

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

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

Runtime/RTAcpi: Some more work on the ASL -> AML compiler, can process our vbox-standard.dsl now, bugref:10733

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.5 KB
Line 
1/* $Id: acpi.h 108029 2025-02-03 15:58:01Z 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_U8,
62 kAcpiAstArgType_U16,
63 kAcpiAstArgType_U32,
64 kAcpiAstArgType_U64,
65 kAcpiAstArgType_32Bit_Hack = 0x7fffffff
66} RTACPIASTARGTYPE;
67
68
69/**
70 * An AST node argument
71 */
72typedef struct RTACPIASTARG
73{
74 /** Argument type. */
75 RTACPIASTARGTYPE enmType;
76 /** Type dependent data. */
77 union
78 {
79 uintptr_t uPtrInternal;
80 PCRTACPIASTNODE pAstNode;
81 const char *pszNameString;
82 uint8_t u8;
83 uint16_t u16;
84 uint32_t u32;
85 uint64_t u64;
86 } u;
87} RTACPIASTARG;
88/** Pointer to an AST node argument. */
89typedef RTACPIASTARG *PRTACPIASTARG;
90/** Pointer to a const AST node argument. */
91typedef const RTACPIASTARG *PCRTACPIASTARG;
92
93
94/**
95 * The core ACPI AST node.
96 */
97typedef struct RTACPIASTNODE
98{
99 /** List node. */
100 RTLISTNODE NdAst;
101 /** The AML opcode defining the node. */
102 uint8_t bOpc;
103 /** Number of "arguments" for the opcode following (for example Scope(), Method(), If(), etc., i.e. anything requiring () after the keyword ). */
104 uint8_t cArgs;
105 /** Padding */
106 uint8_t abRsvd[2];
107 /** Some additional flags. */
108 uint32_t fFlags;
109 /** List of other AST nodes for the opened scope if indicated by the AST flags (RTACPIASTNODE). */
110 RTLISTANCHOR LstScopeNodes;
111 /** The AST node arguments - variable in size. */
112 RTACPIASTARG aArgs[1];
113} RTACPIASTNODE;
114
115/** Default flags. */
116#define RTACPI_AST_NODE_F_DEFAULT 0
117/** The AST node opens a new scope. */
118#define RTACPI_AST_NODE_F_NEW_SCOPE RT_BIT_32(0)
119/** The AST node opcode is part of the extended prefix opcode map. */
120#define RTACPI_AST_NODE_F_EXT_OPC RT_BIT_32(1)
121
122
123/**
124 * Allocates a new ACPI AST node initialized with the given properties.
125 *
126 * @returns Pointer to the new ACPI AST node or NULL if out of memory.
127 * @param bOpc The opcode value for the AST node.
128 * @param fFlags Flags for this node.
129 * @param cArgs Number of arguments to allocate.
130 */
131DECLHIDDEN(PRTACPIASTNODE) rtAcpiAstNodeAlloc(uint8_t bOpc, uint32_t fFlags, uint8_t cArgs);
132
133
134/**
135 * Frees the given AST node and all children nodes linked to this one.
136 *
137 * @param pAstNd The AST node to free.
138 */
139DECLHIDDEN(void) rtAcpiAstNodeFree(PRTACPIASTNODE pAstNd);
140
141
142/**
143 * Dumps the given AST node and everything it references to the given ACPI table.
144 *
145 * @returns IPRT status code.
146 * @param pAstNd The AST node to dump.
147 * @param hAcpiTbl The ACPI table to dump to.
148 */
149DECLHIDDEN(int) rtAcpiAstDumpToTbl(PCRTACPIASTNODE pAstNd, RTACPITBL hAcpiTbl);
150
151
152/**
153 * Worker for decompiling AML bytecode to the ASL source language.
154 *
155 * @returns IPRT status code.
156 * @param hVfsIosOut The VFS I/O stream handle to output the result to.
157 * @param hVfsIosIn The VFS I/O stream handle to read the ACPI table from.
158 * @param pErrInfo Where to return additional error information.
159 */
160DECLHIDDEN(int) rtAcpiTblConvertFromAmlToAsl(RTVFSIOSTREAM hVfsIosOut, RTVFSIOSTREAM hVfsIosIn, PRTERRINFO pErrInfo);
161
162
163/**
164 * Worker for compiling ASL to the AML bytecode.
165 *
166 * @returns IPRT status code.
167 * @param hVfsIosOut The VFS I/O stream handle to output the result to.
168 * @param hVfsIosIn The VFS I/O stream handle to read the ACPI table from.
169 * @param pErrInfo Where to return additional error information.
170 */
171DECLHIDDEN(int) rtAcpiTblConvertFromAslToAml(RTVFSIOSTREAM hVfsIosOut, RTVFSIOSTREAM hVfsIosIn, PRTERRINFO pErrInfo);
172
173
174RT_C_DECLS_END
175
176#endif /* !IPRT_INCLUDED_INTERNAL_acpi_h */
177
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