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
,
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
,
195 const char *string2
);
200 const char *src_string
);
205 const char *src_string
,
228 acpi_native_uint value
,
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
268 acpi_ut_build_simple_object(
269 union acpi_operand_object
*obj
,
270 union acpi_object
*user_obj
,
272 u32
*buffer_space_used
);
275 acpi_ut_build_package_object (
276 union acpi_operand_object
*obj
,
281 acpi_ut_copy_ielement_to_eelement (
283 union acpi_operand_object
*source_object
,
284 union acpi_generic_state
*state
,
288 acpi_ut_copy_ielement_to_ielement (
290 union acpi_operand_object
*source_object
,
291 union acpi_generic_state
*state
,
295 acpi_ut_copy_iobject_to_eobject (
296 union acpi_operand_object
*obj
,
297 struct acpi_buffer
*ret_buffer
);
300 acpi_ut_copy_esimple_to_isimple(
301 union acpi_object
*user_obj
,
302 union acpi_operand_object
**return_obj
);
305 acpi_ut_copy_eobject_to_iobject (
306 union acpi_object
*obj
,
307 union acpi_operand_object
**internal_obj
);
310 acpi_ut_copy_isimple_to_isimple (
311 union acpi_operand_object
*source_obj
,
312 union acpi_operand_object
*dest_obj
);
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
);
321 acpi_ut_copy_simple_object (
322 union acpi_operand_object
*source_desc
,
323 union acpi_operand_object
*dest_desc
);
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
337 acpi_ut_update_object_reference (
338 union acpi_operand_object
*object
,
343 * ut_debug - Debug interfaces
347 acpi_ut_init_stack_ptr_trace (
351 acpi_ut_track_stack_ptr (
357 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
,
380 struct acpi_debug_print_info
*dbg_info
);
383 acpi_ut_status_exit (
385 struct acpi_debug_print_info
*dbg_info
,
391 struct acpi_debug_print_info
*dbg_info
,
397 struct acpi_debug_print_info
*dbg_info
,
401 acpi_ut_report_info (
407 acpi_ut_report_error (
413 acpi_ut_report_warning (
419 acpi_ut_dump_buffer (
425 void ACPI_INTERNAL_VAR_XFACE
426 acpi_ut_debug_print (
427 u32 requested_debug_level
,
429 struct acpi_debug_print_info
*dbg_info
,
431 ...) ACPI_PRINTF_LIKE_FUNC
;
433 void ACPI_INTERNAL_VAR_XFACE
434 acpi_ut_debug_print_raw (
435 u32 requested_debug_level
,
437 struct acpi_debug_print_info
*dbg_info
,
439 ...) ACPI_PRINTF_LIKE_FUNC
;
443 * ut_delete - Object deletion
447 acpi_ut_delete_internal_obj (
448 union acpi_operand_object
*object
);
451 acpi_ut_delete_internal_package_object (
452 union acpi_operand_object
*object
);
455 acpi_ut_delete_internal_simple_object (
456 union acpi_operand_object
*object
);
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"
484 acpi_ut_osi_implementation (
485 struct acpi_walk_state
*walk_state
);
488 acpi_ut_evaluate_object (
489 struct acpi_namespace_node
*prefix_node
,
491 u32 expected_return_btypes
,
492 union acpi_operand_object
**return_desc
);
495 acpi_ut_evaluate_numeric_object (
497 struct acpi_namespace_node
*device_node
,
498 acpi_integer
*address
);
501 acpi_ut_execute_HID (
502 struct acpi_namespace_node
*device_node
,
503 struct acpi_device_id
*hid
);
506 acpi_ut_execute_CID (
507 struct acpi_namespace_node
*device_node
,
508 struct acpi_compatible_id_list
**return_cid_list
);
511 acpi_ut_execute_STA (
512 struct acpi_namespace_node
*device_node
,
516 acpi_ut_execute_UID (
517 struct acpi_namespace_node
*device_node
,
518 struct acpi_device_id
*uid
);
521 acpi_ut_execute_sxds (
522 struct acpi_namespace_node
*device_node
,
526 * ut_mutex - mutual exclusion interfaces
530 acpi_ut_mutex_initialize (
534 acpi_ut_mutex_terminate (
538 acpi_ut_create_mutex (
539 acpi_mutex_handle mutex_id
);
542 acpi_ut_delete_mutex (
543 acpi_mutex_handle mutex_id
);
546 acpi_ut_acquire_mutex (
547 acpi_mutex_handle mutex_id
);
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 (
563 acpi_object_type type
);
566 acpi_ut_allocate_object_desc_dbg (
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)
575 acpi_ut_delete_object_desc (
576 union acpi_operand_object
*object
);
579 acpi_ut_valid_internal_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
596 acpi_ut_add_reference (
597 union acpi_operand_object
*object
);
600 acpi_ut_remove_reference (
601 union acpi_operand_object
*object
);
604 * ut_size - Object size routines
608 acpi_ut_get_simple_object_size (
609 union acpi_operand_object
*obj
,
610 acpi_size
*obj_length
);
613 acpi_ut_get_package_object_size (
614 union acpi_operand_object
*obj
,
615 acpi_size
*obj_length
);
618 acpi_ut_get_object_size(
619 union acpi_operand_object
*obj
,
620 acpi_size
*obj_length
);
623 acpi_ut_get_element_length (
625 union acpi_operand_object
*source_object
,
626 union acpi_generic_state
*state
,
631 * ut_state - Generic state creation/cache routines
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 (
648 struct acpi_thread_state
*
649 acpi_ut_create_thread_state (
652 union acpi_generic_state
*
653 acpi_ut_create_update_state (
654 union acpi_operand_object
*object
,
657 union acpi_generic_state
*
658 acpi_ut_create_pkg_state (
659 void *internal_object
,
660 void *external_object
,
664 acpi_ut_create_update_state_and_push (
665 union acpi_operand_object
*object
,
667 union acpi_generic_state
**state_list
);
669 #ifdef ACPI_FUTURE_USAGE
671 acpi_ut_create_pkg_state_and_push (
672 void *internal_object
,
673 void *external_object
,
675 union acpi_generic_state
**state_list
);
678 union acpi_generic_state
*
679 acpi_ut_create_control_state (
683 acpi_ut_delete_generic_state (
684 union acpi_generic_state
*state
);
686 #ifdef ACPI_ENABLE_OBJECT_CACHE
688 acpi_ut_delete_generic_state_cache (
692 acpi_ut_delete_object_cache (
701 acpi_ut_print_string (
707 acpi_integer in_dividend
,
708 acpi_integer in_divisor
,
709 acpi_integer
*out_quotient
,
710 acpi_integer
*out_remainder
);
713 acpi_ut_short_divide (
714 acpi_integer in_dividend
,
716 acpi_integer
*out_quotient
,
720 acpi_ut_valid_acpi_name (
724 acpi_ut_valid_acpi_character (
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
744 acpi_ut_get_resource_end_tag (
745 union acpi_operand_object
*obj_desc
);
748 acpi_ut_generate_checksum (
753 acpi_ut_dword_byte_swap (
757 acpi_ut_set_integer_width (
760 #ifdef ACPI_DEBUG_OUTPUT
762 acpi_ut_display_init_pathname (
764 struct acpi_namespace_node
*obj_handle
,
771 * Utalloc - memory allocation and object caching
775 acpi_ut_acquire_from_cache (
779 acpi_ut_release_to_cache (
783 #ifdef ACPI_ENABLE_OBJECT_CACHE
785 acpi_ut_delete_generic_cache (
790 acpi_ut_validate_buffer (
791 struct acpi_buffer
*buffer
);
794 acpi_ut_initialize_buffer (
795 struct acpi_buffer
*buffer
,
796 acpi_size required_length
);
799 /* Memory allocation functions */
816 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
819 acpi_ut_allocate_and_track (
826 acpi_ut_callocate_and_track (
833 acpi_ut_free_and_track (
839 struct acpi_debug_mem_block
*
840 acpi_ut_find_allocation (
845 acpi_ut_track_allocation (
847 struct acpi_debug_mem_block
*address
,
855 acpi_ut_remove_allocation (
857 struct acpi_debug_mem_block
*address
,
862 #ifdef ACPI_FUTURE_USAGE
864 acpi_ut_dump_allocation_info (
869 acpi_ut_dump_allocations (
875 #endif /* _ACUTILS_H */