dmresrc.c revision 1.3.2.2 1 1.3.2.2 bouyer /*******************************************************************************
2 1.3.2.2 bouyer *
3 1.3.2.2 bouyer * Module Name: dmresrc.c - Resource Descriptor disassembly
4 1.3.2.2 bouyer *
5 1.3.2.2 bouyer ******************************************************************************/
6 1.3.2.2 bouyer
7 1.3.2.2 bouyer /*
8 1.3.2.2 bouyer * Copyright (C) 2000 - 2011, Intel Corp.
9 1.3.2.2 bouyer * All rights reserved.
10 1.3.2.2 bouyer *
11 1.3.2.2 bouyer * Redistribution and use in source and binary forms, with or without
12 1.3.2.2 bouyer * modification, are permitted provided that the following conditions
13 1.3.2.2 bouyer * are met:
14 1.3.2.2 bouyer * 1. Redistributions of source code must retain the above copyright
15 1.3.2.2 bouyer * notice, this list of conditions, and the following disclaimer,
16 1.3.2.2 bouyer * without modification.
17 1.3.2.2 bouyer * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.3.2.2 bouyer * substantially similar to the "NO WARRANTY" disclaimer below
19 1.3.2.2 bouyer * ("Disclaimer") and any redistribution must be conditioned upon
20 1.3.2.2 bouyer * including a substantially similar Disclaimer requirement for further
21 1.3.2.2 bouyer * binary redistribution.
22 1.3.2.2 bouyer * 3. Neither the names of the above-listed copyright holders nor the names
23 1.3.2.2 bouyer * of any contributors may be used to endorse or promote products derived
24 1.3.2.2 bouyer * from this software without specific prior written permission.
25 1.3.2.2 bouyer *
26 1.3.2.2 bouyer * Alternatively, this software may be distributed under the terms of the
27 1.3.2.2 bouyer * GNU General Public License ("GPL") version 2 as published by the Free
28 1.3.2.2 bouyer * Software Foundation.
29 1.3.2.2 bouyer *
30 1.3.2.2 bouyer * NO WARRANTY
31 1.3.2.2 bouyer * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.3.2.2 bouyer * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.3.2.2 bouyer * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.3.2.2 bouyer * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.3.2.2 bouyer * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.3.2.2 bouyer * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.3.2.2 bouyer * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.3.2.2 bouyer * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.3.2.2 bouyer * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.3.2.2 bouyer * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.3.2.2 bouyer * POSSIBILITY OF SUCH DAMAGES.
42 1.3.2.2 bouyer */
43 1.3.2.2 bouyer
44 1.3.2.2 bouyer
45 1.3.2.2 bouyer #include "acpi.h"
46 1.3.2.2 bouyer #include "accommon.h"
47 1.3.2.2 bouyer #include "amlcode.h"
48 1.3.2.2 bouyer #include "acdisasm.h"
49 1.3.2.2 bouyer
50 1.3.2.2 bouyer #ifdef ACPI_DISASSEMBLER
51 1.3.2.2 bouyer
52 1.3.2.2 bouyer #define _COMPONENT ACPI_CA_DEBUGGER
53 1.3.2.2 bouyer ACPI_MODULE_NAME ("dbresrc")
54 1.3.2.2 bouyer
55 1.3.2.2 bouyer
56 1.3.2.2 bouyer /* Dispatch tables for Resource disassembly functions */
57 1.3.2.2 bouyer
58 1.3.2.2 bouyer typedef
59 1.3.2.2 bouyer void (*ACPI_RESOURCE_HANDLER) (
60 1.3.2.2 bouyer AML_RESOURCE *Resource,
61 1.3.2.2 bouyer UINT32 Length,
62 1.3.2.2 bouyer UINT32 Level);
63 1.3.2.2 bouyer
64 1.3.2.2 bouyer static ACPI_RESOURCE_HANDLER AcpiGbl_DmResourceDispatch [] =
65 1.3.2.2 bouyer {
66 1.3.2.2 bouyer /* Small descriptors */
67 1.3.2.2 bouyer
68 1.3.2.2 bouyer NULL, /* 0x00, Reserved */
69 1.3.2.2 bouyer NULL, /* 0x01, Reserved */
70 1.3.2.2 bouyer NULL, /* 0x02, Reserved */
71 1.3.2.2 bouyer NULL, /* 0x03, Reserved */
72 1.3.2.2 bouyer AcpiDmIrqDescriptor, /* 0x04, ACPI_RESOURCE_NAME_IRQ_FORMAT */
73 1.3.2.2 bouyer AcpiDmDmaDescriptor, /* 0x05, ACPI_RESOURCE_NAME_DMA_FORMAT */
74 1.3.2.2 bouyer AcpiDmStartDependentDescriptor, /* 0x06, ACPI_RESOURCE_NAME_START_DEPENDENT */
75 1.3.2.2 bouyer AcpiDmEndDependentDescriptor, /* 0x07, ACPI_RESOURCE_NAME_END_DEPENDENT */
76 1.3.2.2 bouyer AcpiDmIoDescriptor, /* 0x08, ACPI_RESOURCE_NAME_IO_PORT */
77 1.3.2.2 bouyer AcpiDmFixedIoDescriptor, /* 0x09, ACPI_RESOURCE_NAME_FIXED_IO_PORT */
78 1.3.2.2 bouyer NULL, /* 0x0A, Reserved */
79 1.3.2.2 bouyer NULL, /* 0x0B, Reserved */
80 1.3.2.2 bouyer NULL, /* 0x0C, Reserved */
81 1.3.2.2 bouyer NULL, /* 0x0D, Reserved */
82 1.3.2.2 bouyer AcpiDmVendorSmallDescriptor, /* 0x0E, ACPI_RESOURCE_NAME_SMALL_VENDOR */
83 1.3.2.2 bouyer NULL, /* 0x0F, ACPI_RESOURCE_NAME_END_TAG (not used) */
84 1.3.2.2 bouyer
85 1.3.2.2 bouyer /* Large descriptors */
86 1.3.2.2 bouyer
87 1.3.2.2 bouyer NULL, /* 0x00, Reserved */
88 1.3.2.2 bouyer AcpiDmMemory24Descriptor, /* 0x01, ACPI_RESOURCE_NAME_MEMORY_24 */
89 1.3.2.2 bouyer AcpiDmGenericRegisterDescriptor,/* 0x02, ACPI_RESOURCE_NAME_GENERIC_REGISTER */
90 1.3.2.2 bouyer NULL, /* 0x03, Reserved */
91 1.3.2.2 bouyer AcpiDmVendorLargeDescriptor, /* 0x04, ACPI_RESOURCE_NAME_LARGE_VENDOR */
92 1.3.2.2 bouyer AcpiDmMemory32Descriptor, /* 0x05, ACPI_RESOURCE_NAME_MEMORY_32 */
93 1.3.2.2 bouyer AcpiDmFixedMemory32Descriptor, /* 0x06, ACPI_RESOURCE_NAME_FIXED_MEMORY_32 */
94 1.3.2.2 bouyer AcpiDmDwordDescriptor, /* 0x07, ACPI_RESOURCE_NAME_DWORD_ADDRESS_SPACE */
95 1.3.2.2 bouyer AcpiDmWordDescriptor, /* 0x08, ACPI_RESOURCE_NAME_WORD_ADDRESS_SPACE */
96 1.3.2.2 bouyer AcpiDmInterruptDescriptor, /* 0x09, ACPI_RESOURCE_NAME_EXTENDED_XRUPT */
97 1.3.2.2 bouyer AcpiDmQwordDescriptor, /* 0x0A, ACPI_RESOURCE_NAME_QWORD_ADDRESS_SPACE */
98 1.3.2.2 bouyer AcpiDmExtendedDescriptor /* 0x0B, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS_SPACE */
99 1.3.2.2 bouyer };
100 1.3.2.2 bouyer
101 1.3.2.2 bouyer
102 1.3.2.2 bouyer /* Only used for single-threaded applications */
103 1.3.2.2 bouyer /* TBD: remove when name is passed as parameter to the dump functions */
104 1.3.2.2 bouyer
105 1.3.2.2 bouyer static UINT32 ResourceName;
106 1.3.2.2 bouyer
107 1.3.2.2 bouyer
108 1.3.2.2 bouyer /*******************************************************************************
109 1.3.2.2 bouyer *
110 1.3.2.2 bouyer * FUNCTION: AcpiDmDescriptorName
111 1.3.2.2 bouyer *
112 1.3.2.2 bouyer * PARAMETERS: None
113 1.3.2.2 bouyer *
114 1.3.2.2 bouyer * RETURN: None
115 1.3.2.2 bouyer *
116 1.3.2.2 bouyer * DESCRIPTION: Emit a name for the descriptor if one is present (indicated
117 1.3.2.2 bouyer * by the name being changed from the default name.) A name is only
118 1.3.2.2 bouyer * emitted if a reference to the descriptor has been made somewhere
119 1.3.2.2 bouyer * in the original ASL code.
120 1.3.2.2 bouyer *
121 1.3.2.2 bouyer ******************************************************************************/
122 1.3.2.2 bouyer
123 1.3.2.2 bouyer void
124 1.3.2.2 bouyer AcpiDmDescriptorName (
125 1.3.2.2 bouyer void)
126 1.3.2.2 bouyer {
127 1.3.2.2 bouyer
128 1.3.2.2 bouyer if (ResourceName == ACPI_DEFAULT_RESNAME)
129 1.3.2.2 bouyer {
130 1.3.2.2 bouyer return;
131 1.3.2.2 bouyer }
132 1.3.2.2 bouyer
133 1.3.2.2 bouyer AcpiOsPrintf ("%4.4s", (char *) &ResourceName);
134 1.3.2.2 bouyer }
135 1.3.2.2 bouyer
136 1.3.2.2 bouyer
137 1.3.2.2 bouyer /*******************************************************************************
138 1.3.2.2 bouyer *
139 1.3.2.2 bouyer * FUNCTION: AcpiDmDumpInteger*
140 1.3.2.2 bouyer *
141 1.3.2.2 bouyer * PARAMETERS: Value - Value to emit
142 1.3.2.2 bouyer * Name - Associated name (emitted as a comment)
143 1.3.2.2 bouyer *
144 1.3.2.2 bouyer * RETURN: None
145 1.3.2.2 bouyer *
146 1.3.2.2 bouyer * DESCRIPTION: Integer output helper functions
147 1.3.2.2 bouyer *
148 1.3.2.2 bouyer ******************************************************************************/
149 1.3.2.2 bouyer
150 1.3.2.2 bouyer void
151 1.3.2.2 bouyer AcpiDmDumpInteger8 (
152 1.3.2.2 bouyer UINT8 Value,
153 1.3.2.2 bouyer const char *Name)
154 1.3.2.2 bouyer {
155 1.3.2.2 bouyer AcpiOsPrintf ("0x%2.2X, // %s\n", Value, Name);
156 1.3.2.2 bouyer }
157 1.3.2.2 bouyer
158 1.3.2.2 bouyer void
159 1.3.2.2 bouyer AcpiDmDumpInteger16 (
160 1.3.2.2 bouyer UINT16 Value,
161 1.3.2.2 bouyer const char *Name)
162 1.3.2.2 bouyer {
163 1.3.2.2 bouyer AcpiOsPrintf ("0x%4.4X, // %s\n", Value, Name);
164 1.3.2.2 bouyer }
165 1.3.2.2 bouyer
166 1.3.2.2 bouyer void
167 1.3.2.2 bouyer AcpiDmDumpInteger32 (
168 1.3.2.2 bouyer UINT32 Value,
169 1.3.2.2 bouyer const char *Name)
170 1.3.2.2 bouyer {
171 1.3.2.2 bouyer AcpiOsPrintf ("0x%8.8X, // %s\n", Value, Name);
172 1.3.2.2 bouyer }
173 1.3.2.2 bouyer
174 1.3.2.2 bouyer void
175 1.3.2.2 bouyer AcpiDmDumpInteger64 (
176 1.3.2.2 bouyer UINT64 Value,
177 1.3.2.2 bouyer const char *Name)
178 1.3.2.2 bouyer {
179 1.3.2.2 bouyer AcpiOsPrintf ("0x%8.8X%8.8X, // %s\n", ACPI_FORMAT_UINT64 (Value), Name);
180 1.3.2.2 bouyer }
181 1.3.2.2 bouyer
182 1.3.2.2 bouyer
183 1.3.2.2 bouyer /*******************************************************************************
184 1.3.2.2 bouyer *
185 1.3.2.2 bouyer * FUNCTION: AcpiDmBitList
186 1.3.2.2 bouyer *
187 1.3.2.2 bouyer * PARAMETERS: Mask - 16-bit value corresponding to 16 interrupt
188 1.3.2.2 bouyer * or DMA values
189 1.3.2.2 bouyer *
190 1.3.2.2 bouyer * RETURN: None
191 1.3.2.2 bouyer *
192 1.3.2.2 bouyer * DESCRIPTION: Dump a bit mask as a list of individual interrupt/DMA levels.
193 1.3.2.2 bouyer *
194 1.3.2.2 bouyer ******************************************************************************/
195 1.3.2.2 bouyer
196 1.3.2.2 bouyer void
197 1.3.2.2 bouyer AcpiDmBitList (
198 1.3.2.2 bouyer UINT16 Mask)
199 1.3.2.2 bouyer {
200 1.3.2.2 bouyer UINT32 i;
201 1.3.2.2 bouyer BOOLEAN Previous = FALSE;
202 1.3.2.2 bouyer
203 1.3.2.2 bouyer
204 1.3.2.2 bouyer /* Open the initializer list */
205 1.3.2.2 bouyer
206 1.3.2.2 bouyer AcpiOsPrintf ("{");
207 1.3.2.2 bouyer
208 1.3.2.2 bouyer /* Examine each bit */
209 1.3.2.2 bouyer
210 1.3.2.2 bouyer for (i = 0; i < 16; i++)
211 1.3.2.2 bouyer {
212 1.3.2.2 bouyer /* Only interested in bits that are set to 1 */
213 1.3.2.2 bouyer
214 1.3.2.2 bouyer if (Mask & 1)
215 1.3.2.2 bouyer {
216 1.3.2.2 bouyer if (Previous)
217 1.3.2.2 bouyer {
218 1.3.2.2 bouyer AcpiOsPrintf (",");
219 1.3.2.2 bouyer }
220 1.3.2.2 bouyer Previous = TRUE;
221 1.3.2.2 bouyer AcpiOsPrintf ("%u", i);
222 1.3.2.2 bouyer }
223 1.3.2.2 bouyer
224 1.3.2.2 bouyer Mask >>= 1;
225 1.3.2.2 bouyer }
226 1.3.2.2 bouyer
227 1.3.2.2 bouyer /* Close list */
228 1.3.2.2 bouyer
229 1.3.2.2 bouyer AcpiOsPrintf ("}\n");
230 1.3.2.2 bouyer }
231 1.3.2.2 bouyer
232 1.3.2.2 bouyer
233 1.3.2.2 bouyer /*******************************************************************************
234 1.3.2.2 bouyer *
235 1.3.2.2 bouyer * FUNCTION: AcpiDmResourceTemplate
236 1.3.2.2 bouyer *
237 1.3.2.2 bouyer * PARAMETERS: Info - Curent parse tree walk info
238 1.3.2.2 bouyer * ByteData - Pointer to the byte list data
239 1.3.2.2 bouyer * ByteCount - Length of the byte list
240 1.3.2.2 bouyer *
241 1.3.2.2 bouyer * RETURN: None
242 1.3.2.2 bouyer *
243 1.3.2.2 bouyer * DESCRIPTION: Dump the contents of a Resource Template containing a set of
244 1.3.2.2 bouyer * Resource Descriptors.
245 1.3.2.2 bouyer *
246 1.3.2.2 bouyer ******************************************************************************/
247 1.3.2.2 bouyer
248 1.3.2.2 bouyer void
249 1.3.2.2 bouyer AcpiDmResourceTemplate (
250 1.3.2.2 bouyer ACPI_OP_WALK_INFO *Info,
251 1.3.2.2 bouyer ACPI_PARSE_OBJECT *Op,
252 1.3.2.2 bouyer UINT8 *ByteData,
253 1.3.2.2 bouyer UINT32 ByteCount)
254 1.3.2.2 bouyer {
255 1.3.2.2 bouyer ACPI_STATUS Status;
256 1.3.2.2 bouyer UINT32 CurrentByteOffset;
257 1.3.2.2 bouyer UINT8 ResourceType;
258 1.3.2.2 bouyer UINT32 ResourceLength;
259 1.3.2.2 bouyer void *Aml;
260 1.3.2.2 bouyer UINT32 Level;
261 1.3.2.2 bouyer BOOLEAN DependentFns = FALSE;
262 1.3.2.2 bouyer UINT8 ResourceIndex;
263 1.3.2.2 bouyer ACPI_NAMESPACE_NODE *Node;
264 1.3.2.2 bouyer
265 1.3.2.2 bouyer
266 1.3.2.2 bouyer Level = Info->Level;
267 1.3.2.2 bouyer ResourceName = ACPI_DEFAULT_RESNAME;
268 1.3.2.2 bouyer Node = Op->Common.Node;
269 1.3.2.2 bouyer if (Node)
270 1.3.2.2 bouyer {
271 1.3.2.2 bouyer Node = Node->Child;
272 1.3.2.2 bouyer }
273 1.3.2.2 bouyer
274 1.3.2.2 bouyer for (CurrentByteOffset = 0; CurrentByteOffset < ByteCount;)
275 1.3.2.2 bouyer {
276 1.3.2.2 bouyer Aml = &ByteData[CurrentByteOffset];
277 1.3.2.2 bouyer
278 1.3.2.2 bouyer /* Get the descriptor type and length */
279 1.3.2.2 bouyer
280 1.3.2.2 bouyer ResourceType = AcpiUtGetResourceType (Aml);
281 1.3.2.2 bouyer ResourceLength = AcpiUtGetResourceLength (Aml);
282 1.3.2.2 bouyer
283 1.3.2.2 bouyer /* Validate the Resource Type and Resource Length */
284 1.3.2.2 bouyer
285 1.3.2.2 bouyer Status = AcpiUtValidateResource (Aml, &ResourceIndex);
286 1.3.2.2 bouyer if (ACPI_FAILURE (Status))
287 1.3.2.2 bouyer {
288 1.3.2.2 bouyer AcpiOsPrintf ("/*** Could not validate Resource, type (%X) %s***/\n",
289 1.3.2.2 bouyer ResourceType, AcpiFormatException (Status));
290 1.3.2.2 bouyer return;
291 1.3.2.2 bouyer }
292 1.3.2.2 bouyer
293 1.3.2.2 bouyer /* Point to next descriptor */
294 1.3.2.2 bouyer
295 1.3.2.2 bouyer CurrentByteOffset += AcpiUtGetDescriptorLength (Aml);
296 1.3.2.2 bouyer
297 1.3.2.2 bouyer /* Descriptor pre-processing */
298 1.3.2.2 bouyer
299 1.3.2.2 bouyer switch (ResourceType)
300 1.3.2.2 bouyer {
301 1.3.2.2 bouyer case ACPI_RESOURCE_NAME_START_DEPENDENT:
302 1.3.2.2 bouyer
303 1.3.2.2 bouyer /* Finish a previous StartDependentFns */
304 1.3.2.2 bouyer
305 1.3.2.2 bouyer if (DependentFns)
306 1.3.2.2 bouyer {
307 1.3.2.2 bouyer Level--;
308 1.3.2.2 bouyer AcpiDmIndent (Level);
309 1.3.2.2 bouyer AcpiOsPrintf ("}\n");
310 1.3.2.2 bouyer }
311 1.3.2.2 bouyer break;
312 1.3.2.2 bouyer
313 1.3.2.2 bouyer case ACPI_RESOURCE_NAME_END_DEPENDENT:
314 1.3.2.2 bouyer
315 1.3.2.2 bouyer Level--;
316 1.3.2.2 bouyer DependentFns = FALSE;
317 1.3.2.2 bouyer break;
318 1.3.2.2 bouyer
319 1.3.2.2 bouyer case ACPI_RESOURCE_NAME_END_TAG:
320 1.3.2.2 bouyer
321 1.3.2.2 bouyer /* Normal exit, the resource list is finished */
322 1.3.2.2 bouyer
323 1.3.2.2 bouyer if (DependentFns)
324 1.3.2.2 bouyer {
325 1.3.2.2 bouyer /*
326 1.3.2.2 bouyer * Close an open StartDependentDescriptor. This indicates a
327 1.3.2.2 bouyer * missing EndDependentDescriptor.
328 1.3.2.2 bouyer */
329 1.3.2.2 bouyer Level--;
330 1.3.2.2 bouyer DependentFns = FALSE;
331 1.3.2.2 bouyer
332 1.3.2.2 bouyer /* Go ahead and insert EndDependentFn() */
333 1.3.2.2 bouyer
334 1.3.2.2 bouyer AcpiDmEndDependentDescriptor (Aml, ResourceLength, Level);
335 1.3.2.2 bouyer
336 1.3.2.2 bouyer AcpiDmIndent (Level);
337 1.3.2.2 bouyer AcpiOsPrintf (
338 1.3.2.2 bouyer "/*** Disassembler: inserted missing EndDependentFn () ***/\n");
339 1.3.2.2 bouyer }
340 1.3.2.2 bouyer return;
341 1.3.2.2 bouyer
342 1.3.2.2 bouyer default:
343 1.3.2.2 bouyer break;
344 1.3.2.2 bouyer }
345 1.3.2.2 bouyer
346 1.3.2.2 bouyer /* Disassemble the resource structure */
347 1.3.2.2 bouyer
348 1.3.2.2 bouyer if (Node)
349 1.3.2.2 bouyer {
350 1.3.2.2 bouyer ResourceName = Node->Name.Integer;
351 1.3.2.2 bouyer Node = Node->Peer;
352 1.3.2.2 bouyer }
353 1.3.2.2 bouyer
354 1.3.2.2 bouyer AcpiGbl_DmResourceDispatch [ResourceIndex] (
355 1.3.2.2 bouyer Aml, ResourceLength, Level);
356 1.3.2.2 bouyer
357 1.3.2.2 bouyer /* Descriptor post-processing */
358 1.3.2.2 bouyer
359 1.3.2.2 bouyer if (ResourceType == ACPI_RESOURCE_NAME_START_DEPENDENT)
360 1.3.2.2 bouyer {
361 1.3.2.2 bouyer DependentFns = TRUE;
362 1.3.2.2 bouyer Level++;
363 1.3.2.2 bouyer }
364 1.3.2.2 bouyer }
365 1.3.2.2 bouyer }
366 1.3.2.2 bouyer
367 1.3.2.2 bouyer
368 1.3.2.2 bouyer /*******************************************************************************
369 1.3.2.2 bouyer *
370 1.3.2.2 bouyer * FUNCTION: AcpiDmIsResourceTemplate
371 1.3.2.2 bouyer *
372 1.3.2.2 bouyer * PARAMETERS: Op - Buffer Op to be examined
373 1.3.2.2 bouyer *
374 1.3.2.2 bouyer * RETURN: Status. AE_OK if valid template
375 1.3.2.2 bouyer *
376 1.3.2.2 bouyer * DESCRIPTION: Walk a byte list to determine if it consists of a valid set
377 1.3.2.2 bouyer * of resource descriptors. Nothing is output.
378 1.3.2.2 bouyer *
379 1.3.2.2 bouyer ******************************************************************************/
380 1.3.2.2 bouyer
381 1.3.2.2 bouyer ACPI_STATUS
382 1.3.2.2 bouyer AcpiDmIsResourceTemplate (
383 1.3.2.2 bouyer ACPI_PARSE_OBJECT *Op)
384 1.3.2.2 bouyer {
385 1.3.2.2 bouyer ACPI_STATUS Status;
386 1.3.2.2 bouyer ACPI_PARSE_OBJECT *NextOp;
387 1.3.2.2 bouyer UINT8 *Aml;
388 1.3.2.2 bouyer UINT8 *EndAml;
389 1.3.2.2 bouyer ACPI_SIZE Length;
390 1.3.2.2 bouyer
391 1.3.2.2 bouyer
392 1.3.2.2 bouyer /* This op must be a buffer */
393 1.3.2.2 bouyer
394 1.3.2.2 bouyer if (Op->Common.AmlOpcode != AML_BUFFER_OP)
395 1.3.2.2 bouyer {
396 1.3.2.2 bouyer return (AE_TYPE);
397 1.3.2.2 bouyer }
398 1.3.2.2 bouyer
399 1.3.2.2 bouyer /* Get the ByteData list and length */
400 1.3.2.2 bouyer
401 1.3.2.2 bouyer NextOp = Op->Common.Value.Arg;
402 1.3.2.2 bouyer NextOp = NextOp->Common.Next;
403 1.3.2.2 bouyer if (!NextOp)
404 1.3.2.2 bouyer {
405 1.3.2.2 bouyer return (AE_TYPE);
406 1.3.2.2 bouyer }
407 1.3.2.2 bouyer
408 1.3.2.2 bouyer Aml = NextOp->Named.Data;
409 1.3.2.2 bouyer Length = (ACPI_SIZE) NextOp->Common.Value.Integer;
410 1.3.2.2 bouyer
411 1.3.2.2 bouyer /* Walk the byte list, abort on any invalid descriptor type or length */
412 1.3.2.2 bouyer
413 1.3.2.2 bouyer Status = AcpiUtWalkAmlResources (Aml, Length, NULL, &EndAml);
414 1.3.2.2 bouyer if (ACPI_FAILURE (Status))
415 1.3.2.2 bouyer {
416 1.3.2.2 bouyer return (AE_TYPE);
417 1.3.2.2 bouyer }
418 1.3.2.2 bouyer
419 1.3.2.2 bouyer /*
420 1.3.2.2 bouyer * For the resource template to be valid, one EndTag must appear
421 1.3.2.2 bouyer * at the very end of the ByteList, not before. (For proper disassembly
422 1.3.2.2 bouyer * of a ResourceTemplate, the buffer must not have any extra data after
423 1.3.2.2 bouyer * the EndTag.)
424 1.3.2.2 bouyer */
425 1.3.2.2 bouyer if ((Aml + Length - sizeof (AML_RESOURCE_END_TAG)) != EndAml)
426 1.3.2.2 bouyer {
427 1.3.2.2 bouyer return (AE_AML_NO_RESOURCE_END_TAG);
428 1.3.2.2 bouyer }
429 1.3.2.2 bouyer
430 1.3.2.2 bouyer /*
431 1.3.2.2 bouyer * All resource descriptors are valid, therefore this list appears
432 1.3.2.2 bouyer * to be a valid resource template
433 1.3.2.2 bouyer */
434 1.3.2.2 bouyer return (AE_OK);
435 1.3.2.2 bouyer }
436 1.3.2.2 bouyer
437 1.3.2.2 bouyer #endif
438