Print this page
update to acpica-unix2-20140114
acpica-unix2-20130823
PANKOVs restructure
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/intel/io/acpica/namespace/nsaccess.c
+++ new/usr/src/common/acpica/components/namespace/nsaccess.c
1 1 /*******************************************************************************
2 2 *
3 3 * Module Name: nsaccess - Top-level functions for accessing ACPI namespace
4 4 *
5 5 ******************************************************************************/
6 6
7 7 /*
8 - * Copyright (C) 2000 - 2011, Intel Corp.
8 + * Copyright (C) 2000 - 2014, Intel Corp.
9 9 * All rights reserved.
10 10 *
11 11 * Redistribution and use in source and binary forms, with or without
12 12 * modification, are permitted provided that the following conditions
13 13 * are met:
14 14 * 1. Redistributions of source code must retain the above copyright
15 15 * notice, this list of conditions, and the following disclaimer,
16 16 * without modification.
17 17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 18 * substantially similar to the "NO WARRANTY" disclaimer below
19 19 * ("Disclaimer") and any redistribution must be conditioned upon
20 20 * including a substantially similar Disclaimer requirement for further
21 21 * binary redistribution.
22 22 * 3. Neither the names of the above-listed copyright holders nor the names
23 23 * of any contributors may be used to endorse or promote products derived
24 24 * from this software without specific prior written permission.
25 25 *
26 26 * Alternatively, this software may be distributed under the terms of the
27 27 * GNU General Public License ("GPL") version 2 as published by the Free
28 28 * Software Foundation.
29 29 *
30 30 * NO WARRANTY
31 31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 41 * POSSIBILITY OF SUCH DAMAGES.
42 42 */
43 43
44 44 #define __NSACCESS_C__
45 45
46 46 #include "acpi.h"
47 47 #include "accommon.h"
48 48 #include "amlcode.h"
49 49 #include "acnamesp.h"
50 50 #include "acdispat.h"
51 51
52 52
53 53 #define _COMPONENT ACPI_NAMESPACE
54 54 ACPI_MODULE_NAME ("nsaccess")
55 55
56 56
57 57 /*******************************************************************************
58 58 *
59 59 * FUNCTION: AcpiNsRootInitialize
60 60 *
61 61 * PARAMETERS: None
62 62 *
63 63 * RETURN: Status
64 64 *
65 65 * DESCRIPTION: Allocate and initialize the default root named objects
66 66 *
67 67 * MUTEX: Locks namespace for entire execution
68 68 *
69 69 ******************************************************************************/
70 70
71 71 ACPI_STATUS
72 72 AcpiNsRootInitialize (
73 73 void)
74 74 {
75 75 ACPI_STATUS Status;
76 76 const ACPI_PREDEFINED_NAMES *InitVal = NULL;
77 77 ACPI_NAMESPACE_NODE *NewNode;
78 78 ACPI_OPERAND_OBJECT *ObjDesc;
79 79 ACPI_STRING Val = NULL;
80 80
81 81
82 82 ACPI_FUNCTION_TRACE (NsRootInitialize);
83 83
84 84
85 85 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
86 86 if (ACPI_FAILURE (Status))
87 87 {
88 88 return_ACPI_STATUS (Status);
89 89 }
90 90
91 91 /*
92 92 * The global root ptr is initially NULL, so a non-NULL value indicates
93 93 * that AcpiNsRootInitialize() has already been called; just return.
94 94 */
95 95 if (AcpiGbl_RootNode)
96 96 {
97 97 Status = AE_OK;
98 98 goto UnlockAndExit;
99 99 }
100 100
101 101 /*
102 102 * Tell the rest of the subsystem that the root is initialized
103 103 * (This is OK because the namespace is locked)
104 104 */
105 105 AcpiGbl_RootNode = &AcpiGbl_RootNodeStruct;
106 106
107 107 /* Enter the pre-defined names in the name table */
108 108
109 109 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
110 110 "Entering predefined entries into namespace\n"));
111 111
112 112 for (InitVal = AcpiGbl_PreDefinedNames; InitVal->Name; InitVal++)
113 113 {
↓ open down ↓ |
95 lines elided |
↑ open up ↑ |
114 114 /* _OSI is optional for now, will be permanent later */
115 115
116 116 if (!ACPI_STRCMP (InitVal->Name, "_OSI") && !AcpiGbl_CreateOsiMethod)
117 117 {
118 118 continue;
119 119 }
120 120
121 121 Status = AcpiNsLookup (NULL, InitVal->Name, InitVal->Type,
122 122 ACPI_IMODE_LOAD_PASS2, ACPI_NS_NO_UPSEARCH,
123 123 NULL, &NewNode);
124 -
125 - if (ACPI_FAILURE (Status) || (!NewNode)) /* Must be on same line for code converter */
124 + if (ACPI_FAILURE (Status))
126 125 {
127 126 ACPI_EXCEPTION ((AE_INFO, Status,
128 127 "Could not create predefined name %s",
129 128 InitVal->Name));
129 + continue;
130 130 }
131 131
132 132 /*
133 133 * Name entered successfully. If entry in PreDefinedNames[] specifies
134 134 * an initial value, create the initial value.
135 135 */
136 136 if (InitVal->Val)
137 137 {
138 138 Status = AcpiOsPredefinedOverride (InitVal, &Val);
139 139 if (ACPI_FAILURE (Status))
140 140 {
141 141 ACPI_ERROR ((AE_INFO,
142 142 "Could not override predefined %s",
143 143 InitVal->Name));
144 144 }
145 145
146 146 if (!Val)
147 147 {
148 148 Val = InitVal->Val;
149 149 }
150 150
151 151 /*
152 152 * Entry requests an initial value, allocate a
153 153 * descriptor for it.
154 154 */
155 155 ObjDesc = AcpiUtCreateInternalObject (InitVal->Type);
156 156 if (!ObjDesc)
157 157 {
158 158 Status = AE_NO_MEMORY;
159 159 goto UnlockAndExit;
↓ open down ↓ |
20 lines elided |
↑ open up ↑ |
160 160 }
161 161
162 162 /*
163 163 * Convert value string from table entry to
164 164 * internal representation. Only types actually
165 165 * used for initial values are implemented here.
166 166 */
167 167 switch (InitVal->Type)
168 168 {
169 169 case ACPI_TYPE_METHOD:
170 +
170 171 ObjDesc->Method.ParamCount = (UINT8) ACPI_TO_INTEGER (Val);
171 172 ObjDesc->Common.Flags |= AOPOBJ_DATA_VALID;
172 173
173 174 #if defined (ACPI_ASL_COMPILER)
174 175
175 176 /* Save the parameter count for the iASL compiler */
176 177
177 178 NewNode->Value = ObjDesc->Method.ParamCount;
178 179 #else
179 180 /* Mark this as a very SPECIAL method */
180 181
↓ open down ↓ |
1 lines elided |
↑ open up ↑ |
181 182 ObjDesc->Method.InfoFlags = ACPI_METHOD_INTERNAL_ONLY;
182 183 ObjDesc->Method.Dispatch.Implementation = AcpiUtOsiImplementation;
183 184 #endif
184 185 break;
185 186
186 187 case ACPI_TYPE_INTEGER:
187 188
188 189 ObjDesc->Integer.Value = ACPI_TO_INTEGER (Val);
189 190 break;
190 191
191 -
192 192 case ACPI_TYPE_STRING:
193 193
194 194 /* Build an object around the static string */
195 195
196 196 ObjDesc->String.Length = (UINT32) ACPI_STRLEN (Val);
197 197 ObjDesc->String.Pointer = Val;
198 198 ObjDesc->Common.Flags |= AOPOBJ_STATIC_POINTER;
199 199 break;
200 200
201 -
202 201 case ACPI_TYPE_MUTEX:
203 202
204 203 ObjDesc->Mutex.Node = NewNode;
205 204 ObjDesc->Mutex.SyncLevel = (UINT8) (ACPI_TO_INTEGER (Val) - 1);
206 205
207 206 /* Create a mutex */
208 207
209 208 Status = AcpiOsCreateMutex (&ObjDesc->Mutex.OsMutex);
210 209 if (ACPI_FAILURE (Status))
211 210 {
212 211 AcpiUtRemoveReference (ObjDesc);
213 212 goto UnlockAndExit;
214 213 }
215 214
216 215 /* Special case for ACPI Global Lock */
217 216
218 217 if (ACPI_STRCMP (InitVal->Name, "_GL_") == 0)
219 218 {
220 219 AcpiGbl_GlobalLockMutex = ObjDesc;
221 220
222 221 /* Create additional counting semaphore for global lock */
223 222
↓ open down ↓ |
12 lines elided |
↑ open up ↑ |
224 223 Status = AcpiOsCreateSemaphore (
225 224 1, 0, &AcpiGbl_GlobalLockSemaphore);
226 225 if (ACPI_FAILURE (Status))
227 226 {
228 227 AcpiUtRemoveReference (ObjDesc);
229 228 goto UnlockAndExit;
230 229 }
231 230 }
232 231 break;
233 232
234 -
235 233 default:
236 234
237 235 ACPI_ERROR ((AE_INFO, "Unsupported initial type value 0x%X",
238 236 InitVal->Type));
239 237 AcpiUtRemoveReference (ObjDesc);
240 238 ObjDesc = NULL;
241 239 continue;
242 240 }
243 241
244 242 /* Store pointer to value descriptor in the Node */
245 243
246 244 Status = AcpiNsAttachObject (NewNode, ObjDesc,
247 245 ObjDesc->Common.Type);
248 246
249 247 /* Remove local reference to the object */
250 248
251 249 AcpiUtRemoveReference (ObjDesc);
252 250 }
253 251 }
254 252
255 253
256 254 UnlockAndExit:
257 255 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
258 256
259 257 /* Save a handle to "_GPE", it is always present */
260 258
261 259 if (ACPI_SUCCESS (Status))
262 260 {
263 261 Status = AcpiNsGetNode (NULL, "\\_GPE", ACPI_NS_NO_UPSEARCH,
264 262 &AcpiGbl_FadtGpeDevice);
265 263 }
266 264
267 265 return_ACPI_STATUS (Status);
268 266 }
269 267
270 268
271 269 /*******************************************************************************
272 270 *
273 271 * FUNCTION: AcpiNsLookup
274 272 *
275 273 * PARAMETERS: ScopeInfo - Current scope info block
276 274 * Pathname - Search pathname, in internal format
277 275 * (as represented in the AML stream)
278 276 * Type - Type associated with name
279 277 * InterpreterMode - IMODE_LOAD_PASS2 => add name if not found
280 278 * Flags - Flags describing the search restrictions
281 279 * WalkState - Current state of the walk
282 280 * ReturnNode - Where the Node is placed (if found
283 281 * or created successfully)
284 282 *
285 283 * RETURN: Status
286 284 *
287 285 * DESCRIPTION: Find or enter the passed name in the name space.
288 286 * Log an error if name not found in Exec mode.
289 287 *
290 288 * MUTEX: Assumes namespace is locked.
291 289 *
292 290 ******************************************************************************/
293 291
294 292 ACPI_STATUS
295 293 AcpiNsLookup (
296 294 ACPI_GENERIC_STATE *ScopeInfo,
297 295 char *Pathname,
298 296 ACPI_OBJECT_TYPE Type,
299 297 ACPI_INTERPRETER_MODE InterpreterMode,
300 298 UINT32 Flags,
301 299 ACPI_WALK_STATE *WalkState,
302 300 ACPI_NAMESPACE_NODE **ReturnNode)
303 301 {
304 302 ACPI_STATUS Status;
305 303 char *Path = Pathname;
306 304 ACPI_NAMESPACE_NODE *PrefixNode;
307 305 ACPI_NAMESPACE_NODE *CurrentNode = NULL;
308 306 ACPI_NAMESPACE_NODE *ThisNode = NULL;
309 307 UINT32 NumSegments;
310 308 UINT32 NumCarats;
311 309 ACPI_NAME SimpleName;
312 310 ACPI_OBJECT_TYPE TypeToCheckFor;
313 311 ACPI_OBJECT_TYPE ThisSearchType;
314 312 UINT32 SearchParentFlag = ACPI_NS_SEARCH_PARENT;
315 313 UINT32 LocalFlags;
316 314
317 315
318 316 ACPI_FUNCTION_TRACE (NsLookup);
319 317
320 318
321 319 if (!ReturnNode)
322 320 {
323 321 return_ACPI_STATUS (AE_BAD_PARAMETER);
324 322 }
325 323
326 324 LocalFlags = Flags & ~(ACPI_NS_ERROR_IF_FOUND | ACPI_NS_SEARCH_PARENT);
327 325 *ReturnNode = ACPI_ENTRY_NOT_FOUND;
328 326 AcpiGbl_NsLookupCount++;
329 327
330 328 if (!AcpiGbl_RootNode)
331 329 {
332 330 return_ACPI_STATUS (AE_NO_NAMESPACE);
333 331 }
334 332
335 333 /* Get the prefix scope. A null scope means use the root scope */
336 334
337 335 if ((!ScopeInfo) ||
338 336 (!ScopeInfo->Scope.Node))
339 337 {
340 338 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
341 339 "Null scope prefix, using root node (%p)\n",
342 340 AcpiGbl_RootNode));
343 341
344 342 PrefixNode = AcpiGbl_RootNode;
345 343 }
346 344 else
347 345 {
348 346 PrefixNode = ScopeInfo->Scope.Node;
349 347 if (ACPI_GET_DESCRIPTOR_TYPE (PrefixNode) != ACPI_DESC_TYPE_NAMED)
350 348 {
351 349 ACPI_ERROR ((AE_INFO, "%p is not a namespace node [%s]",
352 350 PrefixNode, AcpiUtGetDescriptorName (PrefixNode)));
353 351 return_ACPI_STATUS (AE_AML_INTERNAL);
354 352 }
355 353
356 354 if (!(Flags & ACPI_NS_PREFIX_IS_SCOPE))
357 355 {
358 356 /*
359 357 * This node might not be a actual "scope" node (such as a
360 358 * Device/Method, etc.) It could be a Package or other object
361 359 * node. Backup up the tree to find the containing scope node.
362 360 */
363 361 while (!AcpiNsOpensScope (PrefixNode->Type) &&
364 362 PrefixNode->Type != ACPI_TYPE_ANY)
365 363 {
366 364 PrefixNode = PrefixNode->Parent;
367 365 }
368 366 }
369 367 }
370 368
371 369 /* Save type. TBD: may be no longer necessary */
372 370
373 371 TypeToCheckFor = Type;
374 372
375 373 /*
376 374 * Begin examination of the actual pathname
377 375 */
378 376 if (!Pathname)
379 377 {
380 378 /* A Null NamePath is allowed and refers to the root */
381 379
382 380 NumSegments = 0;
383 381 ThisNode = AcpiGbl_RootNode;
384 382 Path = "";
385 383
386 384 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
387 385 "Null Pathname (Zero segments), Flags=%X\n", Flags));
388 386 }
389 387 else
390 388 {
391 389 /*
392 390 * Name pointer is valid (and must be in internal name format)
393 391 *
394 392 * Check for scope prefixes:
395 393 *
396 394 * As represented in the AML stream, a namepath consists of an
397 395 * optional scope prefix followed by a name segment part.
398 396 *
399 397 * If present, the scope prefix is either a Root Prefix (in
400 398 * which case the name is fully qualified), or one or more
401 399 * Parent Prefixes (in which case the name's scope is relative
402 400 * to the current scope).
403 401 */
404 402 if (*Path == (UINT8) AML_ROOT_PREFIX)
405 403 {
406 404 /* Pathname is fully qualified, start from the root */
407 405
408 406 ThisNode = AcpiGbl_RootNode;
409 407 SearchParentFlag = ACPI_NS_NO_UPSEARCH;
410 408
411 409 /* Point to name segment part */
412 410
413 411 Path++;
414 412
415 413 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
416 414 "Path is absolute from root [%p]\n", ThisNode));
417 415 }
418 416 else
419 417 {
420 418 /* Pathname is relative to current scope, start there */
421 419
422 420 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
423 421 "Searching relative to prefix scope [%4.4s] (%p)\n",
424 422 AcpiUtGetNodeName (PrefixNode), PrefixNode));
425 423
426 424 /*
427 425 * Handle multiple Parent Prefixes (carat) by just getting
428 426 * the parent node for each prefix instance.
429 427 */
430 428 ThisNode = PrefixNode;
431 429 NumCarats = 0;
432 430 while (*Path == (UINT8) AML_PARENT_PREFIX)
433 431 {
434 432 /* Name is fully qualified, no search rules apply */
435 433
436 434 SearchParentFlag = ACPI_NS_NO_UPSEARCH;
437 435
438 436 /*
439 437 * Point past this prefix to the name segment
440 438 * part or the next Parent Prefix
441 439 */
442 440 Path++;
↓ open down ↓ |
198 lines elided |
↑ open up ↑ |
443 441
444 442 /* Backup to the parent node */
445 443
446 444 NumCarats++;
447 445 ThisNode = ThisNode->Parent;
448 446 if (!ThisNode)
449 447 {
450 448 /* Current scope has no parent scope */
451 449
452 450 ACPI_ERROR ((AE_INFO,
453 - "ACPI path has too many parent prefixes (^) "
454 - "- reached beyond root node"));
451 + "%s: Path has too many parent prefixes (^) "
452 + "- reached beyond root node", Pathname));
455 453 return_ACPI_STATUS (AE_NOT_FOUND);
456 454 }
457 455 }
458 456
459 457 if (SearchParentFlag == ACPI_NS_NO_UPSEARCH)
460 458 {
461 459 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
462 460 "Search scope is [%4.4s], path has %u carat(s)\n",
463 461 AcpiUtGetNodeName (ThisNode), NumCarats));
464 462 }
465 463 }
466 464
467 465 /*
468 466 * Determine the number of ACPI name segments in this pathname.
469 467 *
470 468 * The segment part consists of either:
471 469 * - A Null name segment (0)
472 470 * - A DualNamePrefix followed by two 4-byte name segments
473 471 * - A MultiNamePrefix followed by a byte indicating the
474 472 * number of segments and the segments themselves.
475 473 * - A single 4-byte name segment
476 474 *
477 475 * Examine the name prefix opcode, if any, to determine the number of
478 476 * segments.
479 477 */
480 478 switch (*Path)
481 479 {
482 480 case 0:
483 481 /*
484 482 * Null name after a root or parent prefixes. We already
485 483 * have the correct target node and there are no name segments.
486 484 */
487 485 NumSegments = 0;
488 486 Type = ThisNode->Type;
489 487
490 488 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
491 489 "Prefix-only Pathname (Zero name segments), Flags=%X\n",
492 490 Flags));
493 491 break;
494 492
495 493 case AML_DUAL_NAME_PREFIX:
496 494
497 495 /* More than one NameSeg, search rules do not apply */
498 496
499 497 SearchParentFlag = ACPI_NS_NO_UPSEARCH;
500 498
501 499 /* Two segments, point to first name segment */
502 500
503 501 NumSegments = 2;
504 502 Path++;
505 503
506 504 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
507 505 "Dual Pathname (2 segments, Flags=%X)\n", Flags));
508 506 break;
509 507
510 508 case AML_MULTI_NAME_PREFIX_OP:
511 509
512 510 /* More than one NameSeg, search rules do not apply */
513 511
514 512 SearchParentFlag = ACPI_NS_NO_UPSEARCH;
515 513
516 514 /* Extract segment count, point to first name segment */
517 515
518 516 Path++;
519 517 NumSegments = (UINT32) (UINT8) *Path;
520 518 Path++;
521 519
522 520 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
523 521 "Multi Pathname (%u Segments, Flags=%X)\n",
524 522 NumSegments, Flags));
525 523 break;
526 524
527 525 default:
528 526 /*
529 527 * Not a Null name, no Dual or Multi prefix, hence there is
530 528 * only one name segment and Pathname is already pointing to it.
531 529 */
532 530 NumSegments = 1;
533 531
534 532 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
535 533 "Simple Pathname (1 segment, Flags=%X)\n", Flags));
536 534 break;
537 535 }
538 536
539 537 ACPI_DEBUG_EXEC (AcpiNsPrintPathname (NumSegments, Path));
540 538 }
541 539
542 540
543 541 /*
544 542 * Search namespace for each segment of the name. Loop through and
545 543 * verify (or add to the namespace) each name segment.
546 544 *
547 545 * The object type is significant only at the last name
548 546 * segment. (We don't care about the types along the path, only
549 547 * the type of the final target object.)
550 548 */
551 549 ThisSearchType = ACPI_TYPE_ANY;
552 550 CurrentNode = ThisNode;
553 551 while (NumSegments && CurrentNode)
554 552 {
555 553 NumSegments--;
556 554 if (!NumSegments)
557 555 {
558 556 /* This is the last segment, enable typechecking */
559 557
560 558 ThisSearchType = Type;
561 559
562 560 /*
563 561 * Only allow automatic parent search (search rules) if the caller
564 562 * requested it AND we have a single, non-fully-qualified NameSeg
565 563 */
566 564 if ((SearchParentFlag != ACPI_NS_NO_UPSEARCH) &&
567 565 (Flags & ACPI_NS_SEARCH_PARENT))
568 566 {
569 567 LocalFlags |= ACPI_NS_SEARCH_PARENT;
570 568 }
571 569
572 570 /* Set error flag according to caller */
573 571
574 572 if (Flags & ACPI_NS_ERROR_IF_FOUND)
575 573 {
576 574 LocalFlags |= ACPI_NS_ERROR_IF_FOUND;
577 575 }
578 576 }
579 577
580 578 /* Extract one ACPI name from the front of the pathname */
581 579
582 580 ACPI_MOVE_32_TO_32 (&SimpleName, Path);
583 581
584 582 /* Try to find the single (4 character) ACPI name */
585 583
586 584 Status = AcpiNsSearchAndEnter (SimpleName, WalkState, CurrentNode,
587 585 InterpreterMode, ThisSearchType, LocalFlags, &ThisNode);
588 586 if (ACPI_FAILURE (Status))
589 587 {
590 588 if (Status == AE_NOT_FOUND)
591 589 {
592 590 /* Name not found in ACPI namespace */
593 591
594 592 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
595 593 "Name [%4.4s] not found in scope [%4.4s] %p\n",
596 594 (char *) &SimpleName, (char *) &CurrentNode->Name,
597 595 CurrentNode));
598 596 }
599 597
600 598 *ReturnNode = ThisNode;
601 599 return_ACPI_STATUS (Status);
602 600 }
603 601
604 602 /* More segments to follow? */
605 603
606 604 if (NumSegments > 0)
607 605 {
608 606 /*
609 607 * If we have an alias to an object that opens a scope (such as a
610 608 * device or processor), we need to dereference the alias here so
611 609 * that we can access any children of the original node (via the
612 610 * remaining segments).
613 611 */
614 612 if (ThisNode->Type == ACPI_TYPE_LOCAL_ALIAS)
615 613 {
616 614 if (!ThisNode->Object)
617 615 {
618 616 return_ACPI_STATUS (AE_NOT_EXIST);
619 617 }
620 618
621 619 if (AcpiNsOpensScope (((ACPI_NAMESPACE_NODE *)
622 620 ThisNode->Object)->Type))
623 621 {
624 622 ThisNode = (ACPI_NAMESPACE_NODE *) ThisNode->Object;
625 623 }
626 624 }
627 625 }
628 626
629 627 /* Special handling for the last segment (NumSegments == 0) */
630 628
631 629 else
632 630 {
633 631 /*
634 632 * Sanity typecheck of the target object:
635 633 *
636 634 * If 1) This is the last segment (NumSegments == 0)
637 635 * 2) And we are looking for a specific type
638 636 * (Not checking for TYPE_ANY)
639 637 * 3) Which is not an alias
640 638 * 4) Which is not a local type (TYPE_SCOPE)
641 639 * 5) And the type of target object is known (not TYPE_ANY)
642 640 * 6) And target object does not match what we are looking for
643 641 *
644 642 * Then we have a type mismatch. Just warn and ignore it.
645 643 */
646 644 if ((TypeToCheckFor != ACPI_TYPE_ANY) &&
647 645 (TypeToCheckFor != ACPI_TYPE_LOCAL_ALIAS) &&
648 646 (TypeToCheckFor != ACPI_TYPE_LOCAL_METHOD_ALIAS) &&
649 647 (TypeToCheckFor != ACPI_TYPE_LOCAL_SCOPE) &&
650 648 (ThisNode->Type != ACPI_TYPE_ANY) &&
651 649 (ThisNode->Type != TypeToCheckFor))
652 650 {
653 651 /* Complain about a type mismatch */
654 652
655 653 ACPI_WARNING ((AE_INFO,
656 654 "NsLookup: Type mismatch on %4.4s (%s), searching for (%s)",
657 655 ACPI_CAST_PTR (char, &SimpleName),
658 656 AcpiUtGetTypeName (ThisNode->Type),
659 657 AcpiUtGetTypeName (TypeToCheckFor)));
660 658 }
661 659
662 660 /*
663 661 * If this is the last name segment and we are not looking for a
664 662 * specific type, but the type of found object is known, use that
665 663 * type to (later) see if it opens a scope.
666 664 */
667 665 if (Type == ACPI_TYPE_ANY)
668 666 {
669 667 Type = ThisNode->Type;
670 668 }
671 669 }
672 670
673 671 /* Point to next name segment and make this node current */
674 672
675 673 Path += ACPI_NAME_SIZE;
676 674 CurrentNode = ThisNode;
677 675 }
678 676
679 677 /* Always check if we need to open a new scope */
680 678
681 679 if (!(Flags & ACPI_NS_DONT_OPEN_SCOPE) && (WalkState))
682 680 {
683 681 /*
684 682 * If entry is a type which opens a scope, push the new scope on the
685 683 * scope stack.
686 684 */
687 685 if (AcpiNsOpensScope (Type))
688 686 {
689 687 Status = AcpiDsScopeStackPush (ThisNode, Type, WalkState);
↓ open down ↓ |
225 lines elided |
↑ open up ↑ |
690 688 if (ACPI_FAILURE (Status))
691 689 {
692 690 return_ACPI_STATUS (Status);
693 691 }
694 692 }
695 693 }
696 694
697 695 *ReturnNode = ThisNode;
698 696 return_ACPI_STATUS (AE_OK);
699 697 }
700 -
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX