1433d6423SLionel Sambuc /******************************************************************************
2433d6423SLionel Sambuc *
3433d6423SLionel Sambuc * Module Name: nspredef - Validation of ACPI predefined methods and objects
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 #define ACPI_CREATE_PREDEFINED_TABLE
45433d6423SLionel Sambuc
46433d6423SLionel Sambuc #include "acpi.h"
47433d6423SLionel Sambuc #include "accommon.h"
48433d6423SLionel Sambuc #include "acnamesp.h"
49433d6423SLionel Sambuc #include "acpredef.h"
50433d6423SLionel Sambuc
51433d6423SLionel Sambuc
52433d6423SLionel Sambuc #define _COMPONENT ACPI_NAMESPACE
53433d6423SLionel Sambuc ACPI_MODULE_NAME ("nspredef")
54433d6423SLionel Sambuc
55433d6423SLionel Sambuc
56433d6423SLionel Sambuc /*******************************************************************************
57433d6423SLionel Sambuc *
58433d6423SLionel Sambuc * This module validates predefined ACPI objects that appear in the namespace,
59433d6423SLionel Sambuc * at the time they are evaluated (via AcpiEvaluateObject). The purpose of this
60433d6423SLionel Sambuc * validation is to detect problems with BIOS-exposed predefined ACPI objects
61433d6423SLionel Sambuc * before the results are returned to the ACPI-related drivers.
62433d6423SLionel Sambuc *
63433d6423SLionel Sambuc * There are several areas that are validated:
64433d6423SLionel Sambuc *
65433d6423SLionel Sambuc * 1) The number of input arguments as defined by the method/object in the
66433d6423SLionel Sambuc * ASL is validated against the ACPI specification.
67433d6423SLionel Sambuc * 2) The type of the return object (if any) is validated against the ACPI
68433d6423SLionel Sambuc * specification.
69433d6423SLionel Sambuc * 3) For returned package objects, the count of package elements is
70433d6423SLionel Sambuc * validated, as well as the type of each package element. Nested
71433d6423SLionel Sambuc * packages are supported.
72433d6423SLionel Sambuc *
73433d6423SLionel Sambuc * For any problems found, a warning message is issued.
74433d6423SLionel Sambuc *
75433d6423SLionel Sambuc ******************************************************************************/
76433d6423SLionel Sambuc
77433d6423SLionel Sambuc
78433d6423SLionel Sambuc /* Local prototypes */
79433d6423SLionel Sambuc
80433d6423SLionel Sambuc static ACPI_STATUS
81433d6423SLionel Sambuc AcpiNsCheckReference (
82*29492bb7SDavid van Moolenbroek ACPI_EVALUATE_INFO *Info,
83433d6423SLionel Sambuc ACPI_OPERAND_OBJECT *ReturnObject);
84433d6423SLionel Sambuc
85*29492bb7SDavid van Moolenbroek static UINT32
86*29492bb7SDavid van Moolenbroek AcpiNsGetBitmappedType (
87*29492bb7SDavid van Moolenbroek ACPI_OPERAND_OBJECT *ReturnObject);
88433d6423SLionel Sambuc
89433d6423SLionel Sambuc
90433d6423SLionel Sambuc /*******************************************************************************
91433d6423SLionel Sambuc *
92*29492bb7SDavid van Moolenbroek * FUNCTION: AcpiNsCheckReturnValue
93433d6423SLionel Sambuc *
94433d6423SLionel Sambuc * PARAMETERS: Node - Namespace node for the method/object
95*29492bb7SDavid van Moolenbroek * Info - Method execution information block
96433d6423SLionel Sambuc * UserParamCount - Number of parameters actually passed
97433d6423SLionel Sambuc * ReturnStatus - Status from the object evaluation
98433d6423SLionel Sambuc * ReturnObjectPtr - Pointer to the object returned from the
99433d6423SLionel Sambuc * evaluation of a method or object
100433d6423SLionel Sambuc *
101433d6423SLionel Sambuc * RETURN: Status
102433d6423SLionel Sambuc *
103*29492bb7SDavid van Moolenbroek * DESCRIPTION: Check the value returned from a predefined name.
104433d6423SLionel Sambuc *
105433d6423SLionel Sambuc ******************************************************************************/
106433d6423SLionel Sambuc
107433d6423SLionel Sambuc ACPI_STATUS
AcpiNsCheckReturnValue(ACPI_NAMESPACE_NODE * Node,ACPI_EVALUATE_INFO * Info,UINT32 UserParamCount,ACPI_STATUS ReturnStatus,ACPI_OPERAND_OBJECT ** ReturnObjectPtr)108*29492bb7SDavid van Moolenbroek AcpiNsCheckReturnValue (
109433d6423SLionel Sambuc ACPI_NAMESPACE_NODE *Node,
110*29492bb7SDavid van Moolenbroek ACPI_EVALUATE_INFO *Info,
111433d6423SLionel Sambuc UINT32 UserParamCount,
112433d6423SLionel Sambuc ACPI_STATUS ReturnStatus,
113433d6423SLionel Sambuc ACPI_OPERAND_OBJECT **ReturnObjectPtr)
114433d6423SLionel Sambuc {
115*29492bb7SDavid van Moolenbroek ACPI_STATUS Status;
116433d6423SLionel Sambuc const ACPI_PREDEFINED_INFO *Predefined;
117433d6423SLionel Sambuc
118433d6423SLionel Sambuc
119433d6423SLionel Sambuc /* If not a predefined name, we cannot validate the return object */
120433d6423SLionel Sambuc
121*29492bb7SDavid van Moolenbroek Predefined = Info->Predefined;
122433d6423SLionel Sambuc if (!Predefined)
123433d6423SLionel Sambuc {
124*29492bb7SDavid van Moolenbroek return (AE_OK);
125433d6423SLionel Sambuc }
126433d6423SLionel Sambuc
127433d6423SLionel Sambuc /*
128433d6423SLionel Sambuc * If the method failed or did not actually return an object, we cannot
129433d6423SLionel Sambuc * validate the return object
130433d6423SLionel Sambuc */
131*29492bb7SDavid van Moolenbroek if ((ReturnStatus != AE_OK) &&
132*29492bb7SDavid van Moolenbroek (ReturnStatus != AE_CTRL_RETURN_VALUE))
133433d6423SLionel Sambuc {
134*29492bb7SDavid van Moolenbroek return (AE_OK);
135433d6423SLionel Sambuc }
136433d6423SLionel Sambuc
137433d6423SLionel Sambuc /*
138*29492bb7SDavid van Moolenbroek * Return value validation and possible repair.
139433d6423SLionel Sambuc *
140*29492bb7SDavid van Moolenbroek * 1) Don't perform return value validation/repair if this feature
141*29492bb7SDavid van Moolenbroek * has been disabled via a global option.
142433d6423SLionel Sambuc *
143*29492bb7SDavid van Moolenbroek * 2) We have a return value, but if one wasn't expected, just exit,
144*29492bb7SDavid van Moolenbroek * this is not a problem. For example, if the "Implicit Return"
145*29492bb7SDavid van Moolenbroek * feature is enabled, methods will always return a value.
146*29492bb7SDavid van Moolenbroek *
147*29492bb7SDavid van Moolenbroek * 3) If the return value can be of any type, then we cannot perform
148*29492bb7SDavid van Moolenbroek * any validation, just exit.
149433d6423SLionel Sambuc */
150*29492bb7SDavid van Moolenbroek if (AcpiGbl_DisableAutoRepair ||
151*29492bb7SDavid van Moolenbroek (!Predefined->Info.ExpectedBtypes) ||
152433d6423SLionel Sambuc (Predefined->Info.ExpectedBtypes == ACPI_RTYPE_ALL))
153433d6423SLionel Sambuc {
154*29492bb7SDavid van Moolenbroek return (AE_OK);
155433d6423SLionel Sambuc }
156433d6423SLionel Sambuc
157433d6423SLionel Sambuc /*
158433d6423SLionel Sambuc * Check that the type of the main return object is what is expected
159433d6423SLionel Sambuc * for this predefined name
160433d6423SLionel Sambuc */
161*29492bb7SDavid van Moolenbroek Status = AcpiNsCheckObjectType (Info, ReturnObjectPtr,
162433d6423SLionel Sambuc Predefined->Info.ExpectedBtypes, ACPI_NOT_PACKAGE_ELEMENT);
163433d6423SLionel Sambuc if (ACPI_FAILURE (Status))
164433d6423SLionel Sambuc {
165433d6423SLionel Sambuc goto Exit;
166433d6423SLionel Sambuc }
167433d6423SLionel Sambuc
168433d6423SLionel Sambuc /*
169*29492bb7SDavid van Moolenbroek *
170*29492bb7SDavid van Moolenbroek * 4) If there is no return value and it is optional, just return
171*29492bb7SDavid van Moolenbroek * AE_OK (_WAK).
172*29492bb7SDavid van Moolenbroek */
173*29492bb7SDavid van Moolenbroek if (!(*ReturnObjectPtr))
174*29492bb7SDavid van Moolenbroek {
175*29492bb7SDavid van Moolenbroek goto Exit;
176*29492bb7SDavid van Moolenbroek }
177*29492bb7SDavid van Moolenbroek
178*29492bb7SDavid van Moolenbroek /*
179433d6423SLionel Sambuc * For returned Package objects, check the type of all sub-objects.
180433d6423SLionel Sambuc * Note: Package may have been newly created by call above.
181433d6423SLionel Sambuc */
182433d6423SLionel Sambuc if ((*ReturnObjectPtr)->Common.Type == ACPI_TYPE_PACKAGE)
183433d6423SLionel Sambuc {
184*29492bb7SDavid van Moolenbroek Info->ParentPackage = *ReturnObjectPtr;
185*29492bb7SDavid van Moolenbroek Status = AcpiNsCheckPackage (Info, ReturnObjectPtr);
186433d6423SLionel Sambuc if (ACPI_FAILURE (Status))
187433d6423SLionel Sambuc {
188*29492bb7SDavid van Moolenbroek /* We might be able to fix some errors */
189*29492bb7SDavid van Moolenbroek
190*29492bb7SDavid van Moolenbroek if ((Status != AE_AML_OPERAND_TYPE) &&
191*29492bb7SDavid van Moolenbroek (Status != AE_AML_OPERAND_VALUE))
192*29492bb7SDavid van Moolenbroek {
193433d6423SLionel Sambuc goto Exit;
194433d6423SLionel Sambuc }
195433d6423SLionel Sambuc }
196*29492bb7SDavid van Moolenbroek }
197433d6423SLionel Sambuc
198433d6423SLionel Sambuc /*
199433d6423SLionel Sambuc * The return object was OK, or it was successfully repaired above.
200433d6423SLionel Sambuc * Now make some additional checks such as verifying that package
201433d6423SLionel Sambuc * objects are sorted correctly (if required) or buffer objects have
202433d6423SLionel Sambuc * the correct data width (bytes vs. dwords). These repairs are
203433d6423SLionel Sambuc * performed on a per-name basis, i.e., the code is specific to
204433d6423SLionel Sambuc * particular predefined names.
205433d6423SLionel Sambuc */
206*29492bb7SDavid van Moolenbroek Status = AcpiNsComplexRepairs (Info, Node, Status, ReturnObjectPtr);
207433d6423SLionel Sambuc
208433d6423SLionel Sambuc Exit:
209433d6423SLionel Sambuc /*
210433d6423SLionel Sambuc * If the object validation failed or if we successfully repaired one
211433d6423SLionel Sambuc * or more objects, mark the parent node to suppress further warning
212433d6423SLionel Sambuc * messages during the next evaluation of the same method/object.
213433d6423SLionel Sambuc */
214*29492bb7SDavid van Moolenbroek if (ACPI_FAILURE (Status) ||
215*29492bb7SDavid van Moolenbroek (Info->ReturnFlags & ACPI_OBJECT_REPAIRED))
216433d6423SLionel Sambuc {
217433d6423SLionel Sambuc Node->Flags |= ANOBJ_EVALUATED;
218433d6423SLionel Sambuc }
219433d6423SLionel Sambuc
220433d6423SLionel Sambuc return (Status);
221433d6423SLionel Sambuc }
222433d6423SLionel Sambuc
223433d6423SLionel Sambuc
224433d6423SLionel Sambuc /*******************************************************************************
225433d6423SLionel Sambuc *
226433d6423SLionel Sambuc * FUNCTION: AcpiNsCheckObjectType
227433d6423SLionel Sambuc *
228*29492bb7SDavid van Moolenbroek * PARAMETERS: Info - Method execution information block
229433d6423SLionel Sambuc * ReturnObjectPtr - Pointer to the object returned from the
230433d6423SLionel Sambuc * evaluation of a method or object
231433d6423SLionel Sambuc * ExpectedBtypes - Bitmap of expected return type(s)
232433d6423SLionel Sambuc * PackageIndex - Index of object within parent package (if
233433d6423SLionel Sambuc * applicable - ACPI_NOT_PACKAGE_ELEMENT
234433d6423SLionel Sambuc * otherwise)
235433d6423SLionel Sambuc *
236433d6423SLionel Sambuc * RETURN: Status
237433d6423SLionel Sambuc *
238433d6423SLionel Sambuc * DESCRIPTION: Check the type of the return object against the expected object
239433d6423SLionel Sambuc * type(s). Use of Btype allows multiple expected object types.
240433d6423SLionel Sambuc *
241433d6423SLionel Sambuc ******************************************************************************/
242433d6423SLionel Sambuc
243*29492bb7SDavid van Moolenbroek ACPI_STATUS
AcpiNsCheckObjectType(ACPI_EVALUATE_INFO * Info,ACPI_OPERAND_OBJECT ** ReturnObjectPtr,UINT32 ExpectedBtypes,UINT32 PackageIndex)244433d6423SLionel Sambuc AcpiNsCheckObjectType (
245*29492bb7SDavid van Moolenbroek ACPI_EVALUATE_INFO *Info,
246433d6423SLionel Sambuc ACPI_OPERAND_OBJECT **ReturnObjectPtr,
247433d6423SLionel Sambuc UINT32 ExpectedBtypes,
248433d6423SLionel Sambuc UINT32 PackageIndex)
249433d6423SLionel Sambuc {
250433d6423SLionel Sambuc ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
251433d6423SLionel Sambuc ACPI_STATUS Status = AE_OK;
252433d6423SLionel Sambuc char TypeBuffer[48]; /* Room for 5 types */
253433d6423SLionel Sambuc
254433d6423SLionel Sambuc
255433d6423SLionel Sambuc /* A Namespace node should not get here, but make sure */
256433d6423SLionel Sambuc
257*29492bb7SDavid van Moolenbroek if (ReturnObject &&
258*29492bb7SDavid van Moolenbroek ACPI_GET_DESCRIPTOR_TYPE (ReturnObject) == ACPI_DESC_TYPE_NAMED)
259433d6423SLionel Sambuc {
260*29492bb7SDavid van Moolenbroek ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags,
261433d6423SLionel Sambuc "Invalid return type - Found a Namespace node [%4.4s] type %s",
262433d6423SLionel Sambuc ReturnObject->Node.Name.Ascii,
263433d6423SLionel Sambuc AcpiUtGetTypeName (ReturnObject->Node.Type)));
264433d6423SLionel Sambuc return (AE_AML_OPERAND_TYPE);
265433d6423SLionel Sambuc }
266433d6423SLionel Sambuc
267433d6423SLionel Sambuc /*
268433d6423SLionel Sambuc * Convert the object type (ACPI_TYPE_xxx) to a bitmapped object type.
269433d6423SLionel Sambuc * The bitmapped type allows multiple possible return types.
270433d6423SLionel Sambuc *
271433d6423SLionel Sambuc * Note, the cases below must handle all of the possible types returned
272433d6423SLionel Sambuc * from all of the predefined names (including elements of returned
273433d6423SLionel Sambuc * packages)
274433d6423SLionel Sambuc */
275*29492bb7SDavid van Moolenbroek Info->ReturnBtype = AcpiNsGetBitmappedType (ReturnObject);
276*29492bb7SDavid van Moolenbroek if (Info->ReturnBtype == ACPI_RTYPE_ANY)
277433d6423SLionel Sambuc {
278433d6423SLionel Sambuc /* Not one of the supported objects, must be incorrect */
279433d6423SLionel Sambuc goto TypeErrorExit;
280433d6423SLionel Sambuc }
281433d6423SLionel Sambuc
282433d6423SLionel Sambuc /* For reference objects, check that the reference type is correct */
283433d6423SLionel Sambuc
284*29492bb7SDavid van Moolenbroek if ((Info->ReturnBtype & ExpectedBtypes) == ACPI_RTYPE_REFERENCE)
285433d6423SLionel Sambuc {
286*29492bb7SDavid van Moolenbroek Status = AcpiNsCheckReference (Info, ReturnObject);
287433d6423SLionel Sambuc return (Status);
288433d6423SLionel Sambuc }
289433d6423SLionel Sambuc
290*29492bb7SDavid van Moolenbroek /* Attempt simple repair of the returned object if necessary */
291433d6423SLionel Sambuc
292*29492bb7SDavid van Moolenbroek Status = AcpiNsSimpleRepair (Info, ExpectedBtypes,
293433d6423SLionel Sambuc PackageIndex, ReturnObjectPtr);
294433d6423SLionel Sambuc if (ACPI_SUCCESS (Status))
295433d6423SLionel Sambuc {
296*29492bb7SDavid van Moolenbroek return (AE_OK); /* Successful repair */
297433d6423SLionel Sambuc }
298433d6423SLionel Sambuc
299433d6423SLionel Sambuc
300433d6423SLionel Sambuc TypeErrorExit:
301433d6423SLionel Sambuc
302433d6423SLionel Sambuc /* Create a string with all expected types for this predefined object */
303433d6423SLionel Sambuc
304*29492bb7SDavid van Moolenbroek AcpiUtGetExpectedReturnTypes (TypeBuffer, ExpectedBtypes);
305433d6423SLionel Sambuc
306*29492bb7SDavid van Moolenbroek if (!ReturnObject)
307433d6423SLionel Sambuc {
308*29492bb7SDavid van Moolenbroek ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags,
309*29492bb7SDavid van Moolenbroek "Expected return object of type %s",
310*29492bb7SDavid van Moolenbroek TypeBuffer));
311*29492bb7SDavid van Moolenbroek }
312*29492bb7SDavid van Moolenbroek else if (PackageIndex == ACPI_NOT_PACKAGE_ELEMENT)
313*29492bb7SDavid van Moolenbroek {
314*29492bb7SDavid van Moolenbroek ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags,
315433d6423SLionel Sambuc "Return type mismatch - found %s, expected %s",
316433d6423SLionel Sambuc AcpiUtGetObjectTypeName (ReturnObject), TypeBuffer));
317433d6423SLionel Sambuc }
318433d6423SLionel Sambuc else
319433d6423SLionel Sambuc {
320*29492bb7SDavid van Moolenbroek ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags,
321433d6423SLionel Sambuc "Return Package type mismatch at index %u - "
322433d6423SLionel Sambuc "found %s, expected %s", PackageIndex,
323433d6423SLionel Sambuc AcpiUtGetObjectTypeName (ReturnObject), TypeBuffer));
324433d6423SLionel Sambuc }
325433d6423SLionel Sambuc
326433d6423SLionel Sambuc return (AE_AML_OPERAND_TYPE);
327433d6423SLionel Sambuc }
328433d6423SLionel Sambuc
329433d6423SLionel Sambuc
330433d6423SLionel Sambuc /*******************************************************************************
331433d6423SLionel Sambuc *
332433d6423SLionel Sambuc * FUNCTION: AcpiNsCheckReference
333433d6423SLionel Sambuc *
334*29492bb7SDavid van Moolenbroek * PARAMETERS: Info - Method execution information block
335433d6423SLionel Sambuc * ReturnObject - Object returned from the evaluation of a
336433d6423SLionel Sambuc * method or object
337433d6423SLionel Sambuc *
338433d6423SLionel Sambuc * RETURN: Status
339433d6423SLionel Sambuc *
340433d6423SLionel Sambuc * DESCRIPTION: Check a returned reference object for the correct reference
341433d6423SLionel Sambuc * type. The only reference type that can be returned from a
342433d6423SLionel Sambuc * predefined method is a named reference. All others are invalid.
343433d6423SLionel Sambuc *
344433d6423SLionel Sambuc ******************************************************************************/
345433d6423SLionel Sambuc
346433d6423SLionel Sambuc static ACPI_STATUS
AcpiNsCheckReference(ACPI_EVALUATE_INFO * Info,ACPI_OPERAND_OBJECT * ReturnObject)347433d6423SLionel Sambuc AcpiNsCheckReference (
348*29492bb7SDavid van Moolenbroek ACPI_EVALUATE_INFO *Info,
349433d6423SLionel Sambuc ACPI_OPERAND_OBJECT *ReturnObject)
350433d6423SLionel Sambuc {
351433d6423SLionel Sambuc
352433d6423SLionel Sambuc /*
353433d6423SLionel Sambuc * Check the reference object for the correct reference type (opcode).
354433d6423SLionel Sambuc * The only type of reference that can be converted to an ACPI_OBJECT is
355433d6423SLionel Sambuc * a reference to a named object (reference class: NAME)
356433d6423SLionel Sambuc */
357433d6423SLionel Sambuc if (ReturnObject->Reference.Class == ACPI_REFCLASS_NAME)
358433d6423SLionel Sambuc {
359433d6423SLionel Sambuc return (AE_OK);
360433d6423SLionel Sambuc }
361433d6423SLionel Sambuc
362*29492bb7SDavid van Moolenbroek ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags,
363433d6423SLionel Sambuc "Return type mismatch - unexpected reference object type [%s] %2.2X",
364433d6423SLionel Sambuc AcpiUtGetReferenceName (ReturnObject),
365433d6423SLionel Sambuc ReturnObject->Reference.Class));
366433d6423SLionel Sambuc
367433d6423SLionel Sambuc return (AE_AML_OPERAND_TYPE);
368433d6423SLionel Sambuc }
369433d6423SLionel Sambuc
370433d6423SLionel Sambuc
371433d6423SLionel Sambuc /*******************************************************************************
372433d6423SLionel Sambuc *
373*29492bb7SDavid van Moolenbroek * FUNCTION: AcpiNsGetBitmappedType
374433d6423SLionel Sambuc *
375*29492bb7SDavid van Moolenbroek * PARAMETERS: ReturnObject - Object returned from method/obj evaluation
376433d6423SLionel Sambuc *
377*29492bb7SDavid van Moolenbroek * RETURN: Object return type. ACPI_RTYPE_ANY indicates that the object
378*29492bb7SDavid van Moolenbroek * type is not supported. ACPI_RTYPE_NONE indicates that no
379*29492bb7SDavid van Moolenbroek * object was returned (ReturnObject is NULL).
380433d6423SLionel Sambuc *
381*29492bb7SDavid van Moolenbroek * DESCRIPTION: Convert object type into a bitmapped object return type.
382433d6423SLionel Sambuc *
383433d6423SLionel Sambuc ******************************************************************************/
384433d6423SLionel Sambuc
385*29492bb7SDavid van Moolenbroek static UINT32
AcpiNsGetBitmappedType(ACPI_OPERAND_OBJECT * ReturnObject)386*29492bb7SDavid van Moolenbroek AcpiNsGetBitmappedType (
387*29492bb7SDavid van Moolenbroek ACPI_OPERAND_OBJECT *ReturnObject)
388433d6423SLionel Sambuc {
389*29492bb7SDavid van Moolenbroek UINT32 ReturnBtype;
390433d6423SLionel Sambuc
391433d6423SLionel Sambuc
392*29492bb7SDavid van Moolenbroek if (!ReturnObject)
393433d6423SLionel Sambuc {
394*29492bb7SDavid van Moolenbroek return (ACPI_RTYPE_NONE);
395433d6423SLionel Sambuc }
396*29492bb7SDavid van Moolenbroek
397*29492bb7SDavid van Moolenbroek /* Map ACPI_OBJECT_TYPE to internal bitmapped type */
398*29492bb7SDavid van Moolenbroek
399*29492bb7SDavid van Moolenbroek switch (ReturnObject->Common.Type)
400*29492bb7SDavid van Moolenbroek {
401*29492bb7SDavid van Moolenbroek case ACPI_TYPE_INTEGER:
402*29492bb7SDavid van Moolenbroek
403*29492bb7SDavid van Moolenbroek ReturnBtype = ACPI_RTYPE_INTEGER;
404*29492bb7SDavid van Moolenbroek break;
405*29492bb7SDavid van Moolenbroek
406*29492bb7SDavid van Moolenbroek case ACPI_TYPE_BUFFER:
407*29492bb7SDavid van Moolenbroek
408*29492bb7SDavid van Moolenbroek ReturnBtype = ACPI_RTYPE_BUFFER;
409*29492bb7SDavid van Moolenbroek break;
410*29492bb7SDavid van Moolenbroek
411*29492bb7SDavid van Moolenbroek case ACPI_TYPE_STRING:
412*29492bb7SDavid van Moolenbroek
413*29492bb7SDavid van Moolenbroek ReturnBtype = ACPI_RTYPE_STRING;
414*29492bb7SDavid van Moolenbroek break;
415*29492bb7SDavid van Moolenbroek
416*29492bb7SDavid van Moolenbroek case ACPI_TYPE_PACKAGE:
417*29492bb7SDavid van Moolenbroek
418*29492bb7SDavid van Moolenbroek ReturnBtype = ACPI_RTYPE_PACKAGE;
419*29492bb7SDavid van Moolenbroek break;
420*29492bb7SDavid van Moolenbroek
421*29492bb7SDavid van Moolenbroek case ACPI_TYPE_LOCAL_REFERENCE:
422*29492bb7SDavid van Moolenbroek
423*29492bb7SDavid van Moolenbroek ReturnBtype = ACPI_RTYPE_REFERENCE;
424*29492bb7SDavid van Moolenbroek break;
425*29492bb7SDavid van Moolenbroek
426*29492bb7SDavid van Moolenbroek default:
427*29492bb7SDavid van Moolenbroek
428*29492bb7SDavid van Moolenbroek /* Not one of the supported objects, must be incorrect */
429*29492bb7SDavid van Moolenbroek
430*29492bb7SDavid van Moolenbroek ReturnBtype = ACPI_RTYPE_ANY;
431*29492bb7SDavid van Moolenbroek break;
432433d6423SLionel Sambuc }
433*29492bb7SDavid van Moolenbroek
434*29492bb7SDavid van Moolenbroek return (ReturnBtype);
435433d6423SLionel Sambuc }
436