2c4db995ac5d596abf3eed173e3f0fe9d3c1f527
[reactos.git] / reactos / drivers / bus / acpi / acpica / namespace / nsinit.c
1 /******************************************************************************
2 *
3 * Module Name: nsinit - namespace initialization
4 *
5 *****************************************************************************/
6
7 /******************************************************************************
8 *
9 * 1. Copyright Notice
10 *
11 * Some or all of this work - Copyright (c) 1999 - 2014, Intel Corp.
12 * All rights reserved.
13 *
14 * 2. License
15 *
16 * 2.1. This is your license from Intel Corp. under its intellectual property
17 * rights. You may have additional license terms from the party that provided
18 * you this software, covering your right to use that party's intellectual
19 * property rights.
20 *
21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 * copy of the source code appearing in this file ("Covered Code") an
23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 * base code distributed originally by Intel ("Original Intel Code") to copy,
25 * make derivatives, distribute, use and display any portion of the Covered
26 * Code in any form, with the right to sublicense such rights; and
27 *
28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 * license (with the right to sublicense), under only those claims of Intel
30 * patents that are infringed by the Original Intel Code, to make, use, sell,
31 * offer to sell, and import the Covered Code and derivative works thereof
32 * solely to the minimum extent necessary to exercise the above copyright
33 * license, and in no event shall the patent license extend to any additions
34 * to or modifications of the Original Intel Code. No other license or right
35 * is granted directly or by implication, estoppel or otherwise;
36 *
37 * The above copyright and patent license is granted only if the following
38 * conditions are met:
39 *
40 * 3. Conditions
41 *
42 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 * Redistribution of source code of any substantial portion of the Covered
44 * Code or modification with rights to further distribute source must include
45 * the above Copyright Notice, the above License, this list of Conditions,
46 * and the following Disclaimer and Export Compliance provision. In addition,
47 * Licensee must cause all Covered Code to which Licensee contributes to
48 * contain a file documenting the changes Licensee made to create that Covered
49 * Code and the date of any change. Licensee must include in that file the
50 * documentation of any changes made by any predecessor Licensee. Licensee
51 * must include a prominent statement that the modification is derived,
52 * directly or indirectly, from Original Intel Code.
53 *
54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 * Redistribution of source code of any substantial portion of the Covered
56 * Code or modification without rights to further distribute source must
57 * include the following Disclaimer and Export Compliance provision in the
58 * documentation and/or other materials provided with distribution. In
59 * addition, Licensee may not authorize further sublicense of source of any
60 * portion of the Covered Code, and must include terms to the effect that the
61 * license from Licensee to its licensee is limited to the intellectual
62 * property embodied in the software Licensee provides to its licensee, and
63 * not to intellectual property embodied in modifications its licensee may
64 * make.
65 *
66 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 * substantial portion of the Covered Code or modification must reproduce the
68 * above Copyright Notice, and the following Disclaimer and Export Compliance
69 * provision in the documentation and/or other materials provided with the
70 * distribution.
71 *
72 * 3.4. Intel retains all right, title, and interest in and to the Original
73 * Intel Code.
74 *
75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 * Intel shall be used in advertising or otherwise to promote the sale, use or
77 * other dealings in products derived from or relating to the Covered Code
78 * without prior written authorization from Intel.
79 *
80 * 4. Disclaimer and Export Compliance
81 *
82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88 * PARTICULAR PURPOSE.
89 *
90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97 * LIMITED REMEDY.
98 *
99 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 * software or system incorporating such software without first obtaining any
101 * required license or other approval from the U. S. Department of Commerce or
102 * any other agency or department of the United States Government. In the
103 * event Licensee exports any such software from the United States or
104 * re-exports any such software from a foreign destination, Licensee shall
105 * ensure that the distribution and export/re-export of the software is in
106 * compliance with all laws, regulations, orders, or other restrictions of the
107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 * any of its subsidiaries will export/re-export any technical data, process,
109 * software, or service, directly or indirectly, to any country for which the
110 * United States government or any agency thereof requires an export license,
111 * other governmental approval, or letter of assurance, without first obtaining
112 * such license, approval or letter.
113 *
114 *****************************************************************************/
115
116 #include "acpi.h"
117 #include "accommon.h"
118 #include "acnamesp.h"
119 #include "acdispat.h"
120 #include "acinterp.h"
121
122 #define _COMPONENT ACPI_NAMESPACE
123 ACPI_MODULE_NAME ("nsinit")
124
125 /* Local prototypes */
126
127 static ACPI_STATUS
128 AcpiNsInitOneObject (
129 ACPI_HANDLE ObjHandle,
130 UINT32 Level,
131 void *Context,
132 void **ReturnValue);
133
134 static ACPI_STATUS
135 AcpiNsInitOneDevice (
136 ACPI_HANDLE ObjHandle,
137 UINT32 NestingLevel,
138 void *Context,
139 void **ReturnValue);
140
141 static ACPI_STATUS
142 AcpiNsFindIniMethods (
143 ACPI_HANDLE ObjHandle,
144 UINT32 NestingLevel,
145 void *Context,
146 void **ReturnValue);
147
148
149 /*******************************************************************************
150 *
151 * FUNCTION: AcpiNsInitializeObjects
152 *
153 * PARAMETERS: None
154 *
155 * RETURN: Status
156 *
157 * DESCRIPTION: Walk the entire namespace and perform any necessary
158 * initialization on the objects found therein
159 *
160 ******************************************************************************/
161
162 ACPI_STATUS
163 AcpiNsInitializeObjects (
164 void)
165 {
166 ACPI_STATUS Status;
167 ACPI_INIT_WALK_INFO Info;
168
169
170 ACPI_FUNCTION_TRACE (NsInitializeObjects);
171
172
173 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
174 "**** Starting initialization of namespace objects ****\n"));
175 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
176 "Completing Region/Field/Buffer/Package initialization:\n"));
177
178 /* Set all init info to zero */
179
180 ACPI_MEMSET (&Info, 0, sizeof (ACPI_INIT_WALK_INFO));
181
182 /* Walk entire namespace from the supplied root */
183
184 Status = AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
185 ACPI_UINT32_MAX, AcpiNsInitOneObject, NULL,
186 &Info, NULL);
187 if (ACPI_FAILURE (Status))
188 {
189 ACPI_EXCEPTION ((AE_INFO, Status, "During WalkNamespace"));
190 }
191
192 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
193 " Initialized %u/%u Regions %u/%u Fields %u/%u "
194 "Buffers %u/%u Packages (%u nodes)\n",
195 Info.OpRegionInit, Info.OpRegionCount,
196 Info.FieldInit, Info.FieldCount,
197 Info.BufferInit, Info.BufferCount,
198 Info.PackageInit, Info.PackageCount, Info.ObjectCount));
199
200 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
201 "%u Control Methods found\n%u Op Regions found\n",
202 Info.MethodCount, Info.OpRegionCount));
203
204 return_ACPI_STATUS (AE_OK);
205 }
206
207
208 /*******************************************************************************
209 *
210 * FUNCTION: AcpiNsInitializeDevices
211 *
212 * PARAMETERS: None
213 *
214 * RETURN: ACPI_STATUS
215 *
216 * DESCRIPTION: Walk the entire namespace and initialize all ACPI devices.
217 * This means running _INI on all present devices.
218 *
219 * Note: We install PCI config space handler on region access,
220 * not here.
221 *
222 ******************************************************************************/
223
224 ACPI_STATUS
225 AcpiNsInitializeDevices (
226 void)
227 {
228 ACPI_STATUS Status;
229 ACPI_DEVICE_WALK_INFO Info;
230
231
232 ACPI_FUNCTION_TRACE (NsInitializeDevices);
233
234
235 /* Init counters */
236
237 Info.DeviceCount = 0;
238 Info.Num_STA = 0;
239 Info.Num_INI = 0;
240
241 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
242 "Initializing Device/Processor/Thermal objects "
243 "and executing _INI/_STA methods:\n"));
244
245 /* Tree analysis: find all subtrees that contain _INI methods */
246
247 Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
248 ACPI_UINT32_MAX, FALSE, AcpiNsFindIniMethods, NULL, &Info, NULL);
249 if (ACPI_FAILURE (Status))
250 {
251 goto ErrorExit;
252 }
253
254 /* Allocate the evaluation information block */
255
256 Info.EvaluateInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
257 if (!Info.EvaluateInfo)
258 {
259 Status = AE_NO_MEMORY;
260 goto ErrorExit;
261 }
262
263 /*
264 * Execute the "global" _INI method that may appear at the root. This
265 * support is provided for Windows compatibility (Vista+) and is not
266 * part of the ACPI specification.
267 */
268 Info.EvaluateInfo->PrefixNode = AcpiGbl_RootNode;
269 Info.EvaluateInfo->RelativePathname = METHOD_NAME__INI;
270 Info.EvaluateInfo->Parameters = NULL;
271 Info.EvaluateInfo->Flags = ACPI_IGNORE_RETURN_VALUE;
272
273 Status = AcpiNsEvaluate (Info.EvaluateInfo);
274 if (ACPI_SUCCESS (Status))
275 {
276 Info.Num_INI++;
277 }
278
279 /* Walk namespace to execute all _INIs on present devices */
280
281 Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
282 ACPI_UINT32_MAX, FALSE, AcpiNsInitOneDevice, NULL, &Info, NULL);
283
284 /*
285 * Any _OSI requests should be completed by now. If the BIOS has
286 * requested any Windows OSI strings, we will always truncate
287 * I/O addresses to 16 bits -- for Windows compatibility.
288 */
289 if (AcpiGbl_OsiData >= ACPI_OSI_WIN_2000)
290 {
291 AcpiGbl_TruncateIoAddresses = TRUE;
292 }
293
294 ACPI_FREE (Info.EvaluateInfo);
295 if (ACPI_FAILURE (Status))
296 {
297 goto ErrorExit;
298 }
299
300 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
301 " Executed %u _INI methods requiring %u _STA executions "
302 "(examined %u objects)\n",
303 Info.Num_INI, Info.Num_STA, Info.DeviceCount));
304
305 return_ACPI_STATUS (Status);
306
307
308 ErrorExit:
309 ACPI_EXCEPTION ((AE_INFO, Status, "During device initialization"));
310 return_ACPI_STATUS (Status);
311 }
312
313
314 /*******************************************************************************
315 *
316 * FUNCTION: AcpiNsInitOneObject
317 *
318 * PARAMETERS: ObjHandle - Node
319 * Level - Current nesting level
320 * Context - Points to a init info struct
321 * ReturnValue - Not used
322 *
323 * RETURN: Status
324 *
325 * DESCRIPTION: Callback from AcpiWalkNamespace. Invoked for every object
326 * within the namespace.
327 *
328 * Currently, the only objects that require initialization are:
329 * 1) Methods
330 * 2) Op Regions
331 *
332 ******************************************************************************/
333
334 static ACPI_STATUS
335 AcpiNsInitOneObject (
336 ACPI_HANDLE ObjHandle,
337 UINT32 Level,
338 void *Context,
339 void **ReturnValue)
340 {
341 ACPI_OBJECT_TYPE Type;
342 ACPI_STATUS Status = AE_OK;
343 ACPI_INIT_WALK_INFO *Info = (ACPI_INIT_WALK_INFO *) Context;
344 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
345 ACPI_OPERAND_OBJECT *ObjDesc;
346
347
348 ACPI_FUNCTION_NAME (NsInitOneObject);
349
350
351 Info->ObjectCount++;
352
353 /* And even then, we are only interested in a few object types */
354
355 Type = AcpiNsGetType (ObjHandle);
356 ObjDesc = AcpiNsGetAttachedObject (Node);
357 if (!ObjDesc)
358 {
359 return (AE_OK);
360 }
361
362 /* Increment counters for object types we are looking for */
363
364 switch (Type)
365 {
366 case ACPI_TYPE_REGION:
367
368 Info->OpRegionCount++;
369 break;
370
371 case ACPI_TYPE_BUFFER_FIELD:
372
373 Info->FieldCount++;
374 break;
375
376 case ACPI_TYPE_LOCAL_BANK_FIELD:
377
378 Info->FieldCount++;
379 break;
380
381 case ACPI_TYPE_BUFFER:
382
383 Info->BufferCount++;
384 break;
385
386 case ACPI_TYPE_PACKAGE:
387
388 Info->PackageCount++;
389 break;
390
391 default:
392
393 /* No init required, just exit now */
394
395 return (AE_OK);
396 }
397
398 /* If the object is already initialized, nothing else to do */
399
400 if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
401 {
402 return (AE_OK);
403 }
404
405 /* Must lock the interpreter before executing AML code */
406
407 AcpiExEnterInterpreter ();
408
409 /*
410 * Each of these types can contain executable AML code within the
411 * declaration.
412 */
413 switch (Type)
414 {
415 case ACPI_TYPE_REGION:
416
417 Info->OpRegionInit++;
418 Status = AcpiDsGetRegionArguments (ObjDesc);
419 break;
420
421 case ACPI_TYPE_BUFFER_FIELD:
422
423 Info->FieldInit++;
424 Status = AcpiDsGetBufferFieldArguments (ObjDesc);
425 break;
426
427 case ACPI_TYPE_LOCAL_BANK_FIELD:
428
429 Info->FieldInit++;
430 Status = AcpiDsGetBankFieldArguments (ObjDesc);
431 break;
432
433 case ACPI_TYPE_BUFFER:
434
435 Info->BufferInit++;
436 Status = AcpiDsGetBufferArguments (ObjDesc);
437 break;
438
439 case ACPI_TYPE_PACKAGE:
440
441 Info->PackageInit++;
442 Status = AcpiDsGetPackageArguments (ObjDesc);
443 break;
444
445 default:
446
447 /* No other types can get here */
448
449 break;
450 }
451
452 if (ACPI_FAILURE (Status))
453 {
454 ACPI_EXCEPTION ((AE_INFO, Status,
455 "Could not execute arguments for [%4.4s] (%s)",
456 AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Type)));
457 }
458
459 /*
460 * We ignore errors from above, and always return OK, since we don't want
461 * to abort the walk on any single error.
462 */
463 AcpiExExitInterpreter ();
464 return (AE_OK);
465 }
466
467
468 /*******************************************************************************
469 *
470 * FUNCTION: AcpiNsFindIniMethods
471 *
472 * PARAMETERS: ACPI_WALK_CALLBACK
473 *
474 * RETURN: ACPI_STATUS
475 *
476 * DESCRIPTION: Called during namespace walk. Finds objects named _INI under
477 * device/processor/thermal objects, and marks the entire subtree
478 * with a SUBTREE_HAS_INI flag. This flag is used during the
479 * subsequent device initialization walk to avoid entire subtrees
480 * that do not contain an _INI.
481 *
482 ******************************************************************************/
483
484 static ACPI_STATUS
485 AcpiNsFindIniMethods (
486 ACPI_HANDLE ObjHandle,
487 UINT32 NestingLevel,
488 void *Context,
489 void **ReturnValue)
490 {
491 ACPI_DEVICE_WALK_INFO *Info = ACPI_CAST_PTR (ACPI_DEVICE_WALK_INFO, Context);
492 ACPI_NAMESPACE_NODE *Node;
493 ACPI_NAMESPACE_NODE *ParentNode;
494
495
496 /* Keep count of device/processor/thermal objects */
497
498 Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);
499 if ((Node->Type == ACPI_TYPE_DEVICE) ||
500 (Node->Type == ACPI_TYPE_PROCESSOR) ||
501 (Node->Type == ACPI_TYPE_THERMAL))
502 {
503 Info->DeviceCount++;
504 return (AE_OK);
505 }
506
507 /* We are only looking for methods named _INI */
508
509 if (!ACPI_COMPARE_NAME (Node->Name.Ascii, METHOD_NAME__INI))
510 {
511 return (AE_OK);
512 }
513
514 /*
515 * The only _INI methods that we care about are those that are
516 * present under Device, Processor, and Thermal objects.
517 */
518 ParentNode = Node->Parent;
519 switch (ParentNode->Type)
520 {
521 case ACPI_TYPE_DEVICE:
522 case ACPI_TYPE_PROCESSOR:
523 case ACPI_TYPE_THERMAL:
524
525 /* Mark parent and bubble up the INI present flag to the root */
526
527 while (ParentNode)
528 {
529 ParentNode->Flags |= ANOBJ_SUBTREE_HAS_INI;
530 ParentNode = ParentNode->Parent;
531 }
532 break;
533
534 default:
535
536 break;
537 }
538
539 return (AE_OK);
540 }
541
542
543 /*******************************************************************************
544 *
545 * FUNCTION: AcpiNsInitOneDevice
546 *
547 * PARAMETERS: ACPI_WALK_CALLBACK
548 *
549 * RETURN: ACPI_STATUS
550 *
551 * DESCRIPTION: This is called once per device soon after ACPI is enabled
552 * to initialize each device. It determines if the device is
553 * present, and if so, calls _INI.
554 *
555 ******************************************************************************/
556
557 static ACPI_STATUS
558 AcpiNsInitOneDevice (
559 ACPI_HANDLE ObjHandle,
560 UINT32 NestingLevel,
561 void *Context,
562 void **ReturnValue)
563 {
564 ACPI_DEVICE_WALK_INFO *WalkInfo = ACPI_CAST_PTR (ACPI_DEVICE_WALK_INFO, Context);
565 ACPI_EVALUATE_INFO *Info = WalkInfo->EvaluateInfo;
566 UINT32 Flags;
567 ACPI_STATUS Status;
568 ACPI_NAMESPACE_NODE *DeviceNode;
569
570
571 ACPI_FUNCTION_TRACE (NsInitOneDevice);
572
573
574 /* We are interested in Devices, Processors and ThermalZones only */
575
576 DeviceNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);
577 if ((DeviceNode->Type != ACPI_TYPE_DEVICE) &&
578 (DeviceNode->Type != ACPI_TYPE_PROCESSOR) &&
579 (DeviceNode->Type != ACPI_TYPE_THERMAL))
580 {
581 return_ACPI_STATUS (AE_OK);
582 }
583
584 /*
585 * Because of an earlier namespace analysis, all subtrees that contain an
586 * _INI method are tagged.
587 *
588 * If this device subtree does not contain any _INI methods, we
589 * can exit now and stop traversing this entire subtree.
590 */
591 if (!(DeviceNode->Flags & ANOBJ_SUBTREE_HAS_INI))
592 {
593 return_ACPI_STATUS (AE_CTRL_DEPTH);
594 }
595
596 /*
597 * Run _STA to determine if this device is present and functioning. We
598 * must know this information for two important reasons (from ACPI spec):
599 *
600 * 1) We can only run _INI if the device is present.
601 * 2) We must abort the device tree walk on this subtree if the device is
602 * not present and is not functional (we will not examine the children)
603 *
604 * The _STA method is not required to be present under the device, we
605 * assume the device is present if _STA does not exist.
606 */
607 ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (
608 ACPI_TYPE_METHOD, DeviceNode, METHOD_NAME__STA));
609
610 Status = AcpiUtExecute_STA (DeviceNode, &Flags);
611 if (ACPI_FAILURE (Status))
612 {
613 /* Ignore error and move on to next device */
614
615 return_ACPI_STATUS (AE_OK);
616 }
617
618 /*
619 * Flags == -1 means that _STA was not found. In this case, we assume that
620 * the device is both present and functional.
621 *
622 * From the ACPI spec, description of _STA:
623 *
624 * "If a device object (including the processor object) does not have an
625 * _STA object, then OSPM assumes that all of the above bits are set (in
626 * other words, the device is present, ..., and functioning)"
627 */
628 if (Flags != ACPI_UINT32_MAX)
629 {
630 WalkInfo->Num_STA++;
631 }
632
633 /*
634 * Examine the PRESENT and FUNCTIONING status bits
635 *
636 * Note: ACPI spec does not seem to specify behavior for the present but
637 * not functioning case, so we assume functioning if present.
638 */
639 if (!(Flags & ACPI_STA_DEVICE_PRESENT))
640 {
641 /* Device is not present, we must examine the Functioning bit */
642
643 if (Flags & ACPI_STA_DEVICE_FUNCTIONING)
644 {
645 /*
646 * Device is not present but is "functioning". In this case,
647 * we will not run _INI, but we continue to examine the children
648 * of this device.
649 *
650 * From the ACPI spec, description of _STA: (Note - no mention
651 * of whether to run _INI or not on the device in question)
652 *
653 * "_STA may return bit 0 clear (not present) with bit 3 set
654 * (device is functional). This case is used to indicate a valid
655 * device for which no device driver should be loaded (for example,
656 * a bridge device.) Children of this device may be present and
657 * valid. OSPM should continue enumeration below a device whose
658 * _STA returns this bit combination"
659 */
660 return_ACPI_STATUS (AE_OK);
661 }
662 else
663 {
664 /*
665 * Device is not present and is not functioning. We must abort the
666 * walk of this subtree immediately -- don't look at the children
667 * of such a device.
668 *
669 * From the ACPI spec, description of _INI:
670 *
671 * "If the _STA method indicates that the device is not present,
672 * OSPM will not run the _INI and will not examine the children
673 * of the device for _INI methods"
674 */
675 return_ACPI_STATUS (AE_CTRL_DEPTH);
676 }
677 }
678
679 /*
680 * The device is present or is assumed present if no _STA exists.
681 * Run the _INI if it exists (not required to exist)
682 *
683 * Note: We know there is an _INI within this subtree, but it may not be
684 * under this particular device, it may be lower in the branch.
685 */
686 ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (
687 ACPI_TYPE_METHOD, DeviceNode, METHOD_NAME__INI));
688
689 ACPI_MEMSET (Info, 0, sizeof (ACPI_EVALUATE_INFO));
690 Info->PrefixNode = DeviceNode;
691 Info->RelativePathname = METHOD_NAME__INI;
692 Info->Parameters = NULL;
693 Info->Flags = ACPI_IGNORE_RETURN_VALUE;
694
695 Status = AcpiNsEvaluate (Info);
696 if (ACPI_SUCCESS (Status))
697 {
698 WalkInfo->Num_INI++;
699 }
700
701 #ifdef ACPI_DEBUG_OUTPUT
702 else if (Status != AE_NOT_FOUND)
703 {
704 /* Ignore error and move on to next device */
705
706 char *ScopeName = AcpiNsGetExternalPathname (Info->Node);
707
708 ACPI_EXCEPTION ((AE_INFO, Status, "during %s._INI execution",
709 ScopeName));
710 ACPI_FREE (ScopeName);
711 }
712 #endif
713
714 /* Ignore errors from above */
715
716 Status = AE_OK;
717
718 /*
719 * The _INI method has been run if present; call the Global Initialization
720 * Handler for this device.
721 */
722 if (AcpiGbl_InitHandler)
723 {
724 Status = AcpiGbl_InitHandler (DeviceNode, ACPI_INIT_DEVICE_INI);
725 }
726
727 return_ACPI_STATUS (Status);
728 }