[ACPI] ACPICA 20051021
[linux-2.6/cjktty.git] / drivers / acpi / utilities / utmisc.c
blobe9058d4da1225482f7b927608bdbf9be6a0c1cd6
1 /*******************************************************************************
3 * Module Name: utmisc - common utility procedures
5 ******************************************************************************/
7 /*
8 * Copyright (C) 2000 - 2005, R. Byron Moore
9 * All rights reserved.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
44 #include <acpi/acpi.h>
45 #include <acpi/acnamesp.h>
46 #include <acpi/amlresrc.h>
48 #define _COMPONENT ACPI_UTILITIES
49 ACPI_MODULE_NAME("utmisc")
51 /*******************************************************************************
53 * FUNCTION: acpi_ut_allocate_owner_id
55 * PARAMETERS: owner_id - Where the new owner ID is returned
57 * RETURN: Status
59 * DESCRIPTION: Allocate a table or method owner ID. The owner ID is used to
60 * track objects created by the table or method, to be deleted
61 * when the method exits or the table is unloaded.
63 ******************************************************************************/
64 acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id)
66 acpi_native_uint i;
67 acpi_status status;
69 ACPI_FUNCTION_TRACE("ut_allocate_owner_id");
71 /* Guard against multiple allocations of ID to the same location */
73 if (*owner_id) {
74 ACPI_REPORT_ERROR(("Owner ID [%2.2X] already exists\n",
75 *owner_id));
76 return_ACPI_STATUS(AE_ALREADY_EXISTS);
79 /* Mutex for the global ID mask */
81 status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES);
82 if (ACPI_FAILURE(status)) {
83 return_ACPI_STATUS(status);
86 /* Find a free owner ID */
88 for (i = 0; i < 32; i++) {
89 if (!(acpi_gbl_owner_id_mask & (1 << i))) {
90 ACPI_DEBUG_PRINT((ACPI_DB_VALUES,
91 "Current owner_id mask: %8.8X New ID: %2.2X\n",
92 acpi_gbl_owner_id_mask,
93 (unsigned int)(i + 1)));
95 acpi_gbl_owner_id_mask |= (1 << i);
96 *owner_id = (acpi_owner_id) (i + 1);
97 goto exit;
102 * If we are here, all owner_ids have been allocated. This probably should
103 * not happen since the IDs are reused after deallocation. The IDs are
104 * allocated upon table load (one per table) and method execution, and
105 * they are released when a table is unloaded or a method completes
106 * execution.
108 *owner_id = 0;
109 status = AE_OWNER_ID_LIMIT;
110 ACPI_REPORT_ERROR(("Could not allocate new owner_id (32 max), AE_OWNER_ID_LIMIT\n"));
112 exit:
113 (void)acpi_ut_release_mutex(ACPI_MTX_CACHES);
114 return_ACPI_STATUS(status);
117 /*******************************************************************************
119 * FUNCTION: acpi_ut_release_owner_id
121 * PARAMETERS: owner_id_ptr - Pointer to a previously allocated owner_iD
123 * RETURN: None. No error is returned because we are either exiting a
124 * control method or unloading a table. Either way, we would
125 * ignore any error anyway.
127 * DESCRIPTION: Release a table or method owner ID. Valid IDs are 1 - 32
129 ******************************************************************************/
131 void acpi_ut_release_owner_id(acpi_owner_id * owner_id_ptr)
133 acpi_owner_id owner_id = *owner_id_ptr;
134 acpi_status status;
136 ACPI_FUNCTION_TRACE_U32("ut_release_owner_id", owner_id);
138 /* Always clear the input owner_id (zero is an invalid ID) */
140 *owner_id_ptr = 0;
142 /* Zero is not a valid owner_iD */
144 if ((owner_id == 0) || (owner_id > 32)) {
145 ACPI_REPORT_ERROR(("Invalid owner_id: %2.2X\n", owner_id));
146 return_VOID;
149 /* Mutex for the global ID mask */
151 status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES);
152 if (ACPI_FAILURE(status)) {
153 return_VOID;
156 /* Normalize the ID to zero */
158 owner_id--;
160 /* Free the owner ID only if it is valid */
162 if (acpi_gbl_owner_id_mask & (1 << owner_id)) {
163 acpi_gbl_owner_id_mask ^= (1 << owner_id);
166 (void)acpi_ut_release_mutex(ACPI_MTX_CACHES);
167 return_VOID;
170 /*******************************************************************************
172 * FUNCTION: acpi_ut_strupr (strupr)
174 * PARAMETERS: src_string - The source string to convert
176 * RETURN: None
178 * DESCRIPTION: Convert string to uppercase
180 * NOTE: This is not a POSIX function, so it appears here, not in utclib.c
182 ******************************************************************************/
184 void acpi_ut_strupr(char *src_string)
186 char *string;
188 ACPI_FUNCTION_ENTRY();
190 if (!src_string) {
191 return;
194 /* Walk entire string, uppercasing the letters */
196 for (string = src_string; *string; string++) {
197 *string = (char)ACPI_TOUPPER(*string);
200 return;
203 /*******************************************************************************
205 * FUNCTION: acpi_ut_print_string
207 * PARAMETERS: String - Null terminated ASCII string
208 * max_length - Maximum output length
210 * RETURN: None
212 * DESCRIPTION: Dump an ASCII string with support for ACPI-defined escape
213 * sequences.
215 ******************************************************************************/
217 void acpi_ut_print_string(char *string, u8 max_length)
219 u32 i;
221 if (!string) {
222 acpi_os_printf("<\"NULL STRING PTR\">");
223 return;
226 acpi_os_printf("\"");
227 for (i = 0; string[i] && (i < max_length); i++) {
228 /* Escape sequences */
230 switch (string[i]) {
231 case 0x07:
232 acpi_os_printf("\\a"); /* BELL */
233 break;
235 case 0x08:
236 acpi_os_printf("\\b"); /* BACKSPACE */
237 break;
239 case 0x0C:
240 acpi_os_printf("\\f"); /* FORMFEED */
241 break;
243 case 0x0A:
244 acpi_os_printf("\\n"); /* LINEFEED */
245 break;
247 case 0x0D:
248 acpi_os_printf("\\r"); /* CARRIAGE RETURN */
249 break;
251 case 0x09:
252 acpi_os_printf("\\t"); /* HORIZONTAL TAB */
253 break;
255 case 0x0B:
256 acpi_os_printf("\\v"); /* VERTICAL TAB */
257 break;
259 case '\'': /* Single Quote */
260 case '\"': /* Double Quote */
261 case '\\': /* Backslash */
262 acpi_os_printf("\\%c", (int)string[i]);
263 break;
265 default:
267 /* Check for printable character or hex escape */
269 if (ACPI_IS_PRINT(string[i])) {
270 /* This is a normal character */
272 acpi_os_printf("%c", (int)string[i]);
273 } else {
274 /* All others will be Hex escapes */
276 acpi_os_printf("\\x%2.2X", (s32) string[i]);
278 break;
281 acpi_os_printf("\"");
283 if (i == max_length && string[i]) {
284 acpi_os_printf("...");
288 /*******************************************************************************
290 * FUNCTION: acpi_ut_dword_byte_swap
292 * PARAMETERS: Value - Value to be converted
294 * RETURN: u32 integer with bytes swapped
296 * DESCRIPTION: Convert a 32-bit value to big-endian (swap the bytes)
298 ******************************************************************************/
300 u32 acpi_ut_dword_byte_swap(u32 value)
302 union {
303 u32 value;
304 u8 bytes[4];
305 } out;
306 union {
307 u32 value;
308 u8 bytes[4];
309 } in;
311 ACPI_FUNCTION_ENTRY();
313 in.value = value;
315 out.bytes[0] = in.bytes[3];
316 out.bytes[1] = in.bytes[2];
317 out.bytes[2] = in.bytes[1];
318 out.bytes[3] = in.bytes[0];
320 return (out.value);
323 /*******************************************************************************
325 * FUNCTION: acpi_ut_set_integer_width
327 * PARAMETERS: Revision From DSDT header
329 * RETURN: None
331 * DESCRIPTION: Set the global integer bit width based upon the revision
332 * of the DSDT. For Revision 1 and 0, Integers are 32 bits.
333 * For Revision 2 and above, Integers are 64 bits. Yes, this
334 * makes a difference.
336 ******************************************************************************/
338 void acpi_ut_set_integer_width(u8 revision)
341 if (revision <= 1) {
342 acpi_gbl_integer_bit_width = 32;
343 acpi_gbl_integer_nybble_width = 8;
344 acpi_gbl_integer_byte_width = 4;
345 } else {
346 acpi_gbl_integer_bit_width = 64;
347 acpi_gbl_integer_nybble_width = 16;
348 acpi_gbl_integer_byte_width = 8;
352 #ifdef ACPI_DEBUG_OUTPUT
353 /*******************************************************************************
355 * FUNCTION: acpi_ut_display_init_pathname
357 * PARAMETERS: Type - Object type of the node
358 * obj_handle - Handle whose pathname will be displayed
359 * Path - Additional path string to be appended.
360 * (NULL if no extra path)
362 * RETURN: acpi_status
364 * DESCRIPTION: Display full pathname of an object, DEBUG ONLY
366 ******************************************************************************/
368 void
369 acpi_ut_display_init_pathname(u8 type,
370 struct acpi_namespace_node *obj_handle,
371 char *path)
373 acpi_status status;
374 struct acpi_buffer buffer;
376 ACPI_FUNCTION_ENTRY();
378 /* Only print the path if the appropriate debug level is enabled */
380 if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) {
381 return;
384 /* Get the full pathname to the node */
386 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
387 status = acpi_ns_handle_to_pathname(obj_handle, &buffer);
388 if (ACPI_FAILURE(status)) {
389 return;
392 /* Print what we're doing */
394 switch (type) {
395 case ACPI_TYPE_METHOD:
396 acpi_os_printf("Executing ");
397 break;
399 default:
400 acpi_os_printf("Initializing ");
401 break;
404 /* Print the object type and pathname */
406 acpi_os_printf("%-12s %s",
407 acpi_ut_get_type_name(type), (char *)buffer.pointer);
409 /* Extra path is used to append names like _STA, _INI, etc. */
411 if (path) {
412 acpi_os_printf(".%s", path);
414 acpi_os_printf("\n");
416 ACPI_MEM_FREE(buffer.pointer);
418 #endif
420 /*******************************************************************************
422 * FUNCTION: acpi_ut_valid_acpi_name
424 * PARAMETERS: Name - The name to be examined
426 * RETURN: TRUE if the name is valid, FALSE otherwise
428 * DESCRIPTION: Check for a valid ACPI name. Each character must be one of:
429 * 1) Upper case alpha
430 * 2) numeric
431 * 3) underscore
433 ******************************************************************************/
435 u8 acpi_ut_valid_acpi_name(u32 name)
437 char *name_ptr = (char *)&name;
438 char character;
439 acpi_native_uint i;
441 ACPI_FUNCTION_ENTRY();
443 for (i = 0; i < ACPI_NAME_SIZE; i++) {
444 character = *name_ptr;
445 name_ptr++;
447 if (!((character == '_') ||
448 (character >= 'A' && character <= 'Z') ||
449 (character >= '0' && character <= '9'))) {
450 return (FALSE);
454 return (TRUE);
457 /*******************************************************************************
459 * FUNCTION: acpi_ut_valid_acpi_character
461 * PARAMETERS: Character - The character to be examined
463 * RETURN: 1 if Character may appear in a name, else 0
465 * DESCRIPTION: Check for a printable character
467 ******************************************************************************/
469 u8 acpi_ut_valid_acpi_character(char character)
472 ACPI_FUNCTION_ENTRY();
474 return ((u8) ((character == '_') ||
475 (character >= 'A' && character <= 'Z') ||
476 (character >= '0' && character <= '9')));
479 /*******************************************************************************
481 * FUNCTION: acpi_ut_strtoul64
483 * PARAMETERS: String - Null terminated string
484 * Base - Radix of the string: 10, 16, or ACPI_ANY_BASE
485 * ret_integer - Where the converted integer is returned
487 * RETURN: Status and Converted value
489 * DESCRIPTION: Convert a string into an unsigned value.
490 * NOTE: Does not support Octal strings, not needed.
492 ******************************************************************************/
494 acpi_status
495 acpi_ut_strtoul64(char *string, u32 base, acpi_integer * ret_integer)
497 u32 this_digit = 0;
498 acpi_integer return_value = 0;
499 acpi_integer quotient;
501 ACPI_FUNCTION_TRACE("ut_stroul64");
503 if ((!string) || !(*string)) {
504 goto error_exit;
507 switch (base) {
508 case ACPI_ANY_BASE:
509 case 10:
510 case 16:
511 break;
513 default:
514 /* Invalid Base */
515 return_ACPI_STATUS(AE_BAD_PARAMETER);
518 /* Skip over any white space in the buffer */
520 while (ACPI_IS_SPACE(*string) || *string == '\t') {
521 string++;
525 * If the input parameter Base is zero, then we need to
526 * determine if it is decimal or hexadecimal:
528 if (base == 0) {
529 if ((*string == '0') && (ACPI_TOLOWER(*(string + 1)) == 'x')) {
530 base = 16;
531 string += 2;
532 } else {
533 base = 10;
538 * For hexadecimal base, skip over the leading
539 * 0 or 0x, if they are present.
541 if ((base == 16) &&
542 (*string == '0') && (ACPI_TOLOWER(*(string + 1)) == 'x')) {
543 string += 2;
546 /* Any string left? */
548 if (!(*string)) {
549 goto error_exit;
552 /* Main loop: convert the string to a 64-bit integer */
554 while (*string) {
555 if (ACPI_IS_DIGIT(*string)) {
556 /* Convert ASCII 0-9 to Decimal value */
558 this_digit = ((u8) * string) - '0';
559 } else {
560 if (base == 10) {
561 /* Digit is out of range */
563 goto error_exit;
566 this_digit = (u8) ACPI_TOUPPER(*string);
567 if (ACPI_IS_XDIGIT((char)this_digit)) {
568 /* Convert ASCII Hex char to value */
570 this_digit = this_digit - 'A' + 10;
571 } else {
573 * We allow non-hex chars, just stop now, same as end-of-string.
574 * See ACPI spec, string-to-integer conversion.
576 break;
580 /* Divide the digit into the correct position */
582 (void)
583 acpi_ut_short_divide((ACPI_INTEGER_MAX -
584 (acpi_integer) this_digit), base,
585 &quotient, NULL);
586 if (return_value > quotient) {
587 goto error_exit;
590 return_value *= base;
591 return_value += this_digit;
592 string++;
595 /* All done, normal exit */
597 *ret_integer = return_value;
598 return_ACPI_STATUS(AE_OK);
600 error_exit:
601 /* Base was set/validated above */
603 if (base == 10) {
604 return_ACPI_STATUS(AE_BAD_DECIMAL_CONSTANT);
605 } else {
606 return_ACPI_STATUS(AE_BAD_HEX_CONSTANT);
610 /*******************************************************************************
612 * FUNCTION: acpi_ut_create_update_state_and_push
614 * PARAMETERS: Object - Object to be added to the new state
615 * Action - Increment/Decrement
616 * state_list - List the state will be added to
618 * RETURN: Status
620 * DESCRIPTION: Create a new state and push it
622 ******************************************************************************/
624 acpi_status
625 acpi_ut_create_update_state_and_push(union acpi_operand_object *object,
626 u16 action,
627 union acpi_generic_state **state_list)
629 union acpi_generic_state *state;
631 ACPI_FUNCTION_ENTRY();
633 /* Ignore null objects; these are expected */
635 if (!object) {
636 return (AE_OK);
639 state = acpi_ut_create_update_state(object, action);
640 if (!state) {
641 return (AE_NO_MEMORY);
644 acpi_ut_push_generic_state(state_list, state);
645 return (AE_OK);
648 /*******************************************************************************
650 * FUNCTION: acpi_ut_walk_package_tree
652 * PARAMETERS: source_object - The package to walk
653 * target_object - Target object (if package is being copied)
654 * walk_callback - Called once for each package element
655 * Context - Passed to the callback function
657 * RETURN: Status
659 * DESCRIPTION: Walk through a package
661 ******************************************************************************/
663 acpi_status
664 acpi_ut_walk_package_tree(union acpi_operand_object * source_object,
665 void *target_object,
666 acpi_pkg_callback walk_callback, void *context)
668 acpi_status status = AE_OK;
669 union acpi_generic_state *state_list = NULL;
670 union acpi_generic_state *state;
671 u32 this_index;
672 union acpi_operand_object *this_source_obj;
674 ACPI_FUNCTION_TRACE("ut_walk_package_tree");
676 state = acpi_ut_create_pkg_state(source_object, target_object, 0);
677 if (!state) {
678 return_ACPI_STATUS(AE_NO_MEMORY);
681 while (state) {
682 /* Get one element of the package */
684 this_index = state->pkg.index;
685 this_source_obj = (union acpi_operand_object *)
686 state->pkg.source_object->package.elements[this_index];
689 * Check for:
690 * 1) An uninitialized package element. It is completely
691 * legal to declare a package and leave it uninitialized
692 * 2) Not an internal object - can be a namespace node instead
693 * 3) Any type other than a package. Packages are handled in else
694 * case below.
696 if ((!this_source_obj) ||
697 (ACPI_GET_DESCRIPTOR_TYPE(this_source_obj) !=
698 ACPI_DESC_TYPE_OPERAND)
699 || (ACPI_GET_OBJECT_TYPE(this_source_obj) !=
700 ACPI_TYPE_PACKAGE)) {
701 status =
702 walk_callback(ACPI_COPY_TYPE_SIMPLE,
703 this_source_obj, state, context);
704 if (ACPI_FAILURE(status)) {
705 return_ACPI_STATUS(status);
708 state->pkg.index++;
709 while (state->pkg.index >=
710 state->pkg.source_object->package.count) {
712 * We've handled all of the objects at this level, This means
713 * that we have just completed a package. That package may
714 * have contained one or more packages itself.
716 * Delete this state and pop the previous state (package).
718 acpi_ut_delete_generic_state(state);
719 state = acpi_ut_pop_generic_state(&state_list);
721 /* Finished when there are no more states */
723 if (!state) {
725 * We have handled all of the objects in the top level
726 * package just add the length of the package objects
727 * and exit
729 return_ACPI_STATUS(AE_OK);
733 * Go back up a level and move the index past the just
734 * completed package object.
736 state->pkg.index++;
738 } else {
739 /* This is a subobject of type package */
741 status =
742 walk_callback(ACPI_COPY_TYPE_PACKAGE,
743 this_source_obj, state, context);
744 if (ACPI_FAILURE(status)) {
745 return_ACPI_STATUS(status);
749 * Push the current state and create a new one
750 * The callback above returned a new target package object.
752 acpi_ut_push_generic_state(&state_list, state);
753 state = acpi_ut_create_pkg_state(this_source_obj,
754 state->pkg.
755 this_target_obj, 0);
756 if (!state) {
757 return_ACPI_STATUS(AE_NO_MEMORY);
762 /* We should never get here */
764 return_ACPI_STATUS(AE_AML_INTERNAL);
767 /*******************************************************************************
769 * FUNCTION: acpi_ut_generate_checksum
771 * PARAMETERS: Buffer - Buffer to be scanned
772 * Length - number of bytes to examine
774 * RETURN: The generated checksum
776 * DESCRIPTION: Generate a checksum on a raw buffer
778 ******************************************************************************/
780 u8 acpi_ut_generate_checksum(u8 * buffer, u32 length)
782 u32 i;
783 signed char sum = 0;
785 for (i = 0; i < length; i++) {
786 sum = (signed char)(sum + buffer[i]);
789 return ((u8) (0 - sum));
792 /*******************************************************************************
794 * FUNCTION: acpi_ut_get_resource_type
796 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
798 * RETURN: The Resource Type with no extraneous bits (except the
799 * Large/Small descriptor bit -- this is left alone)
801 * DESCRIPTION: Extract the Resource Type/Name from the first byte of
802 * a resource descriptor.
804 ******************************************************************************/
806 u8 acpi_ut_get_resource_type(void *aml)
808 ACPI_FUNCTION_ENTRY();
811 * Byte 0 contains the descriptor name (Resource Type)
812 * Determine if this is a small or large resource
814 if (*((u8 *) aml) & ACPI_RESOURCE_NAME_LARGE) {
815 /* Large Resource Type -- bits 6:0 contain the name */
817 return (*((u8 *) aml));
818 } else {
819 /* Small Resource Type -- bits 6:3 contain the name */
821 return ((u8) (*((u8 *) aml) & ACPI_RESOURCE_NAME_SMALL_MASK));
825 /*******************************************************************************
827 * FUNCTION: acpi_ut_get_resource_length
829 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
831 * RETURN: Byte Length
833 * DESCRIPTION: Get the "Resource Length" of a raw AML descriptor. By
834 * definition, this does not include the size of the descriptor
835 * header or the length field itself.
837 ******************************************************************************/
839 u16 acpi_ut_get_resource_length(void *aml)
841 u16 resource_length;
843 ACPI_FUNCTION_ENTRY();
846 * Byte 0 contains the descriptor name (Resource Type)
847 * Determine if this is a small or large resource
849 if (*((u8 *) aml) & ACPI_RESOURCE_NAME_LARGE) {
850 /* Large Resource type -- bytes 1-2 contain the 16-bit length */
852 ACPI_MOVE_16_TO_16(&resource_length, &((u8 *) aml)[1]);
854 } else {
855 /* Small Resource type -- bits 2:0 of byte 0 contain the length */
857 resource_length = (u16) (*((u8 *) aml) &
858 ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK);
861 return (resource_length);
864 /*******************************************************************************
866 * FUNCTION: acpi_ut_get_descriptor_length
868 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
870 * RETURN: Byte length
872 * DESCRIPTION: Get the total byte length of a raw AML descriptor, including the
873 * length of the descriptor header and the length field itself.
874 * Used to walk descriptor lists.
876 ******************************************************************************/
878 u32 acpi_ut_get_descriptor_length(void *aml)
880 u32 descriptor_length;
882 ACPI_FUNCTION_ENTRY();
884 /* First get the Resource Length (Does not include header length) */
886 descriptor_length = acpi_ut_get_resource_length(aml);
888 /* Determine if this is a small or large resource */
890 if (*((u8 *) aml) & ACPI_RESOURCE_NAME_LARGE) {
891 descriptor_length += sizeof(struct aml_resource_large_header);
892 } else {
893 descriptor_length += sizeof(struct aml_resource_small_header);
896 return (descriptor_length);
899 /*******************************************************************************
901 * FUNCTION: acpi_ut_get_resource_end_tag
903 * PARAMETERS: obj_desc - The resource template buffer object
905 * RETURN: Pointer to the end tag
907 * DESCRIPTION: Find the END_TAG resource descriptor in an AML resource template
909 ******************************************************************************/
911 u8 *acpi_ut_get_resource_end_tag(union acpi_operand_object * obj_desc)
913 u8 *aml;
914 u8 *end_aml;
916 aml = obj_desc->buffer.pointer;
917 end_aml = aml + obj_desc->buffer.length;
919 /* Walk the resource template, one descriptor per loop */
921 while (aml < end_aml) {
922 if (acpi_ut_get_resource_type(aml) ==
923 ACPI_RESOURCE_NAME_END_TAG) {
924 /* Found the end_tag descriptor, all done */
926 return (aml);
929 /* Point to the next resource descriptor */
931 aml += acpi_ut_get_resource_length(aml);
934 /* End tag was not found */
936 return (NULL);
939 /*******************************************************************************
941 * FUNCTION: acpi_ut_report_error
943 * PARAMETERS: module_name - Caller's module name (for error output)
944 * line_number - Caller's line number (for error output)
945 * component_id - Caller's component ID (for error output)
947 * RETURN: None
949 * DESCRIPTION: Print error message
951 ******************************************************************************/
953 void acpi_ut_report_error(char *module_name, u32 line_number, u32 component_id)
956 acpi_os_printf("%8s-%04d: *** Error: ", module_name, line_number);
959 /*******************************************************************************
961 * FUNCTION: acpi_ut_report_warning
963 * PARAMETERS: module_name - Caller's module name (for error output)
964 * line_number - Caller's line number (for error output)
965 * component_id - Caller's component ID (for error output)
967 * RETURN: None
969 * DESCRIPTION: Print warning message
971 ******************************************************************************/
973 void
974 acpi_ut_report_warning(char *module_name, u32 line_number, u32 component_id)
977 acpi_os_printf("%8s-%04d: *** Warning: ", module_name, line_number);
980 /*******************************************************************************
982 * FUNCTION: acpi_ut_report_info
984 * PARAMETERS: module_name - Caller's module name (for error output)
985 * line_number - Caller's line number (for error output)
986 * component_id - Caller's component ID (for error output)
988 * RETURN: None
990 * DESCRIPTION: Print information message
992 ******************************************************************************/
994 void acpi_ut_report_info(char *module_name, u32 line_number, u32 component_id)
997 acpi_os_printf("%8s-%04d: *** Info: ", module_name, line_number);