ACPICA 20050708 from Bob Moore <robert.moore@intel.com>
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / include / acpi / acutils.h
CommitLineData
1da177e4
LT
1/******************************************************************************
2 *
3 * Name: acutils.h -- prototypes for the common (subsystem-wide) 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#ifndef _ACUTILS_H
45#define _ACUTILS_H
46
47
48typedef
49acpi_status (*acpi_pkg_callback) (
50 u8 object_type,
51 union acpi_operand_object *source_object,
52 union acpi_generic_state *state,
53 void *context);
54
1da177e4
LT
55struct acpi_pkg_info
56{
57 u8 *free_space;
58 acpi_size length;
59 u32 object_space;
60 u32 num_packages;
61};
62
63#define REF_INCREMENT (u16) 0
64#define REF_DECREMENT (u16) 1
65#define REF_FORCE_DELETE (u16) 2
66
67/* acpi_ut_dump_buffer */
68
69#define DB_BYTE_DISPLAY 1
70#define DB_WORD_DISPLAY 2
71#define DB_DWORD_DISPLAY 4
72#define DB_QWORD_DISPLAY 8
73
74
1da177e4 75/*
44f6c012 76 * utglobal - Global data structures and procedures
1da177e4 77 */
1da177e4 78void
44f6c012 79acpi_ut_init_globals (
1da177e4
LT
80 void);
81
1da177e4
LT
82#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
83
84char *
85acpi_ut_get_mutex_name (
86 u32 mutex_id);
87
88#endif
89
90char *
91acpi_ut_get_type_name (
92 acpi_object_type type);
93
94char *
95acpi_ut_get_node_name (
96 void *object);
97
98char *
99acpi_ut_get_descriptor_name (
100 void *object);
101
102char *
103acpi_ut_get_object_type_name (
104 union acpi_operand_object *obj_desc);
105
106char *
107acpi_ut_get_region_name (
108 u8 space_id);
109
110char *
111acpi_ut_get_event_name (
112 u32 event_id);
113
114char
115acpi_ut_hex_to_ascii_char (
116 acpi_integer integer,
117 u32 position);
118
119u8
120acpi_ut_valid_object_type (
121 acpi_object_type type);
122
1da177e4
LT
123
124/*
44f6c012 125 * utinit - miscellaneous initialization and shutdown
1da177e4 126 */
44f6c012
RM
127acpi_status
128acpi_ut_hardware_initialize (
129 void);
1da177e4 130
44f6c012
RM
131void
132acpi_ut_subsystem_shutdown (
133 void);
134
135acpi_status
136acpi_ut_validate_fadt (
137 void);
138
139
140/*
141 * utclib - Local implementations of C library functions
142 */
1da177e4
LT
143#ifndef ACPI_USE_SYSTEM_CLIBRARY
144
145acpi_size
146acpi_ut_strlen (
147 const char *string);
148
149char *
150acpi_ut_strcpy (
151 char *dst_string,
152 const char *src_string);
153
154char *
155acpi_ut_strncpy (
156 char *dst_string,
157 const char *src_string,
158 acpi_size count);
159
160int
161acpi_ut_memcmp (
162 const char *buffer1,
163 const char *buffer2,
164 acpi_size count);
165
166int
167acpi_ut_strncmp (
168 const char *string1,
169 const char *string2,
170 acpi_size count);
171
172int
173acpi_ut_strcmp (
174 const char *string1,
175 const char *string2);
176
177char *
178acpi_ut_strcat (
179 char *dst_string,
180 const char *src_string);
181
182char *
183acpi_ut_strncat (
184 char *dst_string,
185 const char *src_string,
186 acpi_size count);
187
188u32
189acpi_ut_strtoul (
190 const char *string,
191 char **terminator,
192 u32 base);
193
194char *
195acpi_ut_strstr (
196 char *string1,
197 char *string2);
198
199void *
200acpi_ut_memcpy (
201 void *dest,
202 const void *src,
203 acpi_size count);
204
205void *
206acpi_ut_memset (
207 void *dest,
208 acpi_native_uint value,
209 acpi_size count);
210
211int
212acpi_ut_to_upper (
213 int c);
214
215int
216acpi_ut_to_lower (
217 int c);
218
219extern const u8 _acpi_ctype[];
220
221#define _ACPI_XA 0x00 /* extra alphabetic - not supported */
222#define _ACPI_XS 0x40 /* extra space */
223#define _ACPI_BB 0x00 /* BEL, BS, etc. - not supported */
224#define _ACPI_CN 0x20 /* CR, FF, HT, NL, VT */
225#define _ACPI_DI 0x04 /* '0'-'9' */
226#define _ACPI_LO 0x02 /* 'a'-'z' */
227#define _ACPI_PU 0x10 /* punctuation */
228#define _ACPI_SP 0x08 /* space */
229#define _ACPI_UP 0x01 /* 'A'-'Z' */
230#define _ACPI_XD 0x80 /* '0'-'9', 'A'-'F', 'a'-'f' */
231
232#define ACPI_IS_DIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_DI))
233#define ACPI_IS_SPACE(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_SP))
234#define ACPI_IS_XDIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_XD))
235#define ACPI_IS_UPPER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_UP))
236#define ACPI_IS_LOWER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO))
237#define ACPI_IS_PRINT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_SP | _ACPI_PU))
238#define ACPI_IS_ALPHA(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP))
239#define ACPI_IS_ASCII(c) ((c) < 0x80)
240
241#endif /* ACPI_USE_SYSTEM_CLIBRARY */
242
44f6c012 243
1da177e4 244/*
44f6c012 245 * utcopy - Object construction and conversion interfaces
1da177e4 246 */
1da177e4
LT
247acpi_status
248acpi_ut_build_simple_object(
249 union acpi_operand_object *obj,
250 union acpi_object *user_obj,
251 u8 *data_space,
252 u32 *buffer_space_used);
253
254acpi_status
255acpi_ut_build_package_object (
256 union acpi_operand_object *obj,
257 u8 *buffer,
258 u32 *space_used);
259
1da177e4
LT
260acpi_status
261acpi_ut_copy_iobject_to_eobject (
262 union acpi_operand_object *obj,
263 struct acpi_buffer *ret_buffer);
264
1da177e4
LT
265acpi_status
266acpi_ut_copy_eobject_to_iobject (
267 union acpi_object *obj,
268 union acpi_operand_object **internal_obj);
269
270acpi_status
271acpi_ut_copy_isimple_to_isimple (
272 union acpi_operand_object *source_obj,
273 union acpi_operand_object *dest_obj);
274
1da177e4
LT
275acpi_status
276acpi_ut_copy_iobject_to_iobject (
277 union acpi_operand_object *source_desc,
278 union acpi_operand_object **dest_desc,
279 struct acpi_walk_state *walk_state);
280
281
282/*
44f6c012 283 * utcreate - Object creation
1da177e4 284 */
1da177e4
LT
285acpi_status
286acpi_ut_update_object_reference (
287 union acpi_operand_object *object,
288 u16 action);
289
290
291/*
44f6c012 292 * utdebug - Debug interfaces
1da177e4 293 */
1da177e4
LT
294void
295acpi_ut_init_stack_ptr_trace (
296 void);
297
298void
299acpi_ut_track_stack_ptr (
300 void);
301
302void
303acpi_ut_trace (
304 u32 line_number,
f9f4601f
RM
305 char *function_name,
306 char *module_name,
307 u32 component_id);
1da177e4
LT
308
309void
310acpi_ut_trace_ptr (
311 u32 line_number,
f9f4601f
RM
312 char *function_name,
313 char *module_name,
314 u32 component_id,
1da177e4
LT
315 void *pointer);
316
317void
318acpi_ut_trace_u32 (
319 u32 line_number,
f9f4601f
RM
320 char *function_name,
321 char *module_name,
322 u32 component_id,
1da177e4
LT
323 u32 integer);
324
325void
326acpi_ut_trace_str (
327 u32 line_number,
f9f4601f
RM
328 char *function_name,
329 char *module_name,
330 u32 component_id,
1da177e4
LT
331 char *string);
332
333void
334acpi_ut_exit (
335 u32 line_number,
f9f4601f
RM
336 char *function_name,
337 char *module_name,
338 u32 component_id);
1da177e4
LT
339
340void
341acpi_ut_status_exit (
342 u32 line_number,
f9f4601f
RM
343 char *function_name,
344 char *module_name,
345 u32 component_id,
1da177e4
LT
346 acpi_status status);
347
348void
349acpi_ut_value_exit (
350 u32 line_number,
f9f4601f
RM
351 char *function_name,
352 char *module_name,
353 u32 component_id,
1da177e4
LT
354 acpi_integer value);
355
356void
357acpi_ut_ptr_exit (
358 u32 line_number,
f9f4601f
RM
359 char *function_name,
360 char *module_name,
361 u32 component_id,
1da177e4
LT
362 u8 *ptr);
363
364void
365acpi_ut_report_info (
366 char *module_name,
367 u32 line_number,
368 u32 component_id);
369
370void
371acpi_ut_report_error (
372 char *module_name,
373 u32 line_number,
374 u32 component_id);
375
376void
377acpi_ut_report_warning (
378 char *module_name,
379 u32 line_number,
380 u32 component_id);
381
382void
383acpi_ut_dump_buffer (
384 u8 *buffer,
385 u32 count,
386 u32 display,
387 u32 component_id);
388
389void ACPI_INTERNAL_VAR_XFACE
390acpi_ut_debug_print (
391 u32 requested_debug_level,
392 u32 line_number,
f9f4601f
RM
393 char *function_name,
394 char *module_name,
395 u32 component_id,
1da177e4
LT
396 char *format,
397 ...) ACPI_PRINTF_LIKE_FUNC;
398
399void ACPI_INTERNAL_VAR_XFACE
400acpi_ut_debug_print_raw (
401 u32 requested_debug_level,
402 u32 line_number,
f9f4601f
RM
403 char *function_name,
404 char *module_name,
405 u32 component_id,
1da177e4
LT
406 char *format,
407 ...) ACPI_PRINTF_LIKE_FUNC;
408
409
410/*
44f6c012 411 * utdelete - Object deletion and reference counts
1da177e4 412 */
44f6c012
RM
413void
414acpi_ut_add_reference (
415 union acpi_operand_object *object);
1da177e4
LT
416
417void
44f6c012 418acpi_ut_remove_reference (
1da177e4
LT
419 union acpi_operand_object *object);
420
421void
422acpi_ut_delete_internal_package_object (
423 union acpi_operand_object *object);
424
425void
426acpi_ut_delete_internal_simple_object (
427 union acpi_operand_object *object);
428
429void
430acpi_ut_delete_internal_object_list (
431 union acpi_operand_object **obj_list);
432
433
434/*
44f6c012 435 * uteval - object evaluation
1da177e4 436 */
1da177e4
LT
437acpi_status
438acpi_ut_osi_implementation (
439 struct acpi_walk_state *walk_state);
440
441acpi_status
442acpi_ut_evaluate_object (
443 struct acpi_namespace_node *prefix_node,
444 char *path,
445 u32 expected_return_btypes,
446 union acpi_operand_object **return_desc);
447
448acpi_status
449acpi_ut_evaluate_numeric_object (
450 char *object_name,
451 struct acpi_namespace_node *device_node,
452 acpi_integer *address);
453
454acpi_status
455acpi_ut_execute_HID (
456 struct acpi_namespace_node *device_node,
457 struct acpi_device_id *hid);
458
459acpi_status
460acpi_ut_execute_CID (
461 struct acpi_namespace_node *device_node,
462 struct acpi_compatible_id_list **return_cid_list);
463
464acpi_status
465acpi_ut_execute_STA (
466 struct acpi_namespace_node *device_node,
467 u32 *status_flags);
468
469acpi_status
470acpi_ut_execute_UID (
471 struct acpi_namespace_node *device_node,
472 struct acpi_device_id *uid);
473
474acpi_status
475acpi_ut_execute_sxds (
476 struct acpi_namespace_node *device_node,
477 u8 *highest);
478
1da177e4
LT
479
480/*
44f6c012 481 * utobject - internal object create/delete/cache routines
1da177e4 482 */
1da177e4
LT
483union acpi_operand_object *
484acpi_ut_create_internal_object_dbg (
485 char *module_name,
486 u32 line_number,
487 u32 component_id,
488 acpi_object_type type);
489
490void *
491acpi_ut_allocate_object_desc_dbg (
492 char *module_name,
493 u32 line_number,
494 u32 component_id);
495
f9f4601f
RM
496#define acpi_ut_create_internal_object(t) acpi_ut_create_internal_object_dbg (_acpi_module_name,__LINE__,_COMPONENT,t)
497#define acpi_ut_allocate_object_desc() acpi_ut_allocate_object_desc_dbg (_acpi_module_name,__LINE__,_COMPONENT)
1da177e4
LT
498
499void
500acpi_ut_delete_object_desc (
501 union acpi_operand_object *object);
502
503u8
504acpi_ut_valid_internal_object (
505 void *object);
506
507union acpi_operand_object *
508acpi_ut_create_buffer_object (
509 acpi_size buffer_size);
510
511union acpi_operand_object *
512acpi_ut_create_string_object (
513 acpi_size string_size);
514
1da177e4
LT
515acpi_status
516acpi_ut_get_object_size(
517 union acpi_operand_object *obj,
518 acpi_size *obj_length);
519
1da177e4
LT
520
521/*
44f6c012 522 * utstate - Generic state creation/cache routines
1da177e4 523 */
1da177e4
LT
524void
525acpi_ut_push_generic_state (
526 union acpi_generic_state **list_head,
527 union acpi_generic_state *state);
528
529union acpi_generic_state *
530acpi_ut_pop_generic_state (
531 union acpi_generic_state **list_head);
532
533
534union acpi_generic_state *
535acpi_ut_create_generic_state (
536 void);
537
538struct acpi_thread_state *
539acpi_ut_create_thread_state (
540 void);
541
542union acpi_generic_state *
543acpi_ut_create_update_state (
544 union acpi_operand_object *object,
545 u16 action);
546
547union acpi_generic_state *
548acpi_ut_create_pkg_state (
549 void *internal_object,
550 void *external_object,
551 u16 index);
552
553acpi_status
554acpi_ut_create_update_state_and_push (
555 union acpi_operand_object *object,
556 u16 action,
557 union acpi_generic_state **state_list);
558
44f6c012 559#ifdef ACPI_FUTURE_USAGE
1da177e4
LT
560acpi_status
561acpi_ut_create_pkg_state_and_push (
562 void *internal_object,
563 void *external_object,
564 u16 index,
565 union acpi_generic_state **state_list);
44f6c012 566#endif /* ACPI_FUTURE_USAGE */
1da177e4
LT
567
568union acpi_generic_state *
569acpi_ut_create_control_state (
570 void);
571
572void
573acpi_ut_delete_generic_state (
574 union acpi_generic_state *state);
575
44f6c012 576
1da177e4 577/*
44f6c012 578 * utmath
1da177e4 579 */
1da177e4
LT
580acpi_status
581acpi_ut_divide (
582 acpi_integer in_dividend,
583 acpi_integer in_divisor,
584 acpi_integer *out_quotient,
585 acpi_integer *out_remainder);
586
587acpi_status
588acpi_ut_short_divide (
589 acpi_integer in_dividend,
590 u32 divisor,
591 acpi_integer *out_quotient,
592 u32 *out_remainder);
593
44f6c012
RM
594/*
595 * utmisc
596 */
597acpi_status
f9f4601f
RM
598acpi_ut_allocate_owner_id (
599 acpi_owner_id *owner_id);
600
601acpi_status
602acpi_ut_release_owner_id (
603 acpi_owner_id owner_id);
604
605acpi_status
44f6c012
RM
606acpi_ut_walk_package_tree (
607 union acpi_operand_object *source_object,
608 void *target_object,
609 acpi_pkg_callback walk_callback,
610 void *context);
611
612char *
613acpi_ut_strupr (
614 char *src_string);
615
616void
617acpi_ut_print_string (
618 char *string,
619 u8 max_length);
620
1da177e4
LT
621u8
622acpi_ut_valid_acpi_name (
623 u32 name);
624
625u8
626acpi_ut_valid_acpi_character (
627 char character);
628
629acpi_status
630acpi_ut_strtoul64 (
631 char *string,
632 u32 base,
633 acpi_integer *ret_integer);
634
635/* Values for Base above (16=Hex, 10=Decimal) */
636
637#define ACPI_ANY_BASE 0
638
1da177e4
LT
639u8 *
640acpi_ut_get_resource_end_tag (
641 union acpi_operand_object *obj_desc);
642
643u8
644acpi_ut_generate_checksum (
645 u8 *buffer,
646 u32 length);
647
648u32
649acpi_ut_dword_byte_swap (
650 u32 value);
651
652void
653acpi_ut_set_integer_width (
654 u8 revision);
655
656#ifdef ACPI_DEBUG_OUTPUT
657void
658acpi_ut_display_init_pathname (
659 u8 type,
660 struct acpi_namespace_node *obj_handle,
661 char *path);
662
663#endif
664
665
666/*
73459f73 667 * utmutex - mutex support
1da177e4 668 */
73459f73
RM
669acpi_status
670acpi_ut_mutex_initialize (
671 void);
1da177e4
LT
672
673void
73459f73
RM
674acpi_ut_mutex_terminate (
675 void);
1da177e4 676
73459f73
RM
677acpi_status
678acpi_ut_acquire_mutex (
679 acpi_mutex_handle mutex_id);
680
681acpi_status
682acpi_ut_release_mutex (
683 acpi_mutex_handle mutex_id);
684
685
686/*
687 * utalloc - memory allocation and object caching
688 */
689acpi_status
690acpi_ut_create_caches (
691 void);
692
693acpi_status
694acpi_ut_delete_caches (
695 void);
1da177e4
LT
696
697acpi_status
698acpi_ut_validate_buffer (
699 struct acpi_buffer *buffer);
700
701acpi_status
702acpi_ut_initialize_buffer (
703 struct acpi_buffer *buffer,
704 acpi_size required_length);
705
1da177e4
LT
706void *
707acpi_ut_allocate (
708 acpi_size size,
709 u32 component,
710 char *module,
711 u32 line);
712
713void *
714acpi_ut_callocate (
715 acpi_size size,
716 u32 component,
717 char *module,
718 u32 line);
719
1da177e4 720#ifdef ACPI_DBG_TRACK_ALLOCATIONS
1da177e4
LT
721void *
722acpi_ut_allocate_and_track (
723 acpi_size size,
724 u32 component,
725 char *module,
726 u32 line);
727
728void *
729acpi_ut_callocate_and_track (
730 acpi_size size,
731 u32 component,
732 char *module,
733 u32 line);
734
735void
736acpi_ut_free_and_track (
737 void *address,
738 u32 component,
739 char *module,
740 u32 line);
741
44f6c012 742#ifdef ACPI_FUTURE_USAGE
1da177e4
LT
743void
744acpi_ut_dump_allocation_info (
745 void);
44f6c012 746#endif /* ACPI_FUTURE_USAGE */
1da177e4
LT
747
748void
749acpi_ut_dump_allocations (
750 u32 component,
751 char *module);
752#endif
753
1da177e4 754#endif /* _ACUTILS_H */