dmbuffer.c revision 1.13 1 1.1 jruoho /*******************************************************************************
2 1.1 jruoho *
3 1.1 jruoho * Module Name: dmbuffer - AML disassembler, buffer and string support
4 1.1 jruoho *
5 1.1 jruoho ******************************************************************************/
6 1.1 jruoho
7 1.2 christos /*
8 1.11 christos * Copyright (C) 2000 - 2020, Intel Corp.
9 1.1 jruoho * All rights reserved.
10 1.1 jruoho *
11 1.2 christos * Redistribution and use in source and binary forms, with or without
12 1.2 christos * modification, are permitted provided that the following conditions
13 1.2 christos * are met:
14 1.2 christos * 1. Redistributions of source code must retain the above copyright
15 1.2 christos * notice, this list of conditions, and the following disclaimer,
16 1.2 christos * without modification.
17 1.2 christos * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.2 christos * substantially similar to the "NO WARRANTY" disclaimer below
19 1.2 christos * ("Disclaimer") and any redistribution must be conditioned upon
20 1.2 christos * including a substantially similar Disclaimer requirement for further
21 1.2 christos * binary redistribution.
22 1.2 christos * 3. Neither the names of the above-listed copyright holders nor the names
23 1.2 christos * of any contributors may be used to endorse or promote products derived
24 1.2 christos * from this software without specific prior written permission.
25 1.2 christos *
26 1.2 christos * Alternatively, this software may be distributed under the terms of the
27 1.2 christos * GNU General Public License ("GPL") version 2 as published by the Free
28 1.2 christos * Software Foundation.
29 1.2 christos *
30 1.2 christos * NO WARRANTY
31 1.2 christos * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.2 christos * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.2 christos * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.2 christos * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.2 christos * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.2 christos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.2 christos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.2 christos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.2 christos * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.2 christos * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.2 christos * POSSIBILITY OF SUCH DAMAGES.
42 1.2 christos */
43 1.1 jruoho
44 1.1 jruoho #include "acpi.h"
45 1.1 jruoho #include "accommon.h"
46 1.2 christos #include "acutils.h"
47 1.1 jruoho #include "acdisasm.h"
48 1.1 jruoho #include "acparser.h"
49 1.1 jruoho #include "amlcode.h"
50 1.2 christos #include "acinterp.h"
51 1.1 jruoho
52 1.1 jruoho
53 1.1 jruoho #define _COMPONENT ACPI_CA_DEBUGGER
54 1.1 jruoho ACPI_MODULE_NAME ("dmbuffer")
55 1.1 jruoho
56 1.1 jruoho /* Local prototypes */
57 1.1 jruoho
58 1.1 jruoho static void
59 1.2 christos AcpiDmUuid (
60 1.2 christos ACPI_PARSE_OBJECT *Op);
61 1.2 christos
62 1.2 christos static void
63 1.1 jruoho AcpiDmUnicode (
64 1.1 jruoho ACPI_PARSE_OBJECT *Op);
65 1.1 jruoho
66 1.1 jruoho static void
67 1.2 christos AcpiDmGetHardwareIdType (
68 1.1 jruoho ACPI_PARSE_OBJECT *Op);
69 1.1 jruoho
70 1.2 christos static void
71 1.2 christos AcpiDmPldBuffer (
72 1.2 christos UINT32 Level,
73 1.2 christos UINT8 *ByteData,
74 1.2 christos UINT32 ByteCount);
75 1.2 christos
76 1.5 christos static const char *
77 1.5 christos AcpiDmFindNameByIndex (
78 1.5 christos UINT64 Index,
79 1.5 christos const char **List);
80 1.5 christos
81 1.2 christos
82 1.2 christos #define ACPI_BUFFER_BYTES_PER_LINE 8
83 1.2 christos
84 1.2 christos
85 1.1 jruoho /*******************************************************************************
86 1.1 jruoho *
87 1.1 jruoho * FUNCTION: AcpiDmDisasmByteList
88 1.1 jruoho *
89 1.1 jruoho * PARAMETERS: Level - Current source code indentation level
90 1.1 jruoho * ByteData - Pointer to the byte list
91 1.1 jruoho * ByteCount - Length of the byte list
92 1.1 jruoho *
93 1.1 jruoho * RETURN: None
94 1.1 jruoho *
95 1.1 jruoho * DESCRIPTION: Dump an AML "ByteList" in Hex format. 8 bytes per line, prefixed
96 1.1 jruoho * with the hex buffer offset.
97 1.1 jruoho *
98 1.1 jruoho ******************************************************************************/
99 1.1 jruoho
100 1.1 jruoho void
101 1.1 jruoho AcpiDmDisasmByteList (
102 1.1 jruoho UINT32 Level,
103 1.1 jruoho UINT8 *ByteData,
104 1.1 jruoho UINT32 ByteCount)
105 1.1 jruoho {
106 1.1 jruoho UINT32 i;
107 1.2 christos UINT32 j;
108 1.2 christos UINT32 CurrentIndex;
109 1.2 christos UINT8 BufChar;
110 1.1 jruoho
111 1.1 jruoho
112 1.1 jruoho if (!ByteCount)
113 1.1 jruoho {
114 1.1 jruoho return;
115 1.1 jruoho }
116 1.1 jruoho
117 1.2 christos for (i = 0; i < ByteCount; i += ACPI_BUFFER_BYTES_PER_LINE)
118 1.2 christos {
119 1.2 christos /* Line indent and offset prefix for each new line */
120 1.2 christos
121 1.2 christos AcpiDmIndent (Level);
122 1.2 christos if (ByteCount > ACPI_BUFFER_BYTES_PER_LINE)
123 1.2 christos {
124 1.2 christos AcpiOsPrintf ("/* %04X */ ", i);
125 1.2 christos }
126 1.1 jruoho
127 1.2 christos /* Dump the actual hex values */
128 1.1 jruoho
129 1.2 christos for (j = 0; j < ACPI_BUFFER_BYTES_PER_LINE; j++)
130 1.1 jruoho {
131 1.2 christos CurrentIndex = i + j;
132 1.2 christos if (CurrentIndex >= ByteCount)
133 1.1 jruoho {
134 1.2 christos /* Dump fill spaces */
135 1.2 christos
136 1.2 christos AcpiOsPrintf (" ");
137 1.2 christos continue;
138 1.1 jruoho }
139 1.1 jruoho
140 1.2 christos AcpiOsPrintf (" 0x%2.2X", ByteData[CurrentIndex]);
141 1.2 christos
142 1.2 christos /* Add comma if there are more bytes to display */
143 1.2 christos
144 1.2 christos if (CurrentIndex < (ByteCount - 1))
145 1.1 jruoho {
146 1.2 christos AcpiOsPrintf (",");
147 1.2 christos }
148 1.2 christos else
149 1.2 christos {
150 1.2 christos AcpiOsPrintf (" ");
151 1.1 jruoho }
152 1.1 jruoho }
153 1.1 jruoho
154 1.2 christos /* Dump the ASCII equivalents within a comment */
155 1.1 jruoho
156 1.8 christos AcpiOsPrintf (" // ");
157 1.2 christos for (j = 0; j < ACPI_BUFFER_BYTES_PER_LINE; j++)
158 1.2 christos {
159 1.2 christos CurrentIndex = i + j;
160 1.2 christos if (CurrentIndex >= ByteCount)
161 1.2 christos {
162 1.2 christos break;
163 1.2 christos }
164 1.1 jruoho
165 1.2 christos BufChar = ByteData[CurrentIndex];
166 1.3 christos if (isprint (BufChar))
167 1.2 christos {
168 1.2 christos AcpiOsPrintf ("%c", BufChar);
169 1.2 christos }
170 1.2 christos else
171 1.2 christos {
172 1.2 christos AcpiOsPrintf (".");
173 1.2 christos }
174 1.1 jruoho }
175 1.1 jruoho
176 1.2 christos /* Finished with this line */
177 1.2 christos
178 1.8 christos AcpiOsPrintf ("\n");
179 1.1 jruoho }
180 1.1 jruoho }
181 1.1 jruoho
182 1.1 jruoho
183 1.1 jruoho /*******************************************************************************
184 1.1 jruoho *
185 1.1 jruoho * FUNCTION: AcpiDmByteList
186 1.1 jruoho *
187 1.1 jruoho * PARAMETERS: Info - Parse tree walk info
188 1.1 jruoho * Op - Byte list op
189 1.1 jruoho *
190 1.1 jruoho * RETURN: None
191 1.1 jruoho *
192 1.1 jruoho * DESCRIPTION: Dump a buffer byte list, handling the various types of buffers.
193 1.1 jruoho * Buffer type must be already set in the Op DisasmOpcode.
194 1.1 jruoho *
195 1.1 jruoho ******************************************************************************/
196 1.1 jruoho
197 1.1 jruoho void
198 1.1 jruoho AcpiDmByteList (
199 1.1 jruoho ACPI_OP_WALK_INFO *Info,
200 1.1 jruoho ACPI_PARSE_OBJECT *Op)
201 1.1 jruoho {
202 1.1 jruoho UINT8 *ByteData;
203 1.1 jruoho UINT32 ByteCount;
204 1.1 jruoho
205 1.1 jruoho
206 1.1 jruoho ByteData = Op->Named.Data;
207 1.1 jruoho ByteCount = (UINT32) Op->Common.Value.Integer;
208 1.1 jruoho
209 1.1 jruoho /*
210 1.1 jruoho * The byte list belongs to a buffer, and can be produced by either
211 1.1 jruoho * a ResourceTemplate, Unicode, quoted string, or a plain byte list.
212 1.1 jruoho */
213 1.1 jruoho switch (Op->Common.Parent->Common.DisasmOpcode)
214 1.1 jruoho {
215 1.1 jruoho case ACPI_DASM_RESOURCE:
216 1.1 jruoho
217 1.4 christos AcpiDmResourceTemplate (
218 1.4 christos Info, Op->Common.Parent, ByteData, ByteCount);
219 1.1 jruoho break;
220 1.1 jruoho
221 1.1 jruoho case ACPI_DASM_STRING:
222 1.1 jruoho
223 1.1 jruoho AcpiDmIndent (Info->Level);
224 1.2 christos AcpiUtPrintString ((char *) ByteData, ACPI_UINT16_MAX);
225 1.1 jruoho AcpiOsPrintf ("\n");
226 1.1 jruoho break;
227 1.1 jruoho
228 1.2 christos case ACPI_DASM_UUID:
229 1.2 christos
230 1.2 christos AcpiDmUuid (Op);
231 1.2 christos break;
232 1.2 christos
233 1.1 jruoho case ACPI_DASM_UNICODE:
234 1.1 jruoho
235 1.1 jruoho AcpiDmUnicode (Op);
236 1.1 jruoho break;
237 1.1 jruoho
238 1.2 christos case ACPI_DASM_PLD_METHOD:
239 1.2 christos #if 0
240 1.2 christos AcpiDmDisasmByteList (Info->Level, ByteData, ByteCount);
241 1.2 christos #endif
242 1.2 christos AcpiDmPldBuffer (Info->Level, ByteData, ByteCount);
243 1.2 christos break;
244 1.2 christos
245 1.1 jruoho case ACPI_DASM_BUFFER:
246 1.1 jruoho default:
247 1.1 jruoho /*
248 1.1 jruoho * Not a resource, string, or unicode string.
249 1.1 jruoho * Just dump the buffer
250 1.1 jruoho */
251 1.1 jruoho AcpiDmDisasmByteList (Info->Level, ByteData, ByteCount);
252 1.1 jruoho break;
253 1.1 jruoho }
254 1.1 jruoho }
255 1.1 jruoho
256 1.1 jruoho
257 1.1 jruoho /*******************************************************************************
258 1.1 jruoho *
259 1.2 christos * FUNCTION: AcpiDmIsUuidBuffer
260 1.2 christos *
261 1.2 christos * PARAMETERS: Op - Buffer Object to be examined
262 1.2 christos *
263 1.2 christos * RETURN: TRUE if buffer contains a UUID
264 1.2 christos *
265 1.2 christos * DESCRIPTION: Determine if a buffer Op contains a UUID
266 1.2 christos *
267 1.2 christos * To help determine whether the buffer is a UUID versus a raw data buffer,
268 1.2 christos * there a are a couple bytes we can look at:
269 1.2 christos *
270 1.2 christos * xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx
271 1.2 christos *
272 1.2 christos * The variant covered by the UUID specification is indicated by the two most
273 1.2 christos * significant bits of N being 1 0 (i.e., the hexadecimal N will always be
274 1.2 christos * 8, 9, A, or B).
275 1.2 christos *
276 1.2 christos * The variant covered by the UUID specification has five versions. For this
277 1.2 christos * variant, the four bits of M indicates the UUID version (i.e., the
278 1.2 christos * hexadecimal M will be either 1, 2, 3, 4, or 5).
279 1.2 christos *
280 1.2 christos ******************************************************************************/
281 1.2 christos
282 1.2 christos BOOLEAN
283 1.2 christos AcpiDmIsUuidBuffer (
284 1.2 christos ACPI_PARSE_OBJECT *Op)
285 1.2 christos {
286 1.2 christos UINT8 *ByteData;
287 1.2 christos UINT32 ByteCount;
288 1.2 christos ACPI_PARSE_OBJECT *SizeOp;
289 1.2 christos ACPI_PARSE_OBJECT *NextOp;
290 1.2 christos
291 1.2 christos
292 1.2 christos /* Buffer size is the buffer argument */
293 1.2 christos
294 1.2 christos SizeOp = Op->Common.Value.Arg;
295 1.12 christos if (!SizeOp)
296 1.12 christos {
297 1.12 christos return (FALSE);
298 1.12 christos }
299 1.2 christos
300 1.2 christos /* Next, the initializer byte list to examine */
301 1.2 christos
302 1.2 christos NextOp = SizeOp->Common.Next;
303 1.2 christos if (!NextOp)
304 1.2 christos {
305 1.2 christos return (FALSE);
306 1.2 christos }
307 1.2 christos
308 1.2 christos /* Extract the byte list info */
309 1.2 christos
310 1.2 christos ByteData = NextOp->Named.Data;
311 1.2 christos ByteCount = (UINT32) NextOp->Common.Value.Integer;
312 1.2 christos
313 1.2 christos /* Byte count must be exactly 16 */
314 1.2 christos
315 1.2 christos if (ByteCount != UUID_BUFFER_LENGTH)
316 1.2 christos {
317 1.2 christos return (FALSE);
318 1.2 christos }
319 1.2 christos
320 1.2 christos /* Check for valid "M" and "N" values (see function header above) */
321 1.2 christos
322 1.2 christos if (((ByteData[7] & 0xF0) == 0x00) || /* M={1,2,3,4,5} */
323 1.2 christos ((ByteData[7] & 0xF0) > 0x50) ||
324 1.2 christos ((ByteData[8] & 0xF0) < 0x80) || /* N={8,9,A,B} */
325 1.2 christos ((ByteData[8] & 0xF0) > 0xB0))
326 1.2 christos {
327 1.2 christos return (FALSE);
328 1.2 christos }
329 1.2 christos
330 1.2 christos /* Ignore the Size argument in the disassembly of this buffer op */
331 1.2 christos
332 1.2 christos SizeOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
333 1.2 christos return (TRUE);
334 1.2 christos }
335 1.2 christos
336 1.2 christos
337 1.2 christos /*******************************************************************************
338 1.2 christos *
339 1.2 christos * FUNCTION: AcpiDmUuid
340 1.2 christos *
341 1.2 christos * PARAMETERS: Op - Byte List op containing a UUID
342 1.2 christos *
343 1.2 christos * RETURN: None
344 1.2 christos *
345 1.2 christos * DESCRIPTION: Dump a buffer containing a UUID as a standard ASCII string.
346 1.2 christos *
347 1.2 christos * Output Format:
348 1.2 christos * In its canonical form, the UUID is represented by a string containing 32
349 1.2 christos * lowercase hexadecimal digits, displayed in 5 groups separated by hyphens.
350 1.2 christos * The complete form is 8-4-4-4-12 for a total of 36 characters (32
351 1.2 christos * alphanumeric characters representing hex digits and 4 hyphens). In bytes,
352 1.2 christos * 4-2-2-2-6. Example:
353 1.2 christos *
354 1.2 christos * ToUUID ("107ededd-d381-4fd7-8da9-08e9a6c79644")
355 1.2 christos *
356 1.2 christos ******************************************************************************/
357 1.2 christos
358 1.2 christos static void
359 1.2 christos AcpiDmUuid (
360 1.2 christos ACPI_PARSE_OBJECT *Op)
361 1.2 christos {
362 1.2 christos UINT8 *Data;
363 1.2 christos const char *Description;
364 1.2 christos
365 1.2 christos
366 1.2 christos Data = ACPI_CAST_PTR (UINT8, Op->Named.Data);
367 1.2 christos
368 1.2 christos /* Emit the 36-byte UUID string in the proper format/order */
369 1.2 christos
370 1.2 christos AcpiOsPrintf (
371 1.2 christos "\"%2.2x%2.2x%2.2x%2.2x-"
372 1.2 christos "%2.2x%2.2x-"
373 1.2 christos "%2.2x%2.2x-"
374 1.2 christos "%2.2x%2.2x-"
375 1.2 christos "%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x\")",
376 1.2 christos Data[3], Data[2], Data[1], Data[0],
377 1.2 christos Data[5], Data[4],
378 1.2 christos Data[7], Data[6],
379 1.2 christos Data[8], Data[9],
380 1.2 christos Data[10], Data[11], Data[12], Data[13], Data[14], Data[15]);
381 1.2 christos
382 1.2 christos /* Dump the UUID description string if available */
383 1.2 christos
384 1.2 christos Description = AcpiAhMatchUuid (Data);
385 1.2 christos if (Description)
386 1.2 christos {
387 1.2 christos AcpiOsPrintf (" /* %s */", Description);
388 1.2 christos }
389 1.13 christos else
390 1.13 christos {
391 1.13 christos AcpiOsPrintf (" /* Unknown UUID */");
392 1.13 christos }
393 1.2 christos }
394 1.2 christos
395 1.2 christos
396 1.2 christos /*******************************************************************************
397 1.2 christos *
398 1.1 jruoho * FUNCTION: AcpiDmIsUnicodeBuffer
399 1.1 jruoho *
400 1.1 jruoho * PARAMETERS: Op - Buffer Object to be examined
401 1.1 jruoho *
402 1.1 jruoho * RETURN: TRUE if buffer contains a UNICODE string
403 1.1 jruoho *
404 1.1 jruoho * DESCRIPTION: Determine if a buffer Op contains a Unicode string
405 1.1 jruoho *
406 1.1 jruoho ******************************************************************************/
407 1.1 jruoho
408 1.1 jruoho BOOLEAN
409 1.1 jruoho AcpiDmIsUnicodeBuffer (
410 1.1 jruoho ACPI_PARSE_OBJECT *Op)
411 1.1 jruoho {
412 1.1 jruoho UINT8 *ByteData;
413 1.1 jruoho UINT32 ByteCount;
414 1.1 jruoho UINT32 WordCount;
415 1.1 jruoho ACPI_PARSE_OBJECT *SizeOp;
416 1.1 jruoho ACPI_PARSE_OBJECT *NextOp;
417 1.1 jruoho UINT32 i;
418 1.1 jruoho
419 1.1 jruoho
420 1.1 jruoho /* Buffer size is the buffer argument */
421 1.1 jruoho
422 1.1 jruoho SizeOp = Op->Common.Value.Arg;
423 1.12 christos if (!SizeOp)
424 1.12 christos {
425 1.12 christos return (FALSE);
426 1.12 christos }
427 1.1 jruoho
428 1.1 jruoho /* Next, the initializer byte list to examine */
429 1.1 jruoho
430 1.1 jruoho NextOp = SizeOp->Common.Next;
431 1.1 jruoho if (!NextOp)
432 1.1 jruoho {
433 1.1 jruoho return (FALSE);
434 1.1 jruoho }
435 1.1 jruoho
436 1.1 jruoho /* Extract the byte list info */
437 1.1 jruoho
438 1.1 jruoho ByteData = NextOp->Named.Data;
439 1.1 jruoho ByteCount = (UINT32) NextOp->Common.Value.Integer;
440 1.1 jruoho WordCount = ACPI_DIV_2 (ByteCount);
441 1.1 jruoho
442 1.1 jruoho /*
443 1.1 jruoho * Unicode string must have an even number of bytes and last
444 1.1 jruoho * word must be zero
445 1.1 jruoho */
446 1.1 jruoho if ((!ByteCount) ||
447 1.1 jruoho (ByteCount < 4) ||
448 1.1 jruoho (ByteCount & 1) ||
449 1.1 jruoho ((UINT16 *) (void *) ByteData)[WordCount - 1] != 0)
450 1.1 jruoho {
451 1.1 jruoho return (FALSE);
452 1.1 jruoho }
453 1.1 jruoho
454 1.7 christos /*
455 1.7 christos * For each word, 1st byte must be printable ascii, and the
456 1.7 christos * 2nd byte must be zero. This does not allow for escape
457 1.7 christos * sequences, but it is the most secure way to detect a
458 1.7 christos * unicode string.
459 1.7 christos */
460 1.1 jruoho for (i = 0; i < (ByteCount - 2); i += 2)
461 1.1 jruoho {
462 1.2 christos if ((ByteData[i] == 0) ||
463 1.7 christos !(isprint (ByteData[i])) ||
464 1.1 jruoho (ByteData[(ACPI_SIZE) i + 1] != 0))
465 1.1 jruoho {
466 1.1 jruoho return (FALSE);
467 1.1 jruoho }
468 1.1 jruoho }
469 1.1 jruoho
470 1.1 jruoho /* Ignore the Size argument in the disassembly of this buffer op */
471 1.1 jruoho
472 1.1 jruoho SizeOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
473 1.1 jruoho return (TRUE);
474 1.1 jruoho }
475 1.1 jruoho
476 1.1 jruoho
477 1.1 jruoho /*******************************************************************************
478 1.1 jruoho *
479 1.1 jruoho * FUNCTION: AcpiDmIsStringBuffer
480 1.1 jruoho *
481 1.1 jruoho * PARAMETERS: Op - Buffer Object to be examined
482 1.1 jruoho *
483 1.1 jruoho * RETURN: TRUE if buffer contains a ASCII string, FALSE otherwise
484 1.1 jruoho *
485 1.1 jruoho * DESCRIPTION: Determine if a buffer Op contains a ASCII string
486 1.1 jruoho *
487 1.1 jruoho ******************************************************************************/
488 1.1 jruoho
489 1.1 jruoho BOOLEAN
490 1.1 jruoho AcpiDmIsStringBuffer (
491 1.1 jruoho ACPI_PARSE_OBJECT *Op)
492 1.1 jruoho {
493 1.1 jruoho UINT8 *ByteData;
494 1.1 jruoho UINT32 ByteCount;
495 1.1 jruoho ACPI_PARSE_OBJECT *SizeOp;
496 1.1 jruoho ACPI_PARSE_OBJECT *NextOp;
497 1.1 jruoho UINT32 i;
498 1.1 jruoho
499 1.1 jruoho
500 1.1 jruoho /* Buffer size is the buffer argument */
501 1.1 jruoho
502 1.1 jruoho SizeOp = Op->Common.Value.Arg;
503 1.12 christos if (!SizeOp)
504 1.12 christos {
505 1.12 christos return (FALSE);
506 1.12 christos }
507 1.1 jruoho
508 1.1 jruoho /* Next, the initializer byte list to examine */
509 1.1 jruoho
510 1.1 jruoho NextOp = SizeOp->Common.Next;
511 1.1 jruoho if (!NextOp)
512 1.1 jruoho {
513 1.1 jruoho return (FALSE);
514 1.1 jruoho }
515 1.1 jruoho
516 1.1 jruoho /* Extract the byte list info */
517 1.1 jruoho
518 1.1 jruoho ByteData = NextOp->Named.Data;
519 1.1 jruoho ByteCount = (UINT32) NextOp->Common.Value.Integer;
520 1.1 jruoho
521 1.1 jruoho /* Last byte must be the null terminator */
522 1.1 jruoho
523 1.1 jruoho if ((!ByteCount) ||
524 1.1 jruoho (ByteCount < 2) ||
525 1.1 jruoho (ByteData[ByteCount-1] != 0))
526 1.1 jruoho {
527 1.1 jruoho return (FALSE);
528 1.1 jruoho }
529 1.1 jruoho
530 1.7 christos /*
531 1.7 christos * Check for a possible standalone resource EndTag, ignore it
532 1.7 christos * here. However, this sequence is also the string "Y", but
533 1.7 christos * this seems rare enough to be acceptable.
534 1.7 christos */
535 1.7 christos if ((ByteCount == 2) && (ByteData[0] == 0x79))
536 1.7 christos {
537 1.7 christos return (FALSE);
538 1.7 christos }
539 1.7 christos
540 1.7 christos /* Check all bytes for ASCII */
541 1.7 christos
542 1.1 jruoho for (i = 0; i < (ByteCount - 1); i++)
543 1.1 jruoho {
544 1.7 christos /*
545 1.7 christos * TBD: allow some escapes (non-ascii chars).
546 1.1 jruoho * they will be handled in the string output routine
547 1.1 jruoho */
548 1.1 jruoho
549 1.7 christos /* Not a string if not printable ascii */
550 1.7 christos
551 1.3 christos if (!isprint (ByteData[i]))
552 1.1 jruoho {
553 1.1 jruoho return (FALSE);
554 1.1 jruoho }
555 1.1 jruoho }
556 1.1 jruoho
557 1.1 jruoho return (TRUE);
558 1.1 jruoho }
559 1.1 jruoho
560 1.1 jruoho
561 1.1 jruoho /*******************************************************************************
562 1.1 jruoho *
563 1.2 christos * FUNCTION: AcpiDmIsPldBuffer
564 1.2 christos *
565 1.2 christos * PARAMETERS: Op - Buffer Object to be examined
566 1.2 christos *
567 1.6 christos * RETURN: TRUE if buffer appears to contain data produced via the
568 1.6 christos * ToPLD macro, FALSE otherwise
569 1.2 christos *
570 1.2 christos * DESCRIPTION: Determine if a buffer Op contains a _PLD structure
571 1.2 christos *
572 1.2 christos ******************************************************************************/
573 1.2 christos
574 1.2 christos BOOLEAN
575 1.2 christos AcpiDmIsPldBuffer (
576 1.2 christos ACPI_PARSE_OBJECT *Op)
577 1.2 christos {
578 1.2 christos ACPI_NAMESPACE_NODE *Node;
579 1.2 christos ACPI_PARSE_OBJECT *SizeOp;
580 1.6 christos ACPI_PARSE_OBJECT *ByteListOp;
581 1.2 christos ACPI_PARSE_OBJECT *ParentOp;
582 1.6 christos UINT64 BufferSize;
583 1.6 christos UINT64 InitializerSize;
584 1.2 christos
585 1.2 christos
586 1.12 christos if (!Op)
587 1.12 christos {
588 1.12 christos return (FALSE);
589 1.12 christos }
590 1.12 christos
591 1.6 christos /*
592 1.6 christos * Get the BufferSize argument - Buffer(BufferSize)
593 1.6 christos * If the buffer was generated by the ToPld macro, it must
594 1.6 christos * be a BYTE constant.
595 1.6 christos */
596 1.6 christos SizeOp = Op->Common.Value.Arg;
597 1.12 christos if (!SizeOp || SizeOp->Common.AmlOpcode != AML_BYTE_OP)
598 1.6 christos {
599 1.6 christos return (FALSE);
600 1.6 christos }
601 1.6 christos
602 1.6 christos /* Check the declared BufferSize, two possibilities */
603 1.6 christos
604 1.6 christos BufferSize = SizeOp->Common.Value.Integer;
605 1.6 christos if ((BufferSize != ACPI_PLD_REV1_BUFFER_SIZE) &&
606 1.6 christos (BufferSize != ACPI_PLD_REV2_BUFFER_SIZE))
607 1.6 christos {
608 1.6 christos return (FALSE);
609 1.6 christos }
610 1.6 christos
611 1.6 christos /*
612 1.6 christos * Check the initializer list length. This is the actual
613 1.6 christos * number of bytes in the buffer as counted by the AML parser.
614 1.6 christos * The declared BufferSize can be larger than the actual length.
615 1.6 christos * However, for the ToPLD macro, the BufferSize will be the same
616 1.6 christos * as the initializer list length.
617 1.6 christos */
618 1.6 christos ByteListOp = SizeOp->Common.Next;
619 1.6 christos if (!ByteListOp)
620 1.6 christos {
621 1.6 christos return (FALSE); /* Zero-length buffer case */
622 1.6 christos }
623 1.6 christos
624 1.6 christos InitializerSize = ByteListOp->Common.Value.Integer;
625 1.6 christos if ((InitializerSize != ACPI_PLD_REV1_BUFFER_SIZE) &&
626 1.6 christos (InitializerSize != ACPI_PLD_REV2_BUFFER_SIZE))
627 1.6 christos {
628 1.6 christos return (FALSE);
629 1.6 christos }
630 1.6 christos
631 1.6 christos /* Final size check */
632 1.6 christos
633 1.6 christos if (BufferSize != InitializerSize)
634 1.6 christos {
635 1.6 christos return (FALSE);
636 1.6 christos }
637 1.2 christos
638 1.6 christos /* Now examine the buffer parent */
639 1.2 christos
640 1.2 christos ParentOp = Op->Common.Parent;
641 1.2 christos if (!ParentOp)
642 1.2 christos {
643 1.2 christos return (FALSE);
644 1.2 christos }
645 1.2 christos
646 1.2 christos /* Check for form: Name(_PLD, Buffer() {}). Not legal, however */
647 1.2 christos
648 1.2 christos if (ParentOp->Common.AmlOpcode == AML_NAME_OP)
649 1.2 christos {
650 1.2 christos Node = ParentOp->Common.Node;
651 1.2 christos
652 1.10 christos if (ACPI_COMPARE_NAMESEG (Node->Name.Ascii, METHOD_NAME__PLD))
653 1.2 christos {
654 1.2 christos /* Ignore the Size argument in the disassembly of this buffer op */
655 1.2 christos
656 1.2 christos SizeOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
657 1.2 christos return (TRUE);
658 1.2 christos }
659 1.2 christos
660 1.2 christos return (FALSE);
661 1.2 christos }
662 1.2 christos
663 1.6 christos /*
664 1.6 christos * Check for proper form: Name(_PLD, Package() {ToPLD()})
665 1.6 christos *
666 1.6 christos * Note: All other forms such as
667 1.6 christos * Return (Package() {ToPLD()})
668 1.6 christos * Local0 = ToPLD()
669 1.6 christos * etc. are not converted back to the ToPLD macro, because
670 1.6 christos * there is really no deterministic way to disassemble the buffer
671 1.6 christos * back to the ToPLD macro, other than trying to find the "_PLD"
672 1.6 christos * name
673 1.6 christos */
674 1.2 christos if (ParentOp->Common.AmlOpcode == AML_PACKAGE_OP)
675 1.2 christos {
676 1.2 christos ParentOp = ParentOp->Common.Parent;
677 1.2 christos if (!ParentOp)
678 1.2 christos {
679 1.2 christos return (FALSE);
680 1.2 christos }
681 1.2 christos
682 1.2 christos if (ParentOp->Common.AmlOpcode == AML_NAME_OP)
683 1.2 christos {
684 1.2 christos Node = ParentOp->Common.Node;
685 1.2 christos
686 1.10 christos if (ACPI_COMPARE_NAMESEG (Node->Name.Ascii, METHOD_NAME__PLD))
687 1.2 christos {
688 1.2 christos /* Ignore the Size argument in the disassembly of this buffer op */
689 1.2 christos
690 1.2 christos SizeOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
691 1.2 christos return (TRUE);
692 1.2 christos }
693 1.2 christos }
694 1.2 christos }
695 1.2 christos
696 1.2 christos return (FALSE);
697 1.2 christos }
698 1.2 christos
699 1.2 christos
700 1.2 christos /*******************************************************************************
701 1.2 christos *
702 1.2 christos * FUNCTION: AcpiDmFindNameByIndex
703 1.2 christos *
704 1.2 christos * PARAMETERS: Index - Index of array to check
705 1.2 christos * List - Array to reference
706 1.2 christos *
707 1.2 christos * RETURN: String from List or empty string
708 1.2 christos *
709 1.2 christos * DESCRIPTION: Finds and returns the char string located at the given index
710 1.2 christos * position in List.
711 1.2 christos *
712 1.2 christos ******************************************************************************/
713 1.2 christos
714 1.2 christos static const char *
715 1.2 christos AcpiDmFindNameByIndex (
716 1.2 christos UINT64 Index,
717 1.5 christos const char **List)
718 1.2 christos {
719 1.5 christos const char *NameString;
720 1.5 christos UINT32 i;
721 1.2 christos
722 1.2 christos
723 1.2 christos /* Bounds check */
724 1.2 christos
725 1.5 christos NameString = List[0];
726 1.2 christos i = 0;
727 1.2 christos
728 1.5 christos while (NameString)
729 1.2 christos {
730 1.2 christos i++;
731 1.5 christos NameString = List[i];
732 1.2 christos }
733 1.2 christos
734 1.2 christos if (Index >= i)
735 1.2 christos {
736 1.2 christos /* TBD: Add error msg */
737 1.2 christos
738 1.2 christos return ("");
739 1.2 christos }
740 1.2 christos
741 1.2 christos return (List[Index]);
742 1.2 christos }
743 1.2 christos
744 1.2 christos
745 1.2 christos /*******************************************************************************
746 1.2 christos *
747 1.2 christos * FUNCTION: AcpiDmPldBuffer
748 1.2 christos *
749 1.2 christos * PARAMETERS: Level - Current source code indentation level
750 1.2 christos * ByteData - Pointer to the byte list
751 1.2 christos * ByteCount - Length of the byte list
752 1.2 christos *
753 1.2 christos * RETURN: None
754 1.2 christos *
755 1.2 christos * DESCRIPTION: Dump and format the contents of a _PLD buffer object
756 1.2 christos *
757 1.2 christos ******************************************************************************/
758 1.2 christos
759 1.5 christos #define ACPI_PLD_OUTPUT08 "%*.s%-22s = 0x%X,\n", ACPI_MUL_4 (Level), " "
760 1.5 christos #define ACPI_PLD_OUTPUT08P "%*.s%-22s = 0x%X)\n", ACPI_MUL_4 (Level), " "
761 1.5 christos #define ACPI_PLD_OUTPUT16 "%*.s%-22s = 0x%X,\n", ACPI_MUL_4 (Level), " "
762 1.5 christos #define ACPI_PLD_OUTPUT16P "%*.s%-22s = 0x%X)\n", ACPI_MUL_4 (Level), " "
763 1.5 christos #define ACPI_PLD_OUTPUT24 "%*.s%-22s = 0x%X,\n", ACPI_MUL_4 (Level), " "
764 1.5 christos #define ACPI_PLD_OUTPUTSTR "%*.s%-22s = \"%s\",\n", ACPI_MUL_4 (Level), " "
765 1.2 christos
766 1.2 christos static void
767 1.2 christos AcpiDmPldBuffer (
768 1.2 christos UINT32 Level,
769 1.2 christos UINT8 *ByteData,
770 1.2 christos UINT32 ByteCount)
771 1.2 christos {
772 1.2 christos ACPI_PLD_INFO *PldInfo;
773 1.2 christos ACPI_STATUS Status;
774 1.2 christos
775 1.2 christos
776 1.2 christos /* Check for valid byte count */
777 1.2 christos
778 1.2 christos if (ByteCount < ACPI_PLD_REV1_BUFFER_SIZE)
779 1.2 christos {
780 1.2 christos return;
781 1.2 christos }
782 1.2 christos
783 1.2 christos /* Convert _PLD buffer to local _PLD struct */
784 1.2 christos
785 1.2 christos Status = AcpiDecodePldBuffer (ByteData, ByteCount, &PldInfo);
786 1.2 christos if (ACPI_FAILURE (Status))
787 1.2 christos {
788 1.2 christos return;
789 1.2 christos }
790 1.2 christos
791 1.2 christos AcpiOsPrintf ("\n");
792 1.2 christos
793 1.2 christos /* First 32-bit dword */
794 1.2 christos
795 1.2 christos AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_Revision", PldInfo->Revision);
796 1.2 christos AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_IgnoreColor", PldInfo->IgnoreColor);
797 1.2 christos AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_Red", PldInfo->Red);
798 1.2 christos AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_Green", PldInfo->Green);
799 1.2 christos AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_Blue", PldInfo->Blue);
800 1.2 christos
801 1.2 christos /* Second 32-bit dword */
802 1.2 christos
803 1.2 christos AcpiOsPrintf (ACPI_PLD_OUTPUT16, "PLD_Width", PldInfo->Width);
804 1.2 christos AcpiOsPrintf (ACPI_PLD_OUTPUT16, "PLD_Height", PldInfo->Height);
805 1.2 christos
806 1.2 christos /* Third 32-bit dword */
807 1.2 christos
808 1.2 christos AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_UserVisible", PldInfo->UserVisible);
809 1.2 christos AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_Dock", PldInfo->Dock);
810 1.2 christos AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_Lid", PldInfo->Lid);
811 1.2 christos AcpiOsPrintf (ACPI_PLD_OUTPUTSTR, "PLD_Panel",
812 1.5 christos AcpiDmFindNameByIndex(PldInfo->Panel, AcpiGbl_PldPanelList));
813 1.4 christos
814 1.2 christos AcpiOsPrintf (ACPI_PLD_OUTPUTSTR, "PLD_VerticalPosition",
815 1.5 christos AcpiDmFindNameByIndex(PldInfo->VerticalPosition, AcpiGbl_PldVerticalPositionList));
816 1.4 christos
817 1.2 christos AcpiOsPrintf (ACPI_PLD_OUTPUTSTR, "PLD_HorizontalPosition",
818 1.5 christos AcpiDmFindNameByIndex(PldInfo->HorizontalPosition, AcpiGbl_PldHorizontalPositionList));
819 1.4 christos
820 1.2 christos AcpiOsPrintf (ACPI_PLD_OUTPUTSTR, "PLD_Shape",
821 1.5 christos AcpiDmFindNameByIndex(PldInfo->Shape, AcpiGbl_PldShapeList));
822 1.2 christos AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_GroupOrientation", PldInfo->GroupOrientation);
823 1.4 christos
824 1.2 christos AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_GroupToken", PldInfo->GroupToken);
825 1.2 christos AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_GroupPosition", PldInfo->GroupPosition);
826 1.2 christos AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_Bay", PldInfo->Bay);
827 1.2 christos
828 1.2 christos /* Fourth 32-bit dword */
829 1.2 christos
830 1.2 christos AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_Ejectable", PldInfo->Ejectable);
831 1.2 christos AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_EjectRequired", PldInfo->OspmEjectRequired);
832 1.2 christos AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_CabinetNumber", PldInfo->CabinetNumber);
833 1.2 christos AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_CardCageNumber", PldInfo->CardCageNumber);
834 1.2 christos AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_Reference", PldInfo->Reference);
835 1.2 christos AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_Rotation", PldInfo->Rotation);
836 1.2 christos
837 1.4 christos if (ByteCount >= ACPI_PLD_REV2_BUFFER_SIZE)
838 1.2 christos {
839 1.2 christos AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_Order", PldInfo->Order);
840 1.2 christos
841 1.4 christos /* Fifth 32-bit dword */
842 1.2 christos
843 1.4 christos AcpiOsPrintf (ACPI_PLD_OUTPUT16, "PLD_VerticalOffset", PldInfo->VerticalOffset);
844 1.4 christos AcpiOsPrintf (ACPI_PLD_OUTPUT16P, "PLD_HorizontalOffset", PldInfo->HorizontalOffset);
845 1.4 christos }
846 1.4 christos else /* Rev 1 buffer */
847 1.2 christos {
848 1.4 christos AcpiOsPrintf (ACPI_PLD_OUTPUT08P, "PLD_Order", PldInfo->Order);
849 1.2 christos }
850 1.2 christos
851 1.2 christos ACPI_FREE (PldInfo);
852 1.2 christos }
853 1.2 christos
854 1.2 christos
855 1.2 christos /*******************************************************************************
856 1.2 christos *
857 1.1 jruoho * FUNCTION: AcpiDmUnicode
858 1.1 jruoho *
859 1.1 jruoho * PARAMETERS: Op - Byte List op containing Unicode string
860 1.1 jruoho *
861 1.1 jruoho * RETURN: None
862 1.1 jruoho *
863 1.2 christos * DESCRIPTION: Dump Unicode string as a standard ASCII string. (Remove
864 1.1 jruoho * the extra zero bytes).
865 1.1 jruoho *
866 1.1 jruoho ******************************************************************************/
867 1.1 jruoho
868 1.1 jruoho static void
869 1.1 jruoho AcpiDmUnicode (
870 1.1 jruoho ACPI_PARSE_OBJECT *Op)
871 1.1 jruoho {
872 1.1 jruoho UINT16 *WordData;
873 1.1 jruoho UINT32 WordCount;
874 1.1 jruoho UINT32 i;
875 1.2 christos int OutputValue;
876 1.1 jruoho
877 1.1 jruoho
878 1.1 jruoho /* Extract the buffer info as a WORD buffer */
879 1.1 jruoho
880 1.1 jruoho WordData = ACPI_CAST_PTR (UINT16, Op->Named.Data);
881 1.1 jruoho WordCount = ACPI_DIV_2 (((UINT32) Op->Common.Value.Integer));
882 1.1 jruoho
883 1.2 christos /* Write every other byte as an ASCII character */
884 1.1 jruoho
885 1.1 jruoho AcpiOsPrintf ("\"");
886 1.2 christos for (i = 0; i < (WordCount - 1); i++)
887 1.2 christos {
888 1.2 christos OutputValue = (int) WordData[i];
889 1.1 jruoho
890 1.2 christos /* Handle values that must be escaped */
891 1.1 jruoho
892 1.2 christos if ((OutputValue == '\"') ||
893 1.2 christos (OutputValue == '\\'))
894 1.2 christos {
895 1.2 christos AcpiOsPrintf ("\\%c", OutputValue);
896 1.2 christos }
897 1.3 christos else if (!isprint (OutputValue))
898 1.2 christos {
899 1.2 christos AcpiOsPrintf ("\\x%2.2X", OutputValue);
900 1.2 christos }
901 1.2 christos else
902 1.2 christos {
903 1.2 christos AcpiOsPrintf ("%c", OutputValue);
904 1.2 christos }
905 1.1 jruoho }
906 1.1 jruoho
907 1.1 jruoho AcpiOsPrintf ("\")");
908 1.1 jruoho }
909 1.1 jruoho
910 1.1 jruoho
911 1.1 jruoho /*******************************************************************************
912 1.1 jruoho *
913 1.2 christos * FUNCTION: AcpiDmGetHardwareIdType
914 1.1 jruoho *
915 1.1 jruoho * PARAMETERS: Op - Op to be examined
916 1.1 jruoho *
917 1.1 jruoho * RETURN: None
918 1.1 jruoho *
919 1.2 christos * DESCRIPTION: Determine the type of the argument to a _HID or _CID
920 1.2 christos * 1) Strings are allowed
921 1.2 christos * 2) If Integer, determine if it is a valid EISAID
922 1.1 jruoho *
923 1.1 jruoho ******************************************************************************/
924 1.1 jruoho
925 1.1 jruoho static void
926 1.2 christos AcpiDmGetHardwareIdType (
927 1.1 jruoho ACPI_PARSE_OBJECT *Op)
928 1.1 jruoho {
929 1.1 jruoho UINT32 BigEndianId;
930 1.1 jruoho UINT32 Prefix[3];
931 1.1 jruoho UINT32 i;
932 1.1 jruoho
933 1.1 jruoho
934 1.2 christos switch (Op->Common.AmlOpcode)
935 1.2 christos {
936 1.2 christos case AML_STRING_OP:
937 1.2 christos
938 1.2 christos /* Mark this string as an _HID/_CID string */
939 1.2 christos
940 1.2 christos Op->Common.DisasmOpcode = ACPI_DASM_HID_STRING;
941 1.2 christos break;
942 1.2 christos
943 1.2 christos case AML_WORD_OP:
944 1.2 christos case AML_DWORD_OP:
945 1.1 jruoho
946 1.2 christos /* Determine if a Word/Dword is a valid encoded EISAID */
947 1.1 jruoho
948 1.2 christos /* Swap from little-endian to big-endian to simplify conversion */
949 1.1 jruoho
950 1.2 christos BigEndianId = AcpiUtDwordByteSwap ((UINT32) Op->Common.Value.Integer);
951 1.1 jruoho
952 1.2 christos /* Create the 3 leading ASCII letters */
953 1.1 jruoho
954 1.2 christos Prefix[0] = ((BigEndianId >> 26) & 0x1F) + 0x40;
955 1.2 christos Prefix[1] = ((BigEndianId >> 21) & 0x1F) + 0x40;
956 1.2 christos Prefix[2] = ((BigEndianId >> 16) & 0x1F) + 0x40;
957 1.1 jruoho
958 1.2 christos /* Verify that all 3 are ascii and alpha */
959 1.1 jruoho
960 1.2 christos for (i = 0; i < 3; i++)
961 1.1 jruoho {
962 1.2 christos if (!ACPI_IS_ASCII (Prefix[i]) ||
963 1.3 christos !isalpha (Prefix[i]))
964 1.2 christos {
965 1.2 christos return;
966 1.2 christos }
967 1.1 jruoho }
968 1.1 jruoho
969 1.10 christos /* Mark this node as convertible to an EISA ID string */
970 1.2 christos
971 1.2 christos Op->Common.DisasmOpcode = ACPI_DASM_EISAID;
972 1.2 christos break;
973 1.1 jruoho
974 1.2 christos default:
975 1.2 christos break;
976 1.2 christos }
977 1.1 jruoho }
978 1.1 jruoho
979 1.1 jruoho
980 1.1 jruoho /*******************************************************************************
981 1.1 jruoho *
982 1.2 christos * FUNCTION: AcpiDmCheckForHardwareId
983 1.1 jruoho *
984 1.1 jruoho * PARAMETERS: Op - Op to be examined
985 1.1 jruoho *
986 1.1 jruoho * RETURN: None
987 1.1 jruoho *
988 1.2 christos * DESCRIPTION: Determine if a Name() Op is a _HID/_CID.
989 1.1 jruoho *
990 1.1 jruoho ******************************************************************************/
991 1.1 jruoho
992 1.1 jruoho void
993 1.2 christos AcpiDmCheckForHardwareId (
994 1.1 jruoho ACPI_PARSE_OBJECT *Op)
995 1.1 jruoho {
996 1.1 jruoho UINT32 Name;
997 1.1 jruoho ACPI_PARSE_OBJECT *NextOp;
998 1.1 jruoho
999 1.1 jruoho
1000 1.1 jruoho /* Get the NameSegment */
1001 1.1 jruoho
1002 1.1 jruoho Name = AcpiPsGetName (Op);
1003 1.1 jruoho if (!Name)
1004 1.1 jruoho {
1005 1.1 jruoho return;
1006 1.1 jruoho }
1007 1.1 jruoho
1008 1.1 jruoho NextOp = AcpiPsGetDepthNext (NULL, Op);
1009 1.1 jruoho if (!NextOp)
1010 1.1 jruoho {
1011 1.1 jruoho return;
1012 1.1 jruoho }
1013 1.1 jruoho
1014 1.1 jruoho /* Check for _HID - has one argument */
1015 1.1 jruoho
1016 1.10 christos if (ACPI_COMPARE_NAMESEG (&Name, METHOD_NAME__HID))
1017 1.1 jruoho {
1018 1.2 christos AcpiDmGetHardwareIdType (NextOp);
1019 1.1 jruoho return;
1020 1.1 jruoho }
1021 1.1 jruoho
1022 1.1 jruoho /* Exit if not _CID */
1023 1.1 jruoho
1024 1.10 christos if (!ACPI_COMPARE_NAMESEG (&Name, METHOD_NAME__CID))
1025 1.1 jruoho {
1026 1.1 jruoho return;
1027 1.1 jruoho }
1028 1.1 jruoho
1029 1.1 jruoho /* _CID can contain a single argument or a package */
1030 1.1 jruoho
1031 1.1 jruoho if (NextOp->Common.AmlOpcode != AML_PACKAGE_OP)
1032 1.1 jruoho {
1033 1.2 christos AcpiDmGetHardwareIdType (NextOp);
1034 1.1 jruoho return;
1035 1.1 jruoho }
1036 1.1 jruoho
1037 1.2 christos /* _CID with Package: get the package length, check all elements */
1038 1.1 jruoho
1039 1.1 jruoho NextOp = AcpiPsGetDepthNext (NULL, NextOp);
1040 1.2 christos if (!NextOp)
1041 1.2 christos {
1042 1.2 christos return;
1043 1.2 christos }
1044 1.1 jruoho
1045 1.1 jruoho /* Don't need to use the length, just walk the peer list */
1046 1.1 jruoho
1047 1.1 jruoho NextOp = NextOp->Common.Next;
1048 1.1 jruoho while (NextOp)
1049 1.1 jruoho {
1050 1.2 christos AcpiDmGetHardwareIdType (NextOp);
1051 1.1 jruoho NextOp = NextOp->Common.Next;
1052 1.1 jruoho }
1053 1.1 jruoho }
1054 1.1 jruoho
1055 1.1 jruoho
1056 1.1 jruoho /*******************************************************************************
1057 1.1 jruoho *
1058 1.2 christos * FUNCTION: AcpiDmDecompressEisaId
1059 1.1 jruoho *
1060 1.1 jruoho * PARAMETERS: EncodedId - Raw encoded EISA ID.
1061 1.1 jruoho *
1062 1.1 jruoho * RETURN: None
1063 1.1 jruoho *
1064 1.2 christos * DESCRIPTION: Convert an encoded EISAID back to the original ASCII String
1065 1.2 christos * and emit the correct ASL statement. If the ID is known, emit
1066 1.2 christos * a description of the ID as a comment.
1067 1.1 jruoho *
1068 1.1 jruoho ******************************************************************************/
1069 1.1 jruoho
1070 1.1 jruoho void
1071 1.2 christos AcpiDmDecompressEisaId (
1072 1.1 jruoho UINT32 EncodedId)
1073 1.1 jruoho {
1074 1.2 christos char IdBuffer[ACPI_EISAID_STRING_SIZE];
1075 1.2 christos const AH_DEVICE_ID *Info;
1076 1.1 jruoho
1077 1.1 jruoho
1078 1.2 christos /* Convert EISAID to a string an emit the statement */
1079 1.1 jruoho
1080 1.2 christos AcpiExEisaIdToString (IdBuffer, EncodedId);
1081 1.2 christos AcpiOsPrintf ("EisaId (\"%s\")", IdBuffer);
1082 1.1 jruoho
1083 1.2 christos /* If we know about the ID, emit the description */
1084 1.1 jruoho
1085 1.2 christos Info = AcpiAhMatchHardwareId (IdBuffer);
1086 1.2 christos if (Info)
1087 1.2 christos {
1088 1.2 christos AcpiOsPrintf (" /* %s */", Info->Description);
1089 1.2 christos }
1090 1.1 jruoho }
1091