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