1 /******************************************************************************
3 * Name: acutils.h -- prototypes for the common (subsystem-wide) procedures
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2005, 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
,
63 #define REF_INCREMENT (u16) 0
64 #define REF_DECREMENT (u16) 1
65 #define REF_FORCE_DELETE (u16) 2
67 /* acpi_ut_dump_buffer */
69 #define DB_BYTE_DISPLAY 1
70 #define DB_WORD_DISPLAY 2
71 #define DB_DWORD_DISPLAY 4
72 #define DB_QWORD_DISPLAY 8
76 * utglobal - Global data structures and procedures
79 acpi_ut_init_globals (
82 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
85 acpi_ut_get_mutex_name (
91 acpi_ut_get_type_name (
92 acpi_object_type type
);
95 acpi_ut_get_node_name (
99 acpi_ut_get_descriptor_name (
103 acpi_ut_get_object_type_name (
104 union acpi_operand_object
*obj_desc
);
107 acpi_ut_get_region_name (
111 acpi_ut_get_event_name (
115 acpi_ut_hex_to_ascii_char (
116 acpi_integer integer
,
120 acpi_ut_valid_object_type (
121 acpi_object_type type
);
124 acpi_ut_allocate_owner_id (
129 * utinit - miscellaneous initialization and shutdown
132 acpi_ut_hardware_initialize (
136 acpi_ut_subsystem_shutdown (
140 acpi_ut_validate_fadt (
145 * utclib - Local implementations of C library functions
147 #ifndef ACPI_USE_SYSTEM_CLIBRARY
156 const char *src_string
);
161 const char *src_string
,
179 const char *string2
);
184 const char *src_string
);
189 const char *src_string
,
212 acpi_native_uint value
,
223 extern const u8 _acpi_ctype
[];
225 #define _ACPI_XA 0x00 /* extra alphabetic - not supported */
226 #define _ACPI_XS 0x40 /* extra space */
227 #define _ACPI_BB 0x00 /* BEL, BS, etc. - not supported */
228 #define _ACPI_CN 0x20 /* CR, FF, HT, NL, VT */
229 #define _ACPI_DI 0x04 /* '0'-'9' */
230 #define _ACPI_LO 0x02 /* 'a'-'z' */
231 #define _ACPI_PU 0x10 /* punctuation */
232 #define _ACPI_SP 0x08 /* space */
233 #define _ACPI_UP 0x01 /* 'A'-'Z' */
234 #define _ACPI_XD 0x80 /* '0'-'9', 'A'-'F', 'a'-'f' */
236 #define ACPI_IS_DIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_DI))
237 #define ACPI_IS_SPACE(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_SP))
238 #define ACPI_IS_XDIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_XD))
239 #define ACPI_IS_UPPER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_UP))
240 #define ACPI_IS_LOWER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO))
241 #define ACPI_IS_PRINT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_SP | _ACPI_PU))
242 #define ACPI_IS_ALPHA(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP))
243 #define ACPI_IS_ASCII(c) ((c) < 0x80)
245 #endif /* ACPI_USE_SYSTEM_CLIBRARY */
249 * utcopy - Object construction and conversion interfaces
252 acpi_ut_build_simple_object(
253 union acpi_operand_object
*obj
,
254 union acpi_object
*user_obj
,
256 u32
*buffer_space_used
);
259 acpi_ut_build_package_object (
260 union acpi_operand_object
*obj
,
265 acpi_ut_copy_iobject_to_eobject (
266 union acpi_operand_object
*obj
,
267 struct acpi_buffer
*ret_buffer
);
270 acpi_ut_copy_eobject_to_iobject (
271 union acpi_object
*obj
,
272 union acpi_operand_object
**internal_obj
);
275 acpi_ut_copy_isimple_to_isimple (
276 union acpi_operand_object
*source_obj
,
277 union acpi_operand_object
*dest_obj
);
280 acpi_ut_copy_iobject_to_iobject (
281 union acpi_operand_object
*source_desc
,
282 union acpi_operand_object
**dest_desc
,
283 struct acpi_walk_state
*walk_state
);
287 * utcreate - Object creation
290 acpi_ut_update_object_reference (
291 union acpi_operand_object
*object
,
296 * utdebug - Debug interfaces
299 acpi_ut_init_stack_ptr_trace (
303 acpi_ut_track_stack_ptr (
309 struct acpi_debug_print_info
*dbg_info
);
314 struct acpi_debug_print_info
*dbg_info
,
320 struct acpi_debug_print_info
*dbg_info
,
326 struct acpi_debug_print_info
*dbg_info
,
332 struct acpi_debug_print_info
*dbg_info
);
335 acpi_ut_status_exit (
337 struct acpi_debug_print_info
*dbg_info
,
343 struct acpi_debug_print_info
*dbg_info
,
349 struct acpi_debug_print_info
*dbg_info
,
353 acpi_ut_report_info (
359 acpi_ut_report_error (
365 acpi_ut_report_warning (
371 acpi_ut_dump_buffer (
377 void ACPI_INTERNAL_VAR_XFACE
378 acpi_ut_debug_print (
379 u32 requested_debug_level
,
381 struct acpi_debug_print_info
*dbg_info
,
383 ...) ACPI_PRINTF_LIKE_FUNC
;
385 void ACPI_INTERNAL_VAR_XFACE
386 acpi_ut_debug_print_raw (
387 u32 requested_debug_level
,
389 struct acpi_debug_print_info
*dbg_info
,
391 ...) ACPI_PRINTF_LIKE_FUNC
;
395 * utdelete - Object deletion and reference counts
398 acpi_ut_add_reference (
399 union acpi_operand_object
*object
);
402 acpi_ut_remove_reference (
403 union acpi_operand_object
*object
);
406 acpi_ut_delete_internal_package_object (
407 union acpi_operand_object
*object
);
410 acpi_ut_delete_internal_simple_object (
411 union acpi_operand_object
*object
);
414 acpi_ut_delete_internal_object_list (
415 union acpi_operand_object
**obj_list
);
419 * uteval - object evaluation
422 acpi_ut_osi_implementation (
423 struct acpi_walk_state
*walk_state
);
426 acpi_ut_evaluate_object (
427 struct acpi_namespace_node
*prefix_node
,
429 u32 expected_return_btypes
,
430 union acpi_operand_object
**return_desc
);
433 acpi_ut_evaluate_numeric_object (
435 struct acpi_namespace_node
*device_node
,
436 acpi_integer
*address
);
439 acpi_ut_execute_HID (
440 struct acpi_namespace_node
*device_node
,
441 struct acpi_device_id
*hid
);
444 acpi_ut_execute_CID (
445 struct acpi_namespace_node
*device_node
,
446 struct acpi_compatible_id_list
**return_cid_list
);
449 acpi_ut_execute_STA (
450 struct acpi_namespace_node
*device_node
,
454 acpi_ut_execute_UID (
455 struct acpi_namespace_node
*device_node
,
456 struct acpi_device_id
*uid
);
459 acpi_ut_execute_sxds (
460 struct acpi_namespace_node
*device_node
,
465 * utobject - internal object create/delete/cache routines
467 union acpi_operand_object
*
468 acpi_ut_create_internal_object_dbg (
472 acpi_object_type type
);
475 acpi_ut_allocate_object_desc_dbg (
480 #define acpi_ut_create_internal_object(t) acpi_ut_create_internal_object_dbg (_THIS_MODULE,__LINE__,_COMPONENT,t)
481 #define acpi_ut_allocate_object_desc() acpi_ut_allocate_object_desc_dbg (_THIS_MODULE,__LINE__,_COMPONENT)
484 acpi_ut_delete_object_desc (
485 union acpi_operand_object
*object
);
488 acpi_ut_valid_internal_object (
491 union acpi_operand_object
*
492 acpi_ut_create_buffer_object (
493 acpi_size buffer_size
);
495 union acpi_operand_object
*
496 acpi_ut_create_string_object (
497 acpi_size string_size
);
500 acpi_ut_get_object_size(
501 union acpi_operand_object
*obj
,
502 acpi_size
*obj_length
);
506 * utstate - Generic state creation/cache routines
509 acpi_ut_push_generic_state (
510 union acpi_generic_state
**list_head
,
511 union acpi_generic_state
*state
);
513 union acpi_generic_state
*
514 acpi_ut_pop_generic_state (
515 union acpi_generic_state
**list_head
);
518 union acpi_generic_state
*
519 acpi_ut_create_generic_state (
522 struct acpi_thread_state
*
523 acpi_ut_create_thread_state (
526 union acpi_generic_state
*
527 acpi_ut_create_update_state (
528 union acpi_operand_object
*object
,
531 union acpi_generic_state
*
532 acpi_ut_create_pkg_state (
533 void *internal_object
,
534 void *external_object
,
538 acpi_ut_create_update_state_and_push (
539 union acpi_operand_object
*object
,
541 union acpi_generic_state
**state_list
);
543 #ifdef ACPI_FUTURE_USAGE
545 acpi_ut_create_pkg_state_and_push (
546 void *internal_object
,
547 void *external_object
,
549 union acpi_generic_state
**state_list
);
550 #endif /* ACPI_FUTURE_USAGE */
552 union acpi_generic_state
*
553 acpi_ut_create_control_state (
557 acpi_ut_delete_generic_state (
558 union acpi_generic_state
*state
);
560 #ifdef ACPI_ENABLE_OBJECT_CACHE
562 acpi_ut_delete_generic_state_cache (
566 acpi_ut_delete_object_cache (
576 acpi_integer in_dividend
,
577 acpi_integer in_divisor
,
578 acpi_integer
*out_quotient
,
579 acpi_integer
*out_remainder
);
582 acpi_ut_short_divide (
583 acpi_integer in_dividend
,
585 acpi_integer
*out_quotient
,
592 acpi_ut_walk_package_tree (
593 union acpi_operand_object
*source_object
,
595 acpi_pkg_callback walk_callback
,
603 acpi_ut_print_string (
608 acpi_ut_valid_acpi_name (
612 acpi_ut_valid_acpi_character (
619 acpi_integer
*ret_integer
);
621 /* Values for Base above (16=Hex, 10=Decimal) */
623 #define ACPI_ANY_BASE 0
626 acpi_ut_mutex_initialize (
630 acpi_ut_mutex_terminate (
634 acpi_ut_acquire_mutex (
635 acpi_mutex_handle mutex_id
);
638 acpi_ut_release_mutex (
639 acpi_mutex_handle mutex_id
);
642 acpi_ut_get_resource_end_tag (
643 union acpi_operand_object
*obj_desc
);
646 acpi_ut_generate_checksum (
651 acpi_ut_dword_byte_swap (
655 acpi_ut_set_integer_width (
658 #ifdef ACPI_DEBUG_OUTPUT
660 acpi_ut_display_init_pathname (
662 struct acpi_namespace_node
*obj_handle
,
669 * utalloc - memory allocation and object caching
672 acpi_ut_acquire_from_cache (
676 acpi_ut_release_to_cache (
680 #ifdef ACPI_ENABLE_OBJECT_CACHE
682 acpi_ut_delete_generic_cache (
687 acpi_ut_validate_buffer (
688 struct acpi_buffer
*buffer
);
691 acpi_ut_initialize_buffer (
692 struct acpi_buffer
*buffer
,
693 acpi_size required_length
);
709 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
711 acpi_ut_allocate_and_track (
718 acpi_ut_callocate_and_track (
725 acpi_ut_free_and_track (
731 #ifdef ACPI_FUTURE_USAGE
733 acpi_ut_dump_allocation_info (
735 #endif /* ACPI_FUTURE_USAGE */
738 acpi_ut_dump_allocations (
743 #endif /* _ACUTILS_H */