Print this page
update to acpica-unix2-20131115
acpica-unix2-20130823
PANKOVs restructure
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/intel/io/acpica/namespace/nsutils.c
+++ new/usr/src/common/acpica/components/namespace/nsutils.c
1 1 /******************************************************************************
2 2 *
3 3 * Module Name: nsutils - Utilities for accessing ACPI namespace, accessing
4 4 * parents and siblings and Scope manipulation
5 5 *
6 6 *****************************************************************************/
7 7
8 8 /*
9 - * Copyright (C) 2000 - 2011, Intel Corp.
9 + * Copyright (C) 2000 - 2013, Intel Corp.
10 10 * All rights reserved.
11 11 *
12 12 * Redistribution and use in source and binary forms, with or without
13 13 * modification, are permitted provided that the following conditions
14 14 * are met:
15 15 * 1. Redistributions of source code must retain the above copyright
16 16 * notice, this list of conditions, and the following disclaimer,
17 17 * without modification.
18 18 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 19 * substantially similar to the "NO WARRANTY" disclaimer below
20 20 * ("Disclaimer") and any redistribution must be conditioned upon
21 21 * including a substantially similar Disclaimer requirement for further
22 22 * binary redistribution.
23 23 * 3. Neither the names of the above-listed copyright holders nor the names
24 24 * of any contributors may be used to endorse or promote products derived
25 25 * from this software without specific prior written permission.
26 26 *
27 27 * Alternatively, this software may be distributed under the terms of the
28 28 * GNU General Public License ("GPL") version 2 as published by the Free
29 29 * Software Foundation.
30 30 *
31 31 * NO WARRANTY
32 32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 33 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 35 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 36 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 41 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 42 * POSSIBILITY OF SUCH DAMAGES.
43 43 */
44 44
45 45 #define __NSUTILS_C__
46 46
↓ open down ↓ |
27 lines elided |
↑ open up ↑ |
47 47 #include "acpi.h"
48 48 #include "accommon.h"
49 49 #include "acnamesp.h"
50 50 #include "amlcode.h"
51 51
52 52 #define _COMPONENT ACPI_NAMESPACE
53 53 ACPI_MODULE_NAME ("nsutils")
54 54
55 55 /* Local prototypes */
56 56
57 -static BOOLEAN
58 -AcpiNsValidPathSeparator (
59 - char Sep);
60 -
61 57 #ifdef ACPI_OBSOLETE_FUNCTIONS
62 58 ACPI_NAME
63 59 AcpiNsFindParentName (
64 60 ACPI_NAMESPACE_NODE *NodeToSearch);
65 61 #endif
66 62
67 63
68 64 /*******************************************************************************
69 65 *
70 66 * FUNCTION: AcpiNsPrintNodePathname
71 67 *
72 68 * PARAMETERS: Node - Object
73 69 * Message - Prefix message
74 70 *
75 71 * DESCRIPTION: Print an object's full namespace pathname
76 72 * Manages allocation/freeing of a pathname buffer
77 73 *
78 74 ******************************************************************************/
79 75
80 76 void
81 77 AcpiNsPrintNodePathname (
82 78 ACPI_NAMESPACE_NODE *Node,
83 79 const char *Message)
84 80 {
85 81 ACPI_BUFFER Buffer;
86 82 ACPI_STATUS Status;
87 83
88 84
89 85 if (!Node)
90 86 {
91 87 AcpiOsPrintf ("[NULL NAME]");
92 88 return;
93 89 }
94 90
95 91 /* Convert handle to full pathname and print it (with supplied message) */
96 92
97 93 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
98 94
99 95 Status = AcpiNsHandleToPathname (Node, &Buffer);
100 96 if (ACPI_SUCCESS (Status))
101 97 {
102 98 if (Message)
103 99 {
104 100 AcpiOsPrintf ("%s ", Message);
↓ open down ↓ |
34 lines elided |
↑ open up ↑ |
105 101 }
106 102
107 103 AcpiOsPrintf ("[%s] (Node %p)", (char *) Buffer.Pointer, Node);
108 104 ACPI_FREE (Buffer.Pointer);
109 105 }
110 106 }
111 107
112 108
113 109 /*******************************************************************************
114 110 *
115 - * FUNCTION: AcpiNsValidRootPrefix
116 - *
117 - * PARAMETERS: Prefix - Character to be checked
118 - *
119 - * RETURN: TRUE if a valid prefix
120 - *
121 - * DESCRIPTION: Check if a character is a valid ACPI Root prefix
122 - *
123 - ******************************************************************************/
124 -
125 -BOOLEAN
126 -AcpiNsValidRootPrefix (
127 - char Prefix)
128 -{
129 -
130 - return ((BOOLEAN) (Prefix == '\\'));
131 -}
132 -
133 -
134 -/*******************************************************************************
135 - *
136 - * FUNCTION: AcpiNsValidPathSeparator
137 - *
138 - * PARAMETERS: Sep - Character to be checked
139 - *
140 - * RETURN: TRUE if a valid path separator
141 - *
142 - * DESCRIPTION: Check if a character is a valid ACPI path separator
143 - *
144 - ******************************************************************************/
145 -
146 -static BOOLEAN
147 -AcpiNsValidPathSeparator (
148 - char Sep)
149 -{
150 -
151 - return ((BOOLEAN) (Sep == '.'));
152 -}
153 -
154 -
155 -/*******************************************************************************
156 - *
157 111 * FUNCTION: AcpiNsGetType
158 112 *
159 113 * PARAMETERS: Node - Parent Node to be examined
160 114 *
161 115 * RETURN: Type field from Node whose handle is passed
162 116 *
163 117 * DESCRIPTION: Return the type of a Namespace node
164 118 *
165 119 ******************************************************************************/
166 120
167 121 ACPI_OBJECT_TYPE
168 122 AcpiNsGetType (
169 123 ACPI_NAMESPACE_NODE *Node)
170 124 {
171 125 ACPI_FUNCTION_TRACE (NsGetType);
172 126
173 127
174 128 if (!Node)
175 129 {
176 130 ACPI_WARNING ((AE_INFO, "Null Node parameter"));
177 - return_UINT32 (ACPI_TYPE_ANY);
131 + return_UINT8 (ACPI_TYPE_ANY);
178 132 }
179 133
180 - return_UINT32 ((ACPI_OBJECT_TYPE) Node->Type);
134 + return_UINT8 (Node->Type);
181 135 }
182 136
183 137
184 138 /*******************************************************************************
185 139 *
186 140 * FUNCTION: AcpiNsLocal
187 141 *
188 142 * PARAMETERS: Type - A namespace object type
189 143 *
190 144 * RETURN: LOCAL if names must be found locally in objects of the
191 145 * passed type, 0 if enclosing scopes should be searched
192 146 *
193 147 * DESCRIPTION: Returns scope rule for the given object type.
194 148 *
195 149 ******************************************************************************/
196 150
197 151 UINT32
198 152 AcpiNsLocal (
199 153 ACPI_OBJECT_TYPE Type)
200 154 {
201 155 ACPI_FUNCTION_TRACE (NsLocal);
↓ open down ↓ |
11 lines elided |
↑ open up ↑ |
202 156
203 157
204 158 if (!AcpiUtValidObjectType (Type))
205 159 {
206 160 /* Type code out of range */
207 161
208 162 ACPI_WARNING ((AE_INFO, "Invalid Object Type 0x%X", Type));
209 163 return_UINT32 (ACPI_NS_NORMAL);
210 164 }
211 165
212 - return_UINT32 ((UINT32) AcpiGbl_NsProperties[Type] & ACPI_NS_LOCAL);
166 + return_UINT32 (AcpiGbl_NsProperties[Type] & ACPI_NS_LOCAL);
213 167 }
214 168
215 169
216 170 /*******************************************************************************
217 171 *
218 172 * FUNCTION: AcpiNsGetInternalNameLength
219 173 *
220 174 * PARAMETERS: Info - Info struct initialized with the
221 175 * external name pointer.
222 176 *
223 177 * RETURN: None
224 178 *
225 179 * DESCRIPTION: Calculate the length of the internal (AML) namestring
226 180 * corresponding to the external (ASL) namestring.
227 181 *
228 182 ******************************************************************************/
229 183
230 184 void
231 185 AcpiNsGetInternalNameLength (
232 186 ACPI_NAMESTRING_INFO *Info)
233 187 {
234 188 const char *NextExternalChar;
235 189 UINT32 i;
236 190
237 191
238 192 ACPI_FUNCTION_ENTRY ();
239 193
240 194
241 195 NextExternalChar = Info->ExternalName;
242 196 Info->NumCarats = 0;
↓ open down ↓ |
20 lines elided |
↑ open up ↑ |
243 197 Info->NumSegments = 0;
244 198 Info->FullyQualified = FALSE;
245 199
246 200 /*
247 201 * For the internal name, the required length is 4 bytes per segment, plus
248 202 * 1 each for RootPrefix, MultiNamePrefixOp, segment count, trailing null
249 203 * (which is not really needed, but no there's harm in putting it there)
250 204 *
251 205 * strlen() + 1 covers the first NameSeg, which has no path separator
252 206 */
253 - if (AcpiNsValidRootPrefix (*NextExternalChar))
207 + if (ACPI_IS_ROOT_PREFIX (*NextExternalChar))
254 208 {
255 209 Info->FullyQualified = TRUE;
256 210 NextExternalChar++;
257 211
258 212 /* Skip redundant RootPrefix, like \\_SB.PCI0.SBRG.EC0 */
259 213
260 - while (AcpiNsValidRootPrefix (*NextExternalChar))
214 + while (ACPI_IS_ROOT_PREFIX (*NextExternalChar))
261 215 {
262 216 NextExternalChar++;
263 217 }
264 218 }
265 219 else
266 220 {
267 221 /* Handle Carat prefixes */
268 222
269 - while (*NextExternalChar == '^')
223 + while (ACPI_IS_PARENT_PREFIX (*NextExternalChar))
270 224 {
271 225 Info->NumCarats++;
272 226 NextExternalChar++;
273 227 }
274 228 }
275 229
276 230 /*
277 231 * Determine the number of ACPI name "segments" by counting the number of
278 232 * path separators within the string. Start with one segment since the
279 233 * segment count is [(# separators) + 1], and zero separators is ok.
280 234 */
281 235 if (*NextExternalChar)
282 236 {
283 237 Info->NumSegments = 1;
284 238 for (i = 0; NextExternalChar[i]; i++)
285 239 {
286 - if (AcpiNsValidPathSeparator (NextExternalChar[i]))
240 + if (ACPI_IS_PATH_SEPARATOR (NextExternalChar[i]))
287 241 {
288 242 Info->NumSegments++;
289 243 }
290 244 }
291 245 }
292 246
293 247 Info->Length = (ACPI_NAME_SIZE * Info->NumSegments) +
294 248 4 + Info->NumCarats;
295 249
296 250 Info->NextExternalChar = NextExternalChar;
297 251 }
298 252
299 253
300 254 /*******************************************************************************
301 255 *
302 256 * FUNCTION: AcpiNsBuildInternalName
303 257 *
304 258 * PARAMETERS: Info - Info struct fully initialized
305 259 *
306 260 * RETURN: Status
307 261 *
308 262 * DESCRIPTION: Construct the internal (AML) namestring
309 263 * corresponding to the external (ASL) namestring.
310 264 *
311 265 ******************************************************************************/
312 266
313 267 ACPI_STATUS
314 268 AcpiNsBuildInternalName (
315 269 ACPI_NAMESTRING_INFO *Info)
316 270 {
317 271 UINT32 NumSegments = Info->NumSegments;
318 272 char *InternalName = Info->InternalName;
319 273 const char *ExternalName = Info->NextExternalChar;
320 274 char *Result = NULL;
↓ open down ↓ |
24 lines elided |
↑ open up ↑ |
321 275 UINT32 i;
322 276
323 277
324 278 ACPI_FUNCTION_TRACE (NsBuildInternalName);
325 279
326 280
327 281 /* Setup the correct prefixes, counts, and pointers */
328 282
329 283 if (Info->FullyQualified)
330 284 {
331 - InternalName[0] = '\\';
285 + InternalName[0] = AML_ROOT_PREFIX;
332 286
333 287 if (NumSegments <= 1)
334 288 {
335 289 Result = &InternalName[1];
336 290 }
337 291 else if (NumSegments == 2)
338 292 {
339 293 InternalName[1] = AML_DUAL_NAME_PREFIX;
340 294 Result = &InternalName[2];
341 295 }
342 296 else
343 297 {
344 298 InternalName[1] = AML_MULTI_NAME_PREFIX_OP;
345 299 InternalName[2] = (char) NumSegments;
346 300 Result = &InternalName[3];
347 301 }
348 302 }
349 303 else
↓ open down ↓ |
8 lines elided |
↑ open up ↑ |
350 304 {
351 305 /*
352 306 * Not fully qualified.
353 307 * Handle Carats first, then append the name segments
354 308 */
355 309 i = 0;
356 310 if (Info->NumCarats)
357 311 {
358 312 for (i = 0; i < Info->NumCarats; i++)
359 313 {
360 - InternalName[i] = '^';
314 + InternalName[i] = AML_PARENT_PREFIX;
361 315 }
362 316 }
363 317
364 318 if (NumSegments <= 1)
365 319 {
366 320 Result = &InternalName[i];
367 321 }
368 322 else if (NumSegments == 2)
369 323 {
370 324 InternalName[i] = AML_DUAL_NAME_PREFIX;
371 325 Result = &InternalName[(ACPI_SIZE) i+1];
372 326 }
373 327 else
374 328 {
375 329 InternalName[i] = AML_MULTI_NAME_PREFIX_OP;
376 330 InternalName[(ACPI_SIZE) i+1] = (char) NumSegments;
↓ open down ↓ |
6 lines elided |
↑ open up ↑ |
377 331 Result = &InternalName[(ACPI_SIZE) i+2];
378 332 }
379 333 }
380 334
381 335 /* Build the name (minus path separators) */
382 336
383 337 for (; NumSegments; NumSegments--)
384 338 {
385 339 for (i = 0; i < ACPI_NAME_SIZE; i++)
386 340 {
387 - if (AcpiNsValidPathSeparator (*ExternalName) ||
341 + if (ACPI_IS_PATH_SEPARATOR (*ExternalName) ||
388 342 (*ExternalName == 0))
389 343 {
390 344 /* Pad the segment with underscore(s) if segment is short */
391 345
392 346 Result[i] = '_';
393 347 }
394 348 else
395 349 {
396 350 /* Convert the character to uppercase and save it */
397 351
398 352 Result[i] = (char) ACPI_TOUPPER ((int) *ExternalName);
399 353 ExternalName++;
400 354 }
401 355 }
402 356
403 357 /* Now we must have a path separator, or the pathname is bad */
404 358
405 - if (!AcpiNsValidPathSeparator (*ExternalName) &&
359 + if (!ACPI_IS_PATH_SEPARATOR (*ExternalName) &&
406 360 (*ExternalName != 0))
407 361 {
408 - return_ACPI_STATUS (AE_BAD_PARAMETER);
362 + return_ACPI_STATUS (AE_BAD_PATHNAME);
409 363 }
410 364
411 365 /* Move on the next segment */
412 366
413 367 ExternalName++;
414 368 Result += ACPI_NAME_SIZE;
415 369 }
416 370
417 371 /* Terminate the string */
418 372
419 373 *Result = 0;
420 374
421 375 if (Info->FullyQualified)
422 376 {
423 377 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Returning [%p] (abs) \"\\%s\"\n",
424 378 InternalName, InternalName));
425 379 }
426 380 else
427 381 {
428 382 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Returning [%p] (rel) \"%s\"\n",
429 383 InternalName, InternalName));
430 384 }
431 385
432 386 return_ACPI_STATUS (AE_OK);
433 387 }
434 388
435 389
436 390 /*******************************************************************************
437 391 *
438 392 * FUNCTION: AcpiNsInternalizeName
439 393 *
440 394 * PARAMETERS: *ExternalName - External representation of name
441 395 * **Converted Name - Where to return the resulting
442 396 * internal represention of the name
443 397 *
444 398 * RETURN: Status
445 399 *
446 400 * DESCRIPTION: Convert an external representation (e.g. "\_PR_.CPU0")
447 401 * to internal form (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30)
448 402 *
449 403 *******************************************************************************/
450 404
451 405 ACPI_STATUS
452 406 AcpiNsInternalizeName (
453 407 const char *ExternalName,
454 408 char **ConvertedName)
455 409 {
456 410 char *InternalName;
457 411 ACPI_NAMESTRING_INFO Info;
458 412 ACPI_STATUS Status;
459 413
460 414
461 415 ACPI_FUNCTION_TRACE (NsInternalizeName);
462 416
463 417
464 418 if ((!ExternalName) ||
465 419 (*ExternalName == 0) ||
466 420 (!ConvertedName))
467 421 {
468 422 return_ACPI_STATUS (AE_BAD_PARAMETER);
469 423 }
470 424
471 425 /* Get the length of the new internal name */
472 426
473 427 Info.ExternalName = ExternalName;
474 428 AcpiNsGetInternalNameLength (&Info);
475 429
476 430 /* We need a segment to store the internal name */
477 431
478 432 InternalName = ACPI_ALLOCATE_ZEROED (Info.Length);
479 433 if (!InternalName)
480 434 {
481 435 return_ACPI_STATUS (AE_NO_MEMORY);
482 436 }
483 437
484 438 /* Build the name */
485 439
486 440 Info.InternalName = InternalName;
487 441 Status = AcpiNsBuildInternalName (&Info);
488 442 if (ACPI_FAILURE (Status))
489 443 {
490 444 ACPI_FREE (InternalName);
491 445 return_ACPI_STATUS (Status);
492 446 }
493 447
494 448 *ConvertedName = InternalName;
495 449 return_ACPI_STATUS (AE_OK);
496 450 }
497 451
498 452
499 453 /*******************************************************************************
500 454 *
501 455 * FUNCTION: AcpiNsExternalizeName
502 456 *
503 457 * PARAMETERS: InternalNameLength - Lenth of the internal name below
504 458 * InternalName - Internal representation of name
505 459 * ConvertedNameLength - Where the length is returned
506 460 * ConvertedName - Where the resulting external name
507 461 * is returned
508 462 *
509 463 * RETURN: Status
510 464 *
511 465 * DESCRIPTION: Convert internal name (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30)
512 466 * to its external (printable) form (e.g. "\_PR_.CPU0")
513 467 *
514 468 ******************************************************************************/
515 469
516 470 ACPI_STATUS
517 471 AcpiNsExternalizeName (
518 472 UINT32 InternalNameLength,
519 473 const char *InternalName,
520 474 UINT32 *ConvertedNameLength,
521 475 char **ConvertedName)
522 476 {
523 477 UINT32 NamesIndex = 0;
524 478 UINT32 NumSegments = 0;
525 479 UINT32 RequiredLength;
526 480 UINT32 PrefixLength = 0;
527 481 UINT32 i = 0;
528 482 UINT32 j = 0;
529 483
530 484
531 485 ACPI_FUNCTION_TRACE (NsExternalizeName);
532 486
533 487
534 488 if (!InternalNameLength ||
↓ open down ↓ |
116 lines elided |
↑ open up ↑ |
535 489 !InternalName ||
536 490 !ConvertedName)
537 491 {
538 492 return_ACPI_STATUS (AE_BAD_PARAMETER);
539 493 }
540 494
541 495 /* Check for a prefix (one '\' | one or more '^') */
542 496
543 497 switch (InternalName[0])
544 498 {
545 - case '\\':
499 + case AML_ROOT_PREFIX:
500 +
546 501 PrefixLength = 1;
547 502 break;
548 503
549 - case '^':
504 + case AML_PARENT_PREFIX:
505 +
550 506 for (i = 0; i < InternalNameLength; i++)
551 507 {
552 - if (InternalName[i] == '^')
508 + if (ACPI_IS_PARENT_PREFIX (InternalName[i]))
553 509 {
554 510 PrefixLength = i + 1;
555 511 }
556 512 else
557 513 {
558 514 break;
559 515 }
560 516 }
561 517
562 518 if (i == InternalNameLength)
563 519 {
564 520 PrefixLength = i;
565 521 }
566 522
567 523 break;
568 524
569 525 default:
526 +
570 527 break;
571 528 }
572 529
573 530 /*
574 531 * Check for object names. Note that there could be 0-255 of these
575 532 * 4-byte elements.
576 533 */
577 534 if (PrefixLength < InternalNameLength)
578 535 {
579 536 switch (InternalName[PrefixLength])
580 537 {
581 538 case AML_MULTI_NAME_PREFIX_OP:
582 539
583 540 /* <count> 4-byte names */
584 541
585 542 NamesIndex = PrefixLength + 2;
586 543 NumSegments = (UINT8)
587 544 InternalName[(ACPI_SIZE) PrefixLength + 1];
588 545 break;
589 546
590 547 case AML_DUAL_NAME_PREFIX:
591 548
592 549 /* Two 4-byte names */
593 550
594 551 NamesIndex = PrefixLength + 1;
595 552 NumSegments = 2;
596 553 break;
597 554
598 555 case 0:
599 556
600 557 /* NullName */
601 558
602 559 NamesIndex = 0;
603 560 NumSegments = 0;
604 561 break;
605 562
606 563 default:
607 564
608 565 /* one 4-byte name */
609 566
610 567 NamesIndex = PrefixLength;
611 568 NumSegments = 1;
612 569 break;
613 570 }
614 571 }
↓ open down ↓ |
35 lines elided |
↑ open up ↑ |
615 572
616 573 /*
617 574 * Calculate the length of ConvertedName, which equals the length
618 575 * of the prefix, length of all object names, length of any required
619 576 * punctuation ('.') between object names, plus the NULL terminator.
620 577 */
621 578 RequiredLength = PrefixLength + (4 * NumSegments) +
622 579 ((NumSegments > 0) ? (NumSegments - 1) : 0) + 1;
623 580
624 581 /*
625 - * Check to see if we're still in bounds. If not, there's a problem
582 + * Check to see if we're still in bounds. If not, there's a problem
626 583 * with InternalName (invalid format).
627 584 */
628 585 if (RequiredLength > InternalNameLength)
629 586 {
630 587 ACPI_ERROR ((AE_INFO, "Invalid internal name"));
631 588 return_ACPI_STATUS (AE_BAD_PATHNAME);
632 589 }
633 590
634 591 /* Build the ConvertedName */
635 592
636 593 *ConvertedName = ACPI_ALLOCATE_ZEROED (RequiredLength);
637 594 if (!(*ConvertedName))
638 595 {
639 596 return_ACPI_STATUS (AE_NO_MEMORY);
640 597 }
641 598
642 599 j = 0;
643 600
644 601 for (i = 0; i < PrefixLength; i++)
645 602 {
646 603 (*ConvertedName)[j++] = InternalName[i];
647 604 }
↓ open down ↓ |
12 lines elided |
↑ open up ↑ |
648 605
649 606 if (NumSegments > 0)
650 607 {
651 608 for (i = 0; i < NumSegments; i++)
652 609 {
653 610 if (i > 0)
654 611 {
655 612 (*ConvertedName)[j++] = '.';
656 613 }
657 614
658 - (*ConvertedName)[j++] = InternalName[NamesIndex++];
659 - (*ConvertedName)[j++] = InternalName[NamesIndex++];
660 - (*ConvertedName)[j++] = InternalName[NamesIndex++];
661 - (*ConvertedName)[j++] = InternalName[NamesIndex++];
615 + /* Copy and validate the 4-char name segment */
616 +
617 + ACPI_MOVE_NAME (&(*ConvertedName)[j], &InternalName[NamesIndex]);
618 + AcpiUtRepairName (&(*ConvertedName)[j]);
619 +
620 + j += ACPI_NAME_SIZE;
621 + NamesIndex += ACPI_NAME_SIZE;
662 622 }
663 623 }
664 624
665 625 if (ConvertedNameLength)
666 626 {
667 627 *ConvertedNameLength = (UINT32) RequiredLength;
668 628 }
669 629
670 630 return_ACPI_STATUS (AE_OK);
671 631 }
672 632
673 633
674 634 /*******************************************************************************
675 635 *
676 636 * FUNCTION: AcpiNsValidateHandle
677 637 *
678 638 * PARAMETERS: Handle - Handle to be validated and typecast to a
679 639 * namespace node.
680 640 *
681 641 * RETURN: A pointer to a namespace node
682 642 *
683 643 * DESCRIPTION: Convert a namespace handle to a namespace node. Handles special
684 644 * cases for the root node.
685 645 *
686 646 * NOTE: Real integer handles would allow for more verification
687 647 * and keep all pointers within this subsystem - however this introduces
688 648 * more overhead and has not been necessary to this point. Drivers
689 649 * holding handles are typically notified before a node becomes invalid
690 650 * due to a table unload.
691 651 *
692 652 ******************************************************************************/
693 653
694 654 ACPI_NAMESPACE_NODE *
695 655 AcpiNsValidateHandle (
696 656 ACPI_HANDLE Handle)
697 657 {
698 658
699 659 ACPI_FUNCTION_ENTRY ();
700 660
701 661
702 662 /* Parameter validation */
703 663
704 664 if ((!Handle) || (Handle == ACPI_ROOT_OBJECT))
705 665 {
706 666 return (AcpiGbl_RootNode);
707 667 }
708 668
709 669 /* We can at least attempt to verify the handle */
710 670
711 671 if (ACPI_GET_DESCRIPTOR_TYPE (Handle) != ACPI_DESC_TYPE_NAMED)
712 672 {
713 673 return (NULL);
714 674 }
715 675
716 676 return (ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Handle));
717 677 }
718 678
719 679
720 680 /*******************************************************************************
721 681 *
722 682 * FUNCTION: AcpiNsTerminate
723 683 *
724 684 * PARAMETERS: none
725 685 *
↓ open down ↓ |
54 lines elided |
↑ open up ↑ |
726 686 * RETURN: none
727 687 *
728 688 * DESCRIPTION: free memory allocated for namespace and ACPI table storage.
729 689 *
730 690 ******************************************************************************/
731 691
732 692 void
733 693 AcpiNsTerminate (
734 694 void)
735 695 {
736 - ACPI_OPERAND_OBJECT *ObjDesc;
696 + ACPI_STATUS Status;
737 697
738 698
739 699 ACPI_FUNCTION_TRACE (NsTerminate);
740 700
741 701
742 702 /*
743 - * 1) Free the entire namespace -- all nodes and objects
744 - *
745 - * Delete all object descriptors attached to namepsace nodes
703 + * Free the entire namespace -- all nodes and all objects
704 + * attached to the nodes
746 705 */
747 706 AcpiNsDeleteNamespaceSubtree (AcpiGbl_RootNode);
748 707
749 - /* Detach any objects attached to the root */
708 + /* Delete any objects attached to the root node */
750 709
751 - ObjDesc = AcpiNsGetAttachedObject (AcpiGbl_RootNode);
752 - if (ObjDesc)
710 + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
711 + if (ACPI_FAILURE (Status))
753 712 {
754 - AcpiNsDetachObject (AcpiGbl_RootNode);
713 + return_VOID;
755 714 }
756 715
716 + AcpiNsDeleteNode (AcpiGbl_RootNode);
717 + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
718 +
757 719 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Namespace freed\n"));
758 720 return_VOID;
759 721 }
760 722
761 723
762 724 /*******************************************************************************
763 725 *
764 726 * FUNCTION: AcpiNsOpensScope
765 727 *
766 728 * PARAMETERS: Type - A valid namespace type
767 729 *
768 730 * RETURN: NEWSCOPE if the passed type "opens a name scope" according
769 731 * to the ACPI specification, else 0
770 732 *
771 733 ******************************************************************************/
772 734
773 735 UINT32
774 736 AcpiNsOpensScope (
775 737 ACPI_OBJECT_TYPE Type)
776 738 {
777 - ACPI_FUNCTION_TRACE_STR (NsOpensScope, AcpiUtGetTypeName (Type));
739 + ACPI_FUNCTION_ENTRY ();
778 740
779 741
780 - if (!AcpiUtValidObjectType (Type))
742 + if (Type > ACPI_TYPE_LOCAL_MAX)
781 743 {
782 744 /* type code out of range */
783 745
784 746 ACPI_WARNING ((AE_INFO, "Invalid Object Type 0x%X", Type));
785 - return_UINT32 (ACPI_NS_NORMAL);
747 + return (ACPI_NS_NORMAL);
786 748 }
787 749
788 - return_UINT32 (((UINT32) AcpiGbl_NsProperties[Type]) & ACPI_NS_NEWSCOPE);
750 + return (((UINT32) AcpiGbl_NsProperties[Type]) & ACPI_NS_NEWSCOPE);
789 751 }
790 752
791 753
792 754 /*******************************************************************************
793 755 *
794 756 * FUNCTION: AcpiNsGetNode
795 757 *
796 758 * PARAMETERS: *Pathname - Name to be found, in external (ASL) format. The
797 759 * \ (backslash) and ^ (carat) prefixes, and the
798 760 * . (period) to separate segments are supported.
799 761 * PrefixNode - Root of subtree to be searched, or NS_ALL for the
800 - * root of the name space. If Name is fully
762 + * root of the name space. If Name is fully
801 763 * qualified (first INT8 is '\'), the passed value
802 764 * of Scope will not be accessed.
803 765 * Flags - Used to indicate whether to perform upsearch or
804 766 * not.
805 767 * ReturnNode - Where the Node is returned
806 768 *
807 769 * DESCRIPTION: Look up a name relative to a given scope and return the
808 - * corresponding Node. NOTE: Scope can be null.
770 + * corresponding Node. NOTE: Scope can be null.
809 771 *
810 772 * MUTEX: Locks namespace
811 773 *
812 774 ******************************************************************************/
813 775
814 776 ACPI_STATUS
815 777 AcpiNsGetNode (
816 778 ACPI_NAMESPACE_NODE *PrefixNode,
817 779 const char *Pathname,
818 780 UINT32 Flags,
819 781 ACPI_NAMESPACE_NODE **ReturnNode)
820 782 {
821 783 ACPI_GENERIC_STATE ScopeInfo;
822 784 ACPI_STATUS Status;
823 785 char *InternalPath;
824 786
825 787
826 788 ACPI_FUNCTION_TRACE_PTR (NsGetNode, ACPI_CAST_PTR (char, Pathname));
827 789
828 790
791 + /* Simplest case is a null pathname */
792 +
829 793 if (!Pathname)
830 794 {
831 795 *ReturnNode = PrefixNode;
832 796 if (!PrefixNode)
833 797 {
834 798 *ReturnNode = AcpiGbl_RootNode;
835 799 }
836 800 return_ACPI_STATUS (AE_OK);
837 801 }
802 +
803 + /* Quick check for a reference to the root */
804 +
805 + if (ACPI_IS_ROOT_PREFIX (Pathname[0]) && (!Pathname[1]))
806 + {
807 + *ReturnNode = AcpiGbl_RootNode;
808 + return_ACPI_STATUS (AE_OK);
809 + }
838 810
839 811 /* Convert path to internal representation */
840 812
841 813 Status = AcpiNsInternalizeName (Pathname, &InternalPath);
842 814 if (ACPI_FAILURE (Status))
843 815 {
844 816 return_ACPI_STATUS (Status);
845 817 }
846 818
847 819 /* Must lock namespace during lookup */
848 820
849 821 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
850 822 if (ACPI_FAILURE (Status))
851 823 {
852 824 goto Cleanup;
853 825 }
854 826
855 827 /* Setup lookup scope (search starting point) */
856 828
857 829 ScopeInfo.Scope.Node = PrefixNode;
858 830
859 831 /* Lookup the name in the namespace */
860 832
861 833 Status = AcpiNsLookup (&ScopeInfo, InternalPath, ACPI_TYPE_ANY,
862 834 ACPI_IMODE_EXECUTE, (Flags | ACPI_NS_DONT_OPEN_SCOPE),
863 835 NULL, ReturnNode);
864 836 if (ACPI_FAILURE (Status))
865 837 {
866 838 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s, %s\n",
867 839 Pathname, AcpiFormatException (Status)));
868 840 }
869 841
870 842 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
871 843
872 844 Cleanup:
873 845 ACPI_FREE (InternalPath);
874 846 return_ACPI_STATUS (Status);
875 847 }
↓ open down ↓ |
28 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX