Merge rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[linux-2.6/mini2440.git] / include / acpi / acutils.h
blob0de26b8f1028cf1ca7e52e7970247a8cacbaf9a0
1 /******************************************************************************
3 * Name: acutils.h -- prototypes for the common (subsystem-wide) 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 #ifndef _ACUTILS_H
45 #define _ACUTILS_H
48 typedef
49 acpi_status (*acpi_pkg_callback) (
50 u8 object_type,
51 union acpi_operand_object *source_object,
52 union acpi_generic_state *state,
53 void *context);
55 acpi_status
56 acpi_ut_walk_package_tree (
57 union acpi_operand_object *source_object,
58 void *target_object,
59 acpi_pkg_callback walk_callback,
60 void *context);
62 struct acpi_pkg_info
64 u8 *free_space;
65 acpi_size length;
66 u32 object_space;
67 u32 num_packages;
70 #define REF_INCREMENT (u16) 0
71 #define REF_DECREMENT (u16) 1
72 #define REF_FORCE_DELETE (u16) 2
74 /* acpi_ut_dump_buffer */
76 #define DB_BYTE_DISPLAY 1
77 #define DB_WORD_DISPLAY 2
78 #define DB_DWORD_DISPLAY 4
79 #define DB_QWORD_DISPLAY 8
82 /* Global initialization interfaces */
84 void
85 acpi_ut_init_globals (
86 void);
88 void
89 acpi_ut_terminate (
90 void);
94 * ut_init - miscellaneous initialization and shutdown
97 acpi_status
98 acpi_ut_hardware_initialize (
99 void);
101 void
102 acpi_ut_subsystem_shutdown (
103 void);
105 acpi_status
106 acpi_ut_validate_fadt (
107 void);
110 * ut_global - Global data structures and procedures
113 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
115 char *
116 acpi_ut_get_mutex_name (
117 u32 mutex_id);
119 #endif
121 char *
122 acpi_ut_get_type_name (
123 acpi_object_type type);
125 char *
126 acpi_ut_get_node_name (
127 void *object);
129 char *
130 acpi_ut_get_descriptor_name (
131 void *object);
133 char *
134 acpi_ut_get_object_type_name (
135 union acpi_operand_object *obj_desc);
137 char *
138 acpi_ut_get_region_name (
139 u8 space_id);
141 char *
142 acpi_ut_get_event_name (
143 u32 event_id);
145 char
146 acpi_ut_hex_to_ascii_char (
147 acpi_integer integer,
148 u32 position);
151 acpi_ut_valid_object_type (
152 acpi_object_type type);
154 acpi_owner_id
155 acpi_ut_allocate_owner_id (
156 u32 id_type);
160 * ut_clib - Local implementations of C library functions
163 #ifndef ACPI_USE_SYSTEM_CLIBRARY
165 acpi_size
166 acpi_ut_strlen (
167 const char *string);
169 char *
170 acpi_ut_strcpy (
171 char *dst_string,
172 const char *src_string);
174 char *
175 acpi_ut_strncpy (
176 char *dst_string,
177 const char *src_string,
178 acpi_size count);
181 acpi_ut_memcmp (
182 const char *buffer1,
183 const char *buffer2,
184 acpi_size count);
187 acpi_ut_strncmp (
188 const char *string1,
189 const char *string2,
190 acpi_size count);
193 acpi_ut_strcmp (
194 const char *string1,
195 const char *string2);
197 char *
198 acpi_ut_strcat (
199 char *dst_string,
200 const char *src_string);
202 char *
203 acpi_ut_strncat (
204 char *dst_string,
205 const char *src_string,
206 acpi_size count);
209 acpi_ut_strtoul (
210 const char *string,
211 char **terminator,
212 u32 base);
214 char *
215 acpi_ut_strstr (
216 char *string1,
217 char *string2);
219 void *
220 acpi_ut_memcpy (
221 void *dest,
222 const void *src,
223 acpi_size count);
225 void *
226 acpi_ut_memset (
227 void *dest,
228 acpi_native_uint value,
229 acpi_size count);
232 acpi_ut_to_upper (
233 int c);
236 acpi_ut_to_lower (
237 int c);
239 extern const u8 _acpi_ctype[];
241 #define _ACPI_XA 0x00 /* extra alphabetic - not supported */
242 #define _ACPI_XS 0x40 /* extra space */
243 #define _ACPI_BB 0x00 /* BEL, BS, etc. - not supported */
244 #define _ACPI_CN 0x20 /* CR, FF, HT, NL, VT */
245 #define _ACPI_DI 0x04 /* '0'-'9' */
246 #define _ACPI_LO 0x02 /* 'a'-'z' */
247 #define _ACPI_PU 0x10 /* punctuation */
248 #define _ACPI_SP 0x08 /* space */
249 #define _ACPI_UP 0x01 /* 'A'-'Z' */
250 #define _ACPI_XD 0x80 /* '0'-'9', 'A'-'F', 'a'-'f' */
252 #define ACPI_IS_DIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_DI))
253 #define ACPI_IS_SPACE(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_SP))
254 #define ACPI_IS_XDIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_XD))
255 #define ACPI_IS_UPPER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_UP))
256 #define ACPI_IS_LOWER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO))
257 #define ACPI_IS_PRINT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_SP | _ACPI_PU))
258 #define ACPI_IS_ALPHA(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP))
259 #define ACPI_IS_ASCII(c) ((c) < 0x80)
261 #endif /* ACPI_USE_SYSTEM_CLIBRARY */
264 * ut_copy - Object construction and conversion interfaces
267 acpi_status
268 acpi_ut_build_simple_object(
269 union acpi_operand_object *obj,
270 union acpi_object *user_obj,
271 u8 *data_space,
272 u32 *buffer_space_used);
274 acpi_status
275 acpi_ut_build_package_object (
276 union acpi_operand_object *obj,
277 u8 *buffer,
278 u32 *space_used);
280 acpi_status
281 acpi_ut_copy_ielement_to_eelement (
282 u8 object_type,
283 union acpi_operand_object *source_object,
284 union acpi_generic_state *state,
285 void *context);
287 acpi_status
288 acpi_ut_copy_ielement_to_ielement (
289 u8 object_type,
290 union acpi_operand_object *source_object,
291 union acpi_generic_state *state,
292 void *context);
294 acpi_status
295 acpi_ut_copy_iobject_to_eobject (
296 union acpi_operand_object *obj,
297 struct acpi_buffer *ret_buffer);
299 acpi_status
300 acpi_ut_copy_esimple_to_isimple(
301 union acpi_object *user_obj,
302 union acpi_operand_object **return_obj);
304 acpi_status
305 acpi_ut_copy_eobject_to_iobject (
306 union acpi_object *obj,
307 union acpi_operand_object **internal_obj);
309 acpi_status
310 acpi_ut_copy_isimple_to_isimple (
311 union acpi_operand_object *source_obj,
312 union acpi_operand_object *dest_obj);
314 acpi_status
315 acpi_ut_copy_ipackage_to_ipackage (
316 union acpi_operand_object *source_obj,
317 union acpi_operand_object *dest_obj,
318 struct acpi_walk_state *walk_state);
320 acpi_status
321 acpi_ut_copy_simple_object (
322 union acpi_operand_object *source_desc,
323 union acpi_operand_object *dest_desc);
325 acpi_status
326 acpi_ut_copy_iobject_to_iobject (
327 union acpi_operand_object *source_desc,
328 union acpi_operand_object **dest_desc,
329 struct acpi_walk_state *walk_state);
333 * ut_create - Object creation
336 acpi_status
337 acpi_ut_update_object_reference (
338 union acpi_operand_object *object,
339 u16 action);
343 * ut_debug - Debug interfaces
346 void
347 acpi_ut_init_stack_ptr_trace (
348 void);
350 void
351 acpi_ut_track_stack_ptr (
352 void);
354 void
355 acpi_ut_trace (
356 u32 line_number,
357 struct acpi_debug_print_info *dbg_info);
359 void
360 acpi_ut_trace_ptr (
361 u32 line_number,
362 struct acpi_debug_print_info *dbg_info,
363 void *pointer);
365 void
366 acpi_ut_trace_u32 (
367 u32 line_number,
368 struct acpi_debug_print_info *dbg_info,
369 u32 integer);
371 void
372 acpi_ut_trace_str (
373 u32 line_number,
374 struct acpi_debug_print_info *dbg_info,
375 char *string);
377 void
378 acpi_ut_exit (
379 u32 line_number,
380 struct acpi_debug_print_info *dbg_info);
382 void
383 acpi_ut_status_exit (
384 u32 line_number,
385 struct acpi_debug_print_info *dbg_info,
386 acpi_status status);
388 void
389 acpi_ut_value_exit (
390 u32 line_number,
391 struct acpi_debug_print_info *dbg_info,
392 acpi_integer value);
394 void
395 acpi_ut_ptr_exit (
396 u32 line_number,
397 struct acpi_debug_print_info *dbg_info,
398 u8 *ptr);
400 void
401 acpi_ut_report_info (
402 char *module_name,
403 u32 line_number,
404 u32 component_id);
406 void
407 acpi_ut_report_error (
408 char *module_name,
409 u32 line_number,
410 u32 component_id);
412 void
413 acpi_ut_report_warning (
414 char *module_name,
415 u32 line_number,
416 u32 component_id);
418 void
419 acpi_ut_dump_buffer (
420 u8 *buffer,
421 u32 count,
422 u32 display,
423 u32 component_id);
425 void ACPI_INTERNAL_VAR_XFACE
426 acpi_ut_debug_print (
427 u32 requested_debug_level,
428 u32 line_number,
429 struct acpi_debug_print_info *dbg_info,
430 char *format,
431 ...) ACPI_PRINTF_LIKE_FUNC;
433 void ACPI_INTERNAL_VAR_XFACE
434 acpi_ut_debug_print_raw (
435 u32 requested_debug_level,
436 u32 line_number,
437 struct acpi_debug_print_info *dbg_info,
438 char *format,
439 ...) ACPI_PRINTF_LIKE_FUNC;
443 * ut_delete - Object deletion
446 void
447 acpi_ut_delete_internal_obj (
448 union acpi_operand_object *object);
450 void
451 acpi_ut_delete_internal_package_object (
452 union acpi_operand_object *object);
454 void
455 acpi_ut_delete_internal_simple_object (
456 union acpi_operand_object *object);
458 void
459 acpi_ut_delete_internal_object_list (
460 union acpi_operand_object **obj_list);
464 * ut_eval - object evaluation
467 /* Method name strings */
469 #define METHOD_NAME__HID "_HID"
470 #define METHOD_NAME__CID "_CID"
471 #define METHOD_NAME__UID "_UID"
472 #define METHOD_NAME__ADR "_ADR"
473 #define METHOD_NAME__STA "_STA"
474 #define METHOD_NAME__REG "_REG"
475 #define METHOD_NAME__SEG "_SEG"
476 #define METHOD_NAME__BBN "_BBN"
477 #define METHOD_NAME__PRT "_PRT"
478 #define METHOD_NAME__CRS "_CRS"
479 #define METHOD_NAME__PRS "_PRS"
480 #define METHOD_NAME__PRW "_PRW"
483 acpi_status
484 acpi_ut_osi_implementation (
485 struct acpi_walk_state *walk_state);
487 acpi_status
488 acpi_ut_evaluate_object (
489 struct acpi_namespace_node *prefix_node,
490 char *path,
491 u32 expected_return_btypes,
492 union acpi_operand_object **return_desc);
494 acpi_status
495 acpi_ut_evaluate_numeric_object (
496 char *object_name,
497 struct acpi_namespace_node *device_node,
498 acpi_integer *address);
500 acpi_status
501 acpi_ut_execute_HID (
502 struct acpi_namespace_node *device_node,
503 struct acpi_device_id *hid);
505 acpi_status
506 acpi_ut_execute_CID (
507 struct acpi_namespace_node *device_node,
508 struct acpi_compatible_id_list **return_cid_list);
510 acpi_status
511 acpi_ut_execute_STA (
512 struct acpi_namespace_node *device_node,
513 u32 *status_flags);
515 acpi_status
516 acpi_ut_execute_UID (
517 struct acpi_namespace_node *device_node,
518 struct acpi_device_id *uid);
520 acpi_status
521 acpi_ut_execute_sxds (
522 struct acpi_namespace_node *device_node,
523 u8 *highest);
526 * ut_mutex - mutual exclusion interfaces
529 acpi_status
530 acpi_ut_mutex_initialize (
531 void);
533 void
534 acpi_ut_mutex_terminate (
535 void);
537 acpi_status
538 acpi_ut_create_mutex (
539 acpi_mutex_handle mutex_id);
541 acpi_status
542 acpi_ut_delete_mutex (
543 acpi_mutex_handle mutex_id);
545 acpi_status
546 acpi_ut_acquire_mutex (
547 acpi_mutex_handle mutex_id);
549 acpi_status
550 acpi_ut_release_mutex (
551 acpi_mutex_handle mutex_id);
555 * ut_object - internal object create/delete/cache routines
558 union acpi_operand_object *
559 acpi_ut_create_internal_object_dbg (
560 char *module_name,
561 u32 line_number,
562 u32 component_id,
563 acpi_object_type type);
565 void *
566 acpi_ut_allocate_object_desc_dbg (
567 char *module_name,
568 u32 line_number,
569 u32 component_id);
571 #define acpi_ut_create_internal_object(t) acpi_ut_create_internal_object_dbg (_THIS_MODULE,__LINE__,_COMPONENT,t)
572 #define acpi_ut_allocate_object_desc() acpi_ut_allocate_object_desc_dbg (_THIS_MODULE,__LINE__,_COMPONENT)
574 void
575 acpi_ut_delete_object_desc (
576 union acpi_operand_object *object);
579 acpi_ut_valid_internal_object (
580 void *object);
582 union acpi_operand_object *
583 acpi_ut_create_buffer_object (
584 acpi_size buffer_size);
586 union acpi_operand_object *
587 acpi_ut_create_string_object (
588 acpi_size string_size);
592 * ut_ref_cnt - Object reference count management
595 void
596 acpi_ut_add_reference (
597 union acpi_operand_object *object);
599 void
600 acpi_ut_remove_reference (
601 union acpi_operand_object *object);
604 * ut_size - Object size routines
607 acpi_status
608 acpi_ut_get_simple_object_size (
609 union acpi_operand_object *obj,
610 acpi_size *obj_length);
612 acpi_status
613 acpi_ut_get_package_object_size (
614 union acpi_operand_object *obj,
615 acpi_size *obj_length);
617 acpi_status
618 acpi_ut_get_object_size(
619 union acpi_operand_object *obj,
620 acpi_size *obj_length);
622 acpi_status
623 acpi_ut_get_element_length (
624 u8 object_type,
625 union acpi_operand_object *source_object,
626 union acpi_generic_state *state,
627 void *context);
631 * ut_state - Generic state creation/cache routines
634 void
635 acpi_ut_push_generic_state (
636 union acpi_generic_state **list_head,
637 union acpi_generic_state *state);
639 union acpi_generic_state *
640 acpi_ut_pop_generic_state (
641 union acpi_generic_state **list_head);
644 union acpi_generic_state *
645 acpi_ut_create_generic_state (
646 void);
648 struct acpi_thread_state *
649 acpi_ut_create_thread_state (
650 void);
652 union acpi_generic_state *
653 acpi_ut_create_update_state (
654 union acpi_operand_object *object,
655 u16 action);
657 union acpi_generic_state *
658 acpi_ut_create_pkg_state (
659 void *internal_object,
660 void *external_object,
661 u16 index);
663 acpi_status
664 acpi_ut_create_update_state_and_push (
665 union acpi_operand_object *object,
666 u16 action,
667 union acpi_generic_state **state_list);
669 #ifdef ACPI_FUTURE_USAGE
670 acpi_status
671 acpi_ut_create_pkg_state_and_push (
672 void *internal_object,
673 void *external_object,
674 u16 index,
675 union acpi_generic_state **state_list);
676 #endif
678 union acpi_generic_state *
679 acpi_ut_create_control_state (
680 void);
682 void
683 acpi_ut_delete_generic_state (
684 union acpi_generic_state *state);
686 #ifdef ACPI_ENABLE_OBJECT_CACHE
687 void
688 acpi_ut_delete_generic_state_cache (
689 void);
691 void
692 acpi_ut_delete_object_cache (
693 void);
694 #endif
697 * utmisc
700 void
701 acpi_ut_print_string (
702 char *string,
703 u8 max_length);
705 acpi_status
706 acpi_ut_divide (
707 acpi_integer in_dividend,
708 acpi_integer in_divisor,
709 acpi_integer *out_quotient,
710 acpi_integer *out_remainder);
712 acpi_status
713 acpi_ut_short_divide (
714 acpi_integer in_dividend,
715 u32 divisor,
716 acpi_integer *out_quotient,
717 u32 *out_remainder);
720 acpi_ut_valid_acpi_name (
721 u32 name);
724 acpi_ut_valid_acpi_character (
725 char character);
727 acpi_status
728 acpi_ut_strtoul64 (
729 char *string,
730 u32 base,
731 acpi_integer *ret_integer);
733 /* Values for Base above (16=Hex, 10=Decimal) */
735 #define ACPI_ANY_BASE 0
737 #ifdef ACPI_FUTURE_USAGE
738 char *
739 acpi_ut_strupr (
740 char *src_string);
741 #endif
743 u8 *
744 acpi_ut_get_resource_end_tag (
745 union acpi_operand_object *obj_desc);
748 acpi_ut_generate_checksum (
749 u8 *buffer,
750 u32 length);
753 acpi_ut_dword_byte_swap (
754 u32 value);
756 void
757 acpi_ut_set_integer_width (
758 u8 revision);
760 #ifdef ACPI_DEBUG_OUTPUT
761 void
762 acpi_ut_display_init_pathname (
763 u8 type,
764 struct acpi_namespace_node *obj_handle,
765 char *path);
767 #endif
771 * Utalloc - memory allocation and object caching
774 void *
775 acpi_ut_acquire_from_cache (
776 u32 list_id);
778 void
779 acpi_ut_release_to_cache (
780 u32 list_id,
781 void *object);
783 #ifdef ACPI_ENABLE_OBJECT_CACHE
784 void
785 acpi_ut_delete_generic_cache (
786 u32 list_id);
787 #endif
789 acpi_status
790 acpi_ut_validate_buffer (
791 struct acpi_buffer *buffer);
793 acpi_status
794 acpi_ut_initialize_buffer (
795 struct acpi_buffer *buffer,
796 acpi_size required_length);
799 /* Memory allocation functions */
801 void *
802 acpi_ut_allocate (
803 acpi_size size,
804 u32 component,
805 char *module,
806 u32 line);
808 void *
809 acpi_ut_callocate (
810 acpi_size size,
811 u32 component,
812 char *module,
813 u32 line);
816 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
818 void *
819 acpi_ut_allocate_and_track (
820 acpi_size size,
821 u32 component,
822 char *module,
823 u32 line);
825 void *
826 acpi_ut_callocate_and_track (
827 acpi_size size,
828 u32 component,
829 char *module,
830 u32 line);
832 void
833 acpi_ut_free_and_track (
834 void *address,
835 u32 component,
836 char *module,
837 u32 line);
839 struct acpi_debug_mem_block *
840 acpi_ut_find_allocation (
841 u32 list_id,
842 void *allocation);
844 acpi_status
845 acpi_ut_track_allocation (
846 u32 list_id,
847 struct acpi_debug_mem_block *address,
848 acpi_size size,
849 u8 alloc_type,
850 u32 component,
851 char *module,
852 u32 line);
854 acpi_status
855 acpi_ut_remove_allocation (
856 u32 list_id,
857 struct acpi_debug_mem_block *address,
858 u32 component,
859 char *module,
860 u32 line);
862 #ifdef ACPI_FUTURE_USAGE
863 void
864 acpi_ut_dump_allocation_info (
865 void);
866 #endif
868 void
869 acpi_ut_dump_allocations (
870 u32 component,
871 char *module);
872 #endif
875 #endif /* _ACUTILS_H */