Linux Audio

Check our new training course

Embedded Linux training

Mar 10-20, 2025, special US time zones
Register
Loading...
v4.6
  1/******************************************************************************
  2 *
  3 * Module Name: nsutils - Utilities for accessing ACPI namespace, accessing
  4 *                        parents and siblings and Scope manipulation
  5 *
  6 *****************************************************************************/
  7
  8/*
  9 * Copyright (C) 2000 - 2016, Intel Corp.
 10 * All rights reserved.
 11 *
 12 * Redistribution and use in source and binary forms, with or without
 13 * modification, are permitted provided that the following conditions
 14 * are met:
 15 * 1. Redistributions of source code must retain the above copyright
 16 *    notice, this list of conditions, and the following disclaimer,
 17 *    without modification.
 18 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
 19 *    substantially similar to the "NO WARRANTY" disclaimer below
 20 *    ("Disclaimer") and any redistribution must be conditioned upon
 21 *    including a substantially similar Disclaimer requirement for further
 22 *    binary redistribution.
 23 * 3. Neither the names of the above-listed copyright holders nor the names
 24 *    of any contributors may be used to endorse or promote products derived
 25 *    from this software without specific prior written permission.
 26 *
 27 * Alternatively, this software may be distributed under the terms of the
 28 * GNU General Public License ("GPL") version 2 as published by the Free
 29 * Software Foundation.
 30 *
 31 * NO WARRANTY
 32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 33 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
 35 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 36 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
 41 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 42 * POSSIBILITY OF SUCH DAMAGES.
 43 */
 44
 45#include <acpi/acpi.h>
 46#include "accommon.h"
 47#include "acnamesp.h"
 48#include "amlcode.h"
 
 49
 50#define _COMPONENT          ACPI_NAMESPACE
 51ACPI_MODULE_NAME("nsutils")
 52
 53/* Local prototypes */
 
 
 54#ifdef ACPI_OBSOLETE_FUNCTIONS
 55acpi_name acpi_ns_find_parent_name(struct acpi_namespace_node *node_to_search);
 56#endif
 57
 58/*******************************************************************************
 59 *
 60 * FUNCTION:    acpi_ns_print_node_pathname
 61 *
 62 * PARAMETERS:  node            - Object
 63 *              message         - Prefix message
 64 *
 65 * DESCRIPTION: Print an object's full namespace pathname
 66 *              Manages allocation/freeing of a pathname buffer
 67 *
 68 ******************************************************************************/
 69
 70void
 71acpi_ns_print_node_pathname(struct acpi_namespace_node *node,
 72			    const char *message)
 73{
 74	struct acpi_buffer buffer;
 75	acpi_status status;
 76
 77	if (!node) {
 78		acpi_os_printf("[NULL NAME]");
 79		return;
 80	}
 81
 82	/* Convert handle to full pathname and print it (with supplied message) */
 83
 84	buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
 85
 86	status = acpi_ns_handle_to_pathname(node, &buffer, TRUE);
 87	if (ACPI_SUCCESS(status)) {
 88		if (message) {
 89			acpi_os_printf("%s ", message);
 90		}
 91
 92		acpi_os_printf("[%s] (Node %p)", (char *)buffer.pointer, node);
 93		ACPI_FREE(buffer.pointer);
 94	}
 95}
 96
 97/*******************************************************************************
 98 *
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 99 * FUNCTION:    acpi_ns_get_type
100 *
101 * PARAMETERS:  node        - Parent Node to be examined
102 *
103 * RETURN:      Type field from Node whose handle is passed
104 *
105 * DESCRIPTION: Return the type of a Namespace node
106 *
107 ******************************************************************************/
108
109acpi_object_type acpi_ns_get_type(struct acpi_namespace_node * node)
110{
111	ACPI_FUNCTION_TRACE(ns_get_type);
112
113	if (!node) {
114		ACPI_WARNING((AE_INFO, "Null Node parameter"));
115		return_UINT8(ACPI_TYPE_ANY);
116	}
117
118	return_UINT8(node->type);
119}
120
121/*******************************************************************************
122 *
123 * FUNCTION:    acpi_ns_local
124 *
125 * PARAMETERS:  type        - A namespace object type
126 *
127 * RETURN:      LOCAL if names must be found locally in objects of the
128 *              passed type, 0 if enclosing scopes should be searched
129 *
130 * DESCRIPTION: Returns scope rule for the given object type.
131 *
132 ******************************************************************************/
133
134u32 acpi_ns_local(acpi_object_type type)
135{
136	ACPI_FUNCTION_TRACE(ns_local);
137
138	if (!acpi_ut_valid_object_type(type)) {
139
140		/* Type code out of range  */
141
142		ACPI_WARNING((AE_INFO, "Invalid Object Type 0x%X", type));
143		return_UINT32(ACPI_NS_NORMAL);
144	}
145
146	return_UINT32(acpi_gbl_ns_properties[type] & ACPI_NS_LOCAL);
147}
148
149/*******************************************************************************
150 *
151 * FUNCTION:    acpi_ns_get_internal_name_length
152 *
153 * PARAMETERS:  info            - Info struct initialized with the
154 *                                external name pointer.
155 *
156 * RETURN:      None
157 *
158 * DESCRIPTION: Calculate the length of the internal (AML) namestring
159 *              corresponding to the external (ASL) namestring.
160 *
161 ******************************************************************************/
162
163void acpi_ns_get_internal_name_length(struct acpi_namestring_info *info)
164{
165	const char *next_external_char;
166	u32 i;
167
168	ACPI_FUNCTION_ENTRY();
169
170	next_external_char = info->external_name;
171	info->num_carats = 0;
172	info->num_segments = 0;
173	info->fully_qualified = FALSE;
174
175	/*
176	 * For the internal name, the required length is 4 bytes per segment,
177	 * plus 1 each for root_prefix, multi_name_prefix_op, segment count,
178	 * trailing null (which is not really needed, but no there's harm in
179	 * putting it there)
180	 *
181	 * strlen() + 1 covers the first name_seg, which has no path separator
182	 */
183	if (ACPI_IS_ROOT_PREFIX(*next_external_char)) {
184		info->fully_qualified = TRUE;
185		next_external_char++;
186
187		/* Skip redundant root_prefix, like \\_SB.PCI0.SBRG.EC0 */
188
189		while (ACPI_IS_ROOT_PREFIX(*next_external_char)) {
190			next_external_char++;
191		}
192	} else {
193		/* Handle Carat prefixes */
194
195		while (ACPI_IS_PARENT_PREFIX(*next_external_char)) {
196			info->num_carats++;
197			next_external_char++;
198		}
199	}
200
201	/*
202	 * Determine the number of ACPI name "segments" by counting the number of
203	 * path separators within the string. Start with one segment since the
204	 * segment count is [(# separators) + 1], and zero separators is ok.
205	 */
206	if (*next_external_char) {
207		info->num_segments = 1;
208		for (i = 0; next_external_char[i]; i++) {
209			if (ACPI_IS_PATH_SEPARATOR(next_external_char[i])) {
210				info->num_segments++;
211			}
212		}
213	}
214
215	info->length = (ACPI_NAME_SIZE * info->num_segments) +
216	    4 + info->num_carats;
217
218	info->next_external_char = next_external_char;
219}
220
221/*******************************************************************************
222 *
223 * FUNCTION:    acpi_ns_build_internal_name
224 *
225 * PARAMETERS:  info            - Info struct fully initialized
226 *
227 * RETURN:      Status
228 *
229 * DESCRIPTION: Construct the internal (AML) namestring
230 *              corresponding to the external (ASL) namestring.
231 *
232 ******************************************************************************/
233
234acpi_status acpi_ns_build_internal_name(struct acpi_namestring_info *info)
235{
236	u32 num_segments = info->num_segments;
237	char *internal_name = info->internal_name;
238	const char *external_name = info->next_external_char;
239	char *result = NULL;
240	u32 i;
241
242	ACPI_FUNCTION_TRACE(ns_build_internal_name);
243
244	/* Setup the correct prefixes, counts, and pointers */
245
246	if (info->fully_qualified) {
247		internal_name[0] = AML_ROOT_PREFIX;
248
249		if (num_segments <= 1) {
250			result = &internal_name[1];
251		} else if (num_segments == 2) {
252			internal_name[1] = AML_DUAL_NAME_PREFIX;
253			result = &internal_name[2];
254		} else {
255			internal_name[1] = AML_MULTI_NAME_PREFIX_OP;
256			internal_name[2] = (char)num_segments;
257			result = &internal_name[3];
258		}
259	} else {
260		/*
261		 * Not fully qualified.
262		 * Handle Carats first, then append the name segments
263		 */
264		i = 0;
265		if (info->num_carats) {
266			for (i = 0; i < info->num_carats; i++) {
267				internal_name[i] = AML_PARENT_PREFIX;
268			}
269		}
270
271		if (num_segments <= 1) {
272			result = &internal_name[i];
273		} else if (num_segments == 2) {
274			internal_name[i] = AML_DUAL_NAME_PREFIX;
275			result = &internal_name[(acpi_size) i + 1];
276		} else {
277			internal_name[i] = AML_MULTI_NAME_PREFIX_OP;
278			internal_name[(acpi_size) i + 1] = (char)num_segments;
279			result = &internal_name[(acpi_size) i + 2];
280		}
281	}
282
283	/* Build the name (minus path separators) */
284
285	for (; num_segments; num_segments--) {
286		for (i = 0; i < ACPI_NAME_SIZE; i++) {
287			if (ACPI_IS_PATH_SEPARATOR(*external_name) ||
288			    (*external_name == 0)) {
289
290				/* Pad the segment with underscore(s) if segment is short */
291
292				result[i] = '_';
293			} else {
294				/* Convert the character to uppercase and save it */
295
296				result[i] = (char)toupper((int)*external_name);
 
297				external_name++;
298			}
299		}
300
301		/* Now we must have a path separator, or the pathname is bad */
302
303		if (!ACPI_IS_PATH_SEPARATOR(*external_name) &&
304		    (*external_name != 0)) {
305			return_ACPI_STATUS(AE_BAD_PATHNAME);
306		}
307
308		/* Move on the next segment */
309
310		external_name++;
311		result += ACPI_NAME_SIZE;
312	}
313
314	/* Terminate the string */
315
316	*result = 0;
317
318	if (info->fully_qualified) {
319		ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
320				  "Returning [%p] (abs) \"\\%s\"\n",
321				  internal_name, internal_name));
322	} else {
323		ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Returning [%p] (rel) \"%s\"\n",
324				  internal_name, internal_name));
325	}
326
327	return_ACPI_STATUS(AE_OK);
328}
329
330/*******************************************************************************
331 *
332 * FUNCTION:    acpi_ns_internalize_name
333 *
334 * PARAMETERS:  *external_name          - External representation of name
335 *              **Converted name        - Where to return the resulting
336 *                                        internal represention of the name
337 *
338 * RETURN:      Status
339 *
340 * DESCRIPTION: Convert an external representation (e.g. "\_PR_.CPU0")
341 *              to internal form (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30)
342 *
343 *******************************************************************************/
344
345acpi_status
346acpi_ns_internalize_name(const char *external_name, char **converted_name)
347{
348	char *internal_name;
349	struct acpi_namestring_info info;
350	acpi_status status;
351
352	ACPI_FUNCTION_TRACE(ns_internalize_name);
353
354	if ((!external_name) || (*external_name == 0) || (!converted_name)) {
355		return_ACPI_STATUS(AE_BAD_PARAMETER);
356	}
357
358	/* Get the length of the new internal name */
359
360	info.external_name = external_name;
361	acpi_ns_get_internal_name_length(&info);
362
363	/* We need a segment to store the internal  name */
364
365	internal_name = ACPI_ALLOCATE_ZEROED(info.length);
366	if (!internal_name) {
367		return_ACPI_STATUS(AE_NO_MEMORY);
368	}
369
370	/* Build the name */
371
372	info.internal_name = internal_name;
373	status = acpi_ns_build_internal_name(&info);
374	if (ACPI_FAILURE(status)) {
375		ACPI_FREE(internal_name);
376		return_ACPI_STATUS(status);
377	}
378
379	*converted_name = internal_name;
380	return_ACPI_STATUS(AE_OK);
381}
382
383/*******************************************************************************
384 *
385 * FUNCTION:    acpi_ns_externalize_name
386 *
387 * PARAMETERS:  internal_name_length - Lenth of the internal name below
388 *              internal_name       - Internal representation of name
389 *              converted_name_length - Where the length is returned
390 *              converted_name      - Where the resulting external name
391 *                                    is returned
392 *
393 * RETURN:      Status
394 *
395 * DESCRIPTION: Convert internal name (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30)
396 *              to its external (printable) form (e.g. "\_PR_.CPU0")
397 *
398 ******************************************************************************/
399
400acpi_status
401acpi_ns_externalize_name(u32 internal_name_length,
402			 const char *internal_name,
403			 u32 * converted_name_length, char **converted_name)
404{
405	u32 names_index = 0;
406	u32 num_segments = 0;
407	u32 required_length;
408	u32 prefix_length = 0;
409	u32 i = 0;
410	u32 j = 0;
411
412	ACPI_FUNCTION_TRACE(ns_externalize_name);
413
414	if (!internal_name_length || !internal_name || !converted_name) {
415		return_ACPI_STATUS(AE_BAD_PARAMETER);
416	}
417
418	/* Check for a prefix (one '\' | one or more '^') */
419
420	switch (internal_name[0]) {
421	case AML_ROOT_PREFIX:
422
423		prefix_length = 1;
424		break;
425
426	case AML_PARENT_PREFIX:
427
428		for (i = 0; i < internal_name_length; i++) {
429			if (ACPI_IS_PARENT_PREFIX(internal_name[i])) {
430				prefix_length = i + 1;
431			} else {
432				break;
433			}
434		}
435
436		if (i == internal_name_length) {
437			prefix_length = i;
438		}
439
440		break;
441
442	default:
443
444		break;
445	}
446
447	/*
448	 * Check for object names. Note that there could be 0-255 of these
449	 * 4-byte elements.
450	 */
451	if (prefix_length < internal_name_length) {
452		switch (internal_name[prefix_length]) {
453		case AML_MULTI_NAME_PREFIX_OP:
454
455			/* <count> 4-byte names */
456
457			names_index = prefix_length + 2;
458			num_segments = (u8)
459			    internal_name[(acpi_size) prefix_length + 1];
460			break;
461
462		case AML_DUAL_NAME_PREFIX:
463
464			/* Two 4-byte names */
465
466			names_index = prefix_length + 1;
467			num_segments = 2;
468			break;
469
470		case 0:
471
472			/* null_name */
473
474			names_index = 0;
475			num_segments = 0;
476			break;
477
478		default:
479
480			/* one 4-byte name */
481
482			names_index = prefix_length;
483			num_segments = 1;
484			break;
485		}
486	}
487
488	/*
489	 * Calculate the length of converted_name, which equals the length
490	 * of the prefix, length of all object names, length of any required
491	 * punctuation ('.') between object names, plus the NULL terminator.
492	 */
493	required_length = prefix_length + (4 * num_segments) +
494	    ((num_segments > 0) ? (num_segments - 1) : 0) + 1;
495
496	/*
497	 * Check to see if we're still in bounds. If not, there's a problem
498	 * with internal_name (invalid format).
499	 */
500	if (required_length > internal_name_length) {
501		ACPI_ERROR((AE_INFO, "Invalid internal name"));
502		return_ACPI_STATUS(AE_BAD_PATHNAME);
503	}
504
505	/* Build the converted_name */
506
507	*converted_name = ACPI_ALLOCATE_ZEROED(required_length);
508	if (!(*converted_name)) {
509		return_ACPI_STATUS(AE_NO_MEMORY);
510	}
511
512	j = 0;
513
514	for (i = 0; i < prefix_length; i++) {
515		(*converted_name)[j++] = internal_name[i];
516	}
517
518	if (num_segments > 0) {
519		for (i = 0; i < num_segments; i++) {
520			if (i > 0) {
521				(*converted_name)[j++] = '.';
522			}
523
524			/* Copy and validate the 4-char name segment */
525
526			ACPI_MOVE_NAME(&(*converted_name)[j],
527				       &internal_name[names_index]);
528			acpi_ut_repair_name(&(*converted_name)[j]);
529
530			j += ACPI_NAME_SIZE;
531			names_index += ACPI_NAME_SIZE;
532		}
533	}
534
535	if (converted_name_length) {
536		*converted_name_length = (u32) required_length;
537	}
538
539	return_ACPI_STATUS(AE_OK);
540}
541
542/*******************************************************************************
543 *
544 * FUNCTION:    acpi_ns_validate_handle
545 *
546 * PARAMETERS:  handle          - Handle to be validated and typecast to a
547 *                                namespace node.
548 *
549 * RETURN:      A pointer to a namespace node
550 *
551 * DESCRIPTION: Convert a namespace handle to a namespace node. Handles special
552 *              cases for the root node.
553 *
554 * NOTE: Real integer handles would allow for more verification
555 *       and keep all pointers within this subsystem - however this introduces
556 *       more overhead and has not been necessary to this point. Drivers
557 *       holding handles are typically notified before a node becomes invalid
558 *       due to a table unload.
559 *
560 ******************************************************************************/
561
562struct acpi_namespace_node *acpi_ns_validate_handle(acpi_handle handle)
563{
564
565	ACPI_FUNCTION_ENTRY();
566
567	/* Parameter validation */
568
569	if ((!handle) || (handle == ACPI_ROOT_OBJECT)) {
570		return (acpi_gbl_root_node);
571	}
572
573	/* We can at least attempt to verify the handle */
574
575	if (ACPI_GET_DESCRIPTOR_TYPE(handle) != ACPI_DESC_TYPE_NAMED) {
576		return (NULL);
577	}
578
579	return (ACPI_CAST_PTR(struct acpi_namespace_node, handle));
580}
581
582/*******************************************************************************
583 *
584 * FUNCTION:    acpi_ns_terminate
585 *
586 * PARAMETERS:  none
587 *
588 * RETURN:      none
589 *
590 * DESCRIPTION: free memory allocated for namespace and ACPI table storage.
591 *
592 ******************************************************************************/
593
594void acpi_ns_terminate(void)
595{
596	acpi_status status;
597
598	ACPI_FUNCTION_TRACE(ns_terminate);
599
600#ifdef ACPI_EXEC_APP
601	{
602		union acpi_operand_object *prev;
603		union acpi_operand_object *next;
604
605		/* Delete any module-level code blocks */
606
607		next = acpi_gbl_module_code_list;
608		while (next) {
609			prev = next;
610			next = next->method.mutex;
611			prev->method.mutex = NULL;	/* Clear the Mutex (cheated) field */
612			acpi_ut_remove_reference(prev);
613		}
614	}
615#endif
616
617	/*
618	 * Free the entire namespace -- all nodes and all objects
619	 * attached to the nodes
 
620	 */
621	acpi_ns_delete_namespace_subtree(acpi_gbl_root_node);
622
623	/* Delete any objects attached to the root node */
624
625	status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
626	if (ACPI_FAILURE(status)) {
627		return_VOID;
628	}
629
630	acpi_ns_delete_node(acpi_gbl_root_node);
631	(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
632
633	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Namespace freed\n"));
634	return_VOID;
635}
636
637/*******************************************************************************
638 *
639 * FUNCTION:    acpi_ns_opens_scope
640 *
641 * PARAMETERS:  type        - A valid namespace type
642 *
643 * RETURN:      NEWSCOPE if the passed type "opens a name scope" according
644 *              to the ACPI specification, else 0
645 *
646 ******************************************************************************/
647
648u32 acpi_ns_opens_scope(acpi_object_type type)
649{
650	ACPI_FUNCTION_ENTRY();
651
652	if (type > ACPI_TYPE_LOCAL_MAX) {
653
654		/* type code out of range  */
655
656		ACPI_WARNING((AE_INFO, "Invalid Object Type 0x%X", type));
657		return (ACPI_NS_NORMAL);
658	}
659
660	return (((u32)acpi_gbl_ns_properties[type]) & ACPI_NS_NEWSCOPE);
661}
662
663/*******************************************************************************
664 *
665 * FUNCTION:    acpi_ns_get_node
666 *
667 * PARAMETERS:  *pathname   - Name to be found, in external (ASL) format. The
668 *                            \ (backslash) and ^ (carat) prefixes, and the
669 *                            . (period) to separate segments are supported.
670 *              prefix_node  - Root of subtree to be searched, or NS_ALL for the
671 *                            root of the name space. If Name is fully
672 *                            qualified (first s8 is '\'), the passed value
673 *                            of Scope will not be accessed.
674 *              flags       - Used to indicate whether to perform upsearch or
675 *                            not.
676 *              return_node - Where the Node is returned
677 *
678 * DESCRIPTION: Look up a name relative to a given scope and return the
679 *              corresponding Node. NOTE: Scope can be null.
680 *
681 * MUTEX:       Locks namespace
682 *
683 ******************************************************************************/
684
685acpi_status
686acpi_ns_get_node(struct acpi_namespace_node *prefix_node,
687		 const char *pathname,
688		 u32 flags, struct acpi_namespace_node **return_node)
689{
690	union acpi_generic_state scope_info;
691	acpi_status status;
692	char *internal_path;
693
694	ACPI_FUNCTION_TRACE_PTR(ns_get_node, ACPI_CAST_PTR(char, pathname));
695
696	/* Simplest case is a null pathname */
697
698	if (!pathname) {
699		*return_node = prefix_node;
700		if (!prefix_node) {
701			*return_node = acpi_gbl_root_node;
702		}
703
704		return_ACPI_STATUS(AE_OK);
705	}
706
707	/* Quick check for a reference to the root */
708
709	if (ACPI_IS_ROOT_PREFIX(pathname[0]) && (!pathname[1])) {
710		*return_node = acpi_gbl_root_node;
711		return_ACPI_STATUS(AE_OK);
712	}
713
714	/* Convert path to internal representation */
715
716	status = acpi_ns_internalize_name(pathname, &internal_path);
717	if (ACPI_FAILURE(status)) {
718		return_ACPI_STATUS(status);
719	}
720
721	/* Must lock namespace during lookup */
722
723	status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
724	if (ACPI_FAILURE(status)) {
725		goto cleanup;
726	}
727
728	/* Setup lookup scope (search starting point) */
729
730	scope_info.scope.node = prefix_node;
731
732	/* Lookup the name in the namespace */
733
734	status = acpi_ns_lookup(&scope_info, internal_path, ACPI_TYPE_ANY,
735				ACPI_IMODE_EXECUTE,
736				(flags | ACPI_NS_DONT_OPEN_SCOPE), NULL,
737				return_node);
738	if (ACPI_FAILURE(status)) {
739		ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%s, %s\n",
740				  pathname, acpi_format_exception(status)));
741	}
742
743	(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
744
745cleanup:
746	ACPI_FREE(internal_path);
747	return_ACPI_STATUS(status);
748}
v3.5.6
  1/******************************************************************************
  2 *
  3 * Module Name: nsutils - Utilities for accessing ACPI namespace, accessing
  4 *                        parents and siblings and Scope manipulation
  5 *
  6 *****************************************************************************/
  7
  8/*
  9 * Copyright (C) 2000 - 2012, Intel Corp.
 10 * All rights reserved.
 11 *
 12 * Redistribution and use in source and binary forms, with or without
 13 * modification, are permitted provided that the following conditions
 14 * are met:
 15 * 1. Redistributions of source code must retain the above copyright
 16 *    notice, this list of conditions, and the following disclaimer,
 17 *    without modification.
 18 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
 19 *    substantially similar to the "NO WARRANTY" disclaimer below
 20 *    ("Disclaimer") and any redistribution must be conditioned upon
 21 *    including a substantially similar Disclaimer requirement for further
 22 *    binary redistribution.
 23 * 3. Neither the names of the above-listed copyright holders nor the names
 24 *    of any contributors may be used to endorse or promote products derived
 25 *    from this software without specific prior written permission.
 26 *
 27 * Alternatively, this software may be distributed under the terms of the
 28 * GNU General Public License ("GPL") version 2 as published by the Free
 29 * Software Foundation.
 30 *
 31 * NO WARRANTY
 32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 33 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
 35 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 36 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
 41 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 42 * POSSIBILITY OF SUCH DAMAGES.
 43 */
 44
 45#include <acpi/acpi.h>
 46#include "accommon.h"
 47#include "acnamesp.h"
 48#include "amlcode.h"
 49#include "actables.h"
 50
 51#define _COMPONENT          ACPI_NAMESPACE
 52ACPI_MODULE_NAME("nsutils")
 53
 54/* Local prototypes */
 55static u8 acpi_ns_valid_path_separator(char sep);
 56
 57#ifdef ACPI_OBSOLETE_FUNCTIONS
 58acpi_name acpi_ns_find_parent_name(struct acpi_namespace_node *node_to_search);
 59#endif
 60
 61/*******************************************************************************
 62 *
 63 * FUNCTION:    acpi_ns_print_node_pathname
 64 *
 65 * PARAMETERS:  Node            - Object
 66 *              Message         - Prefix message
 67 *
 68 * DESCRIPTION: Print an object's full namespace pathname
 69 *              Manages allocation/freeing of a pathname buffer
 70 *
 71 ******************************************************************************/
 72
 73void
 74acpi_ns_print_node_pathname(struct acpi_namespace_node *node,
 75			    const char *message)
 76{
 77	struct acpi_buffer buffer;
 78	acpi_status status;
 79
 80	if (!node) {
 81		acpi_os_printf("[NULL NAME]");
 82		return;
 83	}
 84
 85	/* Convert handle to full pathname and print it (with supplied message) */
 86
 87	buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
 88
 89	status = acpi_ns_handle_to_pathname(node, &buffer);
 90	if (ACPI_SUCCESS(status)) {
 91		if (message) {
 92			acpi_os_printf("%s ", message);
 93		}
 94
 95		acpi_os_printf("[%s] (Node %p)", (char *)buffer.pointer, node);
 96		ACPI_FREE(buffer.pointer);
 97	}
 98}
 99
100/*******************************************************************************
101 *
102 * FUNCTION:    acpi_ns_valid_root_prefix
103 *
104 * PARAMETERS:  Prefix          - Character to be checked
105 *
106 * RETURN:      TRUE if a valid prefix
107 *
108 * DESCRIPTION: Check if a character is a valid ACPI Root prefix
109 *
110 ******************************************************************************/
111
112u8 acpi_ns_valid_root_prefix(char prefix)
113{
114
115	return ((u8) (prefix == '\\'));
116}
117
118/*******************************************************************************
119 *
120 * FUNCTION:    acpi_ns_valid_path_separator
121 *
122 * PARAMETERS:  Sep         - Character to be checked
123 *
124 * RETURN:      TRUE if a valid path separator
125 *
126 * DESCRIPTION: Check if a character is a valid ACPI path separator
127 *
128 ******************************************************************************/
129
130static u8 acpi_ns_valid_path_separator(char sep)
131{
132
133	return ((u8) (sep == '.'));
134}
135
136/*******************************************************************************
137 *
138 * FUNCTION:    acpi_ns_get_type
139 *
140 * PARAMETERS:  Node        - Parent Node to be examined
141 *
142 * RETURN:      Type field from Node whose handle is passed
143 *
144 * DESCRIPTION: Return the type of a Namespace node
145 *
146 ******************************************************************************/
147
148acpi_object_type acpi_ns_get_type(struct acpi_namespace_node * node)
149{
150	ACPI_FUNCTION_TRACE(ns_get_type);
151
152	if (!node) {
153		ACPI_WARNING((AE_INFO, "Null Node parameter"));
154		return_UINT32(ACPI_TYPE_ANY);
155	}
156
157	return_UINT32((acpi_object_type) node->type);
158}
159
160/*******************************************************************************
161 *
162 * FUNCTION:    acpi_ns_local
163 *
164 * PARAMETERS:  Type        - A namespace object type
165 *
166 * RETURN:      LOCAL if names must be found locally in objects of the
167 *              passed type, 0 if enclosing scopes should be searched
168 *
169 * DESCRIPTION: Returns scope rule for the given object type.
170 *
171 ******************************************************************************/
172
173u32 acpi_ns_local(acpi_object_type type)
174{
175	ACPI_FUNCTION_TRACE(ns_local);
176
177	if (!acpi_ut_valid_object_type(type)) {
178
179		/* Type code out of range  */
180
181		ACPI_WARNING((AE_INFO, "Invalid Object Type 0x%X", type));
182		return_UINT32(ACPI_NS_NORMAL);
183	}
184
185	return_UINT32((u32) acpi_gbl_ns_properties[type] & ACPI_NS_LOCAL);
186}
187
188/*******************************************************************************
189 *
190 * FUNCTION:    acpi_ns_get_internal_name_length
191 *
192 * PARAMETERS:  Info            - Info struct initialized with the
193 *                                external name pointer.
194 *
195 * RETURN:      None
196 *
197 * DESCRIPTION: Calculate the length of the internal (AML) namestring
198 *              corresponding to the external (ASL) namestring.
199 *
200 ******************************************************************************/
201
202void acpi_ns_get_internal_name_length(struct acpi_namestring_info *info)
203{
204	const char *next_external_char;
205	u32 i;
206
207	ACPI_FUNCTION_ENTRY();
208
209	next_external_char = info->external_name;
210	info->num_carats = 0;
211	info->num_segments = 0;
212	info->fully_qualified = FALSE;
213
214	/*
215	 * For the internal name, the required length is 4 bytes per segment, plus
216	 * 1 each for root_prefix, multi_name_prefix_op, segment count, trailing null
217	 * (which is not really needed, but no there's harm in putting it there)
 
218	 *
219	 * strlen() + 1 covers the first name_seg, which has no path separator
220	 */
221	if (acpi_ns_valid_root_prefix(*next_external_char)) {
222		info->fully_qualified = TRUE;
223		next_external_char++;
224
225		/* Skip redundant root_prefix, like \\_SB.PCI0.SBRG.EC0 */
226
227		while (acpi_ns_valid_root_prefix(*next_external_char)) {
228			next_external_char++;
229		}
230	} else {
231		/* Handle Carat prefixes */
232
233		while (*next_external_char == '^') {
234			info->num_carats++;
235			next_external_char++;
236		}
237	}
238
239	/*
240	 * Determine the number of ACPI name "segments" by counting the number of
241	 * path separators within the string. Start with one segment since the
242	 * segment count is [(# separators) + 1], and zero separators is ok.
243	 */
244	if (*next_external_char) {
245		info->num_segments = 1;
246		for (i = 0; next_external_char[i]; i++) {
247			if (acpi_ns_valid_path_separator(next_external_char[i])) {
248				info->num_segments++;
249			}
250		}
251	}
252
253	info->length = (ACPI_NAME_SIZE * info->num_segments) +
254	    4 + info->num_carats;
255
256	info->next_external_char = next_external_char;
257}
258
259/*******************************************************************************
260 *
261 * FUNCTION:    acpi_ns_build_internal_name
262 *
263 * PARAMETERS:  Info            - Info struct fully initialized
264 *
265 * RETURN:      Status
266 *
267 * DESCRIPTION: Construct the internal (AML) namestring
268 *              corresponding to the external (ASL) namestring.
269 *
270 ******************************************************************************/
271
272acpi_status acpi_ns_build_internal_name(struct acpi_namestring_info *info)
273{
274	u32 num_segments = info->num_segments;
275	char *internal_name = info->internal_name;
276	const char *external_name = info->next_external_char;
277	char *result = NULL;
278	u32 i;
279
280	ACPI_FUNCTION_TRACE(ns_build_internal_name);
281
282	/* Setup the correct prefixes, counts, and pointers */
283
284	if (info->fully_qualified) {
285		internal_name[0] = '\\';
286
287		if (num_segments <= 1) {
288			result = &internal_name[1];
289		} else if (num_segments == 2) {
290			internal_name[1] = AML_DUAL_NAME_PREFIX;
291			result = &internal_name[2];
292		} else {
293			internal_name[1] = AML_MULTI_NAME_PREFIX_OP;
294			internal_name[2] = (char)num_segments;
295			result = &internal_name[3];
296		}
297	} else {
298		/*
299		 * Not fully qualified.
300		 * Handle Carats first, then append the name segments
301		 */
302		i = 0;
303		if (info->num_carats) {
304			for (i = 0; i < info->num_carats; i++) {
305				internal_name[i] = '^';
306			}
307		}
308
309		if (num_segments <= 1) {
310			result = &internal_name[i];
311		} else if (num_segments == 2) {
312			internal_name[i] = AML_DUAL_NAME_PREFIX;
313			result = &internal_name[(acpi_size) i + 1];
314		} else {
315			internal_name[i] = AML_MULTI_NAME_PREFIX_OP;
316			internal_name[(acpi_size) i + 1] = (char)num_segments;
317			result = &internal_name[(acpi_size) i + 2];
318		}
319	}
320
321	/* Build the name (minus path separators) */
322
323	for (; num_segments; num_segments--) {
324		for (i = 0; i < ACPI_NAME_SIZE; i++) {
325			if (acpi_ns_valid_path_separator(*external_name) ||
326			    (*external_name == 0)) {
327
328				/* Pad the segment with underscore(s) if segment is short */
329
330				result[i] = '_';
331			} else {
332				/* Convert the character to uppercase and save it */
333
334				result[i] =
335				    (char)ACPI_TOUPPER((int)*external_name);
336				external_name++;
337			}
338		}
339
340		/* Now we must have a path separator, or the pathname is bad */
341
342		if (!acpi_ns_valid_path_separator(*external_name) &&
343		    (*external_name != 0)) {
344			return_ACPI_STATUS(AE_BAD_PATHNAME);
345		}
346
347		/* Move on the next segment */
348
349		external_name++;
350		result += ACPI_NAME_SIZE;
351	}
352
353	/* Terminate the string */
354
355	*result = 0;
356
357	if (info->fully_qualified) {
358		ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
359				  "Returning [%p] (abs) \"\\%s\"\n",
360				  internal_name, internal_name));
361	} else {
362		ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Returning [%p] (rel) \"%s\"\n",
363				  internal_name, internal_name));
364	}
365
366	return_ACPI_STATUS(AE_OK);
367}
368
369/*******************************************************************************
370 *
371 * FUNCTION:    acpi_ns_internalize_name
372 *
373 * PARAMETERS:  *external_name          - External representation of name
374 *              **Converted Name        - Where to return the resulting
375 *                                        internal represention of the name
376 *
377 * RETURN:      Status
378 *
379 * DESCRIPTION: Convert an external representation (e.g. "\_PR_.CPU0")
380 *              to internal form (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30)
381 *
382 *******************************************************************************/
383
384acpi_status
385acpi_ns_internalize_name(const char *external_name, char **converted_name)
386{
387	char *internal_name;
388	struct acpi_namestring_info info;
389	acpi_status status;
390
391	ACPI_FUNCTION_TRACE(ns_internalize_name);
392
393	if ((!external_name) || (*external_name == 0) || (!converted_name)) {
394		return_ACPI_STATUS(AE_BAD_PARAMETER);
395	}
396
397	/* Get the length of the new internal name */
398
399	info.external_name = external_name;
400	acpi_ns_get_internal_name_length(&info);
401
402	/* We need a segment to store the internal  name */
403
404	internal_name = ACPI_ALLOCATE_ZEROED(info.length);
405	if (!internal_name) {
406		return_ACPI_STATUS(AE_NO_MEMORY);
407	}
408
409	/* Build the name */
410
411	info.internal_name = internal_name;
412	status = acpi_ns_build_internal_name(&info);
413	if (ACPI_FAILURE(status)) {
414		ACPI_FREE(internal_name);
415		return_ACPI_STATUS(status);
416	}
417
418	*converted_name = internal_name;
419	return_ACPI_STATUS(AE_OK);
420}
421
422/*******************************************************************************
423 *
424 * FUNCTION:    acpi_ns_externalize_name
425 *
426 * PARAMETERS:  internal_name_length - Lenth of the internal name below
427 *              internal_name       - Internal representation of name
428 *              converted_name_length - Where the length is returned
429 *              converted_name      - Where the resulting external name
430 *                                    is returned
431 *
432 * RETURN:      Status
433 *
434 * DESCRIPTION: Convert internal name (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30)
435 *              to its external (printable) form (e.g. "\_PR_.CPU0")
436 *
437 ******************************************************************************/
438
439acpi_status
440acpi_ns_externalize_name(u32 internal_name_length,
441			 const char *internal_name,
442			 u32 * converted_name_length, char **converted_name)
443{
444	u32 names_index = 0;
445	u32 num_segments = 0;
446	u32 required_length;
447	u32 prefix_length = 0;
448	u32 i = 0;
449	u32 j = 0;
450
451	ACPI_FUNCTION_TRACE(ns_externalize_name);
452
453	if (!internal_name_length || !internal_name || !converted_name) {
454		return_ACPI_STATUS(AE_BAD_PARAMETER);
455	}
456
457	/* Check for a prefix (one '\' | one or more '^') */
458
459	switch (internal_name[0]) {
460	case '\\':
 
461		prefix_length = 1;
462		break;
463
464	case '^':
 
465		for (i = 0; i < internal_name_length; i++) {
466			if (internal_name[i] == '^') {
467				prefix_length = i + 1;
468			} else {
469				break;
470			}
471		}
472
473		if (i == internal_name_length) {
474			prefix_length = i;
475		}
476
477		break;
478
479	default:
 
480		break;
481	}
482
483	/*
484	 * Check for object names. Note that there could be 0-255 of these
485	 * 4-byte elements.
486	 */
487	if (prefix_length < internal_name_length) {
488		switch (internal_name[prefix_length]) {
489		case AML_MULTI_NAME_PREFIX_OP:
490
491			/* <count> 4-byte names */
492
493			names_index = prefix_length + 2;
494			num_segments = (u8)
495			    internal_name[(acpi_size) prefix_length + 1];
496			break;
497
498		case AML_DUAL_NAME_PREFIX:
499
500			/* Two 4-byte names */
501
502			names_index = prefix_length + 1;
503			num_segments = 2;
504			break;
505
506		case 0:
507
508			/* null_name */
509
510			names_index = 0;
511			num_segments = 0;
512			break;
513
514		default:
515
516			/* one 4-byte name */
517
518			names_index = prefix_length;
519			num_segments = 1;
520			break;
521		}
522	}
523
524	/*
525	 * Calculate the length of converted_name, which equals the length
526	 * of the prefix, length of all object names, length of any required
527	 * punctuation ('.') between object names, plus the NULL terminator.
528	 */
529	required_length = prefix_length + (4 * num_segments) +
530	    ((num_segments > 0) ? (num_segments - 1) : 0) + 1;
531
532	/*
533	 * Check to see if we're still in bounds.  If not, there's a problem
534	 * with internal_name (invalid format).
535	 */
536	if (required_length > internal_name_length) {
537		ACPI_ERROR((AE_INFO, "Invalid internal name"));
538		return_ACPI_STATUS(AE_BAD_PATHNAME);
539	}
540
541	/* Build the converted_name */
542
543	*converted_name = ACPI_ALLOCATE_ZEROED(required_length);
544	if (!(*converted_name)) {
545		return_ACPI_STATUS(AE_NO_MEMORY);
546	}
547
548	j = 0;
549
550	for (i = 0; i < prefix_length; i++) {
551		(*converted_name)[j++] = internal_name[i];
552	}
553
554	if (num_segments > 0) {
555		for (i = 0; i < num_segments; i++) {
556			if (i > 0) {
557				(*converted_name)[j++] = '.';
558			}
559
560			(*converted_name)[j++] = internal_name[names_index++];
561			(*converted_name)[j++] = internal_name[names_index++];
562			(*converted_name)[j++] = internal_name[names_index++];
563			(*converted_name)[j++] = internal_name[names_index++];
 
 
 
 
564		}
565	}
566
567	if (converted_name_length) {
568		*converted_name_length = (u32) required_length;
569	}
570
571	return_ACPI_STATUS(AE_OK);
572}
573
574/*******************************************************************************
575 *
576 * FUNCTION:    acpi_ns_validate_handle
577 *
578 * PARAMETERS:  Handle          - Handle to be validated and typecast to a
579 *                                namespace node.
580 *
581 * RETURN:      A pointer to a namespace node
582 *
583 * DESCRIPTION: Convert a namespace handle to a namespace node. Handles special
584 *              cases for the root node.
585 *
586 * NOTE: Real integer handles would allow for more verification
587 *       and keep all pointers within this subsystem - however this introduces
588 *       more overhead and has not been necessary to this point. Drivers
589 *       holding handles are typically notified before a node becomes invalid
590 *       due to a table unload.
591 *
592 ******************************************************************************/
593
594struct acpi_namespace_node *acpi_ns_validate_handle(acpi_handle handle)
595{
596
597	ACPI_FUNCTION_ENTRY();
598
599	/* Parameter validation */
600
601	if ((!handle) || (handle == ACPI_ROOT_OBJECT)) {
602		return (acpi_gbl_root_node);
603	}
604
605	/* We can at least attempt to verify the handle */
606
607	if (ACPI_GET_DESCRIPTOR_TYPE(handle) != ACPI_DESC_TYPE_NAMED) {
608		return (NULL);
609	}
610
611	return (ACPI_CAST_PTR(struct acpi_namespace_node, handle));
612}
613
614/*******************************************************************************
615 *
616 * FUNCTION:    acpi_ns_terminate
617 *
618 * PARAMETERS:  none
619 *
620 * RETURN:      none
621 *
622 * DESCRIPTION: free memory allocated for namespace and ACPI table storage.
623 *
624 ******************************************************************************/
625
626void acpi_ns_terminate(void)
627{
628	union acpi_operand_object *obj_desc;
629
630	ACPI_FUNCTION_TRACE(ns_terminate);
631
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
632	/*
633	 * 1) Free the entire namespace -- all nodes and objects
634	 *
635	 * Delete all object descriptors attached to namepsace nodes
636	 */
637	acpi_ns_delete_namespace_subtree(acpi_gbl_root_node);
638
639	/* Detach any objects attached to the root */
640
641	obj_desc = acpi_ns_get_attached_object(acpi_gbl_root_node);
642	if (obj_desc) {
643		acpi_ns_detach_object(acpi_gbl_root_node);
644	}
645
 
 
 
646	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Namespace freed\n"));
647	return_VOID;
648}
649
650/*******************************************************************************
651 *
652 * FUNCTION:    acpi_ns_opens_scope
653 *
654 * PARAMETERS:  Type        - A valid namespace type
655 *
656 * RETURN:      NEWSCOPE if the passed type "opens a name scope" according
657 *              to the ACPI specification, else 0
658 *
659 ******************************************************************************/
660
661u32 acpi_ns_opens_scope(acpi_object_type type)
662{
663	ACPI_FUNCTION_TRACE_STR(ns_opens_scope, acpi_ut_get_type_name(type));
664
665	if (!acpi_ut_valid_object_type(type)) {
666
667		/* type code out of range  */
668
669		ACPI_WARNING((AE_INFO, "Invalid Object Type 0x%X", type));
670		return_UINT32(ACPI_NS_NORMAL);
671	}
672
673	return_UINT32(((u32) acpi_gbl_ns_properties[type]) & ACPI_NS_NEWSCOPE);
674}
675
676/*******************************************************************************
677 *
678 * FUNCTION:    acpi_ns_get_node
679 *
680 * PARAMETERS:  *Pathname   - Name to be found, in external (ASL) format. The
681 *                            \ (backslash) and ^ (carat) prefixes, and the
682 *                            . (period) to separate segments are supported.
683 *              prefix_node  - Root of subtree to be searched, or NS_ALL for the
684 *                            root of the name space.  If Name is fully
685 *                            qualified (first s8 is '\'), the passed value
686 *                            of Scope will not be accessed.
687 *              Flags       - Used to indicate whether to perform upsearch or
688 *                            not.
689 *              return_node - Where the Node is returned
690 *
691 * DESCRIPTION: Look up a name relative to a given scope and return the
692 *              corresponding Node.  NOTE: Scope can be null.
693 *
694 * MUTEX:       Locks namespace
695 *
696 ******************************************************************************/
697
698acpi_status
699acpi_ns_get_node(struct acpi_namespace_node *prefix_node,
700		 const char *pathname,
701		 u32 flags, struct acpi_namespace_node **return_node)
702{
703	union acpi_generic_state scope_info;
704	acpi_status status;
705	char *internal_path;
706
707	ACPI_FUNCTION_TRACE_PTR(ns_get_node, ACPI_CAST_PTR(char, pathname));
708
 
 
709	if (!pathname) {
710		*return_node = prefix_node;
711		if (!prefix_node) {
712			*return_node = acpi_gbl_root_node;
713		}
 
 
 
 
 
 
 
 
714		return_ACPI_STATUS(AE_OK);
715	}
716
717	/* Convert path to internal representation */
718
719	status = acpi_ns_internalize_name(pathname, &internal_path);
720	if (ACPI_FAILURE(status)) {
721		return_ACPI_STATUS(status);
722	}
723
724	/* Must lock namespace during lookup */
725
726	status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
727	if (ACPI_FAILURE(status)) {
728		goto cleanup;
729	}
730
731	/* Setup lookup scope (search starting point) */
732
733	scope_info.scope.node = prefix_node;
734
735	/* Lookup the name in the namespace */
736
737	status = acpi_ns_lookup(&scope_info, internal_path, ACPI_TYPE_ANY,
738				ACPI_IMODE_EXECUTE,
739				(flags | ACPI_NS_DONT_OPEN_SCOPE), NULL,
740				return_node);
741	if (ACPI_FAILURE(status)) {
742		ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%s, %s\n",
743				  pathname, acpi_format_exception(status)));
744	}
745
746	(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
747
748      cleanup:
749	ACPI_FREE(internal_path);
750	return_ACPI_STATUS(status);
751}