ReactOS 0.4.16-dev-125-g798ea90
nsaccess.c File Reference
#include "acpi.h"
#include "accommon.h"
#include "amlcode.h"
#include "acnamesp.h"
#include "acdispat.h"
Include dependency graph for nsaccess.c:

Go to the source code of this file.

Macros

#define _COMPONENT   ACPI_NAMESPACE
 

Functions

ACPI_STATUS AcpiNsRootInitialize (void)
 
ACPI_STATUS AcpiNsLookup (ACPI_GENERIC_STATE *ScopeInfo, char *Pathname, ACPI_OBJECT_TYPE Type, ACPI_INTERPRETER_MODE InterpreterMode, UINT32 Flags, ACPI_WALK_STATE *WalkState, ACPI_NAMESPACE_NODE **ReturnNode)
 

Macro Definition Documentation

◆ _COMPONENT

#define _COMPONENT   ACPI_NAMESPACE

Definition at line 54 of file nsaccess.c.

Function Documentation

◆ AcpiNsLookup()

ACPI_STATUS AcpiNsLookup ( ACPI_GENERIC_STATE ScopeInfo,
char Pathname,
ACPI_OBJECT_TYPE  Type,
ACPI_INTERPRETER_MODE  InterpreterMode,
UINT32  Flags,
ACPI_WALK_STATE WalkState,
ACPI_NAMESPACE_NODE **  ReturnNode 
)

Definition at line 328 of file nsaccess.c.

336{
338 char *Path = Pathname;
339 char *ExternalPath;
340 ACPI_NAMESPACE_NODE *PrefixNode;
341 ACPI_NAMESPACE_NODE *CurrentNode = NULL;
342 ACPI_NAMESPACE_NODE *ThisNode = NULL;
343 UINT32 NumSegments;
344 UINT32 NumCarats;
345 ACPI_NAME SimpleName;
346 ACPI_OBJECT_TYPE TypeToCheckFor;
347 ACPI_OBJECT_TYPE ThisSearchType;
348 UINT32 SearchParentFlag = ACPI_NS_SEARCH_PARENT;
350 ACPI_INTERPRETER_MODE LocalInterpreterMode;
351
352
353 ACPI_FUNCTION_TRACE (NsLookup);
354
355
356 if (!ReturnNode)
357 {
359 }
360
361 LocalFlags = Flags &
364 *ReturnNode = ACPI_ENTRY_NOT_FOUND;
365 AcpiGbl_NsLookupCount++;
366
367 if (!AcpiGbl_RootNode)
368 {
370 }
371
372 /* Get the prefix scope. A null scope means use the root scope */
373
374 if ((!ScopeInfo) ||
375 (!ScopeInfo->Scope.Node))
376 {
378 "Null scope prefix, using root node (%p)\n",
379 AcpiGbl_RootNode));
380
381 PrefixNode = AcpiGbl_RootNode;
382 }
383 else
384 {
385 PrefixNode = ScopeInfo->Scope.Node;
387 {
388 ACPI_ERROR ((AE_INFO, "%p is not a namespace node [%s]",
389 PrefixNode, AcpiUtGetDescriptorName (PrefixNode)));
391 }
392
394 {
395 /*
396 * This node might not be a actual "scope" node (such as a
397 * Device/Method, etc.) It could be a Package or other object
398 * node. Backup up the tree to find the containing scope node.
399 */
400 while (!AcpiNsOpensScope (PrefixNode->Type) &&
401 PrefixNode->Type != ACPI_TYPE_ANY)
402 {
403 PrefixNode = PrefixNode->Parent;
404 }
405 }
406 }
407
408 /* Save type. TBD: may be no longer necessary */
409
410 TypeToCheckFor = Type;
411
412 /*
413 * Begin examination of the actual pathname
414 */
415 if (!Pathname)
416 {
417 /* A Null NamePath is allowed and refers to the root */
418
419 NumSegments = 0;
420 ThisNode = AcpiGbl_RootNode;
421 Path = "";
422
424 "Null Pathname (Zero segments), Flags=%X\n", Flags));
425 }
426 else
427 {
428 /*
429 * Name pointer is valid (and must be in internal name format)
430 *
431 * Check for scope prefixes:
432 *
433 * As represented in the AML stream, a namepath consists of an
434 * optional scope prefix followed by a name segment part.
435 *
436 * If present, the scope prefix is either a Root Prefix (in
437 * which case the name is fully qualified), or one or more
438 * Parent Prefixes (in which case the name's scope is relative
439 * to the current scope).
440 */
441 if (*Path == (UINT8) AML_ROOT_PREFIX)
442 {
443 /* Pathname is fully qualified, start from the root */
444
445 ThisNode = AcpiGbl_RootNode;
446 SearchParentFlag = ACPI_NS_NO_UPSEARCH;
447
448 /* Point to name segment part */
449
450 Path++;
451
453 "Path is absolute from root [%p]\n", ThisNode));
454 }
455 else
456 {
457 /* Pathname is relative to current scope, start there */
458
460 "Searching relative to prefix scope [%4.4s] (%p)\n",
461 AcpiUtGetNodeName (PrefixNode), PrefixNode));
462
463 /*
464 * Handle multiple Parent Prefixes (carat) by just getting
465 * the parent node for each prefix instance.
466 */
467 ThisNode = PrefixNode;
468 NumCarats = 0;
469 while (*Path == (UINT8) AML_PARENT_PREFIX)
470 {
471 /* Name is fully qualified, no search rules apply */
472
473 SearchParentFlag = ACPI_NS_NO_UPSEARCH;
474
475 /*
476 * Point past this prefix to the name segment
477 * part or the next Parent Prefix
478 */
479 Path++;
480
481 /* Backup to the parent node */
482
483 NumCarats++;
484 ThisNode = ThisNode->Parent;
485 if (!ThisNode)
486 {
487 /*
488 * Current scope has no parent scope. Externalize
489 * the internal path for error message.
490 */
492 NULL, &ExternalPath);
493 if (ACPI_SUCCESS (Status))
494 {
496 "%s: Path has too many parent prefixes (^)",
497 ExternalPath));
498
499 ACPI_FREE (ExternalPath);
500 }
501
503 }
504 }
505
506 if (SearchParentFlag == ACPI_NS_NO_UPSEARCH)
507 {
509 "Search scope is [%4.4s], path has %u carat(s)\n",
510 AcpiUtGetNodeName (ThisNode), NumCarats));
511 }
512 }
513
514 /*
515 * Determine the number of ACPI name segments in this pathname.
516 *
517 * The segment part consists of either:
518 * - A Null name segment (0)
519 * - A DualNamePrefix followed by two 4-byte name segments
520 * - A MultiNamePrefix followed by a byte indicating the
521 * number of segments and the segments themselves.
522 * - A single 4-byte name segment
523 *
524 * Examine the name prefix opcode, if any, to determine the number of
525 * segments.
526 */
527 switch (*Path)
528 {
529 case 0:
530 /*
531 * Null name after a root or parent prefixes. We already
532 * have the correct target node and there are no name segments.
533 */
534 NumSegments = 0;
535 Type = ThisNode->Type;
536
538 "Prefix-only Pathname (Zero name segments), Flags=%X\n",
539 Flags));
540 break;
541
543
544 /* More than one NameSeg, search rules do not apply */
545
546 SearchParentFlag = ACPI_NS_NO_UPSEARCH;
547
548 /* Two segments, point to first name segment */
549
550 NumSegments = 2;
551 Path++;
552
554 "Dual Pathname (2 segments, Flags=%X)\n", Flags));
555 break;
556
558
559 /* More than one NameSeg, search rules do not apply */
560
561 SearchParentFlag = ACPI_NS_NO_UPSEARCH;
562
563 /* Extract segment count, point to first name segment */
564
565 Path++;
566 NumSegments = (UINT32) (UINT8) *Path;
567 Path++;
568
570 "Multi Pathname (%u Segments, Flags=%X)\n",
571 NumSegments, Flags));
572 break;
573
574 default:
575 /*
576 * Not a Null name, no Dual or Multi prefix, hence there is
577 * only one name segment and Pathname is already pointing to it.
578 */
579 NumSegments = 1;
580
582 "Simple Pathname (1 segment, Flags=%X)\n", Flags));
583 break;
584 }
585
587 }
588
589
590 /*
591 * Search namespace for each segment of the name. Loop through and
592 * verify (or add to the namespace) each name segment.
593 *
594 * The object type is significant only at the last name
595 * segment. (We don't care about the types along the path, only
596 * the type of the final target object.)
597 */
598 ThisSearchType = ACPI_TYPE_ANY;
599 CurrentNode = ThisNode;
600
601 while (NumSegments && CurrentNode)
602 {
603 NumSegments--;
604 if (!NumSegments)
605 {
606 /* This is the last segment, enable typechecking */
607
608 ThisSearchType = Type;
609
610 /*
611 * Only allow automatic parent search (search rules) if the caller
612 * requested it AND we have a single, non-fully-qualified NameSeg
613 */
614 if ((SearchParentFlag != ACPI_NS_NO_UPSEARCH) &&
616 {
618 }
619
620 /* Set error flag according to caller */
621
623 {
625 }
626
627 /* Set override flag according to caller */
628
630 {
632 }
633 }
634
635 /* Handle opcodes that create a new NameSeg via a full NamePath */
636
637 LocalInterpreterMode = InterpreterMode;
638 if ((Flags & ACPI_NS_PREFIX_MUST_EXIST) && (NumSegments > 0))
639 {
640 /* Every element of the path must exist (except for the final NameSeg) */
641
642 LocalInterpreterMode = ACPI_IMODE_EXECUTE;
643 }
644
645 /* Extract one ACPI name from the front of the pathname */
646
647 ACPI_MOVE_32_TO_32 (&SimpleName, Path);
648
649 /* Try to find the single (4 character) ACPI name */
650
651 Status = AcpiNsSearchAndEnter (SimpleName, WalkState, CurrentNode,
652 LocalInterpreterMode, ThisSearchType, LocalFlags, &ThisNode);
653 if (ACPI_FAILURE (Status))
654 {
655 if (Status == AE_NOT_FOUND)
656 {
657#if !defined ACPI_ASL_COMPILER /* Note: iASL reports this error by itself, not needed here */
659 {
661 "Object does not exist: %4.4s\n", (char *) &SimpleName);
662 }
663#endif
664 /* Name not found in ACPI namespace */
665
667 "Name [%4.4s] not found in scope [%4.4s] %p\n",
668 (char *) &SimpleName, (char *) &CurrentNode->Name,
669 CurrentNode));
670 }
671
672#ifdef ACPI_EXEC_APP
673 if ((Status == AE_ALREADY_EXISTS) &&
674 (ThisNode->Flags & ANOBJ_NODE_EARLY_INIT))
675 {
676 ThisNode->Flags &= ~ANOBJ_NODE_EARLY_INIT;
677 Status = AE_OK;
678 }
679#endif
680
681#ifdef ACPI_ASL_COMPILER
682 /*
683 * If this ACPI name already exists within the namespace as an
684 * external declaration, then mark the external as a conflicting
685 * declaration and proceed to process the current node as if it did
686 * not exist in the namespace. If this node is not processed as
687 * normal, then it could cause improper namespace resolution
688 * by failing to open a new scope.
689 */
690 if (AcpiGbl_DisasmFlag &&
692 ((ThisNode->Flags & ANOBJ_IS_EXTERNAL) ||
693 (WalkState && WalkState->Opcode == AML_EXTERNAL_OP)))
694 {
695 ThisNode->Flags &= ~ANOBJ_IS_EXTERNAL;
696 ThisNode->Type = (UINT8)ThisSearchType;
697 if (WalkState->Opcode != AML_EXTERNAL_OP)
698 {
700 }
701 break;
702 }
703#endif
704
705 *ReturnNode = ThisNode;
707 }
708
709 /* More segments to follow? */
710
711 if (NumSegments > 0)
712 {
713 /*
714 * If we have an alias to an object that opens a scope (such as a
715 * device or processor), we need to dereference the alias here so
716 * that we can access any children of the original node (via the
717 * remaining segments).
718 */
719 if (ThisNode->Type == ACPI_TYPE_LOCAL_ALIAS)
720 {
721 if (!ThisNode->Object)
722 {
724 }
725
727 ThisNode->Object)->Type))
728 {
729 ThisNode = (ACPI_NAMESPACE_NODE *) ThisNode->Object;
730 }
731 }
732 }
733
734 /* Special handling for the last segment (NumSegments == 0) */
735
736 else
737 {
738 /*
739 * Sanity typecheck of the target object:
740 *
741 * If 1) This is the last segment (NumSegments == 0)
742 * 2) And we are looking for a specific type
743 * (Not checking for TYPE_ANY)
744 * 3) Which is not an alias
745 * 4) Which is not a local type (TYPE_SCOPE)
746 * 5) And the type of target object is known (not TYPE_ANY)
747 * 6) And target object does not match what we are looking for
748 *
749 * Then we have a type mismatch. Just warn and ignore it.
750 */
751 if ((TypeToCheckFor != ACPI_TYPE_ANY) &&
752 (TypeToCheckFor != ACPI_TYPE_LOCAL_ALIAS) &&
753 (TypeToCheckFor != ACPI_TYPE_LOCAL_METHOD_ALIAS) &&
754 (TypeToCheckFor != ACPI_TYPE_LOCAL_SCOPE) &&
755 (ThisNode->Type != ACPI_TYPE_ANY) &&
756 (ThisNode->Type != TypeToCheckFor))
757 {
758 /* Complain about a type mismatch */
759
761 "NsLookup: Type mismatch on %4.4s (%s), searching for (%s)",
762 ACPI_CAST_PTR (char, &SimpleName),
763 AcpiUtGetTypeName (ThisNode->Type),
764 AcpiUtGetTypeName (TypeToCheckFor)));
765 }
766
767 /*
768 * If this is the last name segment and we are not looking for a
769 * specific type, but the type of found object is known, use that
770 * type to (later) see if it opens a scope.
771 */
772 if (Type == ACPI_TYPE_ANY)
773 {
774 Type = ThisNode->Type;
775 }
776 }
777
778 /* Point to next name segment and make this node current */
779
781 CurrentNode = ThisNode;
782 }
783
784 /* Always check if we need to open a new scope */
785
786 if (!(Flags & ACPI_NS_DONT_OPEN_SCOPE) && (WalkState))
787 {
788 /*
789 * If entry is a type which opens a scope, push the new scope on the
790 * scope stack.
791 */
793 {
794 Status = AcpiDsScopeStackPush (ThisNode, Type, WalkState);
795 if (ACPI_FAILURE (Status))
796 {
798 }
799 }
800 }
801
802#ifdef ACPI_EXEC_APP
804 {
805 ThisNode->Flags |= ANOBJ_NODE_EARLY_INIT;
806 }
807#endif
808
809 *ReturnNode = ThisNode;
811}
unsigned char UINT8
unsigned int UINT32
PRTL_UNICODE_STRING_BUFFER Path
Type
Definition: Type.h:7
void AcpiDmMarkExternalConflict(ACPI_NAMESPACE_NODE *Node)
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
#define AE_AML_INTERNAL
Definition: acexcep.h:194
#define AE_BAD_PARAMETER
Definition: acexcep.h:151
#define AE_ALREADY_EXISTS
Definition: acexcep.h:115
#define AE_NOT_FOUND
Definition: acexcep.h:113
#define AE_NOT_EXIST
Definition: acexcep.h:114
#define AE_NO_NAMESPACE
Definition: acexcep.h:111
#define ACPI_SUCCESS(a)
Definition: acexcep.h:94
#define AE_OK
Definition: acexcep.h:97
#define ANOBJ_IS_EXTERNAL
Definition: aclocal.h:224
ACPI_INTERPRETER_MODE
Definition: aclocal.h:166
@ ACPI_IMODE_EXECUTE
Definition: aclocal.h:169
#define ANOBJ_NODE_EARLY_INIT
Definition: aclocal.h:222
#define ACPI_ENTRY_NOT_FOUND
Definition: aclocal.h:154
#define ACPI_GET_DESCRIPTOR_TYPE(d)
Definition: acmacros.h:414
#define ACPI_MOVE_32_TO_32(d, s)
Definition: acmacros.h:148
#define ACPI_NS_OVERRIDE_IF_FOUND
Definition: acnamesp.h:70
#define ACPI_NS_EARLY_INIT
Definition: acnamesp.h:71
#define ACPI_NS_NO_UPSEARCH
Definition: acnamesp.h:62
#define ACPI_NS_ERROR_IF_FOUND
Definition: acnamesp.h:66
ACPI_STATUS AcpiNsSearchAndEnter(UINT32 EntryName, ACPI_WALK_STATE *WalkState, ACPI_NAMESPACE_NODE *Node, ACPI_INTERPRETER_MODE InterpreterMode, ACPI_OBJECT_TYPE Type, UINT32 Flags, ACPI_NAMESPACE_NODE **RetNode)
Definition: nssearch.c:294
ACPI_STATUS AcpiNsExternalizeName(UINT32 InternalNameLength, const char *InternalName, UINT32 *ConvertedNameLength, char **ConvertedName)
Definition: nsutils.c:470
#define ACPI_NS_PREFIX_IS_SCOPE
Definition: acnamesp.h:67
void AcpiNsPrintPathname(UINT32 NumSegments, const char *Pathname)
#define ACPI_NS_DONT_OPEN_SCOPE
Definition: acnamesp.h:64
#define ACPI_NS_SEARCH_PARENT
Definition: acnamesp.h:63
#define ACPI_NS_PREFIX_MUST_EXIST
Definition: acnamesp.h:72
UINT32 AcpiNsOpensScope(ACPI_OBJECT_TYPE Type)
Definition: nsutils.c:736
#define ACPI_DESC_TYPE_NAMED
Definition: acobject.h:577
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
#define ACPI_DEBUG_EXEC(a)
Definition: acoutput.h:477
#define ACPI_WARNING(plist)
Definition: acoutput.h:238
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define ACPI_ERROR(plist)
Definition: acoutput.h:240
#define AE_INFO
Definition: acoutput.h:230
#define ACPI_DB_NAMES
Definition: acoutput.h:166
void ACPI_INTERNAL_VAR_XFACE AcpiOsPrintf(const char *Format,...)
Definition: osl.c:851
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING Pathname
Definition: acpixf.h:704
UINT32 ACPI_OBJECT_TYPE
Definition: actypes.h:685
#define ACPI_TYPE_LOCAL_ALIAS
Definition: actypes.h:720
#define ACPI_FREE(a)
Definition: actypes.h:386
#define ACPI_TYPE_ANY
Definition: actypes.h:687
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define ACPI_CAST_PTR(t, p)
Definition: actypes.h:544
#define ACPI_UINT32_MAX
Definition: actypes.h:66
#define ACPI_TYPE_LOCAL_METHOD_ALIAS
Definition: actypes.h:721
UINT32 ACPI_NAME
Definition: actypes.h:461
#define ACPI_TYPE_LOCAL_SCOPE
Definition: actypes.h:726
#define ACPI_NAMESEG_SIZE
Definition: actypes.h:415
#define ACPI_MSG_BIOS_ERROR
Definition: acutils.h:131
const char * AcpiUtGetTypeName(ACPI_OBJECT_TYPE Type)
Definition: utdecode.c:250
const char * AcpiUtGetNodeName(void *Object)
Definition: utdecode.c:306
const char * AcpiUtGetDescriptorName(void *Object)
Definition: utdecode.c:382
#define AML_PARENT_PREFIX
Definition: amlcode.h:70
#define AML_EXTERNAL_OP
Definition: amlcode.h:65
#define AML_DUAL_NAME_PREFIX
Definition: amlcode.h:66
#define AML_MULTI_NAME_PREFIX
Definition: amlcode.h:67
#define AML_ROOT_PREFIX
Definition: amlcode.h:69
#define NULL
Definition: types.h:112
ACPI_STATUS AcpiDsScopeStackPush(ACPI_NAMESPACE_NODE *Node, ACPI_OBJECT_TYPE Type, ACPI_WALK_STATE *WalkState)
Definition: dswscope.c:107
Status
Definition: gdiplustypes.h:25
UINT NTAPI LocalFlags(HLOCAL hMem)
Definition: heapmem.c:1520
union acpi_operand_object * Object
Definition: aclocal.h:187
struct acpi_namespace_node * Parent
Definition: aclocal.h:192
ACPI_NAME_UNION Name
Definition: aclocal.h:191
ACPI_STATE_COMMON ACPI_NAMESPACE_NODE * Node
Definition: aclocal.h:740
UINT16 Opcode
Definition: acstruct.h:78
ACPI_SCOPE_STATE Scope
Definition: aclocal.h:825
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by AcpiDsBuildInternalObject(), AcpiDsCreateBankField(), AcpiDsCreateBufferField(), AcpiDsCreateField(), AcpiDsCreateIndexField(), AcpiDsCreateOperand(), AcpiDsGetFieldNames(), AcpiDsInitFieldObjects(), AcpiDsLoad1BeginOp(), AcpiDsLoad2BeginOp(), AcpiDsLoad2EndOp(), AcpiDsResolvePackageElement(), AcpiInstallMethod(), AcpiNsConvertToReference(), AcpiNsGetNodeUnlocked(), and AcpiPsGetNextNamepath().

◆ AcpiNsRootInitialize()

ACPI_STATUS AcpiNsRootInitialize ( void  )

Definition at line 73 of file nsaccess.c.

75{
77 const ACPI_PREDEFINED_NAMES *InitVal = NULL;
78 ACPI_NAMESPACE_NODE *NewNode;
79 ACPI_NAMESPACE_NODE *PrevNode = NULL;
80 ACPI_OPERAND_OBJECT *ObjDesc;
81 ACPI_STRING Val = NULL;
82
83
84 ACPI_FUNCTION_TRACE (NsRootInitialize);
85
86
88 if (ACPI_FAILURE (Status))
89 {
91 }
92
93 /*
94 * The global root ptr is initially NULL, so a non-NULL value indicates
95 * that AcpiNsRootInitialize() has already been called; just return.
96 */
97 if (AcpiGbl_RootNode)
98 {
99 Status = AE_OK;
100 goto UnlockAndExit;
101 }
102
103 /*
104 * Tell the rest of the subsystem that the root is initialized
105 * (This is OK because the namespace is locked)
106 */
107 AcpiGbl_RootNode = &AcpiGbl_RootNodeStruct;
108
109 /* Enter the predefined names in the name table */
110
112 "Entering predefined entries into namespace\n"));
113
114 /*
115 * Create the initial (default) namespace.
116 * This namespace looks like something similar to this:
117 *
118 * ACPI Namespace (from Namespace Root):
119 * 0 _GPE Scope 00203160 00
120 * 0 _PR_ Scope 002031D0 00
121 * 0 _SB_ Device 00203240 00 Notify Object: 0020ADD8
122 * 0 _SI_ Scope 002032B0 00
123 * 0 _TZ_ Device 00203320 00
124 * 0 _REV Integer 00203390 00 = 0000000000000002
125 * 0 _OS_ String 00203488 00 Len 14 "Microsoft Windows NT"
126 * 0 _GL_ Mutex 00203580 00 Object 002035F0
127 * 0 _OSI Method 00203678 00 Args 1 Len 0000 Aml 00000000
128 */
129 for (InitVal = AcpiGbl_PreDefinedNames; InitVal->Name; InitVal++)
130 {
131 Status = AE_OK;
132
133 /* _OSI is optional for now, will be permanent later */
134
135 if (!strcmp (InitVal->Name, "_OSI") && !AcpiGbl_CreateOsiMethod)
136 {
137 continue;
138 }
139
140 /*
141 * Create, init, and link the new predefined name
142 * Note: No need to use AcpiNsLookup here because all the
143 * predefined names are at the root level. It is much easier to
144 * just create and link the new node(s) here.
145 */
146 NewNode = AcpiNsCreateNode (*ACPI_CAST_PTR (UINT32, InitVal->Name));
147 if (!NewNode)
148 {
150 goto UnlockAndExit;
151 }
152
154 NewNode->Type = InitVal->Type;
155
156 if (!PrevNode)
157 {
158 AcpiGbl_RootNodeStruct.Child = NewNode;
159 }
160 else
161 {
162 PrevNode->Peer = NewNode;
163 }
164
165 NewNode->Parent = &AcpiGbl_RootNodeStruct;
166 PrevNode = NewNode;
167
168 /*
169 * Name entered successfully. If entry in PreDefinedNames[] specifies
170 * an initial value, create the initial value.
171 */
172 if (InitVal->Val)
173 {
174 Status = AcpiOsPredefinedOverride (InitVal, &Val);
175 if (ACPI_FAILURE (Status))
176 {
178 "Could not override predefined %s",
179 InitVal->Name));
180 }
181
182 if (!Val)
183 {
184 Val = InitVal->Val;
185 }
186
187 /*
188 * Entry requests an initial value, allocate a
189 * descriptor for it.
190 */
191 ObjDesc = AcpiUtCreateInternalObject (InitVal->Type);
192 if (!ObjDesc)
193 {
195 goto UnlockAndExit;
196 }
197
198 /*
199 * Convert value string from table entry to
200 * internal representation. Only types actually
201 * used for initial values are implemented here.
202 */
203 switch (InitVal->Type)
204 {
205 case ACPI_TYPE_METHOD:
206
207 ObjDesc->Method.ParamCount = (UINT8) ACPI_TO_INTEGER (Val);
208 ObjDesc->Common.Flags |= AOPOBJ_DATA_VALID;
209
210#if defined (ACPI_ASL_COMPILER)
211
212 /* Save the parameter count for the iASL compiler */
213
214 NewNode->Value = ObjDesc->Method.ParamCount;
215#else
216 /* Mark this as a very SPECIAL method (_OSI) */
217
220#endif
221 break;
222
224
225 ObjDesc->Integer.Value = ACPI_TO_INTEGER (Val);
226 break;
227
228 case ACPI_TYPE_STRING:
229
230 /* Build an object around the static string */
231
232 ObjDesc->String.Length = (UINT32) strlen (Val);
233 ObjDesc->String.Pointer = Val;
234 ObjDesc->Common.Flags |= AOPOBJ_STATIC_POINTER;
235 break;
236
237 case ACPI_TYPE_MUTEX:
238
239 ObjDesc->Mutex.Node = NewNode;
240 ObjDesc->Mutex.SyncLevel = (UINT8) (ACPI_TO_INTEGER (Val) - 1);
241
242 /* Create a mutex */
243
245 if (ACPI_FAILURE (Status))
246 {
247 AcpiUtRemoveReference (ObjDesc);
248 goto UnlockAndExit;
249 }
250
251 /* Special case for ACPI Global Lock */
252
253 if (strcmp (InitVal->Name, "_GL_") == 0)
254 {
255 AcpiGbl_GlobalLockMutex = ObjDesc;
256
257 /* Create additional counting semaphore for global lock */
258
260 1, 0, &AcpiGbl_GlobalLockSemaphore);
261 if (ACPI_FAILURE (Status))
262 {
263 AcpiUtRemoveReference (ObjDesc);
264 goto UnlockAndExit;
265 }
266 }
267 break;
268
269 default:
270
271 ACPI_ERROR ((AE_INFO, "Unsupported initial type value 0x%X",
272 InitVal->Type));
273 AcpiUtRemoveReference (ObjDesc);
274 ObjDesc = NULL;
275 continue;
276 }
277
278 /* Store pointer to value descriptor in the Node */
279
280 Status = AcpiNsAttachObject (NewNode, ObjDesc,
281 ObjDesc->Common.Type);
282
283 /* Remove local reference to the object */
284
285 AcpiUtRemoveReference (ObjDesc);
286 }
287 }
288
289UnlockAndExit:
291
292 /* Save a handle to "_GPE", it is always present */
293
294 if (ACPI_SUCCESS (Status))
295 {
297 &AcpiGbl_FadtGpeDevice);
298 }
299
301}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define AE_NO_MEMORY
Definition: acexcep.h:112
const ACPI_PREDEFINED_NAMES AcpiGbl_PreDefinedNames[NUM_PREDEFINED_NAMES]
Definition: utglobal.c:113
#define ACPI_MTX_NAMESPACE
Definition: aclocal.h:85
ACPI_STATUS AcpiNsGetNode(ACPI_NAMESPACE_NODE *PrefixNode, const char *ExternalPathname, UINT32 Flags, ACPI_NAMESPACE_NODE **OutNode)
Definition: nsutils.c:863
ACPI_STATUS AcpiNsAttachObject(ACPI_NAMESPACE_NODE *Node, ACPI_OPERAND_OBJECT *Object, ACPI_OBJECT_TYPE Type)
Definition: nsobject.c:76
ACPI_NAMESPACE_NODE * AcpiNsCreateNode(UINT32 Name)
Definition: nsalloc.c:66
#define AOPOBJ_DATA_VALID
Definition: acobject.h:96
#define AOPOBJ_STATIC_POINTER
Definition: acobject.h:95
#define ACPI_METHOD_INTERNAL_ONLY
Definition: acobject.h:237
#define ACPI_DB_INFO
Definition: acoutput.h:153
ACPI_STATUS AcpiOsPredefinedOverride(const ACPI_PREDEFINED_NAMES *InitVal, ACPI_STRING *NewVal)
Definition: osl.c:55
ACPI_STATUS AcpiOsCreateSemaphore(UINT32 MaxUnits, UINT32 InitialUnits, ACPI_SEMAPHORE *OutHandle)
Definition: osl.c:352
#define ACPI_TYPE_STRING
Definition: actypes.h:689
#define ACPI_TYPE_MUTEX
Definition: actypes.h:696
#define ACPI_TO_INTEGER(p)
Definition: actypes.h:554
char * ACPI_STRING
Definition: actypes.h:462
#define ACPI_TYPE_INTEGER
Definition: actypes.h:688
#define AcpiOsCreateMutex(OutHandle)
Definition: actypes.h:274
#define ACPI_TYPE_METHOD
Definition: actypes.h:695
#define AcpiUtCreateInternalObject(t)
Definition: acutils.h:681
ACPI_STATUS AcpiUtAcquireMutex(ACPI_MUTEX_HANDLE MutexId)
Definition: utmutex.c:256
ACPI_STATUS AcpiUtReleaseMutex(ACPI_MUTEX_HANDLE MutexId)
Definition: utmutex.c:348
void AcpiUtRemoveReference(ACPI_OPERAND_OBJECT *Object)
Definition: utdelete.c:790
ACPI_STATUS AcpiUtOsiImplementation(ACPI_WALK_STATE *WalkState)
Definition: utosi.c:472
struct acpi_namespace_node * Peer
Definition: aclocal.h:194
UINT8 DescriptorType
Definition: aclocal.h:188
union acpi_object_method::@613 Dispatch
ACPI_OBJECT_COMMON_HEADER UINT8 InfoFlags
Definition: acobject.h:216
ACPI_INTERNAL_METHOD Implementation
Definition: acobject.h:224
ACPI_OBJECT_COMMON_HEADER UINT8 SyncLevel
Definition: acobject.h:186
ACPI_NAMESPACE_NODE * Node
Definition: acobject.h:193
ACPI_MUTEX OsMutex
Definition: acobject.h:188
const char * Name
Definition: actypes.h:1073
ACPI_OBJECT_METHOD Method
Definition: acobject.h:525
ACPI_OBJECT_MUTEX Mutex
Definition: acobject.h:526
ACPI_OBJECT_INTEGER Integer
Definition: acobject.h:520
ACPI_OBJECT_COMMON Common
Definition: acobject.h:519
ACPI_OBJECT_STRING String
Definition: acobject.h:521

Referenced by AcpiInitializeSubsystem().