[ACPI] ACPICA 20051117
[powerpc.git] / drivers / acpi / utilities / utmisc.c
1 /*******************************************************************************
2  *
3  * Module Name: utmisc - common utility procedures
4  *
5  ******************************************************************************/
6
7 /*
8  * Copyright (C) 2000 - 2005, R. Byron Moore
9  * All rights reserved.
10  *
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.
25  *
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.
29  *
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.
42  */
43
44 #include <acpi/acpi.h>
45 #include <acpi/acnamesp.h>
46
47 #define _COMPONENT          ACPI_UTILITIES
48 ACPI_MODULE_NAME("utmisc")
49
50 /*******************************************************************************
51  *
52  * FUNCTION:    acpi_ut_allocate_owner_id
53  *
54  * PARAMETERS:  owner_id        - Where the new owner ID is returned
55  *
56  * RETURN:      Status
57  *
58  * DESCRIPTION: Allocate a table or method owner ID. The owner ID is used to
59  *              track objects created by the table or method, to be deleted
60  *              when the method exits or the table is unloaded.
61  *
62  ******************************************************************************/
63 acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id)
64 {
65         acpi_native_uint i;
66         acpi_native_uint j;
67         acpi_status status;
68
69         ACPI_FUNCTION_TRACE("ut_allocate_owner_id");
70
71         /* Guard against multiple allocations of ID to the same location */
72
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);
77         }
78
79         /* Mutex for the global ID mask */
80
81         status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES);
82         if (ACPI_FAILURE(status)) {
83                 return_ACPI_STATUS(status);
84         }
85
86         /*
87          * Find a free owner ID, cycle through all possible IDs on repeated
88          * allocations. Note: Index for next possible ID is equal to the value
89          * of the last allocated ID.
90          */
91         for (i = 0, j = acpi_gbl_last_owner_id; i < 32; i++, j++) {
92                 if (j >= 32) {
93                         j = 0;  /* Wraparound to ID start */
94                 }
95
96                 if (!(acpi_gbl_owner_id_mask & (1 << j))) {
97                         /*
98                          * Found a free ID. The actual ID is the bit index plus one,
99                          * making zero an invalid Owner ID. Save this as the last ID
100                          * allocated and update the global ID mask.
101                          */
102                         acpi_gbl_last_owner_id = (acpi_owner_id) (j + 1);
103                         *owner_id = acpi_gbl_last_owner_id;
104
105                         ACPI_DEBUG_PRINT((ACPI_DB_VALUES,
106                                           "Current owner_id mask: %8.8X New ID: %2.2X\n",
107                                           acpi_gbl_owner_id_mask,
108                                           (unsigned int)
109                                           acpi_gbl_last_owner_id));
110
111                         acpi_gbl_owner_id_mask |= (1 << j);
112                         goto exit;
113                 }
114         }
115
116         /*
117          * All owner_ids have been allocated. This typically should
118          * not happen since the IDs are reused after deallocation. The IDs are
119          * allocated upon table load (one per table) and method execution, and
120          * they are released when a table is unloaded or a method completes
121          * execution.
122          *
123          * If this error happens, there may be very deep nesting of invoked control
124          * methods, or there may be a bug where the IDs are not released.
125          */
126         status = AE_OWNER_ID_LIMIT;
127         ACPI_REPORT_ERROR(("Could not allocate new owner_id (32 max), AE_OWNER_ID_LIMIT\n"));
128
129       exit:
130         (void)acpi_ut_release_mutex(ACPI_MTX_CACHES);
131         return_ACPI_STATUS(status);
132 }
133
134 /*******************************************************************************
135  *
136  * FUNCTION:    acpi_ut_release_owner_id
137  *
138  * PARAMETERS:  owner_id_ptr        - Pointer to a previously allocated owner_iD
139  *
140  * RETURN:      None. No error is returned because we are either exiting a
141  *              control method or unloading a table. Either way, we would
142  *              ignore any error anyway.
143  *
144  * DESCRIPTION: Release a table or method owner ID.  Valid IDs are 1 - 32
145  *
146  ******************************************************************************/
147
148 void acpi_ut_release_owner_id(acpi_owner_id * owner_id_ptr)
149 {
150         acpi_owner_id owner_id = *owner_id_ptr;
151         acpi_status status;
152
153         ACPI_FUNCTION_TRACE_U32("ut_release_owner_id", owner_id);
154
155         /* Always clear the input owner_id (zero is an invalid ID) */
156
157         *owner_id_ptr = 0;
158
159         /* Zero is not a valid owner_iD */
160
161         if ((owner_id == 0) || (owner_id > 32)) {
162                 ACPI_REPORT_ERROR(("Invalid owner_id: %2.2X\n", owner_id));
163                 return_VOID;
164         }
165
166         /* Mutex for the global ID mask */
167
168         status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES);
169         if (ACPI_FAILURE(status)) {
170                 return_VOID;
171         }
172
173         /* Normalize the ID to zero */
174
175         owner_id--;
176
177         /* Free the owner ID only if it is valid */
178
179         if (acpi_gbl_owner_id_mask & (1 << owner_id)) {
180                 acpi_gbl_owner_id_mask ^= (1 << owner_id);
181         }
182
183         (void)acpi_ut_release_mutex(ACPI_MTX_CACHES);
184         return_VOID;
185 }
186
187 /*******************************************************************************
188  *
189  * FUNCTION:    acpi_ut_strupr (strupr)
190  *
191  * PARAMETERS:  src_string      - The source string to convert
192  *
193  * RETURN:      None
194  *
195  * DESCRIPTION: Convert string to uppercase
196  *
197  * NOTE: This is not a POSIX function, so it appears here, not in utclib.c
198  *
199  ******************************************************************************/
200
201 void acpi_ut_strupr(char *src_string)
202 {
203         char *string;
204
205         ACPI_FUNCTION_ENTRY();
206
207         if (!src_string) {
208                 return;
209         }
210
211         /* Walk entire string, uppercasing the letters */
212
213         for (string = src_string; *string; string++) {
214                 *string = (char)ACPI_TOUPPER(*string);
215         }
216
217         return;
218 }
219
220 /*******************************************************************************
221  *
222  * FUNCTION:    acpi_ut_print_string
223  *
224  * PARAMETERS:  String          - Null terminated ASCII string
225  *              max_length      - Maximum output length
226  *
227  * RETURN:      None
228  *
229  * DESCRIPTION: Dump an ASCII string with support for ACPI-defined escape
230  *              sequences.
231  *
232  ******************************************************************************/
233
234 void acpi_ut_print_string(char *string, u8 max_length)
235 {
236         u32 i;
237
238         if (!string) {
239                 acpi_os_printf("<\"NULL STRING PTR\">");
240                 return;
241         }
242
243         acpi_os_printf("\"");
244         for (i = 0; string[i] && (i < max_length); i++) {
245                 /* Escape sequences */
246
247                 switch (string[i]) {
248                 case 0x07:
249                         acpi_os_printf("\\a");  /* BELL */
250                         break;
251
252                 case 0x08:
253                         acpi_os_printf("\\b");  /* BACKSPACE */
254                         break;
255
256                 case 0x0C:
257                         acpi_os_printf("\\f");  /* FORMFEED */
258                         break;
259
260                 case 0x0A:
261                         acpi_os_printf("\\n");  /* LINEFEED */
262                         break;
263
264                 case 0x0D:
265                         acpi_os_printf("\\r");  /* CARRIAGE RETURN */
266                         break;
267
268                 case 0x09:
269                         acpi_os_printf("\\t");  /* HORIZONTAL TAB */
270                         break;
271
272                 case 0x0B:
273                         acpi_os_printf("\\v");  /* VERTICAL TAB */
274                         break;
275
276                 case '\'':      /* Single Quote */
277                 case '\"':      /* Double Quote */
278                 case '\\':      /* Backslash */
279                         acpi_os_printf("\\%c", (int)string[i]);
280                         break;
281
282                 default:
283
284                         /* Check for printable character or hex escape */
285
286                         if (ACPI_IS_PRINT(string[i])) {
287                                 /* This is a normal character */
288
289                                 acpi_os_printf("%c", (int)string[i]);
290                         } else {
291                                 /* All others will be Hex escapes */
292
293                                 acpi_os_printf("\\x%2.2X", (s32) string[i]);
294                         }
295                         break;
296                 }
297         }
298         acpi_os_printf("\"");
299
300         if (i == max_length && string[i]) {
301                 acpi_os_printf("...");
302         }
303 }
304
305 /*******************************************************************************
306  *
307  * FUNCTION:    acpi_ut_dword_byte_swap
308  *
309  * PARAMETERS:  Value           - Value to be converted
310  *
311  * RETURN:      u32 integer with bytes swapped
312  *
313  * DESCRIPTION: Convert a 32-bit value to big-endian (swap the bytes)
314  *
315  ******************************************************************************/
316
317 u32 acpi_ut_dword_byte_swap(u32 value)
318 {
319         union {
320                 u32 value;
321                 u8 bytes[4];
322         } out;
323         union {
324                 u32 value;
325                 u8 bytes[4];
326         } in;
327
328         ACPI_FUNCTION_ENTRY();
329
330         in.value = value;
331
332         out.bytes[0] = in.bytes[3];
333         out.bytes[1] = in.bytes[2];
334         out.bytes[2] = in.bytes[1];
335         out.bytes[3] = in.bytes[0];
336
337         return (out.value);
338 }
339
340 /*******************************************************************************
341  *
342  * FUNCTION:    acpi_ut_set_integer_width
343  *
344  * PARAMETERS:  Revision            From DSDT header
345  *
346  * RETURN:      None
347  *
348  * DESCRIPTION: Set the global integer bit width based upon the revision
349  *              of the DSDT.  For Revision 1 and 0, Integers are 32 bits.
350  *              For Revision 2 and above, Integers are 64 bits.  Yes, this
351  *              makes a difference.
352  *
353  ******************************************************************************/
354
355 void acpi_ut_set_integer_width(u8 revision)
356 {
357
358         if (revision <= 1) {
359                 acpi_gbl_integer_bit_width = 32;
360                 acpi_gbl_integer_nybble_width = 8;
361                 acpi_gbl_integer_byte_width = 4;
362         } else {
363                 acpi_gbl_integer_bit_width = 64;
364                 acpi_gbl_integer_nybble_width = 16;
365                 acpi_gbl_integer_byte_width = 8;
366         }
367 }
368
369 #ifdef ACPI_DEBUG_OUTPUT
370 /*******************************************************************************
371  *
372  * FUNCTION:    acpi_ut_display_init_pathname
373  *
374  * PARAMETERS:  Type                - Object type of the node
375  *              obj_handle          - Handle whose pathname will be displayed
376  *              Path                - Additional path string to be appended.
377  *                                      (NULL if no extra path)
378  *
379  * RETURN:      acpi_status
380  *
381  * DESCRIPTION: Display full pathname of an object, DEBUG ONLY
382  *
383  ******************************************************************************/
384
385 void
386 acpi_ut_display_init_pathname(u8 type,
387                               struct acpi_namespace_node *obj_handle,
388                               char *path)
389 {
390         acpi_status status;
391         struct acpi_buffer buffer;
392
393         ACPI_FUNCTION_ENTRY();
394
395         /* Only print the path if the appropriate debug level is enabled */
396
397         if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) {
398                 return;
399         }
400
401         /* Get the full pathname to the node */
402
403         buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
404         status = acpi_ns_handle_to_pathname(obj_handle, &buffer);
405         if (ACPI_FAILURE(status)) {
406                 return;
407         }
408
409         /* Print what we're doing */
410
411         switch (type) {
412         case ACPI_TYPE_METHOD:
413                 acpi_os_printf("Executing  ");
414                 break;
415
416         default:
417                 acpi_os_printf("Initializing ");
418                 break;
419         }
420
421         /* Print the object type and pathname */
422
423         acpi_os_printf("%-12s %s",
424                        acpi_ut_get_type_name(type), (char *)buffer.pointer);
425
426         /* Extra path is used to append names like _STA, _INI, etc. */
427
428         if (path) {
429                 acpi_os_printf(".%s", path);
430         }
431         acpi_os_printf("\n");
432
433         ACPI_MEM_FREE(buffer.pointer);
434 }
435 #endif
436
437 /*******************************************************************************
438  *
439  * FUNCTION:    acpi_ut_valid_acpi_name
440  *
441  * PARAMETERS:  Name            - The name to be examined
442  *
443  * RETURN:      TRUE if the name is valid, FALSE otherwise
444  *
445  * DESCRIPTION: Check for a valid ACPI name.  Each character must be one of:
446  *              1) Upper case alpha
447  *              2) numeric
448  *              3) underscore
449  *
450  ******************************************************************************/
451
452 u8 acpi_ut_valid_acpi_name(u32 name)
453 {
454         char *name_ptr = (char *)&name;
455         char character;
456         acpi_native_uint i;
457
458         ACPI_FUNCTION_ENTRY();
459
460         for (i = 0; i < ACPI_NAME_SIZE; i++) {
461                 character = *name_ptr;
462                 name_ptr++;
463
464                 if (!((character == '_') ||
465                       (character >= 'A' && character <= 'Z') ||
466                       (character >= '0' && character <= '9'))) {
467                         return (FALSE);
468                 }
469         }
470
471         return (TRUE);
472 }
473
474 /*******************************************************************************
475  *
476  * FUNCTION:    acpi_ut_valid_acpi_character
477  *
478  * PARAMETERS:  Character           - The character to be examined
479  *
480  * RETURN:      1 if Character may appear in a name, else 0
481  *
482  * DESCRIPTION: Check for a printable character
483  *
484  ******************************************************************************/
485
486 u8 acpi_ut_valid_acpi_character(char character)
487 {
488
489         ACPI_FUNCTION_ENTRY();
490
491         return ((u8) ((character == '_') ||
492                       (character >= 'A' && character <= 'Z') ||
493                       (character >= '0' && character <= '9')));
494 }
495
496 /*******************************************************************************
497  *
498  * FUNCTION:    acpi_ut_strtoul64
499  *
500  * PARAMETERS:  String          - Null terminated string
501  *              Base            - Radix of the string: 10, 16, or ACPI_ANY_BASE
502  *              ret_integer     - Where the converted integer is returned
503  *
504  * RETURN:      Status and Converted value
505  *
506  * DESCRIPTION: Convert a string into an unsigned value.
507  *              NOTE: Does not support Octal strings, not needed.
508  *
509  ******************************************************************************/
510
511 acpi_status
512 acpi_ut_strtoul64(char *string, u32 base, acpi_integer * ret_integer)
513 {
514         u32 this_digit = 0;
515         acpi_integer return_value = 0;
516         acpi_integer quotient;
517
518         ACPI_FUNCTION_TRACE("ut_stroul64");
519
520         if ((!string) || !(*string)) {
521                 goto error_exit;
522         }
523
524         switch (base) {
525         case ACPI_ANY_BASE:
526         case 10:
527         case 16:
528                 break;
529
530         default:
531                 /* Invalid Base */
532                 return_ACPI_STATUS(AE_BAD_PARAMETER);
533         }
534
535         /* Skip over any white space in the buffer */
536
537         while (ACPI_IS_SPACE(*string) || *string == '\t') {
538                 string++;
539         }
540
541         /*
542          * If the input parameter Base is zero, then we need to
543          * determine if it is decimal or hexadecimal:
544          */
545         if (base == 0) {
546                 if ((*string == '0') && (ACPI_TOLOWER(*(string + 1)) == 'x')) {
547                         base = 16;
548                         string += 2;
549                 } else {
550                         base = 10;
551                 }
552         }
553
554         /*
555          * For hexadecimal base, skip over the leading
556          * 0 or 0x, if they are present.
557          */
558         if ((base == 16) &&
559             (*string == '0') && (ACPI_TOLOWER(*(string + 1)) == 'x')) {
560                 string += 2;
561         }
562
563         /* Any string left? */
564
565         if (!(*string)) {
566                 goto error_exit;
567         }
568
569         /* Main loop: convert the string to a 64-bit integer */
570
571         while (*string) {
572                 if (ACPI_IS_DIGIT(*string)) {
573                         /* Convert ASCII 0-9 to Decimal value */
574
575                         this_digit = ((u8) * string) - '0';
576                 } else {
577                         if (base == 10) {
578                                 /* Digit is out of range */
579
580                                 goto error_exit;
581                         }
582
583                         this_digit = (u8) ACPI_TOUPPER(*string);
584                         if (ACPI_IS_XDIGIT((char)this_digit)) {
585                                 /* Convert ASCII Hex char to value */
586
587                                 this_digit = this_digit - 'A' + 10;
588                         } else {
589                                 /*
590                                  * We allow non-hex chars, just stop now, same as end-of-string.
591                                  * See ACPI spec, string-to-integer conversion.
592                                  */
593                                 break;
594                         }
595                 }
596
597                 /* Divide the digit into the correct position */
598
599                 (void)
600                     acpi_ut_short_divide((ACPI_INTEGER_MAX -
601                                           (acpi_integer) this_digit), base,
602                                          &quotient, NULL);
603                 if (return_value > quotient) {
604                         goto error_exit;
605                 }
606
607                 return_value *= base;
608                 return_value += this_digit;
609                 string++;
610         }
611
612         /* All done, normal exit */
613
614         *ret_integer = return_value;
615         return_ACPI_STATUS(AE_OK);
616
617       error_exit:
618         /* Base was set/validated above */
619
620         if (base == 10) {
621                 return_ACPI_STATUS(AE_BAD_DECIMAL_CONSTANT);
622         } else {
623                 return_ACPI_STATUS(AE_BAD_HEX_CONSTANT);
624         }
625 }
626
627 /*******************************************************************************
628  *
629  * FUNCTION:    acpi_ut_create_update_state_and_push
630  *
631  * PARAMETERS:  Object          - Object to be added to the new state
632  *              Action          - Increment/Decrement
633  *              state_list      - List the state will be added to
634  *
635  * RETURN:      Status
636  *
637  * DESCRIPTION: Create a new state and push it
638  *
639  ******************************************************************************/
640
641 acpi_status
642 acpi_ut_create_update_state_and_push(union acpi_operand_object *object,
643                                      u16 action,
644                                      union acpi_generic_state **state_list)
645 {
646         union acpi_generic_state *state;
647
648         ACPI_FUNCTION_ENTRY();
649
650         /* Ignore null objects; these are expected */
651
652         if (!object) {
653                 return (AE_OK);
654         }
655
656         state = acpi_ut_create_update_state(object, action);
657         if (!state) {
658                 return (AE_NO_MEMORY);
659         }
660
661         acpi_ut_push_generic_state(state_list, state);
662         return (AE_OK);
663 }
664
665 /*******************************************************************************
666  *
667  * FUNCTION:    acpi_ut_walk_package_tree
668  *
669  * PARAMETERS:  source_object       - The package to walk
670  *              target_object       - Target object (if package is being copied)
671  *              walk_callback       - Called once for each package element
672  *              Context             - Passed to the callback function
673  *
674  * RETURN:      Status
675  *
676  * DESCRIPTION: Walk through a package
677  *
678  ******************************************************************************/
679
680 acpi_status
681 acpi_ut_walk_package_tree(union acpi_operand_object * source_object,
682                           void *target_object,
683                           acpi_pkg_callback walk_callback, void *context)
684 {
685         acpi_status status = AE_OK;
686         union acpi_generic_state *state_list = NULL;
687         union acpi_generic_state *state;
688         u32 this_index;
689         union acpi_operand_object *this_source_obj;
690
691         ACPI_FUNCTION_TRACE("ut_walk_package_tree");
692
693         state = acpi_ut_create_pkg_state(source_object, target_object, 0);
694         if (!state) {
695                 return_ACPI_STATUS(AE_NO_MEMORY);
696         }
697
698         while (state) {
699                 /* Get one element of the package */
700
701                 this_index = state->pkg.index;
702                 this_source_obj = (union acpi_operand_object *)
703                     state->pkg.source_object->package.elements[this_index];
704
705                 /*
706                  * Check for:
707                  * 1) An uninitialized package element.  It is completely
708                  *    legal to declare a package and leave it uninitialized
709                  * 2) Not an internal object - can be a namespace node instead
710                  * 3) Any type other than a package.  Packages are handled in else
711                  *    case below.
712                  */
713                 if ((!this_source_obj) ||
714                     (ACPI_GET_DESCRIPTOR_TYPE(this_source_obj) !=
715                      ACPI_DESC_TYPE_OPERAND)
716                     || (ACPI_GET_OBJECT_TYPE(this_source_obj) !=
717                         ACPI_TYPE_PACKAGE)) {
718                         status =
719                             walk_callback(ACPI_COPY_TYPE_SIMPLE,
720                                           this_source_obj, state, context);
721                         if (ACPI_FAILURE(status)) {
722                                 return_ACPI_STATUS(status);
723                         }
724
725                         state->pkg.index++;
726                         while (state->pkg.index >=
727                                state->pkg.source_object->package.count) {
728                                 /*
729                                  * We've handled all of the objects at this level,  This means
730                                  * that we have just completed a package.  That package may
731                                  * have contained one or more packages itself.
732                                  *
733                                  * Delete this state and pop the previous state (package).
734                                  */
735                                 acpi_ut_delete_generic_state(state);
736                                 state = acpi_ut_pop_generic_state(&state_list);
737
738                                 /* Finished when there are no more states */
739
740                                 if (!state) {
741                                         /*
742                                          * We have handled all of the objects in the top level
743                                          * package just add the length of the package objects
744                                          * and exit
745                                          */
746                                         return_ACPI_STATUS(AE_OK);
747                                 }
748
749                                 /*
750                                  * Go back up a level and move the index past the just
751                                  * completed package object.
752                                  */
753                                 state->pkg.index++;
754                         }
755                 } else {
756                         /* This is a subobject of type package */
757
758                         status =
759                             walk_callback(ACPI_COPY_TYPE_PACKAGE,
760                                           this_source_obj, state, context);
761                         if (ACPI_FAILURE(status)) {
762                                 return_ACPI_STATUS(status);
763                         }
764
765                         /*
766                          * Push the current state and create a new one
767                          * The callback above returned a new target package object.
768                          */
769                         acpi_ut_push_generic_state(&state_list, state);
770                         state = acpi_ut_create_pkg_state(this_source_obj,
771                                                          state->pkg.
772                                                          this_target_obj, 0);
773                         if (!state) {
774                                 return_ACPI_STATUS(AE_NO_MEMORY);
775                         }
776                 }
777         }
778
779         /* We should never get here */
780
781         return_ACPI_STATUS(AE_AML_INTERNAL);
782 }
783
784 /*******************************************************************************
785  *
786  * FUNCTION:    acpi_ut_generate_checksum
787  *
788  * PARAMETERS:  Buffer          - Buffer to be scanned
789  *              Length          - number of bytes to examine
790  *
791  * RETURN:      The generated checksum
792  *
793  * DESCRIPTION: Generate a checksum on a raw buffer
794  *
795  ******************************************************************************/
796
797 u8 acpi_ut_generate_checksum(u8 * buffer, u32 length)
798 {
799         u32 i;
800         signed char sum = 0;
801
802         for (i = 0; i < length; i++) {
803                 sum = (signed char)(sum + buffer[i]);
804         }
805
806         return ((u8) (0 - sum));
807 }
808
809 /*******************************************************************************
810  *
811  * FUNCTION:    acpi_ut_report_error
812  *
813  * PARAMETERS:  module_name         - Caller's module name (for error output)
814  *              line_number         - Caller's line number (for error output)
815  *              component_id        - Caller's component ID (for error output)
816  *
817  * RETURN:      None
818  *
819  * DESCRIPTION: Print error message
820  *
821  ******************************************************************************/
822
823 void acpi_ut_report_error(char *module_name, u32 line_number, u32 component_id)
824 {
825
826         acpi_os_printf("%8s-%04d: *** Error: ", module_name, line_number);
827 }
828
829 /*******************************************************************************
830  *
831  * FUNCTION:    acpi_ut_report_warning
832  *
833  * PARAMETERS:  module_name         - Caller's module name (for error output)
834  *              line_number         - Caller's line number (for error output)
835  *              component_id        - Caller's component ID (for error output)
836  *
837  * RETURN:      None
838  *
839  * DESCRIPTION: Print warning message
840  *
841  ******************************************************************************/
842
843 void
844 acpi_ut_report_warning(char *module_name, u32 line_number, u32 component_id)
845 {
846
847         acpi_os_printf("%8s-%04d: *** Warning: ", module_name, line_number);
848 }
849
850 /*******************************************************************************
851  *
852  * FUNCTION:    acpi_ut_report_info
853  *
854  * PARAMETERS:  module_name         - Caller's module name (for error output)
855  *              line_number         - Caller's line number (for error output)
856  *              component_id        - Caller's component ID (for error output)
857  *
858  * RETURN:      None
859  *
860  * DESCRIPTION: Print information message
861  *
862  ******************************************************************************/
863
864 void acpi_ut_report_info(char *module_name, u32 line_number, u32 component_id)
865 {
866
867         acpi_os_printf("%8s-%04d: *** Info: ", module_name, line_number);
868 }