1 /** @file
2   This protocol provides services for creating ACPI system description tables.
3 
4   Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
5   SPDX-License-Identifier: BSD-2-Clause-Patent
6 
7   @par Revision Reference:
8   This Protocol was introduced in PI Specification 1.2.
9 
10 **/
11 
12 #ifndef __ACPI_SYSTEM_DESCRIPTION_TABLE_H___
13 #define __ACPI_SYSTEM_DESCRIPTION_TABLE_H___
14 
15 #define EFI_ACPI_SDT_PROTOCOL_GUID \
16   { 0xeb97088e, 0xcfdf, 0x49c6, { 0xbe, 0x4b, 0xd9, 0x6, 0xa5, 0xb2, 0xe, 0x86 }}
17 
18 typedef UINT32  EFI_ACPI_TABLE_VERSION;
19 typedef VOID    *EFI_ACPI_HANDLE;
20 
21 #define EFI_ACPI_TABLE_VERSION_NONE (1 << 0)
22 #define EFI_ACPI_TABLE_VERSION_1_0B (1 << 1)
23 #define EFI_ACPI_TABLE_VERSION_2_0  (1 << 2)
24 #define EFI_ACPI_TABLE_VERSION_3_0  (1 << 3)
25 #define EFI_ACPI_TABLE_VERSION_4_0  (1 << 4)
26 #define EFI_ACPI_TABLE_VERSION_5_0  (1 << 5)
27 
28 typedef UINT32 EFI_ACPI_DATA_TYPE;
29 #define EFI_ACPI_DATA_TYPE_NONE         0
30 #define EFI_ACPI_DATA_TYPE_OPCODE       1
31 #define EFI_ACPI_DATA_TYPE_NAME_STRING  2
32 #define EFI_ACPI_DATA_TYPE_OP           3
33 #define EFI_ACPI_DATA_TYPE_UINT         4
34 #define EFI_ACPI_DATA_TYPE_STRING       5
35 #define EFI_ACPI_DATA_TYPE_CHILD        6
36 
37 typedef struct {
38   UINT32    Signature;
39   UINT32    Length;
40   UINT8     Revision;
41   UINT8     Checksum;
42   CHAR8     OemId[6];
43   CHAR8     OemTableId[8];
44   UINT32    OemRevision;
45   UINT32    CreatorId;
46   UINT32    CreatorRevision;
47 } EFI_ACPI_SDT_HEADER;
48 
49 typedef
50 EFI_STATUS
51 (EFIAPI *EFI_ACPI_NOTIFICATION_FN)(
52   IN EFI_ACPI_SDT_HEADER    *Table,     ///< A pointer to the ACPI table header.
53   IN EFI_ACPI_TABLE_VERSION Version,    ///< The ACPI table's version.
54   IN UINTN                  TableKey    ///< The table key for this ACPI table.
55 );
56 
57 /**
58   Returns a requested ACPI table.
59 
60   The GetAcpiTable() function returns a pointer to a buffer containing the ACPI table associated
61   with the Index that was input. The following structures are not considered elements in the list of
62   ACPI tables:
63   - Root System Description Pointer (RSD_PTR)
64   - Root System Description Table (RSDT)
65   - Extended System Description Table (XSDT)
66   Version is updated with a bit map containing all the versions of ACPI of which the table is a
67   member. For tables installed via the EFI_ACPI_TABLE_PROTOCOL.InstallAcpiTable() interface,
68   the function returns the value of EFI_ACPI_STD_PROTOCOL.AcpiVersion.
69 
70   @param[in]    Index       The zero-based index of the table to retrieve.
71   @param[out]   Table       Pointer for returning the table buffer.
72   @param[out]   Version     On return, updated with the ACPI versions to which this table belongs. Type
73                             EFI_ACPI_TABLE_VERSION is defined in "Related Definitions" in the
74                             EFI_ACPI_SDT_PROTOCOL.
75   @param[out]   TableKey    On return, points to the table key for the specified ACPI system definition table.
76                             This is identical to the table key used in the EFI_ACPI_TABLE_PROTOCOL.
77                             The TableKey can be passed to EFI_ACPI_TABLE_PROTOCOL.UninstallAcpiTable()
78                             to uninstall the table.
79 
80   @retval EFI_SUCCESS       The function completed successfully.
81   @retval EFI_NOT_FOUND     The requested index is too large and a table was not found.
82 **/
83 typedef
84 EFI_STATUS
85 (EFIAPI *EFI_ACPI_GET_ACPI_TABLE2)(
86   IN    UINTN                   Index,
87   OUT   EFI_ACPI_SDT_HEADER     **Table,
88   OUT   EFI_ACPI_TABLE_VERSION  *Version,
89   OUT   UINTN                   *TableKey
90 );
91 
92 /**
93   Register or unregister a callback when an ACPI table is installed.
94 
95   This function registers or unregisters a function which will be called whenever a new ACPI table is
96   installed.
97 
98   @param[in]    Register        If TRUE, then the specified function will be registered. If FALSE, then the specified
99                                 function will be unregistered.
100   @param[in]    Notification    Points to the callback function to be registered or unregistered.
101 
102   @retval EFI_SUCCESS           Callback successfully registered or unregistered.
103   @retval EFI_INVALID_PARAMETER Notification is NULL
104   @retval EFI_INVALID_PARAMETER Register is FALSE and Notification does not match a known registration function.
105 **/
106 typedef
107 EFI_STATUS
108 (EFIAPI *EFI_ACPI_REGISTER_NOTIFY)(
109   IN BOOLEAN                    Register,
110   IN EFI_ACPI_NOTIFICATION_FN   Notification
111 );
112 
113 /**
114   Create a handle from an ACPI opcode
115 
116   @param[in]  Buffer                 Points to the ACPI opcode.
117   @param[out] Handle                 Upon return, holds the handle.
118 
119   @retval   EFI_SUCCESS             Success
120   @retval   EFI_INVALID_PARAMETER   Buffer is NULL or Handle is NULL or Buffer points to an
121                                     invalid opcode.
122 
123 **/
124 typedef
125 EFI_STATUS
126 (EFIAPI *EFI_ACPI_OPEN)(
127   IN    VOID            *Buffer,
128   OUT   EFI_ACPI_HANDLE *Handle
129 );
130 
131 /**
132   Create a handle for the first ACPI opcode in an ACPI system description table.
133 
134   @param[in]    TableKey    The table key for the ACPI table, as returned by GetTable().
135   @param[out]   Handle      On return, points to the newly created ACPI handle.
136 
137   @retval EFI_SUCCESS       Handle created successfully.
138   @retval EFI_NOT_FOUND     TableKey does not refer to a valid ACPI table.
139 **/
140 typedef
141 EFI_STATUS
142 (EFIAPI *EFI_ACPI_OPEN_SDT)(
143   IN    UINTN           TableKey,
144   OUT   EFI_ACPI_HANDLE *Handle
145 );
146 
147 /**
148   Close an ACPI handle.
149 
150   @param[in] Handle Returns the handle.
151 
152   @retval EFI_SUCCESS           Success
153   @retval EFI_INVALID_PARAMETER Handle is NULL or does not refer to a valid ACPI object.
154 **/
155 typedef
156 EFI_STATUS
157 (EFIAPI *EFI_ACPI_CLOSE)(
158   IN EFI_ACPI_HANDLE Handle
159 );
160 
161 /**
162   Return the child ACPI objects.
163 
164   @param[in]        ParentHandle    Parent handle.
165   @param[in, out]   Handle          On entry, points to the previously returned handle or NULL to start with the first
166                                     handle. On return, points to the next returned ACPI handle or NULL if there are no
167                                     child objects.
168 
169   @retval EFI_SUCCESS               Success
170   @retval EFI_INVALID_PARAMETER     ParentHandle is NULL or does not refer to a valid ACPI object.
171 **/
172 typedef
173 EFI_STATUS
174 (EFIAPI *EFI_ACPI_GET_CHILD)(
175   IN EFI_ACPI_HANDLE        ParentHandle,
176   IN OUT EFI_ACPI_HANDLE    *Handle
177 );
178 
179 /**
180   Retrieve information about an ACPI object.
181 
182   @param[in]    Handle      ACPI object handle.
183   @param[in]    Index       Index of the data to retrieve from the object. In general, indexes read from left-to-right
184                             in the ACPI encoding, with index 0 always being the ACPI opcode.
185   @param[out]   DataType    Points to the returned data type or EFI_ACPI_DATA_TYPE_NONE if no data exists
186                             for the specified index.
187   @param[out]   Data        Upon return, points to the pointer to the data.
188   @param[out]   DataSize    Upon return, points to the size of Data.
189 
190   @retval
191 **/
192 typedef
193 EFI_STATUS
194 (EFIAPI *EFI_ACPI_GET_OPTION)(
195   IN        EFI_ACPI_HANDLE     Handle,
196   IN        UINTN               Index,
197   OUT       EFI_ACPI_DATA_TYPE  *DataType,
198   OUT CONST VOID                **Data,
199   OUT       UINTN               *DataSize
200 );
201 
202 /**
203   Change information about an ACPI object.
204 
205   @param[in]  Handle    ACPI object handle.
206   @param[in]  Index     Index of the data to retrieve from the object. In general, indexes read from left-to-right
207                         in the ACPI encoding, with index 0 always being the ACPI opcode.
208   @param[in]  Data      Points to the data.
209   @param[in]  DataSize  The size of the Data.
210 
211   @retval EFI_SUCCESS           Success
212   @retval EFI_INVALID_PARAMETER Handle is NULL or does not refer to a valid ACPI object.
213   @retval EFI_BAD_BUFFER_SIZE   Data cannot be accommodated in the space occupied by
214                                 the option.
215 
216 **/
217 typedef
218 EFI_STATUS
219 (EFIAPI *EFI_ACPI_SET_OPTION)(
220   IN        EFI_ACPI_HANDLE Handle,
221   IN        UINTN           Index,
222   IN CONST  VOID            *Data,
223   IN        UINTN           DataSize
224 );
225 
226 /**
227   Returns the handle of the ACPI object representing the specified ACPI path
228 
229   @param[in]    HandleIn    Points to the handle of the object representing the starting point for the path search.
230   @param[in]    AcpiPath    Points to the ACPI path, which conforms to the ACPI encoded path format.
231   @param[out]   HandleOut   On return, points to the ACPI object which represents AcpiPath, relative to
232                             HandleIn.
233 
234   @retval EFI_SUCCESS           Success
235   @retval EFI_INVALID_PARAMETER HandleIn is NULL or does not refer to a valid ACPI object.
236 **/
237 typedef
238 EFI_STATUS
239 (EFIAPI *EFI_ACPI_FIND_PATH)(
240   IN    EFI_ACPI_HANDLE HandleIn,
241   IN    VOID            *AcpiPath,
242   OUT   EFI_ACPI_HANDLE *HandleOut
243 );
244 
245 typedef struct _EFI_ACPI_SDT_PROTOCOL {
246   ///
247   /// A bit map containing all the ACPI versions supported by this protocol.
248   ///
249   EFI_ACPI_TABLE_VERSION    AcpiVersion;
250   EFI_ACPI_GET_ACPI_TABLE2  GetAcpiTable;
251   EFI_ACPI_REGISTER_NOTIFY  RegisterNotify;
252   EFI_ACPI_OPEN             Open;
253   EFI_ACPI_OPEN_SDT         OpenSdt;
254   EFI_ACPI_CLOSE            Close;
255   EFI_ACPI_GET_CHILD        GetChild;
256   EFI_ACPI_GET_OPTION       GetOption;
257   EFI_ACPI_SET_OPTION       SetOption;
258   EFI_ACPI_FIND_PATH        FindPath;
259 } EFI_ACPI_SDT_PROTOCOL;
260 
261 extern EFI_GUID gEfiAcpiSdtProtocolGuid;
262 
263 #endif // __ACPI_SYSTEM_DESCRIPTION_TABLE_H___
264