xref: /minix3/minix/drivers/power/acpi/utilities/utmisc.c (revision 29492bb71c7148a089a5afafa0c99409161218df)
1433d6423SLionel Sambuc /*******************************************************************************
2433d6423SLionel Sambuc  *
3433d6423SLionel Sambuc  * Module Name: utmisc - common utility procedures
4433d6423SLionel Sambuc  *
5433d6423SLionel Sambuc  ******************************************************************************/
6433d6423SLionel Sambuc 
7*29492bb7SDavid van Moolenbroek /*
8*29492bb7SDavid van Moolenbroek  * Copyright (C) 2000 - 2014, Intel Corp.
9433d6423SLionel Sambuc  * All rights reserved.
10433d6423SLionel Sambuc  *
11*29492bb7SDavid van Moolenbroek  * Redistribution and use in source and binary forms, with or without
12*29492bb7SDavid van Moolenbroek  * modification, are permitted provided that the following conditions
13*29492bb7SDavid van Moolenbroek  * are met:
14*29492bb7SDavid van Moolenbroek  * 1. Redistributions of source code must retain the above copyright
15*29492bb7SDavid van Moolenbroek  *    notice, this list of conditions, and the following disclaimer,
16*29492bb7SDavid van Moolenbroek  *    without modification.
17*29492bb7SDavid van Moolenbroek  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18*29492bb7SDavid van Moolenbroek  *    substantially similar to the "NO WARRANTY" disclaimer below
19*29492bb7SDavid van Moolenbroek  *    ("Disclaimer") and any redistribution must be conditioned upon
20*29492bb7SDavid van Moolenbroek  *    including a substantially similar Disclaimer requirement for further
21*29492bb7SDavid van Moolenbroek  *    binary redistribution.
22*29492bb7SDavid van Moolenbroek  * 3. Neither the names of the above-listed copyright holders nor the names
23*29492bb7SDavid van Moolenbroek  *    of any contributors may be used to endorse or promote products derived
24*29492bb7SDavid van Moolenbroek  *    from this software without specific prior written permission.
25433d6423SLionel Sambuc  *
26*29492bb7SDavid van Moolenbroek  * Alternatively, this software may be distributed under the terms of the
27*29492bb7SDavid van Moolenbroek  * GNU General Public License ("GPL") version 2 as published by the Free
28*29492bb7SDavid van Moolenbroek  * Software Foundation.
29433d6423SLionel Sambuc  *
30*29492bb7SDavid van Moolenbroek  * NO WARRANTY
31*29492bb7SDavid van Moolenbroek  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32*29492bb7SDavid van Moolenbroek  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33*29492bb7SDavid van Moolenbroek  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34*29492bb7SDavid van Moolenbroek  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35*29492bb7SDavid van Moolenbroek  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36*29492bb7SDavid van Moolenbroek  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37*29492bb7SDavid van Moolenbroek  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38*29492bb7SDavid van Moolenbroek  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39*29492bb7SDavid van Moolenbroek  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40*29492bb7SDavid van Moolenbroek  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41*29492bb7SDavid van Moolenbroek  * POSSIBILITY OF SUCH DAMAGES.
42*29492bb7SDavid van Moolenbroek  */
43433d6423SLionel Sambuc 
44433d6423SLionel Sambuc #include "acpi.h"
45433d6423SLionel Sambuc #include "accommon.h"
46433d6423SLionel Sambuc #include "acnamesp.h"
47433d6423SLionel Sambuc 
48433d6423SLionel Sambuc 
49433d6423SLionel Sambuc #define _COMPONENT          ACPI_UTILITIES
50433d6423SLionel Sambuc         ACPI_MODULE_NAME    ("utmisc")
51433d6423SLionel Sambuc 
52433d6423SLionel Sambuc 
53433d6423SLionel Sambuc /*******************************************************************************
54433d6423SLionel Sambuc  *
55433d6423SLionel Sambuc  * FUNCTION:    AcpiUtIsPciRootBridge
56433d6423SLionel Sambuc  *
57433d6423SLionel Sambuc  * PARAMETERS:  Id              - The HID/CID in string format
58433d6423SLionel Sambuc  *
59433d6423SLionel Sambuc  * RETURN:      TRUE if the Id is a match for a PCI/PCI-Express Root Bridge
60433d6423SLionel Sambuc  *
61433d6423SLionel Sambuc  * DESCRIPTION: Determine if the input ID is a PCI Root Bridge ID.
62433d6423SLionel Sambuc  *
63433d6423SLionel Sambuc  ******************************************************************************/
64433d6423SLionel Sambuc 
65433d6423SLionel Sambuc BOOLEAN
AcpiUtIsPciRootBridge(char * Id)66433d6423SLionel Sambuc AcpiUtIsPciRootBridge (
67433d6423SLionel Sambuc     char                    *Id)
68433d6423SLionel Sambuc {
69433d6423SLionel Sambuc 
70433d6423SLionel Sambuc     /*
71433d6423SLionel Sambuc      * Check if this is a PCI root bridge.
72433d6423SLionel Sambuc      * ACPI 3.0+: check for a PCI Express root also.
73433d6423SLionel Sambuc      */
74433d6423SLionel Sambuc     if (!(ACPI_STRCMP (Id,
75433d6423SLionel Sambuc             PCI_ROOT_HID_STRING)) ||
76433d6423SLionel Sambuc 
77433d6423SLionel Sambuc         !(ACPI_STRCMP (Id,
78433d6423SLionel Sambuc             PCI_EXPRESS_ROOT_HID_STRING)))
79433d6423SLionel Sambuc     {
80433d6423SLionel Sambuc         return (TRUE);
81433d6423SLionel Sambuc     }
82433d6423SLionel Sambuc 
83433d6423SLionel Sambuc     return (FALSE);
84433d6423SLionel Sambuc }
85433d6423SLionel Sambuc 
86433d6423SLionel Sambuc 
87433d6423SLionel Sambuc /*******************************************************************************
88433d6423SLionel Sambuc  *
89433d6423SLionel Sambuc  * FUNCTION:    AcpiUtIsAmlTable
90433d6423SLionel Sambuc  *
91433d6423SLionel Sambuc  * PARAMETERS:  Table               - An ACPI table
92433d6423SLionel Sambuc  *
93433d6423SLionel Sambuc  * RETURN:      TRUE if table contains executable AML; FALSE otherwise
94433d6423SLionel Sambuc  *
95433d6423SLionel Sambuc  * DESCRIPTION: Check ACPI Signature for a table that contains AML code.
96433d6423SLionel Sambuc  *              Currently, these are DSDT,SSDT,PSDT. All other table types are
97433d6423SLionel Sambuc  *              data tables that do not contain AML code.
98433d6423SLionel Sambuc  *
99433d6423SLionel Sambuc  ******************************************************************************/
100433d6423SLionel Sambuc 
101433d6423SLionel Sambuc BOOLEAN
AcpiUtIsAmlTable(ACPI_TABLE_HEADER * Table)102433d6423SLionel Sambuc AcpiUtIsAmlTable (
103433d6423SLionel Sambuc     ACPI_TABLE_HEADER       *Table)
104433d6423SLionel Sambuc {
105433d6423SLionel Sambuc 
106433d6423SLionel Sambuc     /* These are the only tables that contain executable AML */
107433d6423SLionel Sambuc 
108433d6423SLionel Sambuc     if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_DSDT) ||
109433d6423SLionel Sambuc         ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_PSDT) ||
110433d6423SLionel Sambuc         ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_SSDT))
111433d6423SLionel Sambuc     {
112433d6423SLionel Sambuc         return (TRUE);
113433d6423SLionel Sambuc     }
114433d6423SLionel Sambuc 
115433d6423SLionel Sambuc     return (FALSE);
116433d6423SLionel Sambuc }
117433d6423SLionel Sambuc 
118433d6423SLionel Sambuc 
119433d6423SLionel Sambuc /*******************************************************************************
120433d6423SLionel Sambuc  *
121433d6423SLionel Sambuc  * FUNCTION:    AcpiUtDwordByteSwap
122433d6423SLionel Sambuc  *
123433d6423SLionel Sambuc  * PARAMETERS:  Value           - Value to be converted
124433d6423SLionel Sambuc  *
125433d6423SLionel Sambuc  * RETURN:      UINT32 integer with bytes swapped
126433d6423SLionel Sambuc  *
127433d6423SLionel Sambuc  * DESCRIPTION: Convert a 32-bit value to big-endian (swap the bytes)
128433d6423SLionel Sambuc  *
129433d6423SLionel Sambuc  ******************************************************************************/
130433d6423SLionel Sambuc 
131433d6423SLionel Sambuc UINT32
AcpiUtDwordByteSwap(UINT32 Value)132433d6423SLionel Sambuc AcpiUtDwordByteSwap (
133433d6423SLionel Sambuc     UINT32                  Value)
134433d6423SLionel Sambuc {
135433d6423SLionel Sambuc     union
136433d6423SLionel Sambuc     {
137433d6423SLionel Sambuc         UINT32              Value;
138433d6423SLionel Sambuc         UINT8               Bytes[4];
139433d6423SLionel Sambuc     } Out;
140433d6423SLionel Sambuc     union
141433d6423SLionel Sambuc     {
142433d6423SLionel Sambuc         UINT32              Value;
143433d6423SLionel Sambuc         UINT8               Bytes[4];
144433d6423SLionel Sambuc     } In;
145433d6423SLionel Sambuc 
146433d6423SLionel Sambuc 
147433d6423SLionel Sambuc     ACPI_FUNCTION_ENTRY ();
148433d6423SLionel Sambuc 
149433d6423SLionel Sambuc 
150433d6423SLionel Sambuc     In.Value = Value;
151433d6423SLionel Sambuc 
152433d6423SLionel Sambuc     Out.Bytes[0] = In.Bytes[3];
153433d6423SLionel Sambuc     Out.Bytes[1] = In.Bytes[2];
154433d6423SLionel Sambuc     Out.Bytes[2] = In.Bytes[1];
155433d6423SLionel Sambuc     Out.Bytes[3] = In.Bytes[0];
156433d6423SLionel Sambuc 
157433d6423SLionel Sambuc     return (Out.Value);
158433d6423SLionel Sambuc }
159433d6423SLionel Sambuc 
160433d6423SLionel Sambuc 
161433d6423SLionel Sambuc /*******************************************************************************
162433d6423SLionel Sambuc  *
163433d6423SLionel Sambuc  * FUNCTION:    AcpiUtSetIntegerWidth
164433d6423SLionel Sambuc  *
165433d6423SLionel Sambuc  * PARAMETERS:  Revision            From DSDT header
166433d6423SLionel Sambuc  *
167433d6423SLionel Sambuc  * RETURN:      None
168433d6423SLionel Sambuc  *
169433d6423SLionel Sambuc  * DESCRIPTION: Set the global integer bit width based upon the revision
170433d6423SLionel Sambuc  *              of the DSDT. For Revision 1 and 0, Integers are 32 bits.
171433d6423SLionel Sambuc  *              For Revision 2 and above, Integers are 64 bits. Yes, this
172433d6423SLionel Sambuc  *              makes a difference.
173433d6423SLionel Sambuc  *
174433d6423SLionel Sambuc  ******************************************************************************/
175433d6423SLionel Sambuc 
176433d6423SLionel Sambuc void
AcpiUtSetIntegerWidth(UINT8 Revision)177433d6423SLionel Sambuc AcpiUtSetIntegerWidth (
178433d6423SLionel Sambuc     UINT8                   Revision)
179433d6423SLionel Sambuc {
180433d6423SLionel Sambuc 
181433d6423SLionel Sambuc     if (Revision < 2)
182433d6423SLionel Sambuc     {
183433d6423SLionel Sambuc         /* 32-bit case */
184433d6423SLionel Sambuc 
185433d6423SLionel Sambuc         AcpiGbl_IntegerBitWidth    = 32;
186433d6423SLionel Sambuc         AcpiGbl_IntegerNybbleWidth = 8;
187433d6423SLionel Sambuc         AcpiGbl_IntegerByteWidth   = 4;
188433d6423SLionel Sambuc     }
189433d6423SLionel Sambuc     else
190433d6423SLionel Sambuc     {
191433d6423SLionel Sambuc         /* 64-bit case (ACPI 2.0+) */
192433d6423SLionel Sambuc 
193433d6423SLionel Sambuc         AcpiGbl_IntegerBitWidth    = 64;
194433d6423SLionel Sambuc         AcpiGbl_IntegerNybbleWidth = 16;
195433d6423SLionel Sambuc         AcpiGbl_IntegerByteWidth   = 8;
196433d6423SLionel Sambuc     }
197433d6423SLionel Sambuc }
198433d6423SLionel Sambuc 
199433d6423SLionel Sambuc 
200433d6423SLionel Sambuc /*******************************************************************************
201433d6423SLionel Sambuc  *
202433d6423SLionel Sambuc  * FUNCTION:    AcpiUtCreateUpdateStateAndPush
203433d6423SLionel Sambuc  *
204433d6423SLionel Sambuc  * PARAMETERS:  Object          - Object to be added to the new state
205433d6423SLionel Sambuc  *              Action          - Increment/Decrement
206433d6423SLionel Sambuc  *              StateList       - List the state will be added to
207433d6423SLionel Sambuc  *
208433d6423SLionel Sambuc  * RETURN:      Status
209433d6423SLionel Sambuc  *
210433d6423SLionel Sambuc  * DESCRIPTION: Create a new state and push it
211433d6423SLionel Sambuc  *
212433d6423SLionel Sambuc  ******************************************************************************/
213433d6423SLionel Sambuc 
214433d6423SLionel Sambuc ACPI_STATUS
AcpiUtCreateUpdateStateAndPush(ACPI_OPERAND_OBJECT * Object,UINT16 Action,ACPI_GENERIC_STATE ** StateList)215433d6423SLionel Sambuc AcpiUtCreateUpdateStateAndPush (
216433d6423SLionel Sambuc     ACPI_OPERAND_OBJECT     *Object,
217433d6423SLionel Sambuc     UINT16                  Action,
218433d6423SLionel Sambuc     ACPI_GENERIC_STATE      **StateList)
219433d6423SLionel Sambuc {
220433d6423SLionel Sambuc     ACPI_GENERIC_STATE       *State;
221433d6423SLionel Sambuc 
222433d6423SLionel Sambuc 
223433d6423SLionel Sambuc     ACPI_FUNCTION_ENTRY ();
224433d6423SLionel Sambuc 
225433d6423SLionel Sambuc 
226433d6423SLionel Sambuc     /* Ignore null objects; these are expected */
227433d6423SLionel Sambuc 
228433d6423SLionel Sambuc     if (!Object)
229433d6423SLionel Sambuc     {
230433d6423SLionel Sambuc         return (AE_OK);
231433d6423SLionel Sambuc     }
232433d6423SLionel Sambuc 
233433d6423SLionel Sambuc     State = AcpiUtCreateUpdateState (Object, Action);
234433d6423SLionel Sambuc     if (!State)
235433d6423SLionel Sambuc     {
236433d6423SLionel Sambuc         return (AE_NO_MEMORY);
237433d6423SLionel Sambuc     }
238433d6423SLionel Sambuc 
239433d6423SLionel Sambuc     AcpiUtPushGenericState (StateList, State);
240433d6423SLionel Sambuc     return (AE_OK);
241433d6423SLionel Sambuc }
242433d6423SLionel Sambuc 
243433d6423SLionel Sambuc 
244433d6423SLionel Sambuc /*******************************************************************************
245433d6423SLionel Sambuc  *
246433d6423SLionel Sambuc  * FUNCTION:    AcpiUtWalkPackageTree
247433d6423SLionel Sambuc  *
248433d6423SLionel Sambuc  * PARAMETERS:  SourceObject        - The package to walk
249433d6423SLionel Sambuc  *              TargetObject        - Target object (if package is being copied)
250433d6423SLionel Sambuc  *              WalkCallback        - Called once for each package element
251433d6423SLionel Sambuc  *              Context             - Passed to the callback function
252433d6423SLionel Sambuc  *
253433d6423SLionel Sambuc  * RETURN:      Status
254433d6423SLionel Sambuc  *
255433d6423SLionel Sambuc  * DESCRIPTION: Walk through a package
256433d6423SLionel Sambuc  *
257433d6423SLionel Sambuc  ******************************************************************************/
258433d6423SLionel Sambuc 
259433d6423SLionel Sambuc ACPI_STATUS
AcpiUtWalkPackageTree(ACPI_OPERAND_OBJECT * SourceObject,void * TargetObject,ACPI_PKG_CALLBACK WalkCallback,void * Context)260433d6423SLionel Sambuc AcpiUtWalkPackageTree (
261433d6423SLionel Sambuc     ACPI_OPERAND_OBJECT     *SourceObject,
262433d6423SLionel Sambuc     void                    *TargetObject,
263433d6423SLionel Sambuc     ACPI_PKG_CALLBACK       WalkCallback,
264433d6423SLionel Sambuc     void                    *Context)
265433d6423SLionel Sambuc {
266433d6423SLionel Sambuc     ACPI_STATUS             Status = AE_OK;
267433d6423SLionel Sambuc     ACPI_GENERIC_STATE      *StateList = NULL;
268433d6423SLionel Sambuc     ACPI_GENERIC_STATE      *State;
269433d6423SLionel Sambuc     UINT32                  ThisIndex;
270433d6423SLionel Sambuc     ACPI_OPERAND_OBJECT     *ThisSourceObj;
271433d6423SLionel Sambuc 
272433d6423SLionel Sambuc 
273433d6423SLionel Sambuc     ACPI_FUNCTION_TRACE (UtWalkPackageTree);
274433d6423SLionel Sambuc 
275433d6423SLionel Sambuc 
276433d6423SLionel Sambuc     State = AcpiUtCreatePkgState (SourceObject, TargetObject, 0);
277433d6423SLionel Sambuc     if (!State)
278433d6423SLionel Sambuc     {
279433d6423SLionel Sambuc         return_ACPI_STATUS (AE_NO_MEMORY);
280433d6423SLionel Sambuc     }
281433d6423SLionel Sambuc 
282433d6423SLionel Sambuc     while (State)
283433d6423SLionel Sambuc     {
284433d6423SLionel Sambuc         /* Get one element of the package */
285433d6423SLionel Sambuc 
286433d6423SLionel Sambuc         ThisIndex     = State->Pkg.Index;
287433d6423SLionel Sambuc         ThisSourceObj = (ACPI_OPERAND_OBJECT *)
288433d6423SLionel Sambuc                         State->Pkg.SourceObject->Package.Elements[ThisIndex];
289433d6423SLionel Sambuc 
290433d6423SLionel Sambuc         /*
291433d6423SLionel Sambuc          * Check for:
292433d6423SLionel Sambuc          * 1) An uninitialized package element. It is completely
293433d6423SLionel Sambuc          *    legal to declare a package and leave it uninitialized
294433d6423SLionel Sambuc          * 2) Not an internal object - can be a namespace node instead
295433d6423SLionel Sambuc          * 3) Any type other than a package. Packages are handled in else
296433d6423SLionel Sambuc          *    case below.
297433d6423SLionel Sambuc          */
298433d6423SLionel Sambuc         if ((!ThisSourceObj) ||
299433d6423SLionel Sambuc             (ACPI_GET_DESCRIPTOR_TYPE (ThisSourceObj) != ACPI_DESC_TYPE_OPERAND) ||
300433d6423SLionel Sambuc             (ThisSourceObj->Common.Type != ACPI_TYPE_PACKAGE))
301433d6423SLionel Sambuc         {
302433d6423SLionel Sambuc             Status = WalkCallback (ACPI_COPY_TYPE_SIMPLE, ThisSourceObj,
303433d6423SLionel Sambuc                                     State, Context);
304433d6423SLionel Sambuc             if (ACPI_FAILURE (Status))
305433d6423SLionel Sambuc             {
306433d6423SLionel Sambuc                 return_ACPI_STATUS (Status);
307433d6423SLionel Sambuc             }
308433d6423SLionel Sambuc 
309433d6423SLionel Sambuc             State->Pkg.Index++;
310433d6423SLionel Sambuc             while (State->Pkg.Index >= State->Pkg.SourceObject->Package.Count)
311433d6423SLionel Sambuc             {
312433d6423SLionel Sambuc                 /*
313433d6423SLionel Sambuc                  * We've handled all of the objects at this level,  This means
314433d6423SLionel Sambuc                  * that we have just completed a package. That package may
315433d6423SLionel Sambuc                  * have contained one or more packages itself.
316433d6423SLionel Sambuc                  *
317433d6423SLionel Sambuc                  * Delete this state and pop the previous state (package).
318433d6423SLionel Sambuc                  */
319433d6423SLionel Sambuc                 AcpiUtDeleteGenericState (State);
320433d6423SLionel Sambuc                 State = AcpiUtPopGenericState (&StateList);
321433d6423SLionel Sambuc 
322433d6423SLionel Sambuc                 /* Finished when there are no more states */
323433d6423SLionel Sambuc 
324433d6423SLionel Sambuc                 if (!State)
325433d6423SLionel Sambuc                 {
326433d6423SLionel Sambuc                     /*
327433d6423SLionel Sambuc                      * We have handled all of the objects in the top level
328433d6423SLionel Sambuc                      * package just add the length of the package objects
329433d6423SLionel Sambuc                      * and exit
330433d6423SLionel Sambuc                      */
331433d6423SLionel Sambuc                     return_ACPI_STATUS (AE_OK);
332433d6423SLionel Sambuc                 }
333433d6423SLionel Sambuc 
334433d6423SLionel Sambuc                 /*
335433d6423SLionel Sambuc                  * Go back up a level and move the index past the just
336433d6423SLionel Sambuc                  * completed package object.
337433d6423SLionel Sambuc                  */
338433d6423SLionel Sambuc                 State->Pkg.Index++;
339433d6423SLionel Sambuc             }
340433d6423SLionel Sambuc         }
341433d6423SLionel Sambuc         else
342433d6423SLionel Sambuc         {
343433d6423SLionel Sambuc             /* This is a subobject of type package */
344433d6423SLionel Sambuc 
345433d6423SLionel Sambuc             Status = WalkCallback (ACPI_COPY_TYPE_PACKAGE, ThisSourceObj,
346433d6423SLionel Sambuc                                         State, Context);
347433d6423SLionel Sambuc             if (ACPI_FAILURE (Status))
348433d6423SLionel Sambuc             {
349433d6423SLionel Sambuc                 return_ACPI_STATUS (Status);
350433d6423SLionel Sambuc             }
351433d6423SLionel Sambuc 
352433d6423SLionel Sambuc             /*
353433d6423SLionel Sambuc              * Push the current state and create a new one
354433d6423SLionel Sambuc              * The callback above returned a new target package object.
355433d6423SLionel Sambuc              */
356433d6423SLionel Sambuc             AcpiUtPushGenericState (&StateList, State);
357433d6423SLionel Sambuc             State = AcpiUtCreatePkgState (ThisSourceObj,
358433d6423SLionel Sambuc                                             State->Pkg.ThisTargetObj, 0);
359433d6423SLionel Sambuc             if (!State)
360433d6423SLionel Sambuc             {
361433d6423SLionel Sambuc                 /* Free any stacked Update State objects */
362433d6423SLionel Sambuc 
363433d6423SLionel Sambuc                 while (StateList)
364433d6423SLionel Sambuc                 {
365433d6423SLionel Sambuc                     State = AcpiUtPopGenericState (&StateList);
366433d6423SLionel Sambuc                     AcpiUtDeleteGenericState (State);
367433d6423SLionel Sambuc                 }
368433d6423SLionel Sambuc                 return_ACPI_STATUS (AE_NO_MEMORY);
369433d6423SLionel Sambuc             }
370433d6423SLionel Sambuc         }
371433d6423SLionel Sambuc     }
372433d6423SLionel Sambuc 
373433d6423SLionel Sambuc     /* We should never get here */
374433d6423SLionel Sambuc 
375433d6423SLionel Sambuc     return_ACPI_STATUS (AE_AML_INTERNAL);
376433d6423SLionel Sambuc }
377433d6423SLionel Sambuc 
378433d6423SLionel Sambuc 
379*29492bb7SDavid van Moolenbroek #ifdef ACPI_DEBUG_OUTPUT
380433d6423SLionel Sambuc /*******************************************************************************
381433d6423SLionel Sambuc  *
382*29492bb7SDavid van Moolenbroek  * FUNCTION:    AcpiUtDisplayInitPathname
383433d6423SLionel Sambuc  *
384*29492bb7SDavid van Moolenbroek  * PARAMETERS:  Type                - Object type of the node
385*29492bb7SDavid van Moolenbroek  *              ObjHandle           - Handle whose pathname will be displayed
386*29492bb7SDavid van Moolenbroek  *              Path                - Additional path string to be appended.
387*29492bb7SDavid van Moolenbroek  *                                      (NULL if no extra path)
388433d6423SLionel Sambuc  *
389*29492bb7SDavid van Moolenbroek  * RETURN:      ACPI_STATUS
390433d6423SLionel Sambuc  *
391*29492bb7SDavid van Moolenbroek  * DESCRIPTION: Display full pathname of an object, DEBUG ONLY
392433d6423SLionel Sambuc  *
393433d6423SLionel Sambuc  ******************************************************************************/
394433d6423SLionel Sambuc 
395*29492bb7SDavid van Moolenbroek void
AcpiUtDisplayInitPathname(UINT8 Type,ACPI_NAMESPACE_NODE * ObjHandle,char * Path)396*29492bb7SDavid van Moolenbroek AcpiUtDisplayInitPathname (
397*29492bb7SDavid van Moolenbroek     UINT8                   Type,
398*29492bb7SDavid van Moolenbroek     ACPI_NAMESPACE_NODE     *ObjHandle,
399*29492bb7SDavid van Moolenbroek     char                    *Path)
400433d6423SLionel Sambuc {
401*29492bb7SDavid van Moolenbroek     ACPI_STATUS             Status;
402*29492bb7SDavid van Moolenbroek     ACPI_BUFFER             Buffer;
403433d6423SLionel Sambuc 
404433d6423SLionel Sambuc 
405*29492bb7SDavid van Moolenbroek     ACPI_FUNCTION_ENTRY ();
406433d6423SLionel Sambuc 
407*29492bb7SDavid van Moolenbroek 
408*29492bb7SDavid van Moolenbroek     /* Only print the path if the appropriate debug level is enabled */
409*29492bb7SDavid van Moolenbroek 
410*29492bb7SDavid van Moolenbroek     if (!(AcpiDbgLevel & ACPI_LV_INIT_NAMES))
411*29492bb7SDavid van Moolenbroek     {
412*29492bb7SDavid van Moolenbroek         return;
413433d6423SLionel Sambuc     }
414433d6423SLionel Sambuc 
415*29492bb7SDavid van Moolenbroek     /* Get the full pathname to the node */
416*29492bb7SDavid van Moolenbroek 
417*29492bb7SDavid van Moolenbroek     Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
418*29492bb7SDavid van Moolenbroek     Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
419*29492bb7SDavid van Moolenbroek     if (ACPI_FAILURE (Status))
420433d6423SLionel Sambuc     {
421*29492bb7SDavid van Moolenbroek         return;
422433d6423SLionel Sambuc     }
423433d6423SLionel Sambuc 
424*29492bb7SDavid van Moolenbroek     /* Print what we're doing */
425*29492bb7SDavid van Moolenbroek 
426*29492bb7SDavid van Moolenbroek     switch (Type)
427433d6423SLionel Sambuc     {
428*29492bb7SDavid van Moolenbroek     case ACPI_TYPE_METHOD:
429433d6423SLionel Sambuc 
430*29492bb7SDavid van Moolenbroek         AcpiOsPrintf ("Executing    ");
431*29492bb7SDavid van Moolenbroek         break;
432433d6423SLionel Sambuc 
433*29492bb7SDavid van Moolenbroek     default:
434433d6423SLionel Sambuc 
435*29492bb7SDavid van Moolenbroek         AcpiOsPrintf ("Initializing ");
436*29492bb7SDavid van Moolenbroek         break;
437433d6423SLionel Sambuc     }
438433d6423SLionel Sambuc 
439*29492bb7SDavid van Moolenbroek     /* Print the object type and pathname */
440*29492bb7SDavid van Moolenbroek 
441*29492bb7SDavid van Moolenbroek     AcpiOsPrintf ("%-12s  %s",
442*29492bb7SDavid van Moolenbroek         AcpiUtGetTypeName (Type), (char *) Buffer.Pointer);
443*29492bb7SDavid van Moolenbroek 
444*29492bb7SDavid van Moolenbroek     /* Extra path is used to append names like _STA, _INI, etc. */
445*29492bb7SDavid van Moolenbroek 
446*29492bb7SDavid van Moolenbroek     if (Path)
447433d6423SLionel Sambuc     {
448*29492bb7SDavid van Moolenbroek         AcpiOsPrintf (".%s", Path);
449*29492bb7SDavid van Moolenbroek     }
450433d6423SLionel Sambuc     AcpiOsPrintf ("\n");
451*29492bb7SDavid van Moolenbroek 
452*29492bb7SDavid van Moolenbroek     ACPI_FREE (Buffer.Pointer);
453433d6423SLionel Sambuc }
454*29492bb7SDavid van Moolenbroek #endif
455