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