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