dmbuffer.c revision 1.1.1.2.2.2 1 1.1.1.2.2.2 bouyer /*******************************************************************************
2 1.1.1.2.2.2 bouyer *
3 1.1.1.2.2.2 bouyer * Module Name: dmbuffer - AML disassembler, buffer and string support
4 1.1.1.2.2.2 bouyer *
5 1.1.1.2.2.2 bouyer ******************************************************************************/
6 1.1.1.2.2.2 bouyer
7 1.1.1.2.2.2 bouyer /*
8 1.1.1.2.2.2 bouyer * Copyright (C) 2000 - 2011, Intel Corp.
9 1.1.1.2.2.2 bouyer * All rights reserved.
10 1.1.1.2.2.2 bouyer *
11 1.1.1.2.2.2 bouyer * Redistribution and use in source and binary forms, with or without
12 1.1.1.2.2.2 bouyer * modification, are permitted provided that the following conditions
13 1.1.1.2.2.2 bouyer * are met:
14 1.1.1.2.2.2 bouyer * 1. Redistributions of source code must retain the above copyright
15 1.1.1.2.2.2 bouyer * notice, this list of conditions, and the following disclaimer,
16 1.1.1.2.2.2 bouyer * without modification.
17 1.1.1.2.2.2 bouyer * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.1.1.2.2.2 bouyer * substantially similar to the "NO WARRANTY" disclaimer below
19 1.1.1.2.2.2 bouyer * ("Disclaimer") and any redistribution must be conditioned upon
20 1.1.1.2.2.2 bouyer * including a substantially similar Disclaimer requirement for further
21 1.1.1.2.2.2 bouyer * binary redistribution.
22 1.1.1.2.2.2 bouyer * 3. Neither the names of the above-listed copyright holders nor the names
23 1.1.1.2.2.2 bouyer * of any contributors may be used to endorse or promote products derived
24 1.1.1.2.2.2 bouyer * from this software without specific prior written permission.
25 1.1.1.2.2.2 bouyer *
26 1.1.1.2.2.2 bouyer * Alternatively, this software may be distributed under the terms of the
27 1.1.1.2.2.2 bouyer * GNU General Public License ("GPL") version 2 as published by the Free
28 1.1.1.2.2.2 bouyer * Software Foundation.
29 1.1.1.2.2.2 bouyer *
30 1.1.1.2.2.2 bouyer * NO WARRANTY
31 1.1.1.2.2.2 bouyer * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.1.1.2.2.2 bouyer * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.1.1.2.2.2 bouyer * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.1.1.2.2.2 bouyer * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.1.1.2.2.2 bouyer * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.1.1.2.2.2 bouyer * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.1.1.2.2.2 bouyer * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.1.1.2.2.2 bouyer * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.1.1.2.2.2 bouyer * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.1.1.2.2.2 bouyer * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.1.1.2.2.2 bouyer * POSSIBILITY OF SUCH DAMAGES.
42 1.1.1.2.2.2 bouyer */
43 1.1.1.2.2.2 bouyer
44 1.1.1.2.2.2 bouyer
45 1.1.1.2.2.2 bouyer #include "acpi.h"
46 1.1.1.2.2.2 bouyer #include "accommon.h"
47 1.1.1.2.2.2 bouyer #include "acdisasm.h"
48 1.1.1.2.2.2 bouyer #include "acparser.h"
49 1.1.1.2.2.2 bouyer #include "amlcode.h"
50 1.1.1.2.2.2 bouyer
51 1.1.1.2.2.2 bouyer
52 1.1.1.2.2.2 bouyer #ifdef ACPI_DISASSEMBLER
53 1.1.1.2.2.2 bouyer
54 1.1.1.2.2.2 bouyer #define _COMPONENT ACPI_CA_DEBUGGER
55 1.1.1.2.2.2 bouyer ACPI_MODULE_NAME ("dmbuffer")
56 1.1.1.2.2.2 bouyer
57 1.1.1.2.2.2 bouyer /* Local prototypes */
58 1.1.1.2.2.2 bouyer
59 1.1.1.2.2.2 bouyer static void
60 1.1.1.2.2.2 bouyer AcpiDmUnicode (
61 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op);
62 1.1.1.2.2.2 bouyer
63 1.1.1.2.2.2 bouyer static void
64 1.1.1.2.2.2 bouyer AcpiDmIsEisaIdElement (
65 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op);
66 1.1.1.2.2.2 bouyer
67 1.1.1.2.2.2 bouyer
68 1.1.1.2.2.2 bouyer /*******************************************************************************
69 1.1.1.2.2.2 bouyer *
70 1.1.1.2.2.2 bouyer * FUNCTION: AcpiDmDisasmByteList
71 1.1.1.2.2.2 bouyer *
72 1.1.1.2.2.2 bouyer * PARAMETERS: Level - Current source code indentation level
73 1.1.1.2.2.2 bouyer * ByteData - Pointer to the byte list
74 1.1.1.2.2.2 bouyer * ByteCount - Length of the byte list
75 1.1.1.2.2.2 bouyer *
76 1.1.1.2.2.2 bouyer * RETURN: None
77 1.1.1.2.2.2 bouyer *
78 1.1.1.2.2.2 bouyer * DESCRIPTION: Dump an AML "ByteList" in Hex format. 8 bytes per line, prefixed
79 1.1.1.2.2.2 bouyer * with the hex buffer offset.
80 1.1.1.2.2.2 bouyer *
81 1.1.1.2.2.2 bouyer ******************************************************************************/
82 1.1.1.2.2.2 bouyer
83 1.1.1.2.2.2 bouyer void
84 1.1.1.2.2.2 bouyer AcpiDmDisasmByteList (
85 1.1.1.2.2.2 bouyer UINT32 Level,
86 1.1.1.2.2.2 bouyer UINT8 *ByteData,
87 1.1.1.2.2.2 bouyer UINT32 ByteCount)
88 1.1.1.2.2.2 bouyer {
89 1.1.1.2.2.2 bouyer UINT32 i;
90 1.1.1.2.2.2 bouyer
91 1.1.1.2.2.2 bouyer
92 1.1.1.2.2.2 bouyer if (!ByteCount)
93 1.1.1.2.2.2 bouyer {
94 1.1.1.2.2.2 bouyer return;
95 1.1.1.2.2.2 bouyer }
96 1.1.1.2.2.2 bouyer
97 1.1.1.2.2.2 bouyer /* Dump the byte list */
98 1.1.1.2.2.2 bouyer
99 1.1.1.2.2.2 bouyer for (i = 0; i < ByteCount; i++)
100 1.1.1.2.2.2 bouyer {
101 1.1.1.2.2.2 bouyer /* New line every 8 bytes */
102 1.1.1.2.2.2 bouyer
103 1.1.1.2.2.2 bouyer if (((i % 8) == 0) && (i < ByteCount))
104 1.1.1.2.2.2 bouyer {
105 1.1.1.2.2.2 bouyer if (i > 0)
106 1.1.1.2.2.2 bouyer {
107 1.1.1.2.2.2 bouyer AcpiOsPrintf ("\n");
108 1.1.1.2.2.2 bouyer }
109 1.1.1.2.2.2 bouyer
110 1.1.1.2.2.2 bouyer AcpiDmIndent (Level);
111 1.1.1.2.2.2 bouyer if (ByteCount > 7)
112 1.1.1.2.2.2 bouyer {
113 1.1.1.2.2.2 bouyer AcpiOsPrintf ("/* %04X */ ", i);
114 1.1.1.2.2.2 bouyer }
115 1.1.1.2.2.2 bouyer }
116 1.1.1.2.2.2 bouyer
117 1.1.1.2.2.2 bouyer AcpiOsPrintf ("0x%2.2X", (UINT32) ByteData[i]);
118 1.1.1.2.2.2 bouyer
119 1.1.1.2.2.2 bouyer /* Add comma if there are more bytes to display */
120 1.1.1.2.2.2 bouyer
121 1.1.1.2.2.2 bouyer if (i < (ByteCount -1))
122 1.1.1.2.2.2 bouyer {
123 1.1.1.2.2.2 bouyer AcpiOsPrintf (", ");
124 1.1.1.2.2.2 bouyer }
125 1.1.1.2.2.2 bouyer }
126 1.1.1.2.2.2 bouyer
127 1.1.1.2.2.2 bouyer if (Level)
128 1.1.1.2.2.2 bouyer {
129 1.1.1.2.2.2 bouyer AcpiOsPrintf ("\n");
130 1.1.1.2.2.2 bouyer }
131 1.1.1.2.2.2 bouyer }
132 1.1.1.2.2.2 bouyer
133 1.1.1.2.2.2 bouyer
134 1.1.1.2.2.2 bouyer /*******************************************************************************
135 1.1.1.2.2.2 bouyer *
136 1.1.1.2.2.2 bouyer * FUNCTION: AcpiDmByteList
137 1.1.1.2.2.2 bouyer *
138 1.1.1.2.2.2 bouyer * PARAMETERS: Info - Parse tree walk info
139 1.1.1.2.2.2 bouyer * Op - Byte list op
140 1.1.1.2.2.2 bouyer *
141 1.1.1.2.2.2 bouyer * RETURN: None
142 1.1.1.2.2.2 bouyer *
143 1.1.1.2.2.2 bouyer * DESCRIPTION: Dump a buffer byte list, handling the various types of buffers.
144 1.1.1.2.2.2 bouyer * Buffer type must be already set in the Op DisasmOpcode.
145 1.1.1.2.2.2 bouyer *
146 1.1.1.2.2.2 bouyer ******************************************************************************/
147 1.1.1.2.2.2 bouyer
148 1.1.1.2.2.2 bouyer void
149 1.1.1.2.2.2 bouyer AcpiDmByteList (
150 1.1.1.2.2.2 bouyer ACPI_OP_WALK_INFO *Info,
151 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op)
152 1.1.1.2.2.2 bouyer {
153 1.1.1.2.2.2 bouyer UINT8 *ByteData;
154 1.1.1.2.2.2 bouyer UINT32 ByteCount;
155 1.1.1.2.2.2 bouyer
156 1.1.1.2.2.2 bouyer
157 1.1.1.2.2.2 bouyer ByteData = Op->Named.Data;
158 1.1.1.2.2.2 bouyer ByteCount = (UINT32) Op->Common.Value.Integer;
159 1.1.1.2.2.2 bouyer
160 1.1.1.2.2.2 bouyer /*
161 1.1.1.2.2.2 bouyer * The byte list belongs to a buffer, and can be produced by either
162 1.1.1.2.2.2 bouyer * a ResourceTemplate, Unicode, quoted string, or a plain byte list.
163 1.1.1.2.2.2 bouyer */
164 1.1.1.2.2.2 bouyer switch (Op->Common.Parent->Common.DisasmOpcode)
165 1.1.1.2.2.2 bouyer {
166 1.1.1.2.2.2 bouyer case ACPI_DASM_RESOURCE:
167 1.1.1.2.2.2 bouyer
168 1.1.1.2.2.2 bouyer AcpiDmResourceTemplate (Info, Op->Common.Parent, ByteData, ByteCount);
169 1.1.1.2.2.2 bouyer break;
170 1.1.1.2.2.2 bouyer
171 1.1.1.2.2.2 bouyer case ACPI_DASM_STRING:
172 1.1.1.2.2.2 bouyer
173 1.1.1.2.2.2 bouyer AcpiDmIndent (Info->Level);
174 1.1.1.2.2.2 bouyer AcpiUtPrintString ((char *) ByteData, ACPI_UINT8_MAX);
175 1.1.1.2.2.2 bouyer AcpiOsPrintf ("\n");
176 1.1.1.2.2.2 bouyer break;
177 1.1.1.2.2.2 bouyer
178 1.1.1.2.2.2 bouyer case ACPI_DASM_UNICODE:
179 1.1.1.2.2.2 bouyer
180 1.1.1.2.2.2 bouyer AcpiDmUnicode (Op);
181 1.1.1.2.2.2 bouyer break;
182 1.1.1.2.2.2 bouyer
183 1.1.1.2.2.2 bouyer case ACPI_DASM_BUFFER:
184 1.1.1.2.2.2 bouyer default:
185 1.1.1.2.2.2 bouyer
186 1.1.1.2.2.2 bouyer /*
187 1.1.1.2.2.2 bouyer * Not a resource, string, or unicode string.
188 1.1.1.2.2.2 bouyer * Just dump the buffer
189 1.1.1.2.2.2 bouyer */
190 1.1.1.2.2.2 bouyer AcpiDmDisasmByteList (Info->Level, ByteData, ByteCount);
191 1.1.1.2.2.2 bouyer break;
192 1.1.1.2.2.2 bouyer }
193 1.1.1.2.2.2 bouyer }
194 1.1.1.2.2.2 bouyer
195 1.1.1.2.2.2 bouyer
196 1.1.1.2.2.2 bouyer /*******************************************************************************
197 1.1.1.2.2.2 bouyer *
198 1.1.1.2.2.2 bouyer * FUNCTION: AcpiDmIsUnicodeBuffer
199 1.1.1.2.2.2 bouyer *
200 1.1.1.2.2.2 bouyer * PARAMETERS: Op - Buffer Object to be examined
201 1.1.1.2.2.2 bouyer *
202 1.1.1.2.2.2 bouyer * RETURN: TRUE if buffer contains a UNICODE string
203 1.1.1.2.2.2 bouyer *
204 1.1.1.2.2.2 bouyer * DESCRIPTION: Determine if a buffer Op contains a Unicode string
205 1.1.1.2.2.2 bouyer *
206 1.1.1.2.2.2 bouyer ******************************************************************************/
207 1.1.1.2.2.2 bouyer
208 1.1.1.2.2.2 bouyer BOOLEAN
209 1.1.1.2.2.2 bouyer AcpiDmIsUnicodeBuffer (
210 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op)
211 1.1.1.2.2.2 bouyer {
212 1.1.1.2.2.2 bouyer UINT8 *ByteData;
213 1.1.1.2.2.2 bouyer UINT32 ByteCount;
214 1.1.1.2.2.2 bouyer UINT32 WordCount;
215 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *SizeOp;
216 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *NextOp;
217 1.1.1.2.2.2 bouyer UINT32 i;
218 1.1.1.2.2.2 bouyer
219 1.1.1.2.2.2 bouyer
220 1.1.1.2.2.2 bouyer /* Buffer size is the buffer argument */
221 1.1.1.2.2.2 bouyer
222 1.1.1.2.2.2 bouyer SizeOp = Op->Common.Value.Arg;
223 1.1.1.2.2.2 bouyer
224 1.1.1.2.2.2 bouyer /* Next, the initializer byte list to examine */
225 1.1.1.2.2.2 bouyer
226 1.1.1.2.2.2 bouyer NextOp = SizeOp->Common.Next;
227 1.1.1.2.2.2 bouyer if (!NextOp)
228 1.1.1.2.2.2 bouyer {
229 1.1.1.2.2.2 bouyer return (FALSE);
230 1.1.1.2.2.2 bouyer }
231 1.1.1.2.2.2 bouyer
232 1.1.1.2.2.2 bouyer /* Extract the byte list info */
233 1.1.1.2.2.2 bouyer
234 1.1.1.2.2.2 bouyer ByteData = NextOp->Named.Data;
235 1.1.1.2.2.2 bouyer ByteCount = (UINT32) NextOp->Common.Value.Integer;
236 1.1.1.2.2.2 bouyer WordCount = ACPI_DIV_2 (ByteCount);
237 1.1.1.2.2.2 bouyer
238 1.1.1.2.2.2 bouyer /*
239 1.1.1.2.2.2 bouyer * Unicode string must have an even number of bytes and last
240 1.1.1.2.2.2 bouyer * word must be zero
241 1.1.1.2.2.2 bouyer */
242 1.1.1.2.2.2 bouyer if ((!ByteCount) ||
243 1.1.1.2.2.2 bouyer (ByteCount < 4) ||
244 1.1.1.2.2.2 bouyer (ByteCount & 1) ||
245 1.1.1.2.2.2 bouyer ((UINT16 *) (void *) ByteData)[WordCount - 1] != 0)
246 1.1.1.2.2.2 bouyer {
247 1.1.1.2.2.2 bouyer return (FALSE);
248 1.1.1.2.2.2 bouyer }
249 1.1.1.2.2.2 bouyer
250 1.1.1.2.2.2 bouyer /* For each word, 1st byte must be ascii, 2nd byte must be zero */
251 1.1.1.2.2.2 bouyer
252 1.1.1.2.2.2 bouyer for (i = 0; i < (ByteCount - 2); i += 2)
253 1.1.1.2.2.2 bouyer {
254 1.1.1.2.2.2 bouyer if ((!ACPI_IS_PRINT (ByteData[i])) ||
255 1.1.1.2.2.2 bouyer (ByteData[(ACPI_SIZE) i + 1] != 0))
256 1.1.1.2.2.2 bouyer {
257 1.1.1.2.2.2 bouyer return (FALSE);
258 1.1.1.2.2.2 bouyer }
259 1.1.1.2.2.2 bouyer }
260 1.1.1.2.2.2 bouyer
261 1.1.1.2.2.2 bouyer /* Ignore the Size argument in the disassembly of this buffer op */
262 1.1.1.2.2.2 bouyer
263 1.1.1.2.2.2 bouyer SizeOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
264 1.1.1.2.2.2 bouyer return (TRUE);
265 1.1.1.2.2.2 bouyer }
266 1.1.1.2.2.2 bouyer
267 1.1.1.2.2.2 bouyer
268 1.1.1.2.2.2 bouyer /*******************************************************************************
269 1.1.1.2.2.2 bouyer *
270 1.1.1.2.2.2 bouyer * FUNCTION: AcpiDmIsStringBuffer
271 1.1.1.2.2.2 bouyer *
272 1.1.1.2.2.2 bouyer * PARAMETERS: Op - Buffer Object to be examined
273 1.1.1.2.2.2 bouyer *
274 1.1.1.2.2.2 bouyer * RETURN: TRUE if buffer contains a ASCII string, FALSE otherwise
275 1.1.1.2.2.2 bouyer *
276 1.1.1.2.2.2 bouyer * DESCRIPTION: Determine if a buffer Op contains a ASCII string
277 1.1.1.2.2.2 bouyer *
278 1.1.1.2.2.2 bouyer ******************************************************************************/
279 1.1.1.2.2.2 bouyer
280 1.1.1.2.2.2 bouyer BOOLEAN
281 1.1.1.2.2.2 bouyer AcpiDmIsStringBuffer (
282 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op)
283 1.1.1.2.2.2 bouyer {
284 1.1.1.2.2.2 bouyer UINT8 *ByteData;
285 1.1.1.2.2.2 bouyer UINT32 ByteCount;
286 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *SizeOp;
287 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *NextOp;
288 1.1.1.2.2.2 bouyer UINT32 i;
289 1.1.1.2.2.2 bouyer
290 1.1.1.2.2.2 bouyer
291 1.1.1.2.2.2 bouyer /* Buffer size is the buffer argument */
292 1.1.1.2.2.2 bouyer
293 1.1.1.2.2.2 bouyer SizeOp = Op->Common.Value.Arg;
294 1.1.1.2.2.2 bouyer
295 1.1.1.2.2.2 bouyer /* Next, the initializer byte list to examine */
296 1.1.1.2.2.2 bouyer
297 1.1.1.2.2.2 bouyer NextOp = SizeOp->Common.Next;
298 1.1.1.2.2.2 bouyer if (!NextOp)
299 1.1.1.2.2.2 bouyer {
300 1.1.1.2.2.2 bouyer return (FALSE);
301 1.1.1.2.2.2 bouyer }
302 1.1.1.2.2.2 bouyer
303 1.1.1.2.2.2 bouyer /* Extract the byte list info */
304 1.1.1.2.2.2 bouyer
305 1.1.1.2.2.2 bouyer ByteData = NextOp->Named.Data;
306 1.1.1.2.2.2 bouyer ByteCount = (UINT32) NextOp->Common.Value.Integer;
307 1.1.1.2.2.2 bouyer
308 1.1.1.2.2.2 bouyer /* Last byte must be the null terminator */
309 1.1.1.2.2.2 bouyer
310 1.1.1.2.2.2 bouyer if ((!ByteCount) ||
311 1.1.1.2.2.2 bouyer (ByteCount < 2) ||
312 1.1.1.2.2.2 bouyer (ByteData[ByteCount-1] != 0))
313 1.1.1.2.2.2 bouyer {
314 1.1.1.2.2.2 bouyer return (FALSE);
315 1.1.1.2.2.2 bouyer }
316 1.1.1.2.2.2 bouyer
317 1.1.1.2.2.2 bouyer for (i = 0; i < (ByteCount - 1); i++)
318 1.1.1.2.2.2 bouyer {
319 1.1.1.2.2.2 bouyer /* TBD: allow some escapes (non-ascii chars).
320 1.1.1.2.2.2 bouyer * they will be handled in the string output routine
321 1.1.1.2.2.2 bouyer */
322 1.1.1.2.2.2 bouyer
323 1.1.1.2.2.2 bouyer if (!ACPI_IS_PRINT (ByteData[i]))
324 1.1.1.2.2.2 bouyer {
325 1.1.1.2.2.2 bouyer return (FALSE);
326 1.1.1.2.2.2 bouyer }
327 1.1.1.2.2.2 bouyer }
328 1.1.1.2.2.2 bouyer
329 1.1.1.2.2.2 bouyer return (TRUE);
330 1.1.1.2.2.2 bouyer }
331 1.1.1.2.2.2 bouyer
332 1.1.1.2.2.2 bouyer
333 1.1.1.2.2.2 bouyer /*******************************************************************************
334 1.1.1.2.2.2 bouyer *
335 1.1.1.2.2.2 bouyer * FUNCTION: AcpiDmUnicode
336 1.1.1.2.2.2 bouyer *
337 1.1.1.2.2.2 bouyer * PARAMETERS: Op - Byte List op containing Unicode string
338 1.1.1.2.2.2 bouyer *
339 1.1.1.2.2.2 bouyer * RETURN: None
340 1.1.1.2.2.2 bouyer *
341 1.1.1.2.2.2 bouyer * DESCRIPTION: Dump Unicode string as a standard ASCII string. (Remove
342 1.1.1.2.2.2 bouyer * the extra zero bytes).
343 1.1.1.2.2.2 bouyer *
344 1.1.1.2.2.2 bouyer ******************************************************************************/
345 1.1.1.2.2.2 bouyer
346 1.1.1.2.2.2 bouyer static void
347 1.1.1.2.2.2 bouyer AcpiDmUnicode (
348 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op)
349 1.1.1.2.2.2 bouyer {
350 1.1.1.2.2.2 bouyer UINT16 *WordData;
351 1.1.1.2.2.2 bouyer UINT32 WordCount;
352 1.1.1.2.2.2 bouyer UINT32 i;
353 1.1.1.2.2.2 bouyer
354 1.1.1.2.2.2 bouyer
355 1.1.1.2.2.2 bouyer /* Extract the buffer info as a WORD buffer */
356 1.1.1.2.2.2 bouyer
357 1.1.1.2.2.2 bouyer WordData = ACPI_CAST_PTR (UINT16, Op->Named.Data);
358 1.1.1.2.2.2 bouyer WordCount = ACPI_DIV_2 (((UINT32) Op->Common.Value.Integer));
359 1.1.1.2.2.2 bouyer
360 1.1.1.2.2.2 bouyer
361 1.1.1.2.2.2 bouyer AcpiOsPrintf ("\"");
362 1.1.1.2.2.2 bouyer
363 1.1.1.2.2.2 bouyer /* Write every other byte as an ASCII character */
364 1.1.1.2.2.2 bouyer
365 1.1.1.2.2.2 bouyer for (i = 0; i < (WordCount - 1); i++)
366 1.1.1.2.2.2 bouyer {
367 1.1.1.2.2.2 bouyer AcpiOsPrintf ("%c", (int) WordData[i]);
368 1.1.1.2.2.2 bouyer }
369 1.1.1.2.2.2 bouyer
370 1.1.1.2.2.2 bouyer AcpiOsPrintf ("\")");
371 1.1.1.2.2.2 bouyer }
372 1.1.1.2.2.2 bouyer
373 1.1.1.2.2.2 bouyer
374 1.1.1.2.2.2 bouyer /*******************************************************************************
375 1.1.1.2.2.2 bouyer *
376 1.1.1.2.2.2 bouyer * FUNCTION: AcpiDmIsEisaIdElement
377 1.1.1.2.2.2 bouyer *
378 1.1.1.2.2.2 bouyer * PARAMETERS: Op - Op to be examined
379 1.1.1.2.2.2 bouyer *
380 1.1.1.2.2.2 bouyer * RETURN: None
381 1.1.1.2.2.2 bouyer *
382 1.1.1.2.2.2 bouyer * DESCRIPTION: Determine if an Op (argument to _HID or _CID) can be converted
383 1.1.1.2.2.2 bouyer * to an EISA ID.
384 1.1.1.2.2.2 bouyer *
385 1.1.1.2.2.2 bouyer ******************************************************************************/
386 1.1.1.2.2.2 bouyer
387 1.1.1.2.2.2 bouyer static void
388 1.1.1.2.2.2 bouyer AcpiDmIsEisaIdElement (
389 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op)
390 1.1.1.2.2.2 bouyer {
391 1.1.1.2.2.2 bouyer UINT32 BigEndianId;
392 1.1.1.2.2.2 bouyer UINT32 Prefix[3];
393 1.1.1.2.2.2 bouyer UINT32 i;
394 1.1.1.2.2.2 bouyer
395 1.1.1.2.2.2 bouyer
396 1.1.1.2.2.2 bouyer /* The parameter must be either a word or a dword */
397 1.1.1.2.2.2 bouyer
398 1.1.1.2.2.2 bouyer if ((Op->Common.AmlOpcode != AML_DWORD_OP) &&
399 1.1.1.2.2.2 bouyer (Op->Common.AmlOpcode != AML_WORD_OP))
400 1.1.1.2.2.2 bouyer {
401 1.1.1.2.2.2 bouyer return;
402 1.1.1.2.2.2 bouyer }
403 1.1.1.2.2.2 bouyer
404 1.1.1.2.2.2 bouyer /* Swap from little-endian to big-endian to simplify conversion */
405 1.1.1.2.2.2 bouyer
406 1.1.1.2.2.2 bouyer BigEndianId = AcpiUtDwordByteSwap ((UINT32) Op->Common.Value.Integer);
407 1.1.1.2.2.2 bouyer
408 1.1.1.2.2.2 bouyer /* Create the 3 leading ASCII letters */
409 1.1.1.2.2.2 bouyer
410 1.1.1.2.2.2 bouyer Prefix[0] = ((BigEndianId >> 26) & 0x1F) + 0x40;
411 1.1.1.2.2.2 bouyer Prefix[1] = ((BigEndianId >> 21) & 0x1F) + 0x40;
412 1.1.1.2.2.2 bouyer Prefix[2] = ((BigEndianId >> 16) & 0x1F) + 0x40;
413 1.1.1.2.2.2 bouyer
414 1.1.1.2.2.2 bouyer /* Verify that all 3 are ascii and alpha */
415 1.1.1.2.2.2 bouyer
416 1.1.1.2.2.2 bouyer for (i = 0; i < 3; i++)
417 1.1.1.2.2.2 bouyer {
418 1.1.1.2.2.2 bouyer if (!ACPI_IS_ASCII (Prefix[i]) ||
419 1.1.1.2.2.2 bouyer !ACPI_IS_ALPHA (Prefix[i]))
420 1.1.1.2.2.2 bouyer {
421 1.1.1.2.2.2 bouyer return;
422 1.1.1.2.2.2 bouyer }
423 1.1.1.2.2.2 bouyer }
424 1.1.1.2.2.2 bouyer
425 1.1.1.2.2.2 bouyer /* OK - mark this node as convertable to an EISA ID */
426 1.1.1.2.2.2 bouyer
427 1.1.1.2.2.2 bouyer Op->Common.DisasmOpcode = ACPI_DASM_EISAID;
428 1.1.1.2.2.2 bouyer }
429 1.1.1.2.2.2 bouyer
430 1.1.1.2.2.2 bouyer
431 1.1.1.2.2.2 bouyer /*******************************************************************************
432 1.1.1.2.2.2 bouyer *
433 1.1.1.2.2.2 bouyer * FUNCTION: AcpiDmIsEisaId
434 1.1.1.2.2.2 bouyer *
435 1.1.1.2.2.2 bouyer * PARAMETERS: Op - Op to be examined
436 1.1.1.2.2.2 bouyer *
437 1.1.1.2.2.2 bouyer * RETURN: None
438 1.1.1.2.2.2 bouyer *
439 1.1.1.2.2.2 bouyer * DESCRIPTION: Determine if a Name() Op can be converted to an EisaId.
440 1.1.1.2.2.2 bouyer *
441 1.1.1.2.2.2 bouyer ******************************************************************************/
442 1.1.1.2.2.2 bouyer
443 1.1.1.2.2.2 bouyer void
444 1.1.1.2.2.2 bouyer AcpiDmIsEisaId (
445 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op)
446 1.1.1.2.2.2 bouyer {
447 1.1.1.2.2.2 bouyer UINT32 Name;
448 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *NextOp;
449 1.1.1.2.2.2 bouyer
450 1.1.1.2.2.2 bouyer
451 1.1.1.2.2.2 bouyer /* Get the NameSegment */
452 1.1.1.2.2.2 bouyer
453 1.1.1.2.2.2 bouyer Name = AcpiPsGetName (Op);
454 1.1.1.2.2.2 bouyer if (!Name)
455 1.1.1.2.2.2 bouyer {
456 1.1.1.2.2.2 bouyer return;
457 1.1.1.2.2.2 bouyer }
458 1.1.1.2.2.2 bouyer
459 1.1.1.2.2.2 bouyer NextOp = AcpiPsGetDepthNext (NULL, Op);
460 1.1.1.2.2.2 bouyer if (!NextOp)
461 1.1.1.2.2.2 bouyer {
462 1.1.1.2.2.2 bouyer return;
463 1.1.1.2.2.2 bouyer }
464 1.1.1.2.2.2 bouyer
465 1.1.1.2.2.2 bouyer /* Check for _HID - has one argument */
466 1.1.1.2.2.2 bouyer
467 1.1.1.2.2.2 bouyer if (ACPI_COMPARE_NAME (&Name, METHOD_NAME__HID))
468 1.1.1.2.2.2 bouyer {
469 1.1.1.2.2.2 bouyer AcpiDmIsEisaIdElement (NextOp);
470 1.1.1.2.2.2 bouyer return;
471 1.1.1.2.2.2 bouyer }
472 1.1.1.2.2.2 bouyer
473 1.1.1.2.2.2 bouyer /* Exit if not _CID */
474 1.1.1.2.2.2 bouyer
475 1.1.1.2.2.2 bouyer if (!ACPI_COMPARE_NAME (&Name, METHOD_NAME__CID))
476 1.1.1.2.2.2 bouyer {
477 1.1.1.2.2.2 bouyer return;
478 1.1.1.2.2.2 bouyer }
479 1.1.1.2.2.2 bouyer
480 1.1.1.2.2.2 bouyer /* _CID can contain a single argument or a package */
481 1.1.1.2.2.2 bouyer
482 1.1.1.2.2.2 bouyer if (NextOp->Common.AmlOpcode != AML_PACKAGE_OP)
483 1.1.1.2.2.2 bouyer {
484 1.1.1.2.2.2 bouyer AcpiDmIsEisaIdElement (NextOp);
485 1.1.1.2.2.2 bouyer return;
486 1.1.1.2.2.2 bouyer }
487 1.1.1.2.2.2 bouyer
488 1.1.1.2.2.2 bouyer /* _CID with Package: get the package length */
489 1.1.1.2.2.2 bouyer
490 1.1.1.2.2.2 bouyer NextOp = AcpiPsGetDepthNext (NULL, NextOp);
491 1.1.1.2.2.2 bouyer
492 1.1.1.2.2.2 bouyer /* Don't need to use the length, just walk the peer list */
493 1.1.1.2.2.2 bouyer
494 1.1.1.2.2.2 bouyer NextOp = NextOp->Common.Next;
495 1.1.1.2.2.2 bouyer while (NextOp)
496 1.1.1.2.2.2 bouyer {
497 1.1.1.2.2.2 bouyer AcpiDmIsEisaIdElement (NextOp);
498 1.1.1.2.2.2 bouyer NextOp = NextOp->Common.Next;
499 1.1.1.2.2.2 bouyer }
500 1.1.1.2.2.2 bouyer }
501 1.1.1.2.2.2 bouyer
502 1.1.1.2.2.2 bouyer
503 1.1.1.2.2.2 bouyer /*******************************************************************************
504 1.1.1.2.2.2 bouyer *
505 1.1.1.2.2.2 bouyer * FUNCTION: AcpiDmEisaId
506 1.1.1.2.2.2 bouyer *
507 1.1.1.2.2.2 bouyer * PARAMETERS: EncodedId - Raw encoded EISA ID.
508 1.1.1.2.2.2 bouyer *
509 1.1.1.2.2.2 bouyer * RETURN: None
510 1.1.1.2.2.2 bouyer *
511 1.1.1.2.2.2 bouyer * DESCRIPTION: Convert an encoded EISAID back to the original ASCII String.
512 1.1.1.2.2.2 bouyer *
513 1.1.1.2.2.2 bouyer ******************************************************************************/
514 1.1.1.2.2.2 bouyer
515 1.1.1.2.2.2 bouyer void
516 1.1.1.2.2.2 bouyer AcpiDmEisaId (
517 1.1.1.2.2.2 bouyer UINT32 EncodedId)
518 1.1.1.2.2.2 bouyer {
519 1.1.1.2.2.2 bouyer UINT32 BigEndianId;
520 1.1.1.2.2.2 bouyer
521 1.1.1.2.2.2 bouyer
522 1.1.1.2.2.2 bouyer /* Swap from little-endian to big-endian to simplify conversion */
523 1.1.1.2.2.2 bouyer
524 1.1.1.2.2.2 bouyer BigEndianId = AcpiUtDwordByteSwap (EncodedId);
525 1.1.1.2.2.2 bouyer
526 1.1.1.2.2.2 bouyer
527 1.1.1.2.2.2 bouyer /* Split to form "AAANNNN" string */
528 1.1.1.2.2.2 bouyer
529 1.1.1.2.2.2 bouyer AcpiOsPrintf ("EisaId (\"%c%c%c%4.4X\")",
530 1.1.1.2.2.2 bouyer
531 1.1.1.2.2.2 bouyer /* Three Alpha characters (AAA), 5 bits each */
532 1.1.1.2.2.2 bouyer
533 1.1.1.2.2.2 bouyer (int) ((BigEndianId >> 26) & 0x1F) + 0x40,
534 1.1.1.2.2.2 bouyer (int) ((BigEndianId >> 21) & 0x1F) + 0x40,
535 1.1.1.2.2.2 bouyer (int) ((BigEndianId >> 16) & 0x1F) + 0x40,
536 1.1.1.2.2.2 bouyer
537 1.1.1.2.2.2 bouyer /* Numeric part (NNNN) is simply the lower 16 bits */
538 1.1.1.2.2.2 bouyer
539 1.1.1.2.2.2 bouyer (UINT32) (BigEndianId & 0xFFFF));
540 1.1.1.2.2.2 bouyer }
541 1.1.1.2.2.2 bouyer
542 1.1.1.2.2.2 bouyer #endif
543