utresrc.c revision 1.1.1.2.4.2 1 1.1.1.2.4.2 rmind /*******************************************************************************
2 1.1.1.2.4.2 rmind *
3 1.1.1.2.4.2 rmind * Module Name: utresrc - Resource managment utilities
4 1.1.1.2.4.2 rmind *
5 1.1.1.2.4.2 rmind ******************************************************************************/
6 1.1.1.2.4.2 rmind
7 1.1.1.2.4.2 rmind /*
8 1.1.1.2.4.2 rmind * Copyright (C) 2000 - 2011, Intel Corp.
9 1.1.1.2.4.2 rmind * All rights reserved.
10 1.1.1.2.4.2 rmind *
11 1.1.1.2.4.2 rmind * Redistribution and use in source and binary forms, with or without
12 1.1.1.2.4.2 rmind * modification, are permitted provided that the following conditions
13 1.1.1.2.4.2 rmind * are met:
14 1.1.1.2.4.2 rmind * 1. Redistributions of source code must retain the above copyright
15 1.1.1.2.4.2 rmind * notice, this list of conditions, and the following disclaimer,
16 1.1.1.2.4.2 rmind * without modification.
17 1.1.1.2.4.2 rmind * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.1.1.2.4.2 rmind * substantially similar to the "NO WARRANTY" disclaimer below
19 1.1.1.2.4.2 rmind * ("Disclaimer") and any redistribution must be conditioned upon
20 1.1.1.2.4.2 rmind * including a substantially similar Disclaimer requirement for further
21 1.1.1.2.4.2 rmind * binary redistribution.
22 1.1.1.2.4.2 rmind * 3. Neither the names of the above-listed copyright holders nor the names
23 1.1.1.2.4.2 rmind * of any contributors may be used to endorse or promote products derived
24 1.1.1.2.4.2 rmind * from this software without specific prior written permission.
25 1.1.1.2.4.2 rmind *
26 1.1.1.2.4.2 rmind * Alternatively, this software may be distributed under the terms of the
27 1.1.1.2.4.2 rmind * GNU General Public License ("GPL") version 2 as published by the Free
28 1.1.1.2.4.2 rmind * Software Foundation.
29 1.1.1.2.4.2 rmind *
30 1.1.1.2.4.2 rmind * NO WARRANTY
31 1.1.1.2.4.2 rmind * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.1.1.2.4.2 rmind * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.1.1.2.4.2 rmind * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.1.1.2.4.2 rmind * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.1.1.2.4.2 rmind * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.1.1.2.4.2 rmind * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.1.1.2.4.2 rmind * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.1.1.2.4.2 rmind * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.1.1.2.4.2 rmind * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.1.1.2.4.2 rmind * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.1.1.2.4.2 rmind * POSSIBILITY OF SUCH DAMAGES.
42 1.1.1.2.4.2 rmind */
43 1.1.1.2.4.2 rmind
44 1.1.1.2.4.2 rmind
45 1.1.1.2.4.2 rmind #define __UTRESRC_C__
46 1.1.1.2.4.2 rmind
47 1.1.1.2.4.2 rmind #include "acpi.h"
48 1.1.1.2.4.2 rmind #include "accommon.h"
49 1.1.1.2.4.2 rmind #include "amlresrc.h"
50 1.1.1.2.4.2 rmind
51 1.1.1.2.4.2 rmind
52 1.1.1.2.4.2 rmind #define _COMPONENT ACPI_UTILITIES
53 1.1.1.2.4.2 rmind ACPI_MODULE_NAME ("utresrc")
54 1.1.1.2.4.2 rmind
55 1.1.1.2.4.2 rmind
56 1.1.1.2.4.2 rmind #if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUGGER)
57 1.1.1.2.4.2 rmind
58 1.1.1.2.4.2 rmind /*
59 1.1.1.2.4.2 rmind * Strings used to decode resource descriptors.
60 1.1.1.2.4.2 rmind * Used by both the disasssembler and the debugger resource dump routines
61 1.1.1.2.4.2 rmind */
62 1.1.1.2.4.2 rmind const char *AcpiGbl_BmDecode[] =
63 1.1.1.2.4.2 rmind {
64 1.1.1.2.4.2 rmind "NotBusMaster",
65 1.1.1.2.4.2 rmind "BusMaster"
66 1.1.1.2.4.2 rmind };
67 1.1.1.2.4.2 rmind
68 1.1.1.2.4.2 rmind const char *AcpiGbl_ConfigDecode[] =
69 1.1.1.2.4.2 rmind {
70 1.1.1.2.4.2 rmind "0 - Good Configuration",
71 1.1.1.2.4.2 rmind "1 - Acceptable Configuration",
72 1.1.1.2.4.2 rmind "2 - Suboptimal Configuration",
73 1.1.1.2.4.2 rmind "3 - ***Invalid Configuration***",
74 1.1.1.2.4.2 rmind };
75 1.1.1.2.4.2 rmind
76 1.1.1.2.4.2 rmind const char *AcpiGbl_ConsumeDecode[] =
77 1.1.1.2.4.2 rmind {
78 1.1.1.2.4.2 rmind "ResourceProducer",
79 1.1.1.2.4.2 rmind "ResourceConsumer"
80 1.1.1.2.4.2 rmind };
81 1.1.1.2.4.2 rmind
82 1.1.1.2.4.2 rmind const char *AcpiGbl_DecDecode[] =
83 1.1.1.2.4.2 rmind {
84 1.1.1.2.4.2 rmind "PosDecode",
85 1.1.1.2.4.2 rmind "SubDecode"
86 1.1.1.2.4.2 rmind };
87 1.1.1.2.4.2 rmind
88 1.1.1.2.4.2 rmind const char *AcpiGbl_HeDecode[] =
89 1.1.1.2.4.2 rmind {
90 1.1.1.2.4.2 rmind "Level",
91 1.1.1.2.4.2 rmind "Edge"
92 1.1.1.2.4.2 rmind };
93 1.1.1.2.4.2 rmind
94 1.1.1.2.4.2 rmind const char *AcpiGbl_IoDecode[] =
95 1.1.1.2.4.2 rmind {
96 1.1.1.2.4.2 rmind "Decode10",
97 1.1.1.2.4.2 rmind "Decode16"
98 1.1.1.2.4.2 rmind };
99 1.1.1.2.4.2 rmind
100 1.1.1.2.4.2 rmind const char *AcpiGbl_LlDecode[] =
101 1.1.1.2.4.2 rmind {
102 1.1.1.2.4.2 rmind "ActiveHigh",
103 1.1.1.2.4.2 rmind "ActiveLow"
104 1.1.1.2.4.2 rmind };
105 1.1.1.2.4.2 rmind
106 1.1.1.2.4.2 rmind const char *AcpiGbl_MaxDecode[] =
107 1.1.1.2.4.2 rmind {
108 1.1.1.2.4.2 rmind "MaxNotFixed",
109 1.1.1.2.4.2 rmind "MaxFixed"
110 1.1.1.2.4.2 rmind };
111 1.1.1.2.4.2 rmind
112 1.1.1.2.4.2 rmind const char *AcpiGbl_MemDecode[] =
113 1.1.1.2.4.2 rmind {
114 1.1.1.2.4.2 rmind "NonCacheable",
115 1.1.1.2.4.2 rmind "Cacheable",
116 1.1.1.2.4.2 rmind "WriteCombining",
117 1.1.1.2.4.2 rmind "Prefetchable"
118 1.1.1.2.4.2 rmind };
119 1.1.1.2.4.2 rmind
120 1.1.1.2.4.2 rmind const char *AcpiGbl_MinDecode[] =
121 1.1.1.2.4.2 rmind {
122 1.1.1.2.4.2 rmind "MinNotFixed",
123 1.1.1.2.4.2 rmind "MinFixed"
124 1.1.1.2.4.2 rmind };
125 1.1.1.2.4.2 rmind
126 1.1.1.2.4.2 rmind const char *AcpiGbl_MtpDecode[] =
127 1.1.1.2.4.2 rmind {
128 1.1.1.2.4.2 rmind "AddressRangeMemory",
129 1.1.1.2.4.2 rmind "AddressRangeReserved",
130 1.1.1.2.4.2 rmind "AddressRangeACPI",
131 1.1.1.2.4.2 rmind "AddressRangeNVS"
132 1.1.1.2.4.2 rmind };
133 1.1.1.2.4.2 rmind
134 1.1.1.2.4.2 rmind const char *AcpiGbl_RngDecode[] =
135 1.1.1.2.4.2 rmind {
136 1.1.1.2.4.2 rmind "InvalidRanges",
137 1.1.1.2.4.2 rmind "NonISAOnlyRanges",
138 1.1.1.2.4.2 rmind "ISAOnlyRanges",
139 1.1.1.2.4.2 rmind "EntireRange"
140 1.1.1.2.4.2 rmind };
141 1.1.1.2.4.2 rmind
142 1.1.1.2.4.2 rmind const char *AcpiGbl_RwDecode[] =
143 1.1.1.2.4.2 rmind {
144 1.1.1.2.4.2 rmind "ReadOnly",
145 1.1.1.2.4.2 rmind "ReadWrite"
146 1.1.1.2.4.2 rmind };
147 1.1.1.2.4.2 rmind
148 1.1.1.2.4.2 rmind const char *AcpiGbl_ShrDecode[] =
149 1.1.1.2.4.2 rmind {
150 1.1.1.2.4.2 rmind "Exclusive",
151 1.1.1.2.4.2 rmind "Shared"
152 1.1.1.2.4.2 rmind };
153 1.1.1.2.4.2 rmind
154 1.1.1.2.4.2 rmind const char *AcpiGbl_SizDecode[] =
155 1.1.1.2.4.2 rmind {
156 1.1.1.2.4.2 rmind "Transfer8",
157 1.1.1.2.4.2 rmind "Transfer8_16",
158 1.1.1.2.4.2 rmind "Transfer16",
159 1.1.1.2.4.2 rmind "InvalidSize"
160 1.1.1.2.4.2 rmind };
161 1.1.1.2.4.2 rmind
162 1.1.1.2.4.2 rmind const char *AcpiGbl_TrsDecode[] =
163 1.1.1.2.4.2 rmind {
164 1.1.1.2.4.2 rmind "DenseTranslation",
165 1.1.1.2.4.2 rmind "SparseTranslation"
166 1.1.1.2.4.2 rmind };
167 1.1.1.2.4.2 rmind
168 1.1.1.2.4.2 rmind const char *AcpiGbl_TtpDecode[] =
169 1.1.1.2.4.2 rmind {
170 1.1.1.2.4.2 rmind "TypeStatic",
171 1.1.1.2.4.2 rmind "TypeTranslation"
172 1.1.1.2.4.2 rmind };
173 1.1.1.2.4.2 rmind
174 1.1.1.2.4.2 rmind const char *AcpiGbl_TypDecode[] =
175 1.1.1.2.4.2 rmind {
176 1.1.1.2.4.2 rmind "Compatibility",
177 1.1.1.2.4.2 rmind "TypeA",
178 1.1.1.2.4.2 rmind "TypeB",
179 1.1.1.2.4.2 rmind "TypeF"
180 1.1.1.2.4.2 rmind };
181 1.1.1.2.4.2 rmind
182 1.1.1.2.4.2 rmind #endif
183 1.1.1.2.4.2 rmind
184 1.1.1.2.4.2 rmind
185 1.1.1.2.4.2 rmind /*
186 1.1.1.2.4.2 rmind * Base sizes of the raw AML resource descriptors, indexed by resource type.
187 1.1.1.2.4.2 rmind * Zero indicates a reserved (and therefore invalid) resource type.
188 1.1.1.2.4.2 rmind */
189 1.1.1.2.4.2 rmind const UINT8 AcpiGbl_ResourceAmlSizes[] =
190 1.1.1.2.4.2 rmind {
191 1.1.1.2.4.2 rmind /* Small descriptors */
192 1.1.1.2.4.2 rmind
193 1.1.1.2.4.2 rmind 0,
194 1.1.1.2.4.2 rmind 0,
195 1.1.1.2.4.2 rmind 0,
196 1.1.1.2.4.2 rmind 0,
197 1.1.1.2.4.2 rmind ACPI_AML_SIZE_SMALL (AML_RESOURCE_IRQ),
198 1.1.1.2.4.2 rmind ACPI_AML_SIZE_SMALL (AML_RESOURCE_DMA),
199 1.1.1.2.4.2 rmind ACPI_AML_SIZE_SMALL (AML_RESOURCE_START_DEPENDENT),
200 1.1.1.2.4.2 rmind ACPI_AML_SIZE_SMALL (AML_RESOURCE_END_DEPENDENT),
201 1.1.1.2.4.2 rmind ACPI_AML_SIZE_SMALL (AML_RESOURCE_IO),
202 1.1.1.2.4.2 rmind ACPI_AML_SIZE_SMALL (AML_RESOURCE_FIXED_IO),
203 1.1.1.2.4.2 rmind 0,
204 1.1.1.2.4.2 rmind 0,
205 1.1.1.2.4.2 rmind 0,
206 1.1.1.2.4.2 rmind 0,
207 1.1.1.2.4.2 rmind ACPI_AML_SIZE_SMALL (AML_RESOURCE_VENDOR_SMALL),
208 1.1.1.2.4.2 rmind ACPI_AML_SIZE_SMALL (AML_RESOURCE_END_TAG),
209 1.1.1.2.4.2 rmind
210 1.1.1.2.4.2 rmind /* Large descriptors */
211 1.1.1.2.4.2 rmind
212 1.1.1.2.4.2 rmind 0,
213 1.1.1.2.4.2 rmind ACPI_AML_SIZE_LARGE (AML_RESOURCE_MEMORY24),
214 1.1.1.2.4.2 rmind ACPI_AML_SIZE_LARGE (AML_RESOURCE_GENERIC_REGISTER),
215 1.1.1.2.4.2 rmind 0,
216 1.1.1.2.4.2 rmind ACPI_AML_SIZE_LARGE (AML_RESOURCE_VENDOR_LARGE),
217 1.1.1.2.4.2 rmind ACPI_AML_SIZE_LARGE (AML_RESOURCE_MEMORY32),
218 1.1.1.2.4.2 rmind ACPI_AML_SIZE_LARGE (AML_RESOURCE_FIXED_MEMORY32),
219 1.1.1.2.4.2 rmind ACPI_AML_SIZE_LARGE (AML_RESOURCE_ADDRESS32),
220 1.1.1.2.4.2 rmind ACPI_AML_SIZE_LARGE (AML_RESOURCE_ADDRESS16),
221 1.1.1.2.4.2 rmind ACPI_AML_SIZE_LARGE (AML_RESOURCE_EXTENDED_IRQ),
222 1.1.1.2.4.2 rmind ACPI_AML_SIZE_LARGE (AML_RESOURCE_ADDRESS64),
223 1.1.1.2.4.2 rmind ACPI_AML_SIZE_LARGE (AML_RESOURCE_EXTENDED_ADDRESS64)
224 1.1.1.2.4.2 rmind };
225 1.1.1.2.4.2 rmind
226 1.1.1.2.4.2 rmind
227 1.1.1.2.4.2 rmind /*
228 1.1.1.2.4.2 rmind * Resource types, used to validate the resource length field.
229 1.1.1.2.4.2 rmind * The length of fixed-length types must match exactly, variable
230 1.1.1.2.4.2 rmind * lengths must meet the minimum required length, etc.
231 1.1.1.2.4.2 rmind * Zero indicates a reserved (and therefore invalid) resource type.
232 1.1.1.2.4.2 rmind */
233 1.1.1.2.4.2 rmind static const UINT8 AcpiGbl_ResourceTypes[] =
234 1.1.1.2.4.2 rmind {
235 1.1.1.2.4.2 rmind /* Small descriptors */
236 1.1.1.2.4.2 rmind
237 1.1.1.2.4.2 rmind 0,
238 1.1.1.2.4.2 rmind 0,
239 1.1.1.2.4.2 rmind 0,
240 1.1.1.2.4.2 rmind 0,
241 1.1.1.2.4.2 rmind ACPI_SMALL_VARIABLE_LENGTH,
242 1.1.1.2.4.2 rmind ACPI_FIXED_LENGTH,
243 1.1.1.2.4.2 rmind ACPI_SMALL_VARIABLE_LENGTH,
244 1.1.1.2.4.2 rmind ACPI_FIXED_LENGTH,
245 1.1.1.2.4.2 rmind ACPI_FIXED_LENGTH,
246 1.1.1.2.4.2 rmind ACPI_FIXED_LENGTH,
247 1.1.1.2.4.2 rmind 0,
248 1.1.1.2.4.2 rmind 0,
249 1.1.1.2.4.2 rmind 0,
250 1.1.1.2.4.2 rmind 0,
251 1.1.1.2.4.2 rmind ACPI_VARIABLE_LENGTH,
252 1.1.1.2.4.2 rmind ACPI_FIXED_LENGTH,
253 1.1.1.2.4.2 rmind
254 1.1.1.2.4.2 rmind /* Large descriptors */
255 1.1.1.2.4.2 rmind
256 1.1.1.2.4.2 rmind 0,
257 1.1.1.2.4.2 rmind ACPI_FIXED_LENGTH,
258 1.1.1.2.4.2 rmind ACPI_FIXED_LENGTH,
259 1.1.1.2.4.2 rmind 0,
260 1.1.1.2.4.2 rmind ACPI_VARIABLE_LENGTH,
261 1.1.1.2.4.2 rmind ACPI_FIXED_LENGTH,
262 1.1.1.2.4.2 rmind ACPI_FIXED_LENGTH,
263 1.1.1.2.4.2 rmind ACPI_VARIABLE_LENGTH,
264 1.1.1.2.4.2 rmind ACPI_VARIABLE_LENGTH,
265 1.1.1.2.4.2 rmind ACPI_VARIABLE_LENGTH,
266 1.1.1.2.4.2 rmind ACPI_VARIABLE_LENGTH,
267 1.1.1.2.4.2 rmind ACPI_FIXED_LENGTH
268 1.1.1.2.4.2 rmind };
269 1.1.1.2.4.2 rmind
270 1.1.1.2.4.2 rmind
271 1.1.1.2.4.2 rmind /*******************************************************************************
272 1.1.1.2.4.2 rmind *
273 1.1.1.2.4.2 rmind * FUNCTION: AcpiUtWalkAmlResources
274 1.1.1.2.4.2 rmind *
275 1.1.1.2.4.2 rmind * PARAMETERS: Aml - Pointer to the raw AML resource template
276 1.1.1.2.4.2 rmind * AmlLength - Length of the entire template
277 1.1.1.2.4.2 rmind * UserFunction - Called once for each descriptor found. If
278 1.1.1.2.4.2 rmind * NULL, a pointer to the EndTag is returned
279 1.1.1.2.4.2 rmind * Context - Passed to UserFunction
280 1.1.1.2.4.2 rmind *
281 1.1.1.2.4.2 rmind * RETURN: Status
282 1.1.1.2.4.2 rmind *
283 1.1.1.2.4.2 rmind * DESCRIPTION: Walk a raw AML resource list(buffer). User function called
284 1.1.1.2.4.2 rmind * once for each resource found.
285 1.1.1.2.4.2 rmind *
286 1.1.1.2.4.2 rmind ******************************************************************************/
287 1.1.1.2.4.2 rmind
288 1.1.1.2.4.2 rmind ACPI_STATUS
289 1.1.1.2.4.2 rmind AcpiUtWalkAmlResources (
290 1.1.1.2.4.2 rmind UINT8 *Aml,
291 1.1.1.2.4.2 rmind ACPI_SIZE AmlLength,
292 1.1.1.2.4.2 rmind ACPI_WALK_AML_CALLBACK UserFunction,
293 1.1.1.2.4.2 rmind void *Context)
294 1.1.1.2.4.2 rmind {
295 1.1.1.2.4.2 rmind ACPI_STATUS Status;
296 1.1.1.2.4.2 rmind UINT8 *EndAml;
297 1.1.1.2.4.2 rmind UINT8 ResourceIndex;
298 1.1.1.2.4.2 rmind UINT32 Length;
299 1.1.1.2.4.2 rmind UINT32 Offset = 0;
300 1.1.1.2.4.2 rmind
301 1.1.1.2.4.2 rmind
302 1.1.1.2.4.2 rmind ACPI_FUNCTION_TRACE (UtWalkAmlResources);
303 1.1.1.2.4.2 rmind
304 1.1.1.2.4.2 rmind
305 1.1.1.2.4.2 rmind /* The absolute minimum resource template is one EndTag descriptor */
306 1.1.1.2.4.2 rmind
307 1.1.1.2.4.2 rmind if (AmlLength < sizeof (AML_RESOURCE_END_TAG))
308 1.1.1.2.4.2 rmind {
309 1.1.1.2.4.2 rmind return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
310 1.1.1.2.4.2 rmind }
311 1.1.1.2.4.2 rmind
312 1.1.1.2.4.2 rmind /* Point to the end of the resource template buffer */
313 1.1.1.2.4.2 rmind
314 1.1.1.2.4.2 rmind EndAml = Aml + AmlLength;
315 1.1.1.2.4.2 rmind
316 1.1.1.2.4.2 rmind /* Walk the byte list, abort on any invalid descriptor type or length */
317 1.1.1.2.4.2 rmind
318 1.1.1.2.4.2 rmind while (Aml < EndAml)
319 1.1.1.2.4.2 rmind {
320 1.1.1.2.4.2 rmind /* Validate the Resource Type and Resource Length */
321 1.1.1.2.4.2 rmind
322 1.1.1.2.4.2 rmind Status = AcpiUtValidateResource (Aml, &ResourceIndex);
323 1.1.1.2.4.2 rmind if (ACPI_FAILURE (Status))
324 1.1.1.2.4.2 rmind {
325 1.1.1.2.4.2 rmind return_ACPI_STATUS (Status);
326 1.1.1.2.4.2 rmind }
327 1.1.1.2.4.2 rmind
328 1.1.1.2.4.2 rmind /* Get the length of this descriptor */
329 1.1.1.2.4.2 rmind
330 1.1.1.2.4.2 rmind Length = AcpiUtGetDescriptorLength (Aml);
331 1.1.1.2.4.2 rmind
332 1.1.1.2.4.2 rmind /* Invoke the user function */
333 1.1.1.2.4.2 rmind
334 1.1.1.2.4.2 rmind if (UserFunction)
335 1.1.1.2.4.2 rmind {
336 1.1.1.2.4.2 rmind Status = UserFunction (Aml, Length, Offset, ResourceIndex, Context);
337 1.1.1.2.4.2 rmind if (ACPI_FAILURE (Status))
338 1.1.1.2.4.2 rmind {
339 1.1.1.2.4.2 rmind return (Status);
340 1.1.1.2.4.2 rmind }
341 1.1.1.2.4.2 rmind }
342 1.1.1.2.4.2 rmind
343 1.1.1.2.4.2 rmind /* An EndTag descriptor terminates this resource template */
344 1.1.1.2.4.2 rmind
345 1.1.1.2.4.2 rmind if (AcpiUtGetResourceType (Aml) == ACPI_RESOURCE_NAME_END_TAG)
346 1.1.1.2.4.2 rmind {
347 1.1.1.2.4.2 rmind /*
348 1.1.1.2.4.2 rmind * There must be at least one more byte in the buffer for
349 1.1.1.2.4.2 rmind * the 2nd byte of the EndTag
350 1.1.1.2.4.2 rmind */
351 1.1.1.2.4.2 rmind if ((Aml + 1) >= EndAml)
352 1.1.1.2.4.2 rmind {
353 1.1.1.2.4.2 rmind return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
354 1.1.1.2.4.2 rmind }
355 1.1.1.2.4.2 rmind
356 1.1.1.2.4.2 rmind /* Return the pointer to the EndTag if requested */
357 1.1.1.2.4.2 rmind
358 1.1.1.2.4.2 rmind if (!UserFunction)
359 1.1.1.2.4.2 rmind {
360 1.1.1.2.4.2 rmind *(void **) Context = Aml;
361 1.1.1.2.4.2 rmind }
362 1.1.1.2.4.2 rmind
363 1.1.1.2.4.2 rmind /* Normal exit */
364 1.1.1.2.4.2 rmind
365 1.1.1.2.4.2 rmind return_ACPI_STATUS (AE_OK);
366 1.1.1.2.4.2 rmind }
367 1.1.1.2.4.2 rmind
368 1.1.1.2.4.2 rmind Aml += Length;
369 1.1.1.2.4.2 rmind Offset += Length;
370 1.1.1.2.4.2 rmind }
371 1.1.1.2.4.2 rmind
372 1.1.1.2.4.2 rmind /* Did not find an EndTag descriptor */
373 1.1.1.2.4.2 rmind
374 1.1.1.2.4.2 rmind return (AE_AML_NO_RESOURCE_END_TAG);
375 1.1.1.2.4.2 rmind }
376 1.1.1.2.4.2 rmind
377 1.1.1.2.4.2 rmind
378 1.1.1.2.4.2 rmind /*******************************************************************************
379 1.1.1.2.4.2 rmind *
380 1.1.1.2.4.2 rmind * FUNCTION: AcpiUtValidateResource
381 1.1.1.2.4.2 rmind *
382 1.1.1.2.4.2 rmind * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
383 1.1.1.2.4.2 rmind * ReturnIndex - Where the resource index is returned. NULL
384 1.1.1.2.4.2 rmind * if the index is not required.
385 1.1.1.2.4.2 rmind *
386 1.1.1.2.4.2 rmind * RETURN: Status, and optionally the Index into the global resource tables
387 1.1.1.2.4.2 rmind *
388 1.1.1.2.4.2 rmind * DESCRIPTION: Validate an AML resource descriptor by checking the Resource
389 1.1.1.2.4.2 rmind * Type and Resource Length. Returns an index into the global
390 1.1.1.2.4.2 rmind * resource information/dispatch tables for later use.
391 1.1.1.2.4.2 rmind *
392 1.1.1.2.4.2 rmind ******************************************************************************/
393 1.1.1.2.4.2 rmind
394 1.1.1.2.4.2 rmind ACPI_STATUS
395 1.1.1.2.4.2 rmind AcpiUtValidateResource (
396 1.1.1.2.4.2 rmind void *Aml,
397 1.1.1.2.4.2 rmind UINT8 *ReturnIndex)
398 1.1.1.2.4.2 rmind {
399 1.1.1.2.4.2 rmind UINT8 ResourceType;
400 1.1.1.2.4.2 rmind UINT8 ResourceIndex;
401 1.1.1.2.4.2 rmind ACPI_RS_LENGTH ResourceLength;
402 1.1.1.2.4.2 rmind ACPI_RS_LENGTH MinimumResourceLength;
403 1.1.1.2.4.2 rmind
404 1.1.1.2.4.2 rmind
405 1.1.1.2.4.2 rmind ACPI_FUNCTION_ENTRY ();
406 1.1.1.2.4.2 rmind
407 1.1.1.2.4.2 rmind
408 1.1.1.2.4.2 rmind /*
409 1.1.1.2.4.2 rmind * 1) Validate the ResourceType field (Byte 0)
410 1.1.1.2.4.2 rmind */
411 1.1.1.2.4.2 rmind ResourceType = ACPI_GET8 (Aml);
412 1.1.1.2.4.2 rmind
413 1.1.1.2.4.2 rmind /*
414 1.1.1.2.4.2 rmind * Byte 0 contains the descriptor name (Resource Type)
415 1.1.1.2.4.2 rmind * Examine the large/small bit in the resource header
416 1.1.1.2.4.2 rmind */
417 1.1.1.2.4.2 rmind if (ResourceType & ACPI_RESOURCE_NAME_LARGE)
418 1.1.1.2.4.2 rmind {
419 1.1.1.2.4.2 rmind /* Verify the large resource type (name) against the max */
420 1.1.1.2.4.2 rmind
421 1.1.1.2.4.2 rmind if (ResourceType > ACPI_RESOURCE_NAME_LARGE_MAX)
422 1.1.1.2.4.2 rmind {
423 1.1.1.2.4.2 rmind return (AE_AML_INVALID_RESOURCE_TYPE);
424 1.1.1.2.4.2 rmind }
425 1.1.1.2.4.2 rmind
426 1.1.1.2.4.2 rmind /*
427 1.1.1.2.4.2 rmind * Large Resource Type -- bits 6:0 contain the name
428 1.1.1.2.4.2 rmind * Translate range 0x80-0x8B to index range 0x10-0x1B
429 1.1.1.2.4.2 rmind */
430 1.1.1.2.4.2 rmind ResourceIndex = (UINT8) (ResourceType - 0x70);
431 1.1.1.2.4.2 rmind }
432 1.1.1.2.4.2 rmind else
433 1.1.1.2.4.2 rmind {
434 1.1.1.2.4.2 rmind /*
435 1.1.1.2.4.2 rmind * Small Resource Type -- bits 6:3 contain the name
436 1.1.1.2.4.2 rmind * Shift range to index range 0x00-0x0F
437 1.1.1.2.4.2 rmind */
438 1.1.1.2.4.2 rmind ResourceIndex = (UINT8)
439 1.1.1.2.4.2 rmind ((ResourceType & ACPI_RESOURCE_NAME_SMALL_MASK) >> 3);
440 1.1.1.2.4.2 rmind }
441 1.1.1.2.4.2 rmind
442 1.1.1.2.4.2 rmind /* Check validity of the resource type, zero indicates name is invalid */
443 1.1.1.2.4.2 rmind
444 1.1.1.2.4.2 rmind if (!AcpiGbl_ResourceTypes[ResourceIndex])
445 1.1.1.2.4.2 rmind {
446 1.1.1.2.4.2 rmind return (AE_AML_INVALID_RESOURCE_TYPE);
447 1.1.1.2.4.2 rmind }
448 1.1.1.2.4.2 rmind
449 1.1.1.2.4.2 rmind
450 1.1.1.2.4.2 rmind /*
451 1.1.1.2.4.2 rmind * 2) Validate the ResourceLength field. This ensures that the length
452 1.1.1.2.4.2 rmind * is at least reasonable, and guarantees that it is non-zero.
453 1.1.1.2.4.2 rmind */
454 1.1.1.2.4.2 rmind ResourceLength = AcpiUtGetResourceLength (Aml);
455 1.1.1.2.4.2 rmind MinimumResourceLength = AcpiGbl_ResourceAmlSizes[ResourceIndex];
456 1.1.1.2.4.2 rmind
457 1.1.1.2.4.2 rmind /* Validate based upon the type of resource - fixed length or variable */
458 1.1.1.2.4.2 rmind
459 1.1.1.2.4.2 rmind switch (AcpiGbl_ResourceTypes[ResourceIndex])
460 1.1.1.2.4.2 rmind {
461 1.1.1.2.4.2 rmind case ACPI_FIXED_LENGTH:
462 1.1.1.2.4.2 rmind
463 1.1.1.2.4.2 rmind /* Fixed length resource, length must match exactly */
464 1.1.1.2.4.2 rmind
465 1.1.1.2.4.2 rmind if (ResourceLength != MinimumResourceLength)
466 1.1.1.2.4.2 rmind {
467 1.1.1.2.4.2 rmind return (AE_AML_BAD_RESOURCE_LENGTH);
468 1.1.1.2.4.2 rmind }
469 1.1.1.2.4.2 rmind break;
470 1.1.1.2.4.2 rmind
471 1.1.1.2.4.2 rmind case ACPI_VARIABLE_LENGTH:
472 1.1.1.2.4.2 rmind
473 1.1.1.2.4.2 rmind /* Variable length resource, length must be at least the minimum */
474 1.1.1.2.4.2 rmind
475 1.1.1.2.4.2 rmind if (ResourceLength < MinimumResourceLength)
476 1.1.1.2.4.2 rmind {
477 1.1.1.2.4.2 rmind return (AE_AML_BAD_RESOURCE_LENGTH);
478 1.1.1.2.4.2 rmind }
479 1.1.1.2.4.2 rmind break;
480 1.1.1.2.4.2 rmind
481 1.1.1.2.4.2 rmind case ACPI_SMALL_VARIABLE_LENGTH:
482 1.1.1.2.4.2 rmind
483 1.1.1.2.4.2 rmind /* Small variable length resource, length can be (Min) or (Min-1) */
484 1.1.1.2.4.2 rmind
485 1.1.1.2.4.2 rmind if ((ResourceLength > MinimumResourceLength) ||
486 1.1.1.2.4.2 rmind (ResourceLength < (MinimumResourceLength - 1)))
487 1.1.1.2.4.2 rmind {
488 1.1.1.2.4.2 rmind return (AE_AML_BAD_RESOURCE_LENGTH);
489 1.1.1.2.4.2 rmind }
490 1.1.1.2.4.2 rmind break;
491 1.1.1.2.4.2 rmind
492 1.1.1.2.4.2 rmind default:
493 1.1.1.2.4.2 rmind
494 1.1.1.2.4.2 rmind /* Shouldn't happen (because of validation earlier), but be sure */
495 1.1.1.2.4.2 rmind
496 1.1.1.2.4.2 rmind return (AE_AML_INVALID_RESOURCE_TYPE);
497 1.1.1.2.4.2 rmind }
498 1.1.1.2.4.2 rmind
499 1.1.1.2.4.2 rmind /* Optionally return the resource table index */
500 1.1.1.2.4.2 rmind
501 1.1.1.2.4.2 rmind if (ReturnIndex)
502 1.1.1.2.4.2 rmind {
503 1.1.1.2.4.2 rmind *ReturnIndex = ResourceIndex;
504 1.1.1.2.4.2 rmind }
505 1.1.1.2.4.2 rmind
506 1.1.1.2.4.2 rmind return (AE_OK);
507 1.1.1.2.4.2 rmind }
508 1.1.1.2.4.2 rmind
509 1.1.1.2.4.2 rmind
510 1.1.1.2.4.2 rmind /*******************************************************************************
511 1.1.1.2.4.2 rmind *
512 1.1.1.2.4.2 rmind * FUNCTION: AcpiUtGetResourceType
513 1.1.1.2.4.2 rmind *
514 1.1.1.2.4.2 rmind * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
515 1.1.1.2.4.2 rmind *
516 1.1.1.2.4.2 rmind * RETURN: The Resource Type with no extraneous bits (except the
517 1.1.1.2.4.2 rmind * Large/Small descriptor bit -- this is left alone)
518 1.1.1.2.4.2 rmind *
519 1.1.1.2.4.2 rmind * DESCRIPTION: Extract the Resource Type/Name from the first byte of
520 1.1.1.2.4.2 rmind * a resource descriptor.
521 1.1.1.2.4.2 rmind *
522 1.1.1.2.4.2 rmind ******************************************************************************/
523 1.1.1.2.4.2 rmind
524 1.1.1.2.4.2 rmind UINT8
525 1.1.1.2.4.2 rmind AcpiUtGetResourceType (
526 1.1.1.2.4.2 rmind void *Aml)
527 1.1.1.2.4.2 rmind {
528 1.1.1.2.4.2 rmind ACPI_FUNCTION_ENTRY ();
529 1.1.1.2.4.2 rmind
530 1.1.1.2.4.2 rmind
531 1.1.1.2.4.2 rmind /*
532 1.1.1.2.4.2 rmind * Byte 0 contains the descriptor name (Resource Type)
533 1.1.1.2.4.2 rmind * Examine the large/small bit in the resource header
534 1.1.1.2.4.2 rmind */
535 1.1.1.2.4.2 rmind if (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_LARGE)
536 1.1.1.2.4.2 rmind {
537 1.1.1.2.4.2 rmind /* Large Resource Type -- bits 6:0 contain the name */
538 1.1.1.2.4.2 rmind
539 1.1.1.2.4.2 rmind return (ACPI_GET8 (Aml));
540 1.1.1.2.4.2 rmind }
541 1.1.1.2.4.2 rmind else
542 1.1.1.2.4.2 rmind {
543 1.1.1.2.4.2 rmind /* Small Resource Type -- bits 6:3 contain the name */
544 1.1.1.2.4.2 rmind
545 1.1.1.2.4.2 rmind return ((UINT8) (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_SMALL_MASK));
546 1.1.1.2.4.2 rmind }
547 1.1.1.2.4.2 rmind }
548 1.1.1.2.4.2 rmind
549 1.1.1.2.4.2 rmind
550 1.1.1.2.4.2 rmind /*******************************************************************************
551 1.1.1.2.4.2 rmind *
552 1.1.1.2.4.2 rmind * FUNCTION: AcpiUtGetResourceLength
553 1.1.1.2.4.2 rmind *
554 1.1.1.2.4.2 rmind * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
555 1.1.1.2.4.2 rmind *
556 1.1.1.2.4.2 rmind * RETURN: Byte Length
557 1.1.1.2.4.2 rmind *
558 1.1.1.2.4.2 rmind * DESCRIPTION: Get the "Resource Length" of a raw AML descriptor. By
559 1.1.1.2.4.2 rmind * definition, this does not include the size of the descriptor
560 1.1.1.2.4.2 rmind * header or the length field itself.
561 1.1.1.2.4.2 rmind *
562 1.1.1.2.4.2 rmind ******************************************************************************/
563 1.1.1.2.4.2 rmind
564 1.1.1.2.4.2 rmind UINT16
565 1.1.1.2.4.2 rmind AcpiUtGetResourceLength (
566 1.1.1.2.4.2 rmind void *Aml)
567 1.1.1.2.4.2 rmind {
568 1.1.1.2.4.2 rmind ACPI_RS_LENGTH ResourceLength;
569 1.1.1.2.4.2 rmind
570 1.1.1.2.4.2 rmind
571 1.1.1.2.4.2 rmind ACPI_FUNCTION_ENTRY ();
572 1.1.1.2.4.2 rmind
573 1.1.1.2.4.2 rmind
574 1.1.1.2.4.2 rmind /*
575 1.1.1.2.4.2 rmind * Byte 0 contains the descriptor name (Resource Type)
576 1.1.1.2.4.2 rmind * Examine the large/small bit in the resource header
577 1.1.1.2.4.2 rmind */
578 1.1.1.2.4.2 rmind if (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_LARGE)
579 1.1.1.2.4.2 rmind {
580 1.1.1.2.4.2 rmind /* Large Resource type -- bytes 1-2 contain the 16-bit length */
581 1.1.1.2.4.2 rmind
582 1.1.1.2.4.2 rmind ACPI_MOVE_16_TO_16 (&ResourceLength, ACPI_ADD_PTR (UINT8, Aml, 1));
583 1.1.1.2.4.2 rmind
584 1.1.1.2.4.2 rmind }
585 1.1.1.2.4.2 rmind else
586 1.1.1.2.4.2 rmind {
587 1.1.1.2.4.2 rmind /* Small Resource type -- bits 2:0 of byte 0 contain the length */
588 1.1.1.2.4.2 rmind
589 1.1.1.2.4.2 rmind ResourceLength = (UINT16) (ACPI_GET8 (Aml) &
590 1.1.1.2.4.2 rmind ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK);
591 1.1.1.2.4.2 rmind }
592 1.1.1.2.4.2 rmind
593 1.1.1.2.4.2 rmind return (ResourceLength);
594 1.1.1.2.4.2 rmind }
595 1.1.1.2.4.2 rmind
596 1.1.1.2.4.2 rmind
597 1.1.1.2.4.2 rmind /*******************************************************************************
598 1.1.1.2.4.2 rmind *
599 1.1.1.2.4.2 rmind * FUNCTION: AcpiUtGetResourceHeaderLength
600 1.1.1.2.4.2 rmind *
601 1.1.1.2.4.2 rmind * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
602 1.1.1.2.4.2 rmind *
603 1.1.1.2.4.2 rmind * RETURN: Length of the AML header (depends on large/small descriptor)
604 1.1.1.2.4.2 rmind *
605 1.1.1.2.4.2 rmind * DESCRIPTION: Get the length of the header for this resource.
606 1.1.1.2.4.2 rmind *
607 1.1.1.2.4.2 rmind ******************************************************************************/
608 1.1.1.2.4.2 rmind
609 1.1.1.2.4.2 rmind UINT8
610 1.1.1.2.4.2 rmind AcpiUtGetResourceHeaderLength (
611 1.1.1.2.4.2 rmind void *Aml)
612 1.1.1.2.4.2 rmind {
613 1.1.1.2.4.2 rmind ACPI_FUNCTION_ENTRY ();
614 1.1.1.2.4.2 rmind
615 1.1.1.2.4.2 rmind
616 1.1.1.2.4.2 rmind /* Examine the large/small bit in the resource header */
617 1.1.1.2.4.2 rmind
618 1.1.1.2.4.2 rmind if (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_LARGE)
619 1.1.1.2.4.2 rmind {
620 1.1.1.2.4.2 rmind return (sizeof (AML_RESOURCE_LARGE_HEADER));
621 1.1.1.2.4.2 rmind }
622 1.1.1.2.4.2 rmind else
623 1.1.1.2.4.2 rmind {
624 1.1.1.2.4.2 rmind return (sizeof (AML_RESOURCE_SMALL_HEADER));
625 1.1.1.2.4.2 rmind }
626 1.1.1.2.4.2 rmind }
627 1.1.1.2.4.2 rmind
628 1.1.1.2.4.2 rmind
629 1.1.1.2.4.2 rmind /*******************************************************************************
630 1.1.1.2.4.2 rmind *
631 1.1.1.2.4.2 rmind * FUNCTION: AcpiUtGetDescriptorLength
632 1.1.1.2.4.2 rmind *
633 1.1.1.2.4.2 rmind * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
634 1.1.1.2.4.2 rmind *
635 1.1.1.2.4.2 rmind * RETURN: Byte length
636 1.1.1.2.4.2 rmind *
637 1.1.1.2.4.2 rmind * DESCRIPTION: Get the total byte length of a raw AML descriptor, including the
638 1.1.1.2.4.2 rmind * length of the descriptor header and the length field itself.
639 1.1.1.2.4.2 rmind * Used to walk descriptor lists.
640 1.1.1.2.4.2 rmind *
641 1.1.1.2.4.2 rmind ******************************************************************************/
642 1.1.1.2.4.2 rmind
643 1.1.1.2.4.2 rmind UINT32
644 1.1.1.2.4.2 rmind AcpiUtGetDescriptorLength (
645 1.1.1.2.4.2 rmind void *Aml)
646 1.1.1.2.4.2 rmind {
647 1.1.1.2.4.2 rmind ACPI_FUNCTION_ENTRY ();
648 1.1.1.2.4.2 rmind
649 1.1.1.2.4.2 rmind
650 1.1.1.2.4.2 rmind /*
651 1.1.1.2.4.2 rmind * Get the Resource Length (does not include header length) and add
652 1.1.1.2.4.2 rmind * the header length (depends on if this is a small or large resource)
653 1.1.1.2.4.2 rmind */
654 1.1.1.2.4.2 rmind return (AcpiUtGetResourceLength (Aml) +
655 1.1.1.2.4.2 rmind AcpiUtGetResourceHeaderLength (Aml));
656 1.1.1.2.4.2 rmind }
657 1.1.1.2.4.2 rmind
658 1.1.1.2.4.2 rmind
659 1.1.1.2.4.2 rmind /*******************************************************************************
660 1.1.1.2.4.2 rmind *
661 1.1.1.2.4.2 rmind * FUNCTION: AcpiUtGetResourceEndTag
662 1.1.1.2.4.2 rmind *
663 1.1.1.2.4.2 rmind * PARAMETERS: ObjDesc - The resource template buffer object
664 1.1.1.2.4.2 rmind * EndTag - Where the pointer to the EndTag is returned
665 1.1.1.2.4.2 rmind *
666 1.1.1.2.4.2 rmind * RETURN: Status, pointer to the end tag
667 1.1.1.2.4.2 rmind *
668 1.1.1.2.4.2 rmind * DESCRIPTION: Find the EndTag resource descriptor in an AML resource template
669 1.1.1.2.4.2 rmind * Note: allows a buffer length of zero.
670 1.1.1.2.4.2 rmind *
671 1.1.1.2.4.2 rmind ******************************************************************************/
672 1.1.1.2.4.2 rmind
673 1.1.1.2.4.2 rmind ACPI_STATUS
674 1.1.1.2.4.2 rmind AcpiUtGetResourceEndTag (
675 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT *ObjDesc,
676 1.1.1.2.4.2 rmind UINT8 **EndTag)
677 1.1.1.2.4.2 rmind {
678 1.1.1.2.4.2 rmind ACPI_STATUS Status;
679 1.1.1.2.4.2 rmind
680 1.1.1.2.4.2 rmind
681 1.1.1.2.4.2 rmind ACPI_FUNCTION_TRACE (UtGetResourceEndTag);
682 1.1.1.2.4.2 rmind
683 1.1.1.2.4.2 rmind
684 1.1.1.2.4.2 rmind /* Allow a buffer length of zero */
685 1.1.1.2.4.2 rmind
686 1.1.1.2.4.2 rmind if (!ObjDesc->Buffer.Length)
687 1.1.1.2.4.2 rmind {
688 1.1.1.2.4.2 rmind *EndTag = ObjDesc->Buffer.Pointer;
689 1.1.1.2.4.2 rmind return_ACPI_STATUS (AE_OK);
690 1.1.1.2.4.2 rmind }
691 1.1.1.2.4.2 rmind
692 1.1.1.2.4.2 rmind /* Validate the template and get a pointer to the EndTag */
693 1.1.1.2.4.2 rmind
694 1.1.1.2.4.2 rmind Status = AcpiUtWalkAmlResources (ObjDesc->Buffer.Pointer,
695 1.1.1.2.4.2 rmind ObjDesc->Buffer.Length, NULL, EndTag);
696 1.1.1.2.4.2 rmind
697 1.1.1.2.4.2 rmind return_ACPI_STATUS (Status);
698 1.1.1.2.4.2 rmind }
699 1.1.1.2.4.2 rmind
700 1.1.1.2.4.2 rmind
701