17c478bd9Sstevel@tonic-gate /******************************************************************************
27c478bd9Sstevel@tonic-gate *
37c478bd9Sstevel@tonic-gate * Module Name: nsinit - namespace initialization
47c478bd9Sstevel@tonic-gate *
57c478bd9Sstevel@tonic-gate *****************************************************************************/
67c478bd9Sstevel@tonic-gate
7*35786f68SRobert Mustacchi /******************************************************************************
8*35786f68SRobert Mustacchi *
9*35786f68SRobert Mustacchi * 1. Copyright Notice
10*35786f68SRobert Mustacchi *
11*35786f68SRobert Mustacchi * Some or all of this work - Copyright (c) 1999 - 2018, Intel Corp.
127c478bd9Sstevel@tonic-gate * All rights reserved.
137c478bd9Sstevel@tonic-gate *
14*35786f68SRobert Mustacchi * 2. License
15*35786f68SRobert Mustacchi *
16*35786f68SRobert Mustacchi * 2.1. This is your license from Intel Corp. under its intellectual property
17*35786f68SRobert Mustacchi * rights. You may have additional license terms from the party that provided
18*35786f68SRobert Mustacchi * you this software, covering your right to use that party's intellectual
19*35786f68SRobert Mustacchi * property rights.
20*35786f68SRobert Mustacchi *
21*35786f68SRobert Mustacchi * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22*35786f68SRobert Mustacchi * copy of the source code appearing in this file ("Covered Code") an
23*35786f68SRobert Mustacchi * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24*35786f68SRobert Mustacchi * base code distributed originally by Intel ("Original Intel Code") to copy,
25*35786f68SRobert Mustacchi * make derivatives, distribute, use and display any portion of the Covered
26*35786f68SRobert Mustacchi * Code in any form, with the right to sublicense such rights; and
27*35786f68SRobert Mustacchi *
28*35786f68SRobert Mustacchi * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29*35786f68SRobert Mustacchi * license (with the right to sublicense), under only those claims of Intel
30*35786f68SRobert Mustacchi * patents that are infringed by the Original Intel Code, to make, use, sell,
31*35786f68SRobert Mustacchi * offer to sell, and import the Covered Code and derivative works thereof
32*35786f68SRobert Mustacchi * solely to the minimum extent necessary to exercise the above copyright
33*35786f68SRobert Mustacchi * license, and in no event shall the patent license extend to any additions
34*35786f68SRobert Mustacchi * to or modifications of the Original Intel Code. No other license or right
35*35786f68SRobert Mustacchi * is granted directly or by implication, estoppel or otherwise;
36*35786f68SRobert Mustacchi *
37*35786f68SRobert Mustacchi * The above copyright and patent license is granted only if the following
38*35786f68SRobert Mustacchi * conditions are met:
39*35786f68SRobert Mustacchi *
40*35786f68SRobert Mustacchi * 3. Conditions
41*35786f68SRobert Mustacchi *
42*35786f68SRobert Mustacchi * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43*35786f68SRobert Mustacchi * Redistribution of source code of any substantial portion of the Covered
44*35786f68SRobert Mustacchi * Code or modification with rights to further distribute source must include
45*35786f68SRobert Mustacchi * the above Copyright Notice, the above License, this list of Conditions,
46*35786f68SRobert Mustacchi * and the following Disclaimer and Export Compliance provision. In addition,
47*35786f68SRobert Mustacchi * Licensee must cause all Covered Code to which Licensee contributes to
48*35786f68SRobert Mustacchi * contain a file documenting the changes Licensee made to create that Covered
49*35786f68SRobert Mustacchi * Code and the date of any change. Licensee must include in that file the
50*35786f68SRobert Mustacchi * documentation of any changes made by any predecessor Licensee. Licensee
51*35786f68SRobert Mustacchi * must include a prominent statement that the modification is derived,
52*35786f68SRobert Mustacchi * directly or indirectly, from Original Intel Code.
53*35786f68SRobert Mustacchi *
54*35786f68SRobert Mustacchi * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55*35786f68SRobert Mustacchi * Redistribution of source code of any substantial portion of the Covered
56*35786f68SRobert Mustacchi * Code or modification without rights to further distribute source must
57*35786f68SRobert Mustacchi * include the following Disclaimer and Export Compliance provision in the
58*35786f68SRobert Mustacchi * documentation and/or other materials provided with distribution. In
59*35786f68SRobert Mustacchi * addition, Licensee may not authorize further sublicense of source of any
60*35786f68SRobert Mustacchi * portion of the Covered Code, and must include terms to the effect that the
61*35786f68SRobert Mustacchi * license from Licensee to its licensee is limited to the intellectual
62*35786f68SRobert Mustacchi * property embodied in the software Licensee provides to its licensee, and
63*35786f68SRobert Mustacchi * not to intellectual property embodied in modifications its licensee may
64*35786f68SRobert Mustacchi * make.
65*35786f68SRobert Mustacchi *
66*35786f68SRobert Mustacchi * 3.3. Redistribution of Executable. Redistribution in executable form of any
67*35786f68SRobert Mustacchi * substantial portion of the Covered Code or modification must reproduce the
68*35786f68SRobert Mustacchi * above Copyright Notice, and the following Disclaimer and Export Compliance
69*35786f68SRobert Mustacchi * provision in the documentation and/or other materials provided with the
70*35786f68SRobert Mustacchi * distribution.
71*35786f68SRobert Mustacchi *
72*35786f68SRobert Mustacchi * 3.4. Intel retains all right, title, and interest in and to the Original
73*35786f68SRobert Mustacchi * Intel Code.
74*35786f68SRobert Mustacchi *
75*35786f68SRobert Mustacchi * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76*35786f68SRobert Mustacchi * Intel shall be used in advertising or otherwise to promote the sale, use or
77*35786f68SRobert Mustacchi * other dealings in products derived from or relating to the Covered Code
78*35786f68SRobert Mustacchi * without prior written authorization from Intel.
79*35786f68SRobert Mustacchi *
80*35786f68SRobert Mustacchi * 4. Disclaimer and Export Compliance
81*35786f68SRobert Mustacchi *
82*35786f68SRobert Mustacchi * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83*35786f68SRobert Mustacchi * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84*35786f68SRobert Mustacchi * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85*35786f68SRobert Mustacchi * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86*35786f68SRobert Mustacchi * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87*35786f68SRobert Mustacchi * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88*35786f68SRobert Mustacchi * PARTICULAR PURPOSE.
89*35786f68SRobert Mustacchi *
90*35786f68SRobert Mustacchi * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91*35786f68SRobert Mustacchi * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92*35786f68SRobert Mustacchi * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93*35786f68SRobert Mustacchi * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94*35786f68SRobert Mustacchi * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95*35786f68SRobert Mustacchi * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96*35786f68SRobert Mustacchi * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97*35786f68SRobert Mustacchi * LIMITED REMEDY.
98*35786f68SRobert Mustacchi *
99*35786f68SRobert Mustacchi * 4.3. Licensee shall not export, either directly or indirectly, any of this
100*35786f68SRobert Mustacchi * software or system incorporating such software without first obtaining any
101*35786f68SRobert Mustacchi * required license or other approval from the U. S. Department of Commerce or
102*35786f68SRobert Mustacchi * any other agency or department of the United States Government. In the
103*35786f68SRobert Mustacchi * event Licensee exports any such software from the United States or
104*35786f68SRobert Mustacchi * re-exports any such software from a foreign destination, Licensee shall
105*35786f68SRobert Mustacchi * ensure that the distribution and export/re-export of the software is in
106*35786f68SRobert Mustacchi * compliance with all laws, regulations, orders, or other restrictions of the
107*35786f68SRobert Mustacchi * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108*35786f68SRobert Mustacchi * any of its subsidiaries will export/re-export any technical data, process,
109*35786f68SRobert Mustacchi * software, or service, directly or indirectly, to any country for which the
110*35786f68SRobert Mustacchi * United States government or any agency thereof requires an export license,
111*35786f68SRobert Mustacchi * other governmental approval, or letter of assurance, without first obtaining
112*35786f68SRobert Mustacchi * such license, approval or letter.
113*35786f68SRobert Mustacchi *
114*35786f68SRobert Mustacchi *****************************************************************************
115*35786f68SRobert Mustacchi *
116*35786f68SRobert Mustacchi * Alternatively, you may choose to be licensed under the terms of the
117*35786f68SRobert Mustacchi * following license:
118*35786f68SRobert Mustacchi *
11926f3cdf0SGordon Ross * Redistribution and use in source and binary forms, with or without
12026f3cdf0SGordon Ross * modification, are permitted provided that the following conditions
12126f3cdf0SGordon Ross * are met:
12226f3cdf0SGordon Ross * 1. Redistributions of source code must retain the above copyright
12326f3cdf0SGordon Ross * notice, this list of conditions, and the following disclaimer,
12426f3cdf0SGordon Ross * without modification.
12526f3cdf0SGordon Ross * 2. Redistributions in binary form must reproduce at minimum a disclaimer
12626f3cdf0SGordon Ross * substantially similar to the "NO WARRANTY" disclaimer below
12726f3cdf0SGordon Ross * ("Disclaimer") and any redistribution must be conditioned upon
12826f3cdf0SGordon Ross * including a substantially similar Disclaimer requirement for further
12926f3cdf0SGordon Ross * binary redistribution.
13026f3cdf0SGordon Ross * 3. Neither the names of the above-listed copyright holders nor the names
13126f3cdf0SGordon Ross * of any contributors may be used to endorse or promote products derived
13226f3cdf0SGordon Ross * from this software without specific prior written permission.
13326f3cdf0SGordon Ross *
13426f3cdf0SGordon Ross * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
13526f3cdf0SGordon Ross * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136*35786f68SRobert Mustacchi * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
13726f3cdf0SGordon Ross * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138*35786f68SRobert Mustacchi * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139*35786f68SRobert Mustacchi * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140*35786f68SRobert Mustacchi * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141*35786f68SRobert Mustacchi * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142*35786f68SRobert Mustacchi * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143*35786f68SRobert Mustacchi * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144*35786f68SRobert Mustacchi * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145*35786f68SRobert Mustacchi *
146*35786f68SRobert Mustacchi * Alternatively, you may choose to be licensed under the terms of the
147*35786f68SRobert Mustacchi * GNU General Public License ("GPL") version 2 as published by the Free
148*35786f68SRobert Mustacchi * Software Foundation.
149*35786f68SRobert Mustacchi *
150*35786f68SRobert Mustacchi *****************************************************************************/
1517c478bd9Sstevel@tonic-gate
1527c478bd9Sstevel@tonic-gate #include "acpi.h"
153aa2aa9a6SDana Myers #include "accommon.h"
1547c478bd9Sstevel@tonic-gate #include "acnamesp.h"
1557c478bd9Sstevel@tonic-gate #include "acdispat.h"
1567c478bd9Sstevel@tonic-gate #include "acinterp.h"
1577b1019a6SJerry Jelinek #include "acevents.h"
1587c478bd9Sstevel@tonic-gate
1597c478bd9Sstevel@tonic-gate #define _COMPONENT ACPI_NAMESPACE
1607c478bd9Sstevel@tonic-gate ACPI_MODULE_NAME ("nsinit")
1617c478bd9Sstevel@tonic-gate
1627c478bd9Sstevel@tonic-gate /* Local prototypes */
1637c478bd9Sstevel@tonic-gate
1647c478bd9Sstevel@tonic-gate static ACPI_STATUS
1657c478bd9Sstevel@tonic-gate AcpiNsInitOneObject (
1667c478bd9Sstevel@tonic-gate ACPI_HANDLE ObjHandle,
1677c478bd9Sstevel@tonic-gate UINT32 Level,
1687c478bd9Sstevel@tonic-gate void *Context,
1697c478bd9Sstevel@tonic-gate void **ReturnValue);
1707c478bd9Sstevel@tonic-gate
1717c478bd9Sstevel@tonic-gate static ACPI_STATUS
1727c478bd9Sstevel@tonic-gate AcpiNsInitOneDevice (
1737c478bd9Sstevel@tonic-gate ACPI_HANDLE ObjHandle,
1747c478bd9Sstevel@tonic-gate UINT32 NestingLevel,
1757c478bd9Sstevel@tonic-gate void *Context,
1767c478bd9Sstevel@tonic-gate void **ReturnValue);
1777c478bd9Sstevel@tonic-gate
17827f7c583Smyers static ACPI_STATUS
17927f7c583Smyers AcpiNsFindIniMethods (
18027f7c583Smyers ACPI_HANDLE ObjHandle,
18127f7c583Smyers UINT32 NestingLevel,
18227f7c583Smyers void *Context,
18327f7c583Smyers void **ReturnValue);
18427f7c583Smyers
1857c478bd9Sstevel@tonic-gate
1867c478bd9Sstevel@tonic-gate /*******************************************************************************
1877c478bd9Sstevel@tonic-gate *
1887c478bd9Sstevel@tonic-gate * FUNCTION: AcpiNsInitializeObjects
1897c478bd9Sstevel@tonic-gate *
1907c478bd9Sstevel@tonic-gate * PARAMETERS: None
1917c478bd9Sstevel@tonic-gate *
1927c478bd9Sstevel@tonic-gate * RETURN: Status
1937c478bd9Sstevel@tonic-gate *
1947c478bd9Sstevel@tonic-gate * DESCRIPTION: Walk the entire namespace and perform any necessary
1957c478bd9Sstevel@tonic-gate * initialization on the objects found therein
1967c478bd9Sstevel@tonic-gate *
1977c478bd9Sstevel@tonic-gate ******************************************************************************/
1987c478bd9Sstevel@tonic-gate
1997c478bd9Sstevel@tonic-gate ACPI_STATUS
AcpiNsInitializeObjects(void)2007c478bd9Sstevel@tonic-gate AcpiNsInitializeObjects (
2017c478bd9Sstevel@tonic-gate void)
2027c478bd9Sstevel@tonic-gate {
2037c478bd9Sstevel@tonic-gate ACPI_STATUS Status;
2047c478bd9Sstevel@tonic-gate ACPI_INIT_WALK_INFO Info;
2057c478bd9Sstevel@tonic-gate
2067c478bd9Sstevel@tonic-gate
20727f7c583Smyers ACPI_FUNCTION_TRACE (NsInitializeObjects);
2087c478bd9Sstevel@tonic-gate
2097c478bd9Sstevel@tonic-gate
2107b1019a6SJerry Jelinek ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
2117b1019a6SJerry Jelinek "[Init] Completing Initialization of ACPI Objects\n"));
2127c478bd9Sstevel@tonic-gate ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
2137c478bd9Sstevel@tonic-gate "**** Starting initialization of namespace objects ****\n"));
2147c478bd9Sstevel@tonic-gate ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
2157b1019a6SJerry Jelinek "Completing Region/Field/Buffer/Package initialization:\n"));
2167c478bd9Sstevel@tonic-gate
2177c478bd9Sstevel@tonic-gate /* Set all init info to zero */
2187c478bd9Sstevel@tonic-gate
2197b1019a6SJerry Jelinek memset (&Info, 0, sizeof (ACPI_INIT_WALK_INFO));
2207c478bd9Sstevel@tonic-gate
2217c478bd9Sstevel@tonic-gate /* Walk entire namespace from the supplied root */
2227c478bd9Sstevel@tonic-gate
2237c478bd9Sstevel@tonic-gate Status = AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
2247b1019a6SJerry Jelinek ACPI_UINT32_MAX, AcpiNsInitOneObject, NULL,
2257b1019a6SJerry Jelinek &Info, NULL);
2267c478bd9Sstevel@tonic-gate if (ACPI_FAILURE (Status))
2277c478bd9Sstevel@tonic-gate {
22830082d0cSmyers ACPI_EXCEPTION ((AE_INFO, Status, "During WalkNamespace"));
2297c478bd9Sstevel@tonic-gate }
2307c478bd9Sstevel@tonic-gate
2317c478bd9Sstevel@tonic-gate ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
2327b1019a6SJerry Jelinek " Initialized %u/%u Regions %u/%u Fields %u/%u "
23326f3cdf0SGordon Ross "Buffers %u/%u Packages (%u nodes)\n",
2347c478bd9Sstevel@tonic-gate Info.OpRegionInit, Info.OpRegionCount,
2357c478bd9Sstevel@tonic-gate Info.FieldInit, Info.FieldCount,
2367c478bd9Sstevel@tonic-gate Info.BufferInit, Info.BufferCount,
2377c478bd9Sstevel@tonic-gate Info.PackageInit, Info.PackageCount, Info.ObjectCount));
2387c478bd9Sstevel@tonic-gate
2397c478bd9Sstevel@tonic-gate ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
2407b1019a6SJerry Jelinek "%u Control Methods found\n%u Op Regions found\n",
2417b1019a6SJerry Jelinek Info.MethodCount, Info.OpRegionCount));
2427c478bd9Sstevel@tonic-gate
2437c478bd9Sstevel@tonic-gate return_ACPI_STATUS (AE_OK);
2447c478bd9Sstevel@tonic-gate }
2457c478bd9Sstevel@tonic-gate
2467c478bd9Sstevel@tonic-gate
2477c478bd9Sstevel@tonic-gate /*******************************************************************************
2487c478bd9Sstevel@tonic-gate *
2497c478bd9Sstevel@tonic-gate * FUNCTION: AcpiNsInitializeDevices
2507c478bd9Sstevel@tonic-gate *
2517c478bd9Sstevel@tonic-gate * PARAMETERS: None
2527c478bd9Sstevel@tonic-gate *
2537c478bd9Sstevel@tonic-gate * RETURN: ACPI_STATUS
2547c478bd9Sstevel@tonic-gate *
2557c478bd9Sstevel@tonic-gate * DESCRIPTION: Walk the entire namespace and initialize all ACPI devices.
2567c478bd9Sstevel@tonic-gate * This means running _INI on all present devices.
2577c478bd9Sstevel@tonic-gate *
2587c478bd9Sstevel@tonic-gate * Note: We install PCI config space handler on region access,
2597c478bd9Sstevel@tonic-gate * not here.
2607c478bd9Sstevel@tonic-gate *
2617c478bd9Sstevel@tonic-gate ******************************************************************************/
2627c478bd9Sstevel@tonic-gate
2637c478bd9Sstevel@tonic-gate ACPI_STATUS
AcpiNsInitializeDevices(UINT32 Flags)2647c478bd9Sstevel@tonic-gate AcpiNsInitializeDevices (
2657b1019a6SJerry Jelinek UINT32 Flags)
2667c478bd9Sstevel@tonic-gate {
2677b1019a6SJerry Jelinek ACPI_STATUS Status = AE_OK;
2687c478bd9Sstevel@tonic-gate ACPI_DEVICE_WALK_INFO Info;
2697b1019a6SJerry Jelinek ACPI_HANDLE Handle;
2707c478bd9Sstevel@tonic-gate
2717c478bd9Sstevel@tonic-gate
27227f7c583Smyers ACPI_FUNCTION_TRACE (NsInitializeDevices);
2737c478bd9Sstevel@tonic-gate
2747c478bd9Sstevel@tonic-gate
2757b1019a6SJerry Jelinek if (!(Flags & ACPI_NO_DEVICE_INIT))
2767b1019a6SJerry Jelinek {
2777b1019a6SJerry Jelinek ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
2787b1019a6SJerry Jelinek "[Init] Initializing ACPI Devices\n"));
2797c478bd9Sstevel@tonic-gate
2807b1019a6SJerry Jelinek /* Init counters */
2817c478bd9Sstevel@tonic-gate
2827b1019a6SJerry Jelinek Info.DeviceCount = 0;
2837b1019a6SJerry Jelinek Info.Num_STA = 0;
2847b1019a6SJerry Jelinek Info.Num_INI = 0;
28527f7c583Smyers
2867b1019a6SJerry Jelinek ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
2877b1019a6SJerry Jelinek "Initializing Device/Processor/Thermal objects "
2887b1019a6SJerry Jelinek "and executing _INI/_STA methods:\n"));
2897c478bd9Sstevel@tonic-gate
2907b1019a6SJerry Jelinek /* Tree analysis: find all subtrees that contain _INI methods */
2917c478bd9Sstevel@tonic-gate
2927b1019a6SJerry Jelinek Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
2937b1019a6SJerry Jelinek ACPI_UINT32_MAX, FALSE, AcpiNsFindIniMethods, NULL, &Info, NULL);
2947b1019a6SJerry Jelinek if (ACPI_FAILURE (Status))
2957b1019a6SJerry Jelinek {
2967b1019a6SJerry Jelinek goto ErrorExit;
2977b1019a6SJerry Jelinek }
2987c478bd9Sstevel@tonic-gate
2997b1019a6SJerry Jelinek /* Allocate the evaluation information block */
30057190917SDana Myers
3017b1019a6SJerry Jelinek Info.EvaluateInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
3027b1019a6SJerry Jelinek if (!Info.EvaluateInfo)
3037b1019a6SJerry Jelinek {
3047b1019a6SJerry Jelinek Status = AE_NO_MEMORY;
3057b1019a6SJerry Jelinek goto ErrorExit;
3067b1019a6SJerry Jelinek }
30757190917SDana Myers
3087b1019a6SJerry Jelinek /*
3097b1019a6SJerry Jelinek * Execute the "global" _INI method that may appear at the root.
3107b1019a6SJerry Jelinek * This support is provided for Windows compatibility (Vista+) and
3117b1019a6SJerry Jelinek * is not part of the ACPI specification.
3127b1019a6SJerry Jelinek */
3137b1019a6SJerry Jelinek Info.EvaluateInfo->PrefixNode = AcpiGbl_RootNode;
3147b1019a6SJerry Jelinek Info.EvaluateInfo->RelativePathname = METHOD_NAME__INI;
3157b1019a6SJerry Jelinek Info.EvaluateInfo->Parameters = NULL;
3167b1019a6SJerry Jelinek Info.EvaluateInfo->Flags = ACPI_IGNORE_RETURN_VALUE;
3177b1019a6SJerry Jelinek
3187b1019a6SJerry Jelinek Status = AcpiNsEvaluate (Info.EvaluateInfo);
3197b1019a6SJerry Jelinek if (ACPI_SUCCESS (Status))
3207b1019a6SJerry Jelinek {
3217b1019a6SJerry Jelinek Info.Num_INI++;
3227b1019a6SJerry Jelinek }
3237c478bd9Sstevel@tonic-gate
3247b1019a6SJerry Jelinek /*
3257b1019a6SJerry Jelinek * Execute \_SB._INI.
3267b1019a6SJerry Jelinek * There appears to be a strict order requirement for \_SB._INI,
3277b1019a6SJerry Jelinek * which should be evaluated before any _REG evaluations.
3287b1019a6SJerry Jelinek */
3297b1019a6SJerry Jelinek Status = AcpiGetHandle (NULL, "\\_SB", &Handle);
3307b1019a6SJerry Jelinek if (ACPI_SUCCESS (Status))
3317b1019a6SJerry Jelinek {
3327b1019a6SJerry Jelinek memset (Info.EvaluateInfo, 0, sizeof (ACPI_EVALUATE_INFO));
3337b1019a6SJerry Jelinek Info.EvaluateInfo->PrefixNode = Handle;
3347b1019a6SJerry Jelinek Info.EvaluateInfo->RelativePathname = METHOD_NAME__INI;
3357b1019a6SJerry Jelinek Info.EvaluateInfo->Parameters = NULL;
3367b1019a6SJerry Jelinek Info.EvaluateInfo->Flags = ACPI_IGNORE_RETURN_VALUE;
3377b1019a6SJerry Jelinek
3387b1019a6SJerry Jelinek Status = AcpiNsEvaluate (Info.EvaluateInfo);
3397b1019a6SJerry Jelinek if (ACPI_SUCCESS (Status))
3407b1019a6SJerry Jelinek {
3417b1019a6SJerry Jelinek Info.Num_INI++;
3427b1019a6SJerry Jelinek }
3437b1019a6SJerry Jelinek }
3447b1019a6SJerry Jelinek }
34527f7c583Smyers
34626f3cdf0SGordon Ross /*
3477b1019a6SJerry Jelinek * Run all _REG methods
3487b1019a6SJerry Jelinek *
3497b1019a6SJerry Jelinek * Note: Any objects accessed by the _REG methods will be automatically
3507b1019a6SJerry Jelinek * initialized, even if they contain executable AML (see the call to
3517b1019a6SJerry Jelinek * AcpiNsInitializeObjects below).
3527b1019a6SJerry Jelinek *
3537b1019a6SJerry Jelinek * Note: According to the ACPI specification, we actually needn't execute
3547b1019a6SJerry Jelinek * _REG for SystemMemory/SystemIo operation regions, but for PCI_Config
3557b1019a6SJerry Jelinek * operation regions, it is required to evaluate _REG for those on a PCI
3567b1019a6SJerry Jelinek * root bus that doesn't contain _BBN object. So this code is kept here
3577b1019a6SJerry Jelinek * in order not to break things.
35826f3cdf0SGordon Ross */
3597b1019a6SJerry Jelinek if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT))
36026f3cdf0SGordon Ross {
3617b1019a6SJerry Jelinek ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
3627b1019a6SJerry Jelinek "[Init] Executing _REG OpRegion methods\n"));
3637b1019a6SJerry Jelinek
3647b1019a6SJerry Jelinek Status = AcpiEvInitializeOpRegions ();
3657b1019a6SJerry Jelinek if (ACPI_FAILURE (Status))
3667b1019a6SJerry Jelinek {
3677b1019a6SJerry Jelinek goto ErrorExit;
3687b1019a6SJerry Jelinek }
36926f3cdf0SGordon Ross }
37026f3cdf0SGordon Ross
3717b1019a6SJerry Jelinek if (!(Flags & ACPI_NO_DEVICE_INIT))
3727c478bd9Sstevel@tonic-gate {
3737b1019a6SJerry Jelinek /* Walk namespace to execute all _INIs on present devices */
3747c478bd9Sstevel@tonic-gate
3757b1019a6SJerry Jelinek Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
3767b1019a6SJerry Jelinek ACPI_UINT32_MAX, FALSE, AcpiNsInitOneDevice, NULL, &Info, NULL);
3777b1019a6SJerry Jelinek
3787b1019a6SJerry Jelinek /*
3797b1019a6SJerry Jelinek * Any _OSI requests should be completed by now. If the BIOS has
3807b1019a6SJerry Jelinek * requested any Windows OSI strings, we will always truncate
3817b1019a6SJerry Jelinek * I/O addresses to 16 bits -- for Windows compatibility.
3827b1019a6SJerry Jelinek */
3837b1019a6SJerry Jelinek if (AcpiGbl_OsiData >= ACPI_OSI_WIN_2000)
3847b1019a6SJerry Jelinek {
3857b1019a6SJerry Jelinek AcpiGbl_TruncateIoAddresses = TRUE;
3867b1019a6SJerry Jelinek }
3877b1019a6SJerry Jelinek
3887b1019a6SJerry Jelinek ACPI_FREE (Info.EvaluateInfo);
3897b1019a6SJerry Jelinek if (ACPI_FAILURE (Status))
3907b1019a6SJerry Jelinek {
3917b1019a6SJerry Jelinek goto ErrorExit;
3927b1019a6SJerry Jelinek }
3937b1019a6SJerry Jelinek
3947b1019a6SJerry Jelinek ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
3957b1019a6SJerry Jelinek " Executed %u _INI methods requiring %u _STA executions "
3967b1019a6SJerry Jelinek "(examined %u objects)\n",
3977b1019a6SJerry Jelinek Info.Num_INI, Info.Num_STA, Info.DeviceCount));
3987b1019a6SJerry Jelinek }
3997c478bd9Sstevel@tonic-gate
4007c478bd9Sstevel@tonic-gate return_ACPI_STATUS (Status);
40127f7c583Smyers
40227f7c583Smyers
40327f7c583Smyers ErrorExit:
40427f7c583Smyers ACPI_EXCEPTION ((AE_INFO, Status, "During device initialization"));
40527f7c583Smyers return_ACPI_STATUS (Status);
4067c478bd9Sstevel@tonic-gate }
4077c478bd9Sstevel@tonic-gate
4087c478bd9Sstevel@tonic-gate
409*35786f68SRobert Mustacchi /*******************************************************************************
410*35786f68SRobert Mustacchi *
411*35786f68SRobert Mustacchi * FUNCTION: AcpiNsInitOnePackage
412*35786f68SRobert Mustacchi *
413*35786f68SRobert Mustacchi * PARAMETERS: ObjHandle - Node
414*35786f68SRobert Mustacchi * Level - Current nesting level
415*35786f68SRobert Mustacchi * Context - Not used
416*35786f68SRobert Mustacchi * ReturnValue - Not used
417*35786f68SRobert Mustacchi *
418*35786f68SRobert Mustacchi * RETURN: Status
419*35786f68SRobert Mustacchi *
420*35786f68SRobert Mustacchi * DESCRIPTION: Callback from AcpiWalkNamespace. Invoked for every package
421*35786f68SRobert Mustacchi * within the namespace. Used during dynamic load of an SSDT.
422*35786f68SRobert Mustacchi *
423*35786f68SRobert Mustacchi ******************************************************************************/
424*35786f68SRobert Mustacchi
425*35786f68SRobert Mustacchi ACPI_STATUS
AcpiNsInitOnePackage(ACPI_HANDLE ObjHandle,UINT32 Level,void * Context,void ** ReturnValue)426*35786f68SRobert Mustacchi AcpiNsInitOnePackage (
427*35786f68SRobert Mustacchi ACPI_HANDLE ObjHandle,
428*35786f68SRobert Mustacchi UINT32 Level,
429*35786f68SRobert Mustacchi void *Context,
430*35786f68SRobert Mustacchi void **ReturnValue)
431*35786f68SRobert Mustacchi {
432*35786f68SRobert Mustacchi ACPI_STATUS Status;
433*35786f68SRobert Mustacchi ACPI_OPERAND_OBJECT *ObjDesc;
434*35786f68SRobert Mustacchi ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
435*35786f68SRobert Mustacchi
436*35786f68SRobert Mustacchi
437*35786f68SRobert Mustacchi ObjDesc = AcpiNsGetAttachedObject (Node);
438*35786f68SRobert Mustacchi if (!ObjDesc)
439*35786f68SRobert Mustacchi {
440*35786f68SRobert Mustacchi return (AE_OK);
441*35786f68SRobert Mustacchi }
442*35786f68SRobert Mustacchi
443*35786f68SRobert Mustacchi /* Exit if package is already initialized */
444*35786f68SRobert Mustacchi
445*35786f68SRobert Mustacchi if (ObjDesc->Package.Flags & AOPOBJ_DATA_VALID)
446*35786f68SRobert Mustacchi {
447*35786f68SRobert Mustacchi return (AE_OK);
448*35786f68SRobert Mustacchi }
449*35786f68SRobert Mustacchi
450*35786f68SRobert Mustacchi Status = AcpiDsGetPackageArguments (ObjDesc);
451*35786f68SRobert Mustacchi if (ACPI_FAILURE (Status))
452*35786f68SRobert Mustacchi {
453*35786f68SRobert Mustacchi return (AE_OK);
454*35786f68SRobert Mustacchi }
455*35786f68SRobert Mustacchi
456*35786f68SRobert Mustacchi Status = AcpiUtWalkPackageTree (ObjDesc, NULL, AcpiDsInitPackageElement,
457*35786f68SRobert Mustacchi NULL);
458*35786f68SRobert Mustacchi if (ACPI_FAILURE (Status))
459*35786f68SRobert Mustacchi {
460*35786f68SRobert Mustacchi return (AE_OK);
461*35786f68SRobert Mustacchi }
462*35786f68SRobert Mustacchi
463*35786f68SRobert Mustacchi ObjDesc->Package.Flags |= AOPOBJ_DATA_VALID;
464*35786f68SRobert Mustacchi return (AE_OK);
465*35786f68SRobert Mustacchi }
466*35786f68SRobert Mustacchi
467*35786f68SRobert Mustacchi
4687c478bd9Sstevel@tonic-gate /*******************************************************************************
4697c478bd9Sstevel@tonic-gate *
4707c478bd9Sstevel@tonic-gate * FUNCTION: AcpiNsInitOneObject
4717c478bd9Sstevel@tonic-gate *
4727c478bd9Sstevel@tonic-gate * PARAMETERS: ObjHandle - Node
4737c478bd9Sstevel@tonic-gate * Level - Current nesting level
4747c478bd9Sstevel@tonic-gate * Context - Points to a init info struct
4757c478bd9Sstevel@tonic-gate * ReturnValue - Not used
4767c478bd9Sstevel@tonic-gate *
4777c478bd9Sstevel@tonic-gate * RETURN: Status
4787c478bd9Sstevel@tonic-gate *
4797b1019a6SJerry Jelinek * DESCRIPTION: Callback from AcpiWalkNamespace. Invoked for every object
480*35786f68SRobert Mustacchi * within the namespace.
4817c478bd9Sstevel@tonic-gate *
4827c478bd9Sstevel@tonic-gate * Currently, the only objects that require initialization are:
4837c478bd9Sstevel@tonic-gate * 1) Methods
4847c478bd9Sstevel@tonic-gate * 2) Op Regions
4857c478bd9Sstevel@tonic-gate *
4867c478bd9Sstevel@tonic-gate ******************************************************************************/
4877c478bd9Sstevel@tonic-gate
4887c478bd9Sstevel@tonic-gate static ACPI_STATUS
AcpiNsInitOneObject(ACPI_HANDLE ObjHandle,UINT32 Level,void * Context,void ** ReturnValue)4897c478bd9Sstevel@tonic-gate AcpiNsInitOneObject (
4907c478bd9Sstevel@tonic-gate ACPI_HANDLE ObjHandle,
4917c478bd9Sstevel@tonic-gate UINT32 Level,
4927c478bd9Sstevel@tonic-gate void *Context,
4937c478bd9Sstevel@tonic-gate void **ReturnValue)
4947c478bd9Sstevel@tonic-gate {
4957c478bd9Sstevel@tonic-gate ACPI_OBJECT_TYPE Type;
496db2bae30SDana Myers ACPI_STATUS Status = AE_OK;
4977c478bd9Sstevel@tonic-gate ACPI_INIT_WALK_INFO *Info = (ACPI_INIT_WALK_INFO *) Context;
4987c478bd9Sstevel@tonic-gate ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
4997c478bd9Sstevel@tonic-gate ACPI_OPERAND_OBJECT *ObjDesc;
5007c478bd9Sstevel@tonic-gate
5017c478bd9Sstevel@tonic-gate
50227f7c583Smyers ACPI_FUNCTION_NAME (NsInitOneObject);
5037c478bd9Sstevel@tonic-gate
5047c478bd9Sstevel@tonic-gate
5057c478bd9Sstevel@tonic-gate Info->ObjectCount++;
5067c478bd9Sstevel@tonic-gate
5077c478bd9Sstevel@tonic-gate /* And even then, we are only interested in a few object types */
5087c478bd9Sstevel@tonic-gate
5097c478bd9Sstevel@tonic-gate Type = AcpiNsGetType (ObjHandle);
5107c478bd9Sstevel@tonic-gate ObjDesc = AcpiNsGetAttachedObject (Node);
5117c478bd9Sstevel@tonic-gate if (!ObjDesc)
5127c478bd9Sstevel@tonic-gate {
5137c478bd9Sstevel@tonic-gate return (AE_OK);
5147c478bd9Sstevel@tonic-gate }
5157c478bd9Sstevel@tonic-gate
5167c478bd9Sstevel@tonic-gate /* Increment counters for object types we are looking for */
5177c478bd9Sstevel@tonic-gate
5187c478bd9Sstevel@tonic-gate switch (Type)
5197c478bd9Sstevel@tonic-gate {
5207c478bd9Sstevel@tonic-gate case ACPI_TYPE_REGION:
5217b1019a6SJerry Jelinek
5227c478bd9Sstevel@tonic-gate Info->OpRegionCount++;
5237c478bd9Sstevel@tonic-gate break;
5247c478bd9Sstevel@tonic-gate
5257c478bd9Sstevel@tonic-gate case ACPI_TYPE_BUFFER_FIELD:
5267b1019a6SJerry Jelinek
5277c478bd9Sstevel@tonic-gate Info->FieldCount++;
5287c478bd9Sstevel@tonic-gate break;
5297c478bd9Sstevel@tonic-gate
530db2bae30SDana Myers case ACPI_TYPE_LOCAL_BANK_FIELD:
5317b1019a6SJerry Jelinek
532db2bae30SDana Myers Info->FieldCount++;
533db2bae30SDana Myers break;
534db2bae30SDana Myers
5357c478bd9Sstevel@tonic-gate case ACPI_TYPE_BUFFER:
5367b1019a6SJerry Jelinek
5377c478bd9Sstevel@tonic-gate Info->BufferCount++;
5387c478bd9Sstevel@tonic-gate break;
5397c478bd9Sstevel@tonic-gate
5407c478bd9Sstevel@tonic-gate case ACPI_TYPE_PACKAGE:
5417b1019a6SJerry Jelinek
5427c478bd9Sstevel@tonic-gate Info->PackageCount++;
5437c478bd9Sstevel@tonic-gate break;
5447c478bd9Sstevel@tonic-gate
5457c478bd9Sstevel@tonic-gate default:
5467c478bd9Sstevel@tonic-gate
5477c478bd9Sstevel@tonic-gate /* No init required, just exit now */
5487b1019a6SJerry Jelinek
5497c478bd9Sstevel@tonic-gate return (AE_OK);
5507c478bd9Sstevel@tonic-gate }
5517c478bd9Sstevel@tonic-gate
552aa2aa9a6SDana Myers /* If the object is already initialized, nothing else to do */
553aa2aa9a6SDana Myers
5547c478bd9Sstevel@tonic-gate if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
5557c478bd9Sstevel@tonic-gate {
5567c478bd9Sstevel@tonic-gate return (AE_OK);
5577c478bd9Sstevel@tonic-gate }
5587c478bd9Sstevel@tonic-gate
559aa2aa9a6SDana Myers /* Must lock the interpreter before executing AML code */
560aa2aa9a6SDana Myers
561db2bae30SDana Myers AcpiExEnterInterpreter ();
5627c478bd9Sstevel@tonic-gate
5637c478bd9Sstevel@tonic-gate /*
5647c478bd9Sstevel@tonic-gate * Each of these types can contain executable AML code within the
5657c478bd9Sstevel@tonic-gate * declaration.
5667c478bd9Sstevel@tonic-gate */
5677c478bd9Sstevel@tonic-gate switch (Type)
5687c478bd9Sstevel@tonic-gate {
5697c478bd9Sstevel@tonic-gate case ACPI_TYPE_REGION:
5707c478bd9Sstevel@tonic-gate
5717c478bd9Sstevel@tonic-gate Info->OpRegionInit++;
5727c478bd9Sstevel@tonic-gate Status = AcpiDsGetRegionArguments (ObjDesc);
5737c478bd9Sstevel@tonic-gate break;
5747c478bd9Sstevel@tonic-gate
5757c478bd9Sstevel@tonic-gate case ACPI_TYPE_BUFFER_FIELD:
5767c478bd9Sstevel@tonic-gate
5777c478bd9Sstevel@tonic-gate Info->FieldInit++;
5787c478bd9Sstevel@tonic-gate Status = AcpiDsGetBufferFieldArguments (ObjDesc);
5797c478bd9Sstevel@tonic-gate break;
5807c478bd9Sstevel@tonic-gate
581db2bae30SDana Myers case ACPI_TYPE_LOCAL_BANK_FIELD:
582db2bae30SDana Myers
583db2bae30SDana Myers Info->FieldInit++;
584db2bae30SDana Myers Status = AcpiDsGetBankFieldArguments (ObjDesc);
585db2bae30SDana Myers break;
586db2bae30SDana Myers
5877c478bd9Sstevel@tonic-gate case ACPI_TYPE_BUFFER:
5887c478bd9Sstevel@tonic-gate
5897c478bd9Sstevel@tonic-gate Info->BufferInit++;
5907c478bd9Sstevel@tonic-gate Status = AcpiDsGetBufferArguments (ObjDesc);
5917c478bd9Sstevel@tonic-gate break;
5927c478bd9Sstevel@tonic-gate
5937c478bd9Sstevel@tonic-gate case ACPI_TYPE_PACKAGE:
5947c478bd9Sstevel@tonic-gate
595*35786f68SRobert Mustacchi /* Complete the initialization/resolution of the package object */
596*35786f68SRobert Mustacchi
5977c478bd9Sstevel@tonic-gate Info->PackageInit++;
598*35786f68SRobert Mustacchi Status = AcpiNsInitOnePackage (ObjHandle, Level, NULL, NULL);
5997c478bd9Sstevel@tonic-gate break;
6007c478bd9Sstevel@tonic-gate
6017c478bd9Sstevel@tonic-gate default:
6027b1019a6SJerry Jelinek
6037c478bd9Sstevel@tonic-gate /* No other types can get here */
6047b1019a6SJerry Jelinek
6057c478bd9Sstevel@tonic-gate break;
6067c478bd9Sstevel@tonic-gate }
6077c478bd9Sstevel@tonic-gate
6087c478bd9Sstevel@tonic-gate if (ACPI_FAILURE (Status))
6097c478bd9Sstevel@tonic-gate {
61030082d0cSmyers ACPI_EXCEPTION ((AE_INFO, Status,
61130082d0cSmyers "Could not execute arguments for [%4.4s] (%s)",
61230082d0cSmyers AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Type)));
6137c478bd9Sstevel@tonic-gate }
6147c478bd9Sstevel@tonic-gate
6157c478bd9Sstevel@tonic-gate /*
6167c478bd9Sstevel@tonic-gate * We ignore errors from above, and always return OK, since we don't want
6177c478bd9Sstevel@tonic-gate * to abort the walk on any single error.
6187c478bd9Sstevel@tonic-gate */
6197c478bd9Sstevel@tonic-gate AcpiExExitInterpreter ();
6207c478bd9Sstevel@tonic-gate return (AE_OK);
6217c478bd9Sstevel@tonic-gate }
6227c478bd9Sstevel@tonic-gate
6237c478bd9Sstevel@tonic-gate
62427f7c583Smyers /*******************************************************************************
62527f7c583Smyers *
62627f7c583Smyers * FUNCTION: AcpiNsFindIniMethods
62727f7c583Smyers *
62827f7c583Smyers * PARAMETERS: ACPI_WALK_CALLBACK
62927f7c583Smyers *
63027f7c583Smyers * RETURN: ACPI_STATUS
63127f7c583Smyers *
63227f7c583Smyers * DESCRIPTION: Called during namespace walk. Finds objects named _INI under
63327f7c583Smyers * device/processor/thermal objects, and marks the entire subtree
63427f7c583Smyers * with a SUBTREE_HAS_INI flag. This flag is used during the
63527f7c583Smyers * subsequent device initialization walk to avoid entire subtrees
63627f7c583Smyers * that do not contain an _INI.
63727f7c583Smyers *
63827f7c583Smyers ******************************************************************************/
63927f7c583Smyers
64027f7c583Smyers static ACPI_STATUS
AcpiNsFindIniMethods(ACPI_HANDLE ObjHandle,UINT32 NestingLevel,void * Context,void ** ReturnValue)64127f7c583Smyers AcpiNsFindIniMethods (
64227f7c583Smyers ACPI_HANDLE ObjHandle,
64327f7c583Smyers UINT32 NestingLevel,
64427f7c583Smyers void *Context,
64527f7c583Smyers void **ReturnValue)
64627f7c583Smyers {
64727f7c583Smyers ACPI_DEVICE_WALK_INFO *Info = ACPI_CAST_PTR (ACPI_DEVICE_WALK_INFO, Context);
64827f7c583Smyers ACPI_NAMESPACE_NODE *Node;
64927f7c583Smyers ACPI_NAMESPACE_NODE *ParentNode;
65027f7c583Smyers
65127f7c583Smyers
65227f7c583Smyers /* Keep count of device/processor/thermal objects */
65327f7c583Smyers
65427f7c583Smyers Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);
65527f7c583Smyers if ((Node->Type == ACPI_TYPE_DEVICE) ||
65627f7c583Smyers (Node->Type == ACPI_TYPE_PROCESSOR) ||
65727f7c583Smyers (Node->Type == ACPI_TYPE_THERMAL))
65827f7c583Smyers {
65927f7c583Smyers Info->DeviceCount++;
66027f7c583Smyers return (AE_OK);
66127f7c583Smyers }
66227f7c583Smyers
66327f7c583Smyers /* We are only looking for methods named _INI */
66427f7c583Smyers
66527f7c583Smyers if (!ACPI_COMPARE_NAME (Node->Name.Ascii, METHOD_NAME__INI))
66627f7c583Smyers {
66727f7c583Smyers return (AE_OK);
66827f7c583Smyers }
66927f7c583Smyers
67027f7c583Smyers /*
67127f7c583Smyers * The only _INI methods that we care about are those that are
67227f7c583Smyers * present under Device, Processor, and Thermal objects.
67327f7c583Smyers */
67426f3cdf0SGordon Ross ParentNode = Node->Parent;
67527f7c583Smyers switch (ParentNode->Type)
67627f7c583Smyers {
67727f7c583Smyers case ACPI_TYPE_DEVICE:
67827f7c583Smyers case ACPI_TYPE_PROCESSOR:
67927f7c583Smyers case ACPI_TYPE_THERMAL:
68027f7c583Smyers
68127f7c583Smyers /* Mark parent and bubble up the INI present flag to the root */
68227f7c583Smyers
68327f7c583Smyers while (ParentNode)
68427f7c583Smyers {
68527f7c583Smyers ParentNode->Flags |= ANOBJ_SUBTREE_HAS_INI;
68626f3cdf0SGordon Ross ParentNode = ParentNode->Parent;
68727f7c583Smyers }
68827f7c583Smyers break;
68927f7c583Smyers
69027f7c583Smyers default:
6917b1019a6SJerry Jelinek
69227f7c583Smyers break;
69327f7c583Smyers }
69427f7c583Smyers
69527f7c583Smyers return (AE_OK);
69627f7c583Smyers }
69727f7c583Smyers
69827f7c583Smyers
6997c478bd9Sstevel@tonic-gate /*******************************************************************************
7007c478bd9Sstevel@tonic-gate *
7017c478bd9Sstevel@tonic-gate * FUNCTION: AcpiNsInitOneDevice
7027c478bd9Sstevel@tonic-gate *
7037c478bd9Sstevel@tonic-gate * PARAMETERS: ACPI_WALK_CALLBACK
7047c478bd9Sstevel@tonic-gate *
7057c478bd9Sstevel@tonic-gate * RETURN: ACPI_STATUS
7067c478bd9Sstevel@tonic-gate *
7077c478bd9Sstevel@tonic-gate * DESCRIPTION: This is called once per device soon after ACPI is enabled
7087c478bd9Sstevel@tonic-gate * to initialize each device. It determines if the device is
7097c478bd9Sstevel@tonic-gate * present, and if so, calls _INI.
7107c478bd9Sstevel@tonic-gate *
7117c478bd9Sstevel@tonic-gate ******************************************************************************/
7127c478bd9Sstevel@tonic-gate
7137c478bd9Sstevel@tonic-gate static ACPI_STATUS
AcpiNsInitOneDevice(ACPI_HANDLE ObjHandle,UINT32 NestingLevel,void * Context,void ** ReturnValue)7147c478bd9Sstevel@tonic-gate AcpiNsInitOneDevice (
7157c478bd9Sstevel@tonic-gate ACPI_HANDLE ObjHandle,
7167c478bd9Sstevel@tonic-gate UINT32 NestingLevel,
7177c478bd9Sstevel@tonic-gate void *Context,
7187c478bd9Sstevel@tonic-gate void **ReturnValue)
7197c478bd9Sstevel@tonic-gate {
72027f7c583Smyers ACPI_DEVICE_WALK_INFO *WalkInfo = ACPI_CAST_PTR (ACPI_DEVICE_WALK_INFO, Context);
72127f7c583Smyers ACPI_EVALUATE_INFO *Info = WalkInfo->EvaluateInfo;
7227c478bd9Sstevel@tonic-gate UINT32 Flags;
7237c478bd9Sstevel@tonic-gate ACPI_STATUS Status;
72430082d0cSmyers ACPI_NAMESPACE_NODE *DeviceNode;
7257c478bd9Sstevel@tonic-gate
7267c478bd9Sstevel@tonic-gate
72727f7c583Smyers ACPI_FUNCTION_TRACE (NsInitOneDevice);
7287c478bd9Sstevel@tonic-gate
7297c478bd9Sstevel@tonic-gate
73027f7c583Smyers /* We are interested in Devices, Processors and ThermalZones only */
7317c478bd9Sstevel@tonic-gate
73227f7c583Smyers DeviceNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);
73330082d0cSmyers if ((DeviceNode->Type != ACPI_TYPE_DEVICE) &&
73430082d0cSmyers (DeviceNode->Type != ACPI_TYPE_PROCESSOR) &&
73530082d0cSmyers (DeviceNode->Type != ACPI_TYPE_THERMAL))
7367c478bd9Sstevel@tonic-gate {
7377c478bd9Sstevel@tonic-gate return_ACPI_STATUS (AE_OK);
7387c478bd9Sstevel@tonic-gate }
7397c478bd9Sstevel@tonic-gate
7407c478bd9Sstevel@tonic-gate /*
74127f7c583Smyers * Because of an earlier namespace analysis, all subtrees that contain an
74227f7c583Smyers * _INI method are tagged.
74327f7c583Smyers *
74427f7c583Smyers * If this device subtree does not contain any _INI methods, we
74527f7c583Smyers * can exit now and stop traversing this entire subtree.
74630082d0cSmyers */
74727f7c583Smyers if (!(DeviceNode->Flags & ANOBJ_SUBTREE_HAS_INI))
74830082d0cSmyers {
74927f7c583Smyers return_ACPI_STATUS (AE_CTRL_DEPTH);
75030082d0cSmyers }
75130082d0cSmyers
75230082d0cSmyers /*
75327f7c583Smyers * Run _STA to determine if this device is present and functioning. We
75427f7c583Smyers * must know this information for two important reasons (from ACPI spec):
75527f7c583Smyers *
75627f7c583Smyers * 1) We can only run _INI if the device is present.
75727f7c583Smyers * 2) We must abort the device tree walk on this subtree if the device is
75827f7c583Smyers * not present and is not functional (we will not examine the children)
75927f7c583Smyers *
76027f7c583Smyers * The _STA method is not required to be present under the device, we
76127f7c583Smyers * assume the device is present if _STA does not exist.
7627c478bd9Sstevel@tonic-gate */
76327f7c583Smyers ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (
76427f7c583Smyers ACPI_TYPE_METHOD, DeviceNode, METHOD_NAME__STA));
7657c478bd9Sstevel@tonic-gate
76627f7c583Smyers Status = AcpiUtExecute_STA (DeviceNode, &Flags);
7677c478bd9Sstevel@tonic-gate if (ACPI_FAILURE (Status))
7687c478bd9Sstevel@tonic-gate {
76930082d0cSmyers /* Ignore error and move on to next device */
7707c478bd9Sstevel@tonic-gate
77130082d0cSmyers return_ACPI_STATUS (AE_OK);
7727c478bd9Sstevel@tonic-gate }
77330082d0cSmyers
77427f7c583Smyers /*
77527f7c583Smyers * Flags == -1 means that _STA was not found. In this case, we assume that
77627f7c583Smyers * the device is both present and functional.
77727f7c583Smyers *
77827f7c583Smyers * From the ACPI spec, description of _STA:
77927f7c583Smyers *
78027f7c583Smyers * "If a device object (including the processor object) does not have an
78127f7c583Smyers * _STA object, then OSPM assumes that all of the above bits are set (in
78227f7c583Smyers * other words, the device is present, ..., and functioning)"
78327f7c583Smyers */
78430082d0cSmyers if (Flags != ACPI_UINT32_MAX)
7857c478bd9Sstevel@tonic-gate {
78627f7c583Smyers WalkInfo->Num_STA++;
78730082d0cSmyers }
7887c478bd9Sstevel@tonic-gate
78927f7c583Smyers /*
79027f7c583Smyers * Examine the PRESENT and FUNCTIONING status bits
79127f7c583Smyers *
79227f7c583Smyers * Note: ACPI spec does not seem to specify behavior for the present but
79327f7c583Smyers * not functioning case, so we assume functioning if present.
79427f7c583Smyers */
79530082d0cSmyers if (!(Flags & ACPI_STA_DEVICE_PRESENT))
79630082d0cSmyers {
79727f7c583Smyers /* Device is not present, we must examine the Functioning bit */
7987c478bd9Sstevel@tonic-gate
79927f7c583Smyers if (Flags & ACPI_STA_DEVICE_FUNCTIONING)
80027f7c583Smyers {
80127f7c583Smyers /*
80227f7c583Smyers * Device is not present but is "functioning". In this case,
80327f7c583Smyers * we will not run _INI, but we continue to examine the children
80427f7c583Smyers * of this device.
80527f7c583Smyers *
80627f7c583Smyers * From the ACPI spec, description of _STA: (Note - no mention
80727f7c583Smyers * of whether to run _INI or not on the device in question)
80827f7c583Smyers *
80927f7c583Smyers * "_STA may return bit 0 clear (not present) with bit 3 set
81027f7c583Smyers * (device is functional). This case is used to indicate a valid
81127f7c583Smyers * device for which no device driver should be loaded (for example,
81227f7c583Smyers * a bridge device.) Children of this device may be present and
81327f7c583Smyers * valid. OSPM should continue enumeration below a device whose
81427f7c583Smyers * _STA returns this bit combination"
81527f7c583Smyers */
81627f7c583Smyers return_ACPI_STATUS (AE_OK);
81727f7c583Smyers }
81827f7c583Smyers else
81927f7c583Smyers {
82027f7c583Smyers /*
82127f7c583Smyers * Device is not present and is not functioning. We must abort the
82227f7c583Smyers * walk of this subtree immediately -- don't look at the children
82327f7c583Smyers * of such a device.
82427f7c583Smyers *
82527f7c583Smyers * From the ACPI spec, description of _INI:
82627f7c583Smyers *
82727f7c583Smyers * "If the _STA method indicates that the device is not present,
82827f7c583Smyers * OSPM will not run the _INI and will not examine the children
82927f7c583Smyers * of the device for _INI methods"
83027f7c583Smyers */
83127f7c583Smyers return_ACPI_STATUS (AE_CTRL_DEPTH);
83227f7c583Smyers }
8337c478bd9Sstevel@tonic-gate }
8347c478bd9Sstevel@tonic-gate
8357c478bd9Sstevel@tonic-gate /*
83627f7c583Smyers * The device is present or is assumed present if no _STA exists.
83727f7c583Smyers * Run the _INI if it exists (not required to exist)
83827f7c583Smyers *
83927f7c583Smyers * Note: We know there is an _INI within this subtree, but it may not be
84027f7c583Smyers * under this particular device, it may be lower in the branch.
8417c478bd9Sstevel@tonic-gate */
8427b1019a6SJerry Jelinek if (!ACPI_COMPARE_NAME (DeviceNode->Name.Ascii, "_SB_") ||
8437b1019a6SJerry Jelinek DeviceNode->Parent != AcpiGbl_RootNode)
8447c478bd9Sstevel@tonic-gate {
8457b1019a6SJerry Jelinek ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (
8467b1019a6SJerry Jelinek ACPI_TYPE_METHOD, DeviceNode, METHOD_NAME__INI));
8477c478bd9Sstevel@tonic-gate
8487b1019a6SJerry Jelinek memset (Info, 0, sizeof (ACPI_EVALUATE_INFO));
8497b1019a6SJerry Jelinek Info->PrefixNode = DeviceNode;
8507b1019a6SJerry Jelinek Info->RelativePathname = METHOD_NAME__INI;
8517b1019a6SJerry Jelinek Info->Parameters = NULL;
8527b1019a6SJerry Jelinek Info->Flags = ACPI_IGNORE_RETURN_VALUE;
8537b1019a6SJerry Jelinek
8547b1019a6SJerry Jelinek Status = AcpiNsEvaluate (Info);
8557b1019a6SJerry Jelinek if (ACPI_SUCCESS (Status))
8567c478bd9Sstevel@tonic-gate {
8577b1019a6SJerry Jelinek WalkInfo->Num_INI++;
8587c478bd9Sstevel@tonic-gate }
8597c478bd9Sstevel@tonic-gate
86027f7c583Smyers #ifdef ACPI_DEBUG_OUTPUT
8617b1019a6SJerry Jelinek else if (Status != AE_NOT_FOUND)
8627b1019a6SJerry Jelinek {
8637b1019a6SJerry Jelinek /* Ignore error and move on to next device */
8647c478bd9Sstevel@tonic-gate
8657b1019a6SJerry Jelinek char *ScopeName = AcpiNsGetNormalizedPathname (DeviceNode, TRUE);
86627f7c583Smyers
8677b1019a6SJerry Jelinek ACPI_EXCEPTION ((AE_INFO, Status, "during %s._INI execution",
8687b1019a6SJerry Jelinek ScopeName));
8697b1019a6SJerry Jelinek ACPI_FREE (ScopeName);
8707b1019a6SJerry Jelinek }
87127f7c583Smyers #endif
8727b1019a6SJerry Jelinek }
87327f7c583Smyers
87427f7c583Smyers /* Ignore errors from above */
8757c478bd9Sstevel@tonic-gate
87627f7c583Smyers Status = AE_OK;
87727f7c583Smyers
87827f7c583Smyers /*
87927f7c583Smyers * The _INI method has been run if present; call the Global Initialization
88027f7c583Smyers * Handler for this device.
88127f7c583Smyers */
8827c478bd9Sstevel@tonic-gate if (AcpiGbl_InitHandler)
8837c478bd9Sstevel@tonic-gate {
88427f7c583Smyers Status = AcpiGbl_InitHandler (DeviceNode, ACPI_INIT_DEVICE_INI);
8857c478bd9Sstevel@tonic-gate }
8867c478bd9Sstevel@tonic-gate
88727f7c583Smyers return_ACPI_STATUS (Status);
8887c478bd9Sstevel@tonic-gate }
889