aslmapoutput.c revision 1.1.1.4 1 1.1 christos /******************************************************************************
2 1.1 christos *
3 1.1 christos * Module Name: aslmapoutput - Output/emit the resource descriptor/device maps
4 1.1 christos *
5 1.1 christos *****************************************************************************/
6 1.1 christos
7 1.1 christos /*
8 1.1.1.4 christos * Copyright (C) 2000 - 2016, Intel Corp.
9 1.1 christos * All rights reserved.
10 1.1 christos *
11 1.1 christos * Redistribution and use in source and binary forms, with or without
12 1.1 christos * modification, are permitted provided that the following conditions
13 1.1 christos * are met:
14 1.1 christos * 1. Redistributions of source code must retain the above copyright
15 1.1 christos * notice, this list of conditions, and the following disclaimer,
16 1.1 christos * without modification.
17 1.1 christos * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.1 christos * substantially similar to the "NO WARRANTY" disclaimer below
19 1.1 christos * ("Disclaimer") and any redistribution must be conditioned upon
20 1.1 christos * including a substantially similar Disclaimer requirement for further
21 1.1 christos * binary redistribution.
22 1.1 christos * 3. Neither the names of the above-listed copyright holders nor the names
23 1.1 christos * of any contributors may be used to endorse or promote products derived
24 1.1 christos * from this software without specific prior written permission.
25 1.1 christos *
26 1.1 christos * Alternatively, this software may be distributed under the terms of the
27 1.1 christos * GNU General Public License ("GPL") version 2 as published by the Free
28 1.1 christos * Software Foundation.
29 1.1 christos *
30 1.1 christos * NO WARRANTY
31 1.1 christos * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.1 christos * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.1 christos * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.1 christos * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.1 christos * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.1 christos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.1 christos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.1 christos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.1 christos * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.1 christos * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.1 christos * POSSIBILITY OF SUCH DAMAGES.
42 1.1 christos */
43 1.1 christos
44 1.1 christos #include "acpi.h"
45 1.1 christos #include "accommon.h"
46 1.1 christos #include "acapps.h"
47 1.1 christos #include "aslcompiler.h"
48 1.1 christos #include "aslcompiler.y.h"
49 1.1 christos #include "acinterp.h"
50 1.1 christos #include "acparser.h"
51 1.1 christos #include "acnamesp.h"
52 1.1 christos #include "amlcode.h"
53 1.1 christos
54 1.1 christos /* This module used for application-level code only */
55 1.1 christos
56 1.1 christos #define _COMPONENT ACPI_COMPILER
57 1.1 christos ACPI_MODULE_NAME ("aslmapoutput")
58 1.1 christos
59 1.1 christos /* Local prototypes */
60 1.1 christos
61 1.1 christos static void
62 1.1 christos MpEmitGpioInfo (
63 1.1 christos void);
64 1.1 christos
65 1.1 christos static void
66 1.1 christos MpEmitSerialInfo (
67 1.1 christos void);
68 1.1 christos
69 1.1 christos static void
70 1.1 christos MpEmitDeviceTree (
71 1.1 christos void);
72 1.1 christos
73 1.1 christos static ACPI_STATUS
74 1.1 christos MpEmitOneDevice (
75 1.1 christos ACPI_HANDLE ObjHandle,
76 1.1 christos UINT32 NestingLevel,
77 1.1 christos void *Context,
78 1.1 christos void **ReturnValue);
79 1.1 christos
80 1.1 christos static void
81 1.1 christos MpXrefDevices (
82 1.1 christos ACPI_GPIO_INFO *Info);
83 1.1 christos
84 1.1 christos static ACPI_STATUS
85 1.1 christos MpNamespaceXrefBegin (
86 1.1 christos ACPI_PARSE_OBJECT *Op,
87 1.1 christos UINT32 Level,
88 1.1 christos void *Context);
89 1.1 christos
90 1.1 christos
91 1.1 christos /* Strings used to decode flag bits */
92 1.1 christos
93 1.1 christos const char *DirectionDecode[] =
94 1.1 christos {
95 1.1 christos "Both I/O ",
96 1.1 christos "InputOnly ",
97 1.1 christos "OutputOnly ",
98 1.1 christos "Preserve "
99 1.1 christos };
100 1.1 christos
101 1.1 christos const char *PolarityDecode[] =
102 1.1 christos {
103 1.1 christos "ActiveHigh",
104 1.1 christos "ActiveLow ",
105 1.1 christos "ActiveBoth",
106 1.1 christos "Reserved "
107 1.1 christos };
108 1.1 christos
109 1.1 christos
110 1.1 christos /*******************************************************************************
111 1.1 christos *
112 1.1 christos * FUNCTION: MpEmitMappingInfo
113 1.1 christos *
114 1.1 christos * PARAMETERS: None
115 1.1 christos *
116 1.1 christos * RETURN: None
117 1.1 christos *
118 1.1 christos * DESCRIPTION: External interface.
119 1.1.1.2 christos * Map file has already been opened. Emit all of the collected
120 1.1 christos * hardware mapping information. Includes: GPIO information,
121 1.1 christos * Serial information, and a dump of the entire ACPI device tree.
122 1.1 christos *
123 1.1 christos ******************************************************************************/
124 1.1 christos
125 1.1 christos void
126 1.1 christos MpEmitMappingInfo (
127 1.1 christos void)
128 1.1 christos {
129 1.1 christos
130 1.1 christos /* Mapfile option enabled? */
131 1.1 christos
132 1.1 christos if (!Gbl_MapfileFlag)
133 1.1 christos {
134 1.1 christos return;
135 1.1 christos }
136 1.1 christos
137 1.1 christos if (!Gbl_GpioList)
138 1.1 christos {
139 1.1 christos FlPrintFile (ASL_FILE_MAP_OUTPUT,
140 1.1 christos "\nNo GPIO devices found\n");
141 1.1 christos }
142 1.1 christos
143 1.1 christos if (!Gbl_SerialList)
144 1.1 christos {
145 1.1 christos FlPrintFile (ASL_FILE_MAP_OUTPUT,
146 1.1 christos "\nNo Serial devices found (I2C/SPI/UART)\n");
147 1.1 christos }
148 1.1 christos
149 1.1 christos if (!Gbl_GpioList && !Gbl_SerialList)
150 1.1 christos {
151 1.1 christos return;
152 1.1 christos }
153 1.1 christos
154 1.1 christos /* Headers */
155 1.1 christos
156 1.1 christos FlPrintFile (ASL_FILE_MAP_OUTPUT, "\nResource Descriptor Connectivity Map\n");
157 1.1 christos FlPrintFile (ASL_FILE_MAP_OUTPUT, "------------------------------------\n");
158 1.1 christos
159 1.1 christos /* Emit GPIO and Serial descriptors, then entire ACPI device tree */
160 1.1 christos
161 1.1 christos MpEmitGpioInfo ();
162 1.1 christos MpEmitSerialInfo ();
163 1.1 christos MpEmitDeviceTree ();
164 1.1 christos
165 1.1 christos /* Clear the lists - no need to free memory here */
166 1.1 christos
167 1.1 christos Gbl_SerialList = NULL;
168 1.1 christos Gbl_GpioList = NULL;
169 1.1 christos }
170 1.1 christos
171 1.1 christos
172 1.1 christos /*******************************************************************************
173 1.1 christos *
174 1.1 christos * FUNCTION: MpEmitGpioInfo
175 1.1 christos *
176 1.1 christos * PARAMETERS: None
177 1.1 christos *
178 1.1 christos * RETURN: None
179 1.1 christos *
180 1.1 christos * DESCRIPTION: Emit the info about all GPIO devices found during the
181 1.1 christos * compile or disassembly.
182 1.1 christos *
183 1.1 christos ******************************************************************************/
184 1.1 christos
185 1.1 christos static void
186 1.1 christos MpEmitGpioInfo (
187 1.1 christos void)
188 1.1 christos {
189 1.1 christos ACPI_GPIO_INFO *Info;
190 1.1 christos char *Type;
191 1.1 christos char *PrevDeviceName = NULL;
192 1.1 christos const char *Direction;
193 1.1 christos const char *Polarity;
194 1.1 christos char *ParentPathname;
195 1.1 christos const char *Description;
196 1.1 christos char *HidString;
197 1.1 christos const AH_DEVICE_ID *HidInfo;
198 1.1 christos
199 1.1 christos
200 1.1 christos /* Walk the GPIO descriptor list */
201 1.1 christos
202 1.1 christos Info = Gbl_GpioList;
203 1.1 christos while (Info)
204 1.1 christos {
205 1.1 christos HidString = MpGetHidViaNamestring (Info->DeviceName);
206 1.1 christos
207 1.1 christos /* Print header info for the controller itself */
208 1.1 christos
209 1.1 christos if (!PrevDeviceName ||
210 1.1.1.3 christos strcmp (PrevDeviceName, Info->DeviceName))
211 1.1 christos {
212 1.1 christos FlPrintFile (ASL_FILE_MAP_OUTPUT,
213 1.1 christos "\n\nGPIO Controller: %-8s %-28s",
214 1.1 christos HidString, Info->DeviceName);
215 1.1 christos
216 1.1 christos HidInfo = AcpiAhMatchHardwareId (HidString);
217 1.1 christos if (HidInfo)
218 1.1 christos {
219 1.1 christos FlPrintFile (ASL_FILE_MAP_OUTPUT, " // %s",
220 1.1 christos HidInfo->Description);
221 1.1 christos }
222 1.1 christos
223 1.1 christos FlPrintFile (ASL_FILE_MAP_OUTPUT,
224 1.1 christos "\n\nPin Type Direction Polarity"
225 1.1 christos " Dest _HID Destination\n");
226 1.1 christos }
227 1.1 christos
228 1.1 christos PrevDeviceName = Info->DeviceName;
229 1.1 christos
230 1.1 christos /* Setup various strings based upon the type (GpioInt or GpioIo) */
231 1.1 christos
232 1.1 christos switch (Info->Type)
233 1.1 christos {
234 1.1 christos case AML_RESOURCE_GPIO_TYPE_INT:
235 1.1 christos
236 1.1 christos Type = "GpioInt";
237 1.1 christos Direction = "-Interrupt-";
238 1.1 christos Polarity = PolarityDecode[Info->Polarity];
239 1.1 christos break;
240 1.1 christos
241 1.1 christos case AML_RESOURCE_GPIO_TYPE_IO:
242 1.1 christos
243 1.1 christos Type = "GpioIo ";
244 1.1 christos Direction = DirectionDecode[Info->Direction];
245 1.1 christos Polarity = " ";
246 1.1 christos break;
247 1.1 christos
248 1.1 christos default:
249 1.1 christos continue;
250 1.1 christos }
251 1.1 christos
252 1.1 christos /* Emit the GPIO info */
253 1.1 christos
254 1.1 christos FlPrintFile (ASL_FILE_MAP_OUTPUT, "%4.4X %s %s %s ",
255 1.1 christos Info->PinNumber, Type, Direction, Polarity);
256 1.1 christos
257 1.1 christos ParentPathname = NULL;
258 1.1 christos HidString = MpGetConnectionInfo (Info->Op, Info->PinIndex,
259 1.1 christos &Info->TargetNode, &ParentPathname);
260 1.1 christos if (HidString)
261 1.1 christos {
262 1.1 christos /*
263 1.1 christos * This is a Connection() field
264 1.1 christos * Attempt to find all references to the field.
265 1.1 christos */
266 1.1 christos FlPrintFile (ASL_FILE_MAP_OUTPUT, "%8s %-28s",
267 1.1 christos HidString, ParentPathname);
268 1.1 christos
269 1.1 christos MpXrefDevices (Info);
270 1.1 christos }
271 1.1 christos else
272 1.1 christos {
273 1.1 christos /*
274 1.1 christos * For Devices, attempt to get the _HID description string.
275 1.1 christos * Failing that (many _HIDs are not recognized), attempt to
276 1.1 christos * get the _DDN description string.
277 1.1 christos */
278 1.1 christos HidString = MpGetParentDeviceHid (Info->Op, &Info->TargetNode,
279 1.1 christos &ParentPathname);
280 1.1 christos
281 1.1 christos FlPrintFile (ASL_FILE_MAP_OUTPUT, "%8s %-28s",
282 1.1 christos HidString, ParentPathname);
283 1.1 christos
284 1.1 christos /* Get the _HID description or _DDN string */
285 1.1 christos
286 1.1 christos HidInfo = AcpiAhMatchHardwareId (HidString);
287 1.1 christos if (HidInfo)
288 1.1 christos {
289 1.1 christos FlPrintFile (ASL_FILE_MAP_OUTPUT, " // %s",
290 1.1 christos HidInfo->Description);
291 1.1 christos }
292 1.1 christos else if ((Description = MpGetDdnValue (ParentPathname)))
293 1.1 christos {
294 1.1 christos FlPrintFile (ASL_FILE_MAP_OUTPUT, " // %s (_DDN)",
295 1.1 christos Description);
296 1.1 christos }
297 1.1 christos }
298 1.1 christos
299 1.1 christos FlPrintFile (ASL_FILE_MAP_OUTPUT, "\n");
300 1.1 christos ACPI_FREE (ParentPathname);
301 1.1 christos Info = Info->Next;
302 1.1 christos }
303 1.1 christos }
304 1.1 christos
305 1.1 christos
306 1.1 christos /*******************************************************************************
307 1.1 christos *
308 1.1 christos * FUNCTION: MpEmitSerialInfo
309 1.1 christos *
310 1.1 christos * PARAMETERS: None
311 1.1 christos *
312 1.1 christos * RETURN: None
313 1.1 christos *
314 1.1 christos * DESCRIPTION: Emit the info about all Serial devices found during the
315 1.1 christos * compile or disassembly.
316 1.1 christos *
317 1.1 christos ******************************************************************************/
318 1.1 christos
319 1.1 christos static void
320 1.1 christos MpEmitSerialInfo (
321 1.1 christos void)
322 1.1 christos {
323 1.1 christos ACPI_SERIAL_INFO *Info;
324 1.1 christos char *Type;
325 1.1 christos char *ParentPathname;
326 1.1 christos char *PrevDeviceName = NULL;
327 1.1 christos char *HidString;
328 1.1 christos const AH_DEVICE_ID *HidInfo;
329 1.1 christos const char *Description;
330 1.1 christos AML_RESOURCE *Resource;
331 1.1 christos
332 1.1 christos
333 1.1 christos /* Walk the constructed serial descriptor list */
334 1.1 christos
335 1.1 christos Info = Gbl_SerialList;
336 1.1 christos while (Info)
337 1.1 christos {
338 1.1 christos Resource = Info->Resource;
339 1.1 christos switch (Resource->CommonSerialBus.Type)
340 1.1 christos {
341 1.1 christos case AML_RESOURCE_I2C_SERIALBUSTYPE:
342 1.1 christos Type = "I2C ";
343 1.1 christos break;
344 1.1 christos
345 1.1 christos case AML_RESOURCE_SPI_SERIALBUSTYPE:
346 1.1 christos Type = "SPI ";
347 1.1 christos break;
348 1.1 christos
349 1.1 christos case AML_RESOURCE_UART_SERIALBUSTYPE:
350 1.1 christos Type = "UART";
351 1.1 christos break;
352 1.1 christos
353 1.1 christos default:
354 1.1 christos Type = "UNKN";
355 1.1 christos break;
356 1.1 christos }
357 1.1 christos
358 1.1 christos HidString = MpGetHidViaNamestring (Info->DeviceName);
359 1.1 christos
360 1.1 christos /* Print header info for the controller itself */
361 1.1 christos
362 1.1 christos if (!PrevDeviceName ||
363 1.1.1.3 christos strcmp (PrevDeviceName, Info->DeviceName))
364 1.1 christos {
365 1.1 christos FlPrintFile (ASL_FILE_MAP_OUTPUT, "\n\n%s Controller: ",
366 1.1 christos Type);
367 1.1 christos FlPrintFile (ASL_FILE_MAP_OUTPUT, "%-8s %-28s",
368 1.1 christos HidString, Info->DeviceName);
369 1.1 christos
370 1.1 christos HidInfo = AcpiAhMatchHardwareId (HidString);
371 1.1 christos if (HidInfo)
372 1.1 christos {
373 1.1 christos FlPrintFile (ASL_FILE_MAP_OUTPUT, " // %s",
374 1.1 christos HidInfo->Description);
375 1.1 christos }
376 1.1 christos
377 1.1 christos FlPrintFile (ASL_FILE_MAP_OUTPUT, "\n\n");
378 1.1 christos FlPrintFile (ASL_FILE_MAP_OUTPUT,
379 1.1 christos "Type Address Speed Dest _HID Destination\n");
380 1.1 christos }
381 1.1 christos
382 1.1 christos PrevDeviceName = Info->DeviceName;
383 1.1 christos
384 1.1 christos FlPrintFile (ASL_FILE_MAP_OUTPUT, "%s %4.4X %8.8X ",
385 1.1 christos Type, Info->Address, Info->Speed);
386 1.1 christos
387 1.1 christos ParentPathname = NULL;
388 1.1 christos HidString = MpGetConnectionInfo (Info->Op, 0, &Info->TargetNode,
389 1.1 christos &ParentPathname);
390 1.1 christos if (HidString)
391 1.1 christos {
392 1.1 christos /*
393 1.1 christos * This is a Connection() field
394 1.1 christos * Attempt to find all references to the field.
395 1.1 christos */
396 1.1 christos FlPrintFile (ASL_FILE_MAP_OUTPUT, "%8s %-28s",
397 1.1 christos HidString, ParentPathname);
398 1.1 christos }
399 1.1 christos else
400 1.1 christos {
401 1.1 christos /* Normal resource template */
402 1.1 christos
403 1.1 christos HidString = MpGetParentDeviceHid (Info->Op, &Info->TargetNode,
404 1.1 christos &ParentPathname);
405 1.1 christos FlPrintFile (ASL_FILE_MAP_OUTPUT, "%8s %-28s",
406 1.1 christos HidString, ParentPathname);
407 1.1 christos
408 1.1 christos /* Get the _HID description or _DDN string */
409 1.1 christos
410 1.1 christos HidInfo = AcpiAhMatchHardwareId (HidString);
411 1.1 christos if (HidInfo)
412 1.1 christos {
413 1.1 christos FlPrintFile (ASL_FILE_MAP_OUTPUT, " // %s",
414 1.1 christos HidInfo->Description);
415 1.1 christos }
416 1.1 christos else if ((Description = MpGetDdnValue (ParentPathname)))
417 1.1 christos {
418 1.1 christos FlPrintFile (ASL_FILE_MAP_OUTPUT, " // %s (_DDN)",
419 1.1 christos Description);
420 1.1 christos }
421 1.1 christos }
422 1.1 christos
423 1.1 christos FlPrintFile (ASL_FILE_MAP_OUTPUT, "\n");
424 1.1 christos ACPI_FREE (ParentPathname);
425 1.1 christos Info = Info->Next;
426 1.1 christos }
427 1.1 christos }
428 1.1 christos
429 1.1 christos
430 1.1 christos /*******************************************************************************
431 1.1 christos *
432 1.1 christos * FUNCTION: MpEmitDeviceTree
433 1.1 christos *
434 1.1 christos * PARAMETERS: None
435 1.1 christos *
436 1.1 christos * RETURN: None
437 1.1 christos *
438 1.1 christos * DESCRIPTION: Emit information about all devices within the ACPI namespace.
439 1.1 christos *
440 1.1 christos ******************************************************************************/
441 1.1 christos
442 1.1 christos static void
443 1.1 christos MpEmitDeviceTree (
444 1.1 christos void)
445 1.1 christos {
446 1.1 christos
447 1.1 christos FlPrintFile (ASL_FILE_MAP_OUTPUT, "\n\nACPI Device Tree\n");
448 1.1 christos FlPrintFile (ASL_FILE_MAP_OUTPUT, "----------------\n\n");
449 1.1 christos
450 1.1 christos FlPrintFile (ASL_FILE_MAP_OUTPUT, "Device Pathname "
451 1.1 christos "_HID Description\n\n");
452 1.1 christos
453 1.1 christos /* Walk the namespace from the root */
454 1.1 christos
455 1.1 christos (void) AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
456 1.1.1.4 christos ACPI_UINT32_MAX, FALSE, MpEmitOneDevice, NULL, NULL, NULL);
457 1.1 christos }
458 1.1 christos
459 1.1 christos
460 1.1 christos /*******************************************************************************
461 1.1 christos *
462 1.1 christos * FUNCTION: MpEmitOneDevice
463 1.1 christos *
464 1.1 christos * PARAMETERS: ACPI_NAMESPACE_WALK callback
465 1.1 christos *
466 1.1 christos * RETURN: Status
467 1.1 christos *
468 1.1 christos * DESCRIPTION: Emit information about one ACPI device in the namespace. Used
469 1.1 christos * during dump of all device objects within the namespace.
470 1.1 christos *
471 1.1 christos ******************************************************************************/
472 1.1 christos
473 1.1 christos static ACPI_STATUS
474 1.1 christos MpEmitOneDevice (
475 1.1 christos ACPI_HANDLE ObjHandle,
476 1.1 christos UINT32 NestingLevel,
477 1.1 christos void *Context,
478 1.1 christos void **ReturnValue)
479 1.1 christos {
480 1.1 christos char *DevicePathname;
481 1.1 christos char *DdnString;
482 1.1 christos char *HidString;
483 1.1 christos const AH_DEVICE_ID *HidInfo;
484 1.1 christos
485 1.1 christos
486 1.1 christos /* Device pathname */
487 1.1 christos
488 1.1 christos DevicePathname = AcpiNsGetExternalPathname (
489 1.1 christos ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle));
490 1.1 christos
491 1.1 christos FlPrintFile (ASL_FILE_MAP_OUTPUT, "%-32s", DevicePathname);
492 1.1 christos
493 1.1 christos /* _HID or _DDN */
494 1.1 christos
495 1.1 christos HidString = MpGetHidValue (
496 1.1 christos ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle));
497 1.1 christos FlPrintFile (ASL_FILE_MAP_OUTPUT, "%8s", HidString);
498 1.1 christos
499 1.1 christos HidInfo = AcpiAhMatchHardwareId (HidString);
500 1.1 christos if (HidInfo)
501 1.1 christos {
502 1.1 christos FlPrintFile (ASL_FILE_MAP_OUTPUT, " // %s",
503 1.1 christos HidInfo->Description);
504 1.1 christos }
505 1.1 christos else if ((DdnString = MpGetDdnValue (DevicePathname)))
506 1.1 christos {
507 1.1 christos FlPrintFile (ASL_FILE_MAP_OUTPUT, " // %s (_DDN)", DdnString);
508 1.1 christos }
509 1.1 christos
510 1.1 christos FlPrintFile (ASL_FILE_MAP_OUTPUT, "\n");
511 1.1 christos ACPI_FREE (DevicePathname);
512 1.1 christos return (AE_OK);
513 1.1 christos }
514 1.1 christos
515 1.1 christos
516 1.1 christos /*******************************************************************************
517 1.1 christos *
518 1.1 christos * FUNCTION: MpXrefDevices
519 1.1 christos *
520 1.1 christos * PARAMETERS: Info - A GPIO Info block
521 1.1 christos *
522 1.1 christos * RETURN: None
523 1.1 christos *
524 1.1 christos * DESCRIPTION: Cross-reference the parse tree and find all references to the
525 1.1 christos * specified GPIO device.
526 1.1 christos *
527 1.1 christos ******************************************************************************/
528 1.1 christos
529 1.1 christos static void
530 1.1 christos MpXrefDevices (
531 1.1 christos ACPI_GPIO_INFO *Info)
532 1.1 christos {
533 1.1 christos
534 1.1 christos /* Walk the entire parse tree */
535 1.1 christos
536 1.1 christos TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD,
537 1.1 christos MpNamespaceXrefBegin, NULL, Info);
538 1.1 christos
539 1.1 christos if (!Info->References)
540 1.1 christos {
541 1.1 christos FlPrintFile (ASL_FILE_MAP_OUTPUT, " // **** No references in table");
542 1.1 christos }
543 1.1 christos }
544 1.1 christos
545 1.1 christos
546 1.1 christos /*******************************************************************************
547 1.1 christos *
548 1.1 christos * FUNCTION: MpNamespaceXrefBegin
549 1.1 christos *
550 1.1 christos * PARAMETERS: WALK_PARSE_TREE callback
551 1.1 christos *
552 1.1 christos * RETURN: Status
553 1.1 christos *
554 1.1 christos * DESCRIPTION: Walk parse tree callback used to cross-reference GPIO pins.
555 1.1 christos *
556 1.1 christos ******************************************************************************/
557 1.1 christos
558 1.1 christos static ACPI_STATUS
559 1.1 christos MpNamespaceXrefBegin (
560 1.1 christos ACPI_PARSE_OBJECT *Op,
561 1.1 christos UINT32 Level,
562 1.1 christos void *Context)
563 1.1 christos {
564 1.1 christos ACPI_GPIO_INFO *Info = ACPI_CAST_PTR (ACPI_GPIO_INFO, Context);
565 1.1 christos const ACPI_OPCODE_INFO *OpInfo;
566 1.1 christos char *DevicePathname;
567 1.1 christos ACPI_PARSE_OBJECT *ParentOp;
568 1.1 christos char *HidString;
569 1.1 christos
570 1.1 christos
571 1.1 christos ACPI_FUNCTION_TRACE_PTR (MpNamespaceXrefBegin, Op);
572 1.1 christos
573 1.1 christos /*
574 1.1 christos * If this node is the actual declaration of a name
575 1.1 christos * [such as the XXXX name in "Method (XXXX)"],
576 1.1 christos * we are not interested in it here. We only care about names that
577 1.1 christos * are references to other objects within the namespace and the
578 1.1 christos * parent objects of name declarations
579 1.1 christos */
580 1.1 christos if (Op->Asl.CompileFlags & NODE_IS_NAME_DECLARATION)
581 1.1 christos {
582 1.1 christos return (AE_OK);
583 1.1 christos }
584 1.1 christos
585 1.1 christos /* We are only interested in opcodes that have an associated name */
586 1.1 christos
587 1.1 christos OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
588 1.1 christos
589 1.1 christos if ((OpInfo->Flags & AML_NAMED) ||
590 1.1 christos (OpInfo->Flags & AML_CREATE))
591 1.1 christos {
592 1.1 christos return (AE_OK);
593 1.1 christos }
594 1.1 christos
595 1.1 christos if ((Op->Asl.ParseOpcode != PARSEOP_NAMESTRING) &&
596 1.1 christos (Op->Asl.ParseOpcode != PARSEOP_NAMESEG) &&
597 1.1 christos (Op->Asl.ParseOpcode != PARSEOP_METHODCALL))
598 1.1 christos {
599 1.1 christos return (AE_OK);
600 1.1 christos }
601 1.1 christos
602 1.1 christos if (!Op->Asl.Node)
603 1.1 christos {
604 1.1 christos return (AE_OK);
605 1.1 christos }
606 1.1 christos
607 1.1 christos ParentOp = Op->Asl.Parent;
608 1.1 christos if (ParentOp->Asl.ParseOpcode == PARSEOP_FIELD)
609 1.1 christos {
610 1.1 christos return (AE_OK);
611 1.1 christos }
612 1.1 christos
613 1.1 christos if (Op->Asl.Node == Info->TargetNode)
614 1.1 christos {
615 1.1 christos while (ParentOp && (!ParentOp->Asl.Node))
616 1.1 christos {
617 1.1 christos ParentOp = ParentOp->Asl.Parent;
618 1.1 christos }
619 1.1 christos
620 1.1 christos if (ParentOp)
621 1.1 christos {
622 1.1 christos DevicePathname = AcpiNsGetExternalPathname (
623 1.1 christos ParentOp->Asl.Node);
624 1.1 christos
625 1.1 christos if (!Info->References)
626 1.1 christos {
627 1.1 christos FlPrintFile (ASL_FILE_MAP_OUTPUT, " // References:");
628 1.1 christos }
629 1.1 christos
630 1.1 christos HidString = MpGetHidViaNamestring (DevicePathname);
631 1.1 christos
632 1.1 christos FlPrintFile (ASL_FILE_MAP_OUTPUT, " %s [%s]",
633 1.1 christos DevicePathname, HidString);
634 1.1 christos
635 1.1 christos Info->References++;
636 1.1.1.2 christos
637 1.1.1.2 christos ACPI_FREE (DevicePathname);
638 1.1 christos }
639 1.1 christos }
640 1.1 christos
641 1.1 christos return (AE_OK);
642 1.1 christos }
643