1 /******************************************************************************
3 * Name: acutils.h -- prototypes for the common (subsystem-wide) procedures
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2004, R. Byron Moore
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
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.
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.
49 acpi_status (*acpi_pkg_callback) (
51 union acpi_operand_object *source_object,
52 union acpi_generic_state *state,
56 acpi_ut_walk_package_tree (
57 union acpi_operand_object *source_object,
59 acpi_pkg_callback walk_callback,
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 */
85 acpi_ut_init_globals (
94 * ut_init - miscellaneous initialization and shutdown
98 acpi_ut_hardware_initialize (
102 acpi_ut_subsystem_shutdown (
106 acpi_ut_validate_fadt (
110 * ut_global - Global data structures and procedures
113 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
116 acpi_ut_get_mutex_name (
122 acpi_ut_get_type_name (
123 acpi_object_type type);
126 acpi_ut_get_node_name (
130 acpi_ut_get_descriptor_name (
134 acpi_ut_get_object_type_name (
135 union acpi_operand_object *obj_desc);
138 acpi_ut_get_region_name (
142 acpi_ut_get_event_name (
146 acpi_ut_hex_to_ascii_char (
147 acpi_integer integer,
151 acpi_ut_valid_object_type (
152 acpi_object_type type);
155 acpi_ut_allocate_owner_id (
160 * ut_clib - Local implementations of C library functions
163 #ifndef ACPI_USE_SYSTEM_CLIBRARY
172 const char *src_string);
177 const char *src_string,
189 const char *string2);
194 const char *src_string);
199 const char *src_string,
222 acpi_native_uint value,
233 extern const u8 _acpi_ctype[];
235 #define _ACPI_XA 0x00 /* extra alphabetic - not supported */
236 #define _ACPI_XS 0x40 /* extra space */
237 #define _ACPI_BB 0x00 /* BEL, BS, etc. - not supported */
238 #define _ACPI_CN 0x20 /* CR, FF, HT, NL, VT */
239 #define _ACPI_DI 0x04 /* '0'-'9' */
240 #define _ACPI_LO 0x02 /* 'a'-'z' */
241 #define _ACPI_PU 0x10 /* punctuation */
242 #define _ACPI_SP 0x08 /* space */
243 #define _ACPI_UP 0x01 /* 'A'-'Z' */
244 #define _ACPI_XD 0x80 /* '0'-'9', 'A'-'F', 'a'-'f' */
246 #define ACPI_IS_DIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_DI))
247 #define ACPI_IS_SPACE(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_SP))
248 #define ACPI_IS_XDIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_XD))
249 #define ACPI_IS_UPPER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_UP))
250 #define ACPI_IS_LOWER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO))
251 #define ACPI_IS_PRINT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_SP | _ACPI_PU))
252 #define ACPI_IS_ALPHA(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP))
253 #define ACPI_IS_ASCII(c) ((c) < 0x80)
255 #endif /* ACPI_USE_SYSTEM_CLIBRARY */
258 * ut_copy - Object construction and conversion interfaces
262 acpi_ut_build_simple_object(
263 union acpi_operand_object *obj,
264 union acpi_object *user_obj,
266 u32 *buffer_space_used);
269 acpi_ut_build_package_object (
270 union acpi_operand_object *obj,
275 acpi_ut_copy_ielement_to_eelement (
277 union acpi_operand_object *source_object,
278 union acpi_generic_state *state,
282 acpi_ut_copy_ielement_to_ielement (
284 union acpi_operand_object *source_object,
285 union acpi_generic_state *state,
289 acpi_ut_copy_iobject_to_eobject (
290 union acpi_operand_object *obj,
291 struct acpi_buffer *ret_buffer);
294 acpi_ut_copy_esimple_to_isimple(
295 union acpi_object *user_obj,
296 union acpi_operand_object **return_obj);
299 acpi_ut_copy_eobject_to_iobject (
300 union acpi_object *obj,
301 union acpi_operand_object **internal_obj);
304 acpi_ut_copy_isimple_to_isimple (
305 union acpi_operand_object *source_obj,
306 union acpi_operand_object *dest_obj);
309 acpi_ut_copy_ipackage_to_ipackage (
310 union acpi_operand_object *source_obj,
311 union acpi_operand_object *dest_obj,
312 struct acpi_walk_state *walk_state);
315 acpi_ut_copy_simple_object (
316 union acpi_operand_object *source_desc,
317 union acpi_operand_object *dest_desc);
320 acpi_ut_copy_iobject_to_iobject (
321 union acpi_operand_object *source_desc,
322 union acpi_operand_object **dest_desc,
323 struct acpi_walk_state *walk_state);
327 * ut_create - Object creation
331 acpi_ut_update_object_reference (
332 union acpi_operand_object *object,
337 * ut_debug - Debug interfaces
341 acpi_ut_init_stack_ptr_trace (
345 acpi_ut_track_stack_ptr (
351 struct acpi_debug_print_info *dbg_info);
356 struct acpi_debug_print_info *dbg_info,
362 struct acpi_debug_print_info *dbg_info,
368 struct acpi_debug_print_info *dbg_info,
374 struct acpi_debug_print_info *dbg_info);
377 acpi_ut_status_exit (
379 struct acpi_debug_print_info *dbg_info,
385 struct acpi_debug_print_info *dbg_info,
391 struct acpi_debug_print_info *dbg_info,
395 acpi_ut_report_info (
401 acpi_ut_report_error (
407 acpi_ut_report_warning (
413 acpi_ut_dump_buffer (
419 void ACPI_INTERNAL_VAR_XFACE
420 acpi_ut_debug_print (
421 u32 requested_debug_level,
423 struct acpi_debug_print_info *dbg_info,
425 ...) ACPI_PRINTF_LIKE_FUNC;
427 void ACPI_INTERNAL_VAR_XFACE
428 acpi_ut_debug_print_raw (
429 u32 requested_debug_level,
431 struct acpi_debug_print_info *dbg_info,
433 ...) ACPI_PRINTF_LIKE_FUNC;
437 * ut_delete - Object deletion
441 acpi_ut_delete_internal_obj (
442 union acpi_operand_object *object);
445 acpi_ut_delete_internal_package_object (
446 union acpi_operand_object *object);
449 acpi_ut_delete_internal_simple_object (
450 union acpi_operand_object *object);
453 acpi_ut_delete_internal_object_list (
454 union acpi_operand_object **obj_list);
458 * ut_eval - object evaluation
461 /* Method name strings */
463 #define METHOD_NAME__HID "_HID"
464 #define METHOD_NAME__CID "_CID"
465 #define METHOD_NAME__UID "_UID"
466 #define METHOD_NAME__ADR "_ADR"
467 #define METHOD_NAME__STA "_STA"
468 #define METHOD_NAME__REG "_REG"
469 #define METHOD_NAME__SEG "_SEG"
470 #define METHOD_NAME__BBN "_BBN"
471 #define METHOD_NAME__PRT "_PRT"
472 #define METHOD_NAME__CRS "_CRS"
473 #define METHOD_NAME__PRS "_PRS"
474 #define METHOD_NAME__PRW "_PRW"
478 acpi_ut_osi_implementation (
479 struct acpi_walk_state *walk_state);
482 acpi_ut_evaluate_object (
483 struct acpi_namespace_node *prefix_node,
485 u32 expected_return_btypes,
486 union acpi_operand_object **return_desc);
489 acpi_ut_evaluate_numeric_object (
491 struct acpi_namespace_node *device_node,
492 acpi_integer *address);
495 acpi_ut_execute_HID (
496 struct acpi_namespace_node *device_node,
497 struct acpi_device_id *hid);
500 acpi_ut_execute_CID (
501 struct acpi_namespace_node *device_node,
502 struct acpi_compatible_id_list **return_cid_list);
505 acpi_ut_execute_STA (
506 struct acpi_namespace_node *device_node,
510 acpi_ut_execute_UID (
511 struct acpi_namespace_node *device_node,
512 struct acpi_device_id *uid);
515 acpi_ut_execute_sxds (
516 struct acpi_namespace_node *device_node,
520 * ut_mutex - mutual exclusion interfaces
524 acpi_ut_mutex_initialize (
528 acpi_ut_mutex_terminate (
532 acpi_ut_create_mutex (
533 acpi_mutex_handle mutex_id);
536 acpi_ut_delete_mutex (
537 acpi_mutex_handle mutex_id);
540 acpi_ut_acquire_mutex (
541 acpi_mutex_handle mutex_id);
544 acpi_ut_release_mutex (
545 acpi_mutex_handle mutex_id);
549 * ut_object - internal object create/delete/cache routines
552 union acpi_operand_object *
553 acpi_ut_create_internal_object_dbg (
557 acpi_object_type type);
560 acpi_ut_allocate_object_desc_dbg (
565 #define acpi_ut_create_internal_object(t) acpi_ut_create_internal_object_dbg (_THIS_MODULE,__LINE__,_COMPONENT,t)
566 #define acpi_ut_allocate_object_desc() acpi_ut_allocate_object_desc_dbg (_THIS_MODULE,__LINE__,_COMPONENT)
569 acpi_ut_delete_object_desc (
570 union acpi_operand_object *object);
573 acpi_ut_valid_internal_object (
576 union acpi_operand_object *
577 acpi_ut_create_buffer_object (
578 acpi_size buffer_size);
582 * ut_ref_cnt - Object reference count management
586 acpi_ut_add_reference (
587 union acpi_operand_object *object);
590 acpi_ut_remove_reference (
591 union acpi_operand_object *object);
594 * ut_size - Object size routines
598 acpi_ut_get_simple_object_size (
599 union acpi_operand_object *obj,
600 acpi_size *obj_length);
603 acpi_ut_get_package_object_size (
604 union acpi_operand_object *obj,
605 acpi_size *obj_length);
608 acpi_ut_get_object_size(
609 union acpi_operand_object *obj,
610 acpi_size *obj_length);
613 acpi_ut_get_element_length (
615 union acpi_operand_object *source_object,
616 union acpi_generic_state *state,
621 * ut_state - Generic state creation/cache routines
625 acpi_ut_push_generic_state (
626 union acpi_generic_state **list_head,
627 union acpi_generic_state *state);
629 union acpi_generic_state *
630 acpi_ut_pop_generic_state (
631 union acpi_generic_state **list_head);
634 union acpi_generic_state *
635 acpi_ut_create_generic_state (
638 struct acpi_thread_state *
639 acpi_ut_create_thread_state (
642 union acpi_generic_state *
643 acpi_ut_create_update_state (
644 union acpi_operand_object *object,
647 union acpi_generic_state *
648 acpi_ut_create_pkg_state (
649 void *internal_object,
650 void *external_object,
654 acpi_ut_create_update_state_and_push (
655 union acpi_operand_object *object,
657 union acpi_generic_state **state_list);
660 acpi_ut_create_pkg_state_and_push (
661 void *internal_object,
662 void *external_object,
664 union acpi_generic_state **state_list);
666 union acpi_generic_state *
667 acpi_ut_create_control_state (
671 acpi_ut_delete_generic_state (
672 union acpi_generic_state *state);
675 acpi_ut_delete_generic_state_cache (
679 acpi_ut_delete_object_cache (
687 acpi_ut_print_string (
693 acpi_integer *in_dividend,
694 acpi_integer *in_divisor,
695 acpi_integer *out_quotient,
696 acpi_integer *out_remainder);
699 acpi_ut_short_divide (
700 acpi_integer *in_dividend,
702 acpi_integer *out_quotient,
706 acpi_ut_valid_acpi_name (
710 acpi_ut_valid_acpi_character (
717 acpi_integer *ret_integer);
724 acpi_ut_get_resource_end_tag (
725 union acpi_operand_object *obj_desc);
728 acpi_ut_generate_checksum (
733 acpi_ut_dword_byte_swap (
737 acpi_ut_set_integer_width (
740 #ifdef ACPI_DEBUG_OUTPUT
742 acpi_ut_display_init_pathname (
744 struct acpi_namespace_node *obj_handle,
751 * Utalloc - memory allocation and object caching
755 acpi_ut_acquire_from_cache (
759 acpi_ut_release_to_cache (
764 acpi_ut_delete_generic_cache (
768 acpi_ut_validate_buffer (
769 struct acpi_buffer *buffer);
772 acpi_ut_initialize_buffer (
773 struct acpi_buffer *buffer,
774 acpi_size required_length);
777 /* Memory allocation functions */
794 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
797 acpi_ut_allocate_and_track (
804 acpi_ut_callocate_and_track (
811 acpi_ut_free_and_track (
817 struct acpi_debug_mem_block *
818 acpi_ut_find_allocation (
823 acpi_ut_track_allocation (
825 struct acpi_debug_mem_block *address,
833 acpi_ut_remove_allocation (
835 struct acpi_debug_mem_block *address,
841 acpi_ut_dump_allocation_info (
845 acpi_ut_dump_allocations (
851 #endif /* _ACUTILS_H */