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