]>
Commit | Line | Data |
---|---|---|
422e93e1 PG |
1 | /** @file\r |
2 | AML Resource Data.\r | |
3 | \r | |
4 | Copyright (c) 2019 - 2020, Arm Limited. All rights reserved.<BR>\r | |
5 | \r | |
6 | SPDX-License-Identifier: BSD-2-Clause-Patent\r | |
7 | \r | |
8 | @par Glossary:\r | |
9 | - Rd or RD - Resource Data\r | |
10 | - Rds or RDS - Resource Data Small\r | |
11 | - Rdl or RDL - Resource Data Large\r | |
12 | **/\r | |
13 | \r | |
14 | #ifndef AML_RESOURCE_DATA_H_\r | |
15 | #define AML_RESOURCE_DATA_H_\r | |
16 | \r | |
17 | /* This header file does not include internal Node definition,\r | |
18 | i.e. AML_ROOT_NODE, AML_OBJECT_NODE, etc. The node definitions\r | |
19 | must be included by the caller file. The function prototypes must\r | |
20 | only expose AML_NODE_HANDLE, AML_ROOT_NODE_HANDLE, etc. node\r | |
21 | definitions.\r | |
22 | This allows to keep the functions defined here both internal and\r | |
23 | potentially external. If necessary, any function of this file can\r | |
24 | be exposed externally.\r | |
25 | The Api folder is internal to the AmlLib, but should only use these\r | |
26 | functions. They provide a "safe" way to interact with the AmlLib.\r | |
27 | */\r | |
28 | \r | |
29 | #include <AmlInclude.h>\r | |
30 | #include <IndustryStandard/Acpi.h>\r | |
31 | \r | |
32 | /**\r | |
33 | @defgroup ResourceDataLibrary Resource data library\r | |
34 | @ingroup AMLLib\r | |
35 | @{\r | |
36 | Resource data are defined in the ACPI 6.3 specification,\r | |
37 | s6.4 "Resource Data Types for ACPI". They can be created in ASL via the\r | |
38 | ResourceTemplate () statement, cf s19.3.3 "ASL Resource Templates".\r | |
39 | \r | |
40 | Resource data can be of the small or large type. The difference between\r | |
41 | small and large resource data elements is their encoding.\r | |
42 | \r | |
43 | Resource data are stored in the variable list of arguments of object\r | |
44 | nodes.\r | |
45 | @}\r | |
46 | */\r | |
47 | \r | |
48 | /** Resource Descriptor header for Small/Large Resource Data Object.\r | |
49 | This is the first byte of a Small/Large Resource Data element.\r | |
50 | \r | |
51 | Can be a ACPI_SMALL_RESOURCE_HEADER or ACPI_LARGE_RESOURCE_HEADER.\r | |
52 | \r | |
53 | @ingroup ResourceDataStructures\r | |
54 | */\r | |
55 | typedef UINT8 AML_RD_HEADER;\r | |
56 | \r | |
57 | /** Mask for the small resource data size.\r | |
58 | \r | |
59 | @ingroup ResourceDataStructures\r | |
60 | */\r | |
731c67e1 | 61 | #define AML_RD_SMALL_SIZE_MASK (0x7U)\r |
422e93e1 PG |
62 | \r |
63 | /** Mask for the small resource data ID.\r | |
64 | \r | |
65 | @ingroup ResourceDataStructures\r | |
66 | */\r | |
731c67e1 | 67 | #define AML_RD_SMALL_ID_MASK (0xFU << 3)\r |
422e93e1 PG |
68 | \r |
69 | /** Mask for the large resource data ID.\r | |
70 | \r | |
71 | @ingroup ResourceDataStructures\r | |
72 | */\r | |
731c67e1 | 73 | #define AML_RD_LARGE_ID_MASK (0x7FU)\r |
422e93e1 PG |
74 | \r |
75 | /**\r | |
76 | @defgroup ResourceDataApis Resource data APIs\r | |
77 | @ingroup ResourceDataLibrary\r | |
78 | @{\r | |
79 | Resource data APIs allow to manipulate/decode resource data elements.\r | |
80 | @}\r | |
81 | */\r | |
82 | \r | |
83 | /** Check whether a resource data is of the large type.\r | |
84 | \r | |
85 | @ingroup ResourceDataApis\r | |
86 | \r | |
87 | @param [in] Header Pointer to the first byte of a resource data.\r | |
88 | \r | |
89 | @retval TRUE If the resource data is of the large type.\r | |
90 | @retval FALSE Otherwise.\r | |
91 | **/\r | |
92 | #define AML_RD_IS_LARGE(Header) \\r | |
93 | (((ACPI_SMALL_RESOURCE_HEADER*)Header)->Bits.Type == \\r | |
94 | ACPI_LARGE_ITEM_FLAG)\r | |
95 | \r | |
96 | /** Build a small resource data descriptor Id.\r | |
97 | The small/large bit is included in the descriptor Id,\r | |
98 | but the size bits are not included.\r | |
99 | \r | |
100 | @ingroup ResourceDataApis\r | |
101 | \r | |
102 | @param [in] Id Descriptor Id.\r | |
103 | \r | |
104 | @return A descriptor Id.\r | |
105 | **/\r | |
106 | #define AML_RD_BUILD_SMALL_DESC_ID(Id) ((AML_RD_HEADER)((Id & 0xF) << 3))\r | |
107 | \r | |
108 | /** Build a large resource data descriptor Id.\r | |
109 | The small/large bit is included in the descriptor Id.\r | |
110 | \r | |
111 | @ingroup ResourceDataApis\r | |
112 | \r | |
113 | @param [in] Id Id of the descriptor.\r | |
114 | \r | |
115 | @return A descriptor Id.\r | |
116 | **/\r | |
117 | #define AML_RD_BUILD_LARGE_DESC_ID(Id) ((AML_RD_HEADER)((BIT7) | Id))\r | |
118 | \r | |
119 | /** Check whether the resource data has the input descriptor Id.\r | |
120 | \r | |
121 | The small/large bit is included in the descriptor Id,\r | |
122 | but the size bits are not included for small resource data elements.\r | |
123 | \r | |
124 | @ingroup ResourceDataApis\r | |
125 | \r | |
126 | @param [in] Header Pointer to the first byte of a resource data\r | |
127 | element.\r | |
128 | @param [in] DescriptorId The descriptor to check against.\r | |
129 | \r | |
130 | @retval TRUE The resource data has the descriptor Id.\r | |
131 | @retval FALSE Otherwise.\r | |
132 | **/\r | |
133 | BOOLEAN\r | |
134 | EFIAPI\r | |
135 | AmlRdCompareDescId (\r | |
731c67e1 MK |
136 | IN CONST AML_RD_HEADER *Header,\r |
137 | IN AML_RD_HEADER DescriptorId\r | |
422e93e1 PG |
138 | );\r |
139 | \r | |
140 | /** Get the descriptor Id of the resource data.\r | |
141 | \r | |
142 | The small/large bit is included in the descriptor Id,\r | |
143 | but the size bits are not included for small resource data elements.\r | |
144 | \r | |
145 | @ingroup ResourceDataApis\r | |
146 | \r | |
147 | @param [in] Header Pointer to the first byte of a resource data.\r | |
148 | \r | |
149 | @return A descriptor Id.\r | |
150 | **/\r | |
151 | AML_RD_HEADER\r | |
152 | EFIAPI\r | |
153 | AmlRdGetDescId (\r | |
731c67e1 | 154 | IN CONST AML_RD_HEADER *Header\r |
422e93e1 PG |
155 | );\r |
156 | \r | |
157 | /** Get the size of a resource data element.\r | |
158 | \r | |
159 | If the resource data element is of the large type, the Header\r | |
160 | is expected to be at least 3 bytes long.\r | |
161 | \r | |
162 | @ingroup ResourceDataApis\r | |
163 | \r | |
164 | @param [in] Header Pointer to the first byte of a resource data.\r | |
165 | \r | |
166 | @return The size of the resource data element.\r | |
167 | **/\r | |
168 | UINT32\r | |
169 | EFIAPI\r | |
170 | AmlRdGetSize (\r | |
731c67e1 | 171 | IN CONST AML_RD_HEADER *Header\r |
422e93e1 PG |
172 | );\r |
173 | \r | |
28b2df47 PG |
174 | /** Set the Checksum of an EndTag resource data.\r |
175 | \r | |
176 | ACPI 6.4, s6.4.2.9 "End Tag":\r | |
177 | "This checksum is generated such that adding it to the sum of all the data\r | |
178 | bytes will produce a zero sum."\r | |
179 | "If the checksum field is zero, the resource data is treated as if the\r | |
180 | checksum operation succeeded. Configuration proceeds normally."\r | |
181 | \r | |
182 | @param [in] Header Pointer to the first byte of a resource data.\r | |
183 | @param [in] CheckSum Checksum value to set.\r | |
184 | \r | |
185 | @retval EFI_SUCCESS The function completed successfully.\r | |
186 | @retval EFI_INVALID_PARAMETER Invalid parameter.\r | |
187 | **/\r | |
188 | EFI_STATUS\r | |
189 | EFIAPI\r | |
190 | AmlRdSetEndTagChecksum (\r | |
731c67e1 MK |
191 | IN CONST AML_RD_HEADER *Header,\r |
192 | IN UINT8 CheckSum\r | |
28b2df47 PG |
193 | );\r |
194 | \r | |
422e93e1 | 195 | #endif // AML_RESOURCE_DATA_H_\r |