ReactOS 0.4.15-dev-8102-g108db8f
nspredef.c File Reference
#include "acpi.h"
#include "accommon.h"
#include "acnamesp.h"
#include "acpredef.h"
Include dependency graph for nspredef.c:

Go to the source code of this file.

Macros

#define ACPI_CREATE_PREDEFINED_TABLE
 
#define _COMPONENT   ACPI_NAMESPACE
 

Functions

static ACPI_STATUS AcpiNsCheckReference (ACPI_EVALUATE_INFO *Info, ACPI_OPERAND_OBJECT *ReturnObject)
 
static UINT32 AcpiNsGetBitmappedType (ACPI_OPERAND_OBJECT *ReturnObject)
 
ACPI_STATUS AcpiNsCheckReturnValue (ACPI_NAMESPACE_NODE *Node, ACPI_EVALUATE_INFO *Info, UINT32 UserParamCount, ACPI_STATUS ReturnStatus, ACPI_OPERAND_OBJECT **ReturnObjectPtr)
 
ACPI_STATUS AcpiNsCheckObjectType (ACPI_EVALUATE_INFO *Info, ACPI_OPERAND_OBJECT **ReturnObjectPtr, UINT32 ExpectedBtypes, UINT32 PackageIndex)
 

Macro Definition Documentation

◆ _COMPONENT

#define _COMPONENT   ACPI_NAMESPACE

Definition at line 52 of file nspredef.c.

◆ ACPI_CREATE_PREDEFINED_TABLE

#define ACPI_CREATE_PREDEFINED_TABLE

Definition at line 44 of file nspredef.c.

Function Documentation

◆ AcpiNsCheckObjectType()

ACPI_STATUS AcpiNsCheckObjectType ( ACPI_EVALUATE_INFO Info,
ACPI_OPERAND_OBJECT **  ReturnObjectPtr,
UINT32  ExpectedBtypes,
UINT32  PackageIndex 
)

Definition at line 245 of file nspredef.c.

250{
251 ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
253 char TypeBuffer[96]; /* Room for 10 types */
254
255
256 /* A Namespace node should not get here, but make sure */
257
258 if (ReturnObject &&
260 {
261 ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags,
262 "Invalid return type - Found a Namespace node [%4.4s] type %s",
263 ReturnObject->Node.Name.Ascii,
264 AcpiUtGetTypeName (ReturnObject->Node.Type)));
265 return (AE_AML_OPERAND_TYPE);
266 }
267
268 /*
269 * Convert the object type (ACPI_TYPE_xxx) to a bitmapped object type.
270 * The bitmapped type allows multiple possible return types.
271 *
272 * Note, the cases below must handle all of the possible types returned
273 * from all of the predefined names (including elements of returned
274 * packages)
275 */
276 Info->ReturnBtype = AcpiNsGetBitmappedType (ReturnObject);
277 if (Info->ReturnBtype == ACPI_RTYPE_ANY)
278 {
279 /* Not one of the supported objects, must be incorrect */
280 goto TypeErrorExit;
281 }
282
283 /* For reference objects, check that the reference type is correct */
284
285 if ((Info->ReturnBtype & ExpectedBtypes) == ACPI_RTYPE_REFERENCE)
286 {
287 Status = AcpiNsCheckReference (Info, ReturnObject);
288 return (Status);
289 }
290
291 /* Attempt simple repair of the returned object if necessary */
292
293 Status = AcpiNsSimpleRepair (Info, ExpectedBtypes,
294 PackageIndex, ReturnObjectPtr);
295 if (ACPI_SUCCESS (Status))
296 {
297 return (AE_OK); /* Successful repair */
298 }
299
300
301TypeErrorExit:
302
303 /* Create a string with all expected types for this predefined object */
304
305 AcpiUtGetExpectedReturnTypes (TypeBuffer, ExpectedBtypes);
306
307 if (!ReturnObject)
308 {
309 ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags,
310 "Expected return object of type %s",
311 TypeBuffer));
312 }
313 else if (PackageIndex == ACPI_NOT_PACKAGE_ELEMENT)
314 {
315 ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags,
316 "Return type mismatch - found %s, expected %s",
317 AcpiUtGetObjectTypeName (ReturnObject), TypeBuffer));
318 }
319 else
320 {
321 ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags,
322 "Return Package type mismatch at index %u - "
323 "found %s, expected %s", PackageIndex,
324 AcpiUtGetObjectTypeName (ReturnObject), TypeBuffer));
325 }
326
327 return (AE_AML_OPERAND_TYPE);
328}
#define AE_AML_OPERAND_TYPE
Definition: acexcep.h:182
#define ACPI_SUCCESS(a)
Definition: acexcep.h:94
#define AE_OK
Definition: acexcep.h:97
#define ACPI_RTYPE_REFERENCE
Definition: aclocal.h:482
#define ACPI_RTYPE_ANY
Definition: aclocal.h:476
#define ACPI_GET_DESCRIPTOR_TYPE(d)
Definition: acmacros.h:414
#define ACPI_WARN_PREDEFINED(plist)
Definition: acmacros.h:464
ACPI_STATUS AcpiNsSimpleRepair(ACPI_EVALUATE_INFO *Info, UINT32 ExpectedBtypes, UINT32 PackageIndex, ACPI_OPERAND_OBJECT **ReturnObjectPtr)
Definition: nsrepair.c:153
#define ACPI_NOT_PACKAGE_ELEMENT
Definition: acnamesp.h:82
#define ACPI_DESC_TYPE_NAMED
Definition: acobject.h:577
#define AE_INFO
Definition: acoutput.h:230
UINT32 ACPI_STATUS
Definition: actypes.h:460
const char * AcpiUtGetTypeName(ACPI_OBJECT_TYPE Type)
Definition: utdecode.c:250
const char * AcpiUtGetObjectTypeName(ACPI_OPERAND_OBJECT *ObjDesc)
Definition: utdecode.c:264
void AcpiUtGetExpectedReturnTypes(char *Buffer, UINT32 ExpectedBtypes)
Definition: utpredef.c:158
Status
Definition: gdiplustypes.h:25
static ACPI_STATUS AcpiNsCheckReference(ACPI_EVALUATE_INFO *Info, ACPI_OPERAND_OBJECT *ReturnObject)
Definition: nspredef.c:348
static UINT32 AcpiNsGetBitmappedType(ACPI_OPERAND_OBJECT *ReturnObject)
Definition: nspredef.c:387
ACPI_NAME_UNION Name
Definition: aclocal.h:191
char Ascii[4]
Definition: actbl.h:394
ACPI_NAMESPACE_NODE Node
Definition: acobject.h:550
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690

Referenced by AcpiNsCheckPackage(), AcpiNsCheckPackageElements(), AcpiNsCheckPackageList(), and AcpiNsCheckReturnValue().

◆ AcpiNsCheckReference()

static ACPI_STATUS AcpiNsCheckReference ( ACPI_EVALUATE_INFO Info,
ACPI_OPERAND_OBJECT ReturnObject 
)
static

Definition at line 348 of file nspredef.c.

351{
352
353 /*
354 * Check the reference object for the correct reference type (opcode).
355 * The only type of reference that can be converted to an ACPI_OBJECT is
356 * a reference to a named object (reference class: NAME)
357 */
358 if (ReturnObject->Reference.Class == ACPI_REFCLASS_NAME)
359 {
360 return (AE_OK);
361 }
362
363 ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags,
364 "Return type mismatch - unexpected reference object type [%s] %2.2X",
365 AcpiUtGetReferenceName (ReturnObject),
366 ReturnObject->Reference.Class));
367
368 return (AE_AML_OPERAND_TYPE);
369}
@ ACPI_REFCLASS_NAME
Definition: acobject.h:464
const char * AcpiUtGetReferenceName(ACPI_OPERAND_OBJECT *Object)
Definition: utdecode.c:426
ACPI_OBJECT_COMMON_HEADER UINT8 Class
Definition: acobject.h:443
ACPI_OBJECT_REFERENCE Reference
Definition: acobject.h:540

Referenced by AcpiNsCheckObjectType().

◆ AcpiNsCheckReturnValue()

ACPI_STATUS AcpiNsCheckReturnValue ( ACPI_NAMESPACE_NODE Node,
ACPI_EVALUATE_INFO Info,
UINT32  UserParamCount,
ACPI_STATUS  ReturnStatus,
ACPI_OPERAND_OBJECT **  ReturnObjectPtr 
)

Definition at line 108 of file nspredef.c.

114{
116 const ACPI_PREDEFINED_INFO *Predefined;
117
118 ACPI_FUNCTION_TRACE (NsCheckReturnValue);
119
120 /* If not a predefined name, we cannot validate the return object */
121
122 Predefined = Info->Predefined;
123 if (!Predefined)
124 {
126 }
127
128 /*
129 * If the method failed or did not actually return an object, we cannot
130 * validate the return object
131 */
132 if ((ReturnStatus != AE_OK) &&
133 (ReturnStatus != AE_CTRL_RETURN_VALUE))
134 {
136 }
137
138 /*
139 * Return value validation and possible repair.
140 *
141 * 1) Don't perform return value validation/repair if this feature
142 * has been disabled via a global option.
143 *
144 * 2) We have a return value, but if one wasn't expected, just exit,
145 * this is not a problem. For example, if the "Implicit Return"
146 * feature is enabled, methods will always return a value.
147 *
148 * 3) If the return value can be of any type, then we cannot perform
149 * any validation, just exit.
150 */
151 if (AcpiGbl_DisableAutoRepair ||
152 (!Predefined->Info.ExpectedBtypes) ||
153 (Predefined->Info.ExpectedBtypes == ACPI_RTYPE_ALL))
154 {
156 }
157
158 /*
159 * Check that the type of the main return object is what is expected
160 * for this predefined name
161 */
162 Status = AcpiNsCheckObjectType (Info, ReturnObjectPtr,
164 if (ACPI_FAILURE (Status))
165 {
166 goto Exit;
167 }
168
169 /*
170 *
171 * 4) If there is no return value and it is optional, just return
172 * AE_OK (_WAK).
173 */
174 if (!(*ReturnObjectPtr))
175 {
176 goto Exit;
177 }
178
179 /*
180 * For returned Package objects, check the type of all sub-objects.
181 * Note: Package may have been newly created by call above.
182 */
183 if ((*ReturnObjectPtr)->Common.Type == ACPI_TYPE_PACKAGE)
184 {
185 Info->ParentPackage = *ReturnObjectPtr;
186 Status = AcpiNsCheckPackage (Info, ReturnObjectPtr);
187 if (ACPI_FAILURE (Status))
188 {
189 /* We might be able to fix some errors */
190
191 if ((Status != AE_AML_OPERAND_TYPE) &&
193 {
194 goto Exit;
195 }
196 }
197 }
198
199 /*
200 * The return object was OK, or it was successfully repaired above.
201 * Now make some additional checks such as verifying that package
202 * objects are sorted correctly (if required) or buffer objects have
203 * the correct data width (bytes vs. dwords). These repairs are
204 * performed on a per-name basis, i.e., the code is specific to
205 * particular predefined names.
206 */
207 Status = AcpiNsComplexRepairs (Info, Node, Status, ReturnObjectPtr);
208
209Exit:
210 /*
211 * If the object validation failed or if we successfully repaired one
212 * or more objects, mark the parent node to suppress further warning
213 * messages during the next evaluation of the same method/object.
214 */
215 if (ACPI_FAILURE (Status) ||
216 (Info->ReturnFlags & ACPI_OBJECT_REPAIRED))
217 {
218 Node->Flags |= ANOBJ_EVALUATED;
219 }
220
222}
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
#define AE_CTRL_RETURN_VALUE
Definition: acexcep.h:224
#define AE_AML_OPERAND_VALUE
Definition: acexcep.h:183
#define ANOBJ_EVALUATED
Definition: aclocal.h:220
#define ACPI_RTYPE_ALL
Definition: aclocal.h:483
ACPI_STATUS AcpiNsComplexRepairs(ACPI_EVALUATE_INFO *Info, ACPI_NAMESPACE_NODE *Node, ACPI_STATUS ValidateStatus, ACPI_OPERAND_OBJECT **ReturnObjectPtr)
Definition: nsrepair2.c:206
ACPI_STATUS AcpiNsCheckPackage(ACPI_EVALUATE_INFO *Info, ACPI_OPERAND_OBJECT **ReturnObjectPtr)
Definition: nsprepkg.c:96
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define ACPI_OBJECT_REPAIRED
Definition: acstruct.h:235
#define ACPI_TYPE_PACKAGE
Definition: actypes.h:691
ACPI_STATUS AcpiNsCheckObjectType(ACPI_EVALUATE_INFO *Info, ACPI_OPERAND_OBJECT **ReturnObjectPtr, UINT32 ExpectedBtypes, UINT32 PackageIndex)
Definition: nspredef.c:245
static void Exit(void)
Definition: sock.c:1330
UINT8 ExpectedBtypes
Definition: aclocal.h:377
ACPI_NAME_INFO Info
Definition: aclocal.h:441
Definition: dlist.c:348

Referenced by AcpiNsEvaluate().

◆ AcpiNsGetBitmappedType()

static UINT32 AcpiNsGetBitmappedType ( ACPI_OPERAND_OBJECT ReturnObject)
static

Definition at line 387 of file nspredef.c.

389{
390 UINT32 ReturnBtype;
391
392
393 if (!ReturnObject)
394 {
395 return (ACPI_RTYPE_NONE);
396 }
397
398 /* Map ACPI_OBJECT_TYPE to internal bitmapped type */
399
400 switch (ReturnObject->Common.Type)
401 {
403
404 ReturnBtype = ACPI_RTYPE_INTEGER;
405 break;
406
407 case ACPI_TYPE_BUFFER:
408
409 ReturnBtype = ACPI_RTYPE_BUFFER;
410 break;
411
412 case ACPI_TYPE_STRING:
413
414 ReturnBtype = ACPI_RTYPE_STRING;
415 break;
416
418
419 ReturnBtype = ACPI_RTYPE_PACKAGE;
420 break;
421
423
424 ReturnBtype = ACPI_RTYPE_REFERENCE;
425 break;
426
427 default:
428
429 /* Not one of the supported objects, must be incorrect */
430
431 ReturnBtype = ACPI_RTYPE_ANY;
432 break;
433 }
434
435 return (ReturnBtype);
436}
unsigned int UINT32
#define ACPI_RTYPE_STRING
Definition: aclocal.h:479
#define ACPI_RTYPE_INTEGER
Definition: aclocal.h:478
#define ACPI_RTYPE_PACKAGE
Definition: aclocal.h:481
#define ACPI_RTYPE_BUFFER
Definition: aclocal.h:480
#define ACPI_RTYPE_NONE
Definition: aclocal.h:477
#define ACPI_TYPE_LOCAL_REFERENCE
Definition: actypes.h:719
#define ACPI_TYPE_STRING
Definition: actypes.h:689
#define ACPI_TYPE_BUFFER
Definition: actypes.h:690
#define ACPI_TYPE_INTEGER
Definition: actypes.h:688
ACPI_OBJECT_COMMON Common
Definition: acobject.h:519

Referenced by AcpiNsCheckObjectType().