[ACPI] revert R40 workaround
[deliverable/linux.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
123acpi_owner_id
124acpi_ut_allocate_owner_id (
125 u32 id_type);
126
127
128/*
44f6c012 129 * utinit - miscellaneous initialization and shutdown
1da177e4 130 */
44f6c012
RM
131acpi_status
132acpi_ut_hardware_initialize (
133 void);
1da177e4 134
44f6c012
RM
135void
136acpi_ut_subsystem_shutdown (
137 void);
138
139acpi_status
140acpi_ut_validate_fadt (
141 void);
142
143
144/*
145 * utclib - Local implementations of C library functions
146 */
1da177e4
LT
147#ifndef ACPI_USE_SYSTEM_CLIBRARY
148
149acpi_size
150acpi_ut_strlen (
151 const char *string);
152
153char *
154acpi_ut_strcpy (
155 char *dst_string,
156 const char *src_string);
157
158char *
159acpi_ut_strncpy (
160 char *dst_string,
161 const char *src_string,
162 acpi_size count);
163
164int
165acpi_ut_memcmp (
166 const char *buffer1,
167 const char *buffer2,
168 acpi_size count);
169
170int
171acpi_ut_strncmp (
172 const char *string1,
173 const char *string2,
174 acpi_size count);
175
176int
177acpi_ut_strcmp (
178 const char *string1,
179 const char *string2);
180
181char *
182acpi_ut_strcat (
183 char *dst_string,
184 const char *src_string);
185
186char *
187acpi_ut_strncat (
188 char *dst_string,
189 const char *src_string,
190 acpi_size count);
191
192u32
193acpi_ut_strtoul (
194 const char *string,
195 char **terminator,
196 u32 base);
197
198char *
199acpi_ut_strstr (
200 char *string1,
201 char *string2);
202
203void *
204acpi_ut_memcpy (
205 void *dest,
206 const void *src,
207 acpi_size count);
208
209void *
210acpi_ut_memset (
211 void *dest,
212 acpi_native_uint value,
213 acpi_size count);
214
215int
216acpi_ut_to_upper (
217 int c);
218
219int
220acpi_ut_to_lower (
221 int c);
222
223extern const u8 _acpi_ctype[];
224
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' */
235
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)
244
245#endif /* ACPI_USE_SYSTEM_CLIBRARY */
246
44f6c012 247
1da177e4 248/*
44f6c012 249 * utcopy - Object construction and conversion interfaces
1da177e4 250 */
1da177e4
LT
251acpi_status
252acpi_ut_build_simple_object(
253 union acpi_operand_object *obj,
254 union acpi_object *user_obj,
255 u8 *data_space,
256 u32 *buffer_space_used);
257
258acpi_status
259acpi_ut_build_package_object (
260 union acpi_operand_object *obj,
261 u8 *buffer,
262 u32 *space_used);
263
1da177e4
LT
264acpi_status
265acpi_ut_copy_iobject_to_eobject (
266 union acpi_operand_object *obj,
267 struct acpi_buffer *ret_buffer);
268
1da177e4
LT
269acpi_status
270acpi_ut_copy_eobject_to_iobject (
271 union acpi_object *obj,
272 union acpi_operand_object **internal_obj);
273
274acpi_status
275acpi_ut_copy_isimple_to_isimple (
276 union acpi_operand_object *source_obj,
277 union acpi_operand_object *dest_obj);
278
1da177e4
LT
279acpi_status
280acpi_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);
284
285
286/*
44f6c012 287 * utcreate - Object creation
1da177e4 288 */
1da177e4
LT
289acpi_status
290acpi_ut_update_object_reference (
291 union acpi_operand_object *object,
292 u16 action);
293
294
295/*
44f6c012 296 * utdebug - Debug interfaces
1da177e4 297 */
1da177e4
LT
298void
299acpi_ut_init_stack_ptr_trace (
300 void);
301
302void
303acpi_ut_track_stack_ptr (
304 void);
305
306void
307acpi_ut_trace (
308 u32 line_number,
309 struct acpi_debug_print_info *dbg_info);
310
311void
312acpi_ut_trace_ptr (
313 u32 line_number,
314 struct acpi_debug_print_info *dbg_info,
315 void *pointer);
316
317void
318acpi_ut_trace_u32 (
319 u32 line_number,
320 struct acpi_debug_print_info *dbg_info,
321 u32 integer);
322
323void
324acpi_ut_trace_str (
325 u32 line_number,
326 struct acpi_debug_print_info *dbg_info,
327 char *string);
328
329void
330acpi_ut_exit (
331 u32 line_number,
332 struct acpi_debug_print_info *dbg_info);
333
334void
335acpi_ut_status_exit (
336 u32 line_number,
337 struct acpi_debug_print_info *dbg_info,
338 acpi_status status);
339
340void
341acpi_ut_value_exit (
342 u32 line_number,
343 struct acpi_debug_print_info *dbg_info,
344 acpi_integer value);
345
346void
347acpi_ut_ptr_exit (
348 u32 line_number,
349 struct acpi_debug_print_info *dbg_info,
350 u8 *ptr);
351
352void
353acpi_ut_report_info (
354 char *module_name,
355 u32 line_number,
356 u32 component_id);
357
358void
359acpi_ut_report_error (
360 char *module_name,
361 u32 line_number,
362 u32 component_id);
363
364void
365acpi_ut_report_warning (
366 char *module_name,
367 u32 line_number,
368 u32 component_id);
369
370void
371acpi_ut_dump_buffer (
372 u8 *buffer,
373 u32 count,
374 u32 display,
375 u32 component_id);
376
377void ACPI_INTERNAL_VAR_XFACE
378acpi_ut_debug_print (
379 u32 requested_debug_level,
380 u32 line_number,
381 struct acpi_debug_print_info *dbg_info,
382 char *format,
383 ...) ACPI_PRINTF_LIKE_FUNC;
384
385void ACPI_INTERNAL_VAR_XFACE
386acpi_ut_debug_print_raw (
387 u32 requested_debug_level,
388 u32 line_number,
389 struct acpi_debug_print_info *dbg_info,
390 char *format,
391 ...) ACPI_PRINTF_LIKE_FUNC;
392
393
394/*
44f6c012 395 * utdelete - Object deletion and reference counts
1da177e4 396 */
44f6c012
RM
397void
398acpi_ut_add_reference (
399 union acpi_operand_object *object);
1da177e4
LT
400
401void
44f6c012 402acpi_ut_remove_reference (
1da177e4
LT
403 union acpi_operand_object *object);
404
405void
406acpi_ut_delete_internal_package_object (
407 union acpi_operand_object *object);
408
409void
410acpi_ut_delete_internal_simple_object (
411 union acpi_operand_object *object);
412
413void
414acpi_ut_delete_internal_object_list (
415 union acpi_operand_object **obj_list);
416
417
418/*
44f6c012 419 * uteval - object evaluation
1da177e4 420 */
1da177e4
LT
421acpi_status
422acpi_ut_osi_implementation (
423 struct acpi_walk_state *walk_state);
424
425acpi_status
426acpi_ut_evaluate_object (
427 struct acpi_namespace_node *prefix_node,
428 char *path,
429 u32 expected_return_btypes,
430 union acpi_operand_object **return_desc);
431
432acpi_status
433acpi_ut_evaluate_numeric_object (
434 char *object_name,
435 struct acpi_namespace_node *device_node,
436 acpi_integer *address);
437
438acpi_status
439acpi_ut_execute_HID (
440 struct acpi_namespace_node *device_node,
441 struct acpi_device_id *hid);
442
443acpi_status
444acpi_ut_execute_CID (
445 struct acpi_namespace_node *device_node,
446 struct acpi_compatible_id_list **return_cid_list);
447
448acpi_status
449acpi_ut_execute_STA (
450 struct acpi_namespace_node *device_node,
451 u32 *status_flags);
452
453acpi_status
454acpi_ut_execute_UID (
455 struct acpi_namespace_node *device_node,
456 struct acpi_device_id *uid);
457
458acpi_status
459acpi_ut_execute_sxds (
460 struct acpi_namespace_node *device_node,
461 u8 *highest);
462
1da177e4
LT
463
464/*
44f6c012 465 * utobject - internal object create/delete/cache routines
1da177e4 466 */
1da177e4
LT
467union acpi_operand_object *
468acpi_ut_create_internal_object_dbg (
469 char *module_name,
470 u32 line_number,
471 u32 component_id,
472 acpi_object_type type);
473
474void *
475acpi_ut_allocate_object_desc_dbg (
476 char *module_name,
477 u32 line_number,
478 u32 component_id);
479
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)
482
483void
484acpi_ut_delete_object_desc (
485 union acpi_operand_object *object);
486
487u8
488acpi_ut_valid_internal_object (
489 void *object);
490
491union acpi_operand_object *
492acpi_ut_create_buffer_object (
493 acpi_size buffer_size);
494
495union acpi_operand_object *
496acpi_ut_create_string_object (
497 acpi_size string_size);
498
1da177e4
LT
499acpi_status
500acpi_ut_get_object_size(
501 union acpi_operand_object *obj,
502 acpi_size *obj_length);
503
1da177e4
LT
504
505/*
44f6c012 506 * utstate - Generic state creation/cache routines
1da177e4 507 */
1da177e4
LT
508void
509acpi_ut_push_generic_state (
510 union acpi_generic_state **list_head,
511 union acpi_generic_state *state);
512
513union acpi_generic_state *
514acpi_ut_pop_generic_state (
515 union acpi_generic_state **list_head);
516
517
518union acpi_generic_state *
519acpi_ut_create_generic_state (
520 void);
521
522struct acpi_thread_state *
523acpi_ut_create_thread_state (
524 void);
525
526union acpi_generic_state *
527acpi_ut_create_update_state (
528 union acpi_operand_object *object,
529 u16 action);
530
531union acpi_generic_state *
532acpi_ut_create_pkg_state (
533 void *internal_object,
534 void *external_object,
535 u16 index);
536
537acpi_status
538acpi_ut_create_update_state_and_push (
539 union acpi_operand_object *object,
540 u16 action,
541 union acpi_generic_state **state_list);
542
44f6c012 543#ifdef ACPI_FUTURE_USAGE
1da177e4
LT
544acpi_status
545acpi_ut_create_pkg_state_and_push (
546 void *internal_object,
547 void *external_object,
548 u16 index,
549 union acpi_generic_state **state_list);
44f6c012 550#endif /* ACPI_FUTURE_USAGE */
1da177e4
LT
551
552union acpi_generic_state *
553acpi_ut_create_control_state (
554 void);
555
556void
557acpi_ut_delete_generic_state (
558 union acpi_generic_state *state);
559
44f6c012 560
1da177e4 561/*
44f6c012 562 * utmath
1da177e4 563 */
1da177e4
LT
564acpi_status
565acpi_ut_divide (
566 acpi_integer in_dividend,
567 acpi_integer in_divisor,
568 acpi_integer *out_quotient,
569 acpi_integer *out_remainder);
570
571acpi_status
572acpi_ut_short_divide (
573 acpi_integer in_dividend,
574 u32 divisor,
575 acpi_integer *out_quotient,
576 u32 *out_remainder);
577
44f6c012
RM
578/*
579 * utmisc
580 */
581acpi_status
582acpi_ut_walk_package_tree (
583 union acpi_operand_object *source_object,
584 void *target_object,
585 acpi_pkg_callback walk_callback,
586 void *context);
587
588char *
589acpi_ut_strupr (
590 char *src_string);
591
592void
593acpi_ut_print_string (
594 char *string,
595 u8 max_length);
596
1da177e4
LT
597u8
598acpi_ut_valid_acpi_name (
599 u32 name);
600
601u8
602acpi_ut_valid_acpi_character (
603 char character);
604
605acpi_status
606acpi_ut_strtoul64 (
607 char *string,
608 u32 base,
609 acpi_integer *ret_integer);
610
611/* Values for Base above (16=Hex, 10=Decimal) */
612
613#define ACPI_ANY_BASE 0
614
1da177e4
LT
615u8 *
616acpi_ut_get_resource_end_tag (
617 union acpi_operand_object *obj_desc);
618
619u8
620acpi_ut_generate_checksum (
621 u8 *buffer,
622 u32 length);
623
624u32
625acpi_ut_dword_byte_swap (
626 u32 value);
627
628void
629acpi_ut_set_integer_width (
630 u8 revision);
631
632#ifdef ACPI_DEBUG_OUTPUT
633void
634acpi_ut_display_init_pathname (
635 u8 type,
636 struct acpi_namespace_node *obj_handle,
637 char *path);
638
639#endif
640
641
642/*
73459f73 643 * utmutex - mutex support
1da177e4 644 */
73459f73
RM
645acpi_status
646acpi_ut_mutex_initialize (
647 void);
1da177e4
LT
648
649void
73459f73
RM
650acpi_ut_mutex_terminate (
651 void);
1da177e4 652
73459f73
RM
653acpi_status
654acpi_ut_acquire_mutex (
655 acpi_mutex_handle mutex_id);
656
657acpi_status
658acpi_ut_release_mutex (
659 acpi_mutex_handle mutex_id);
660
661
662/*
663 * utalloc - memory allocation and object caching
664 */
665acpi_status
666acpi_ut_create_caches (
667 void);
668
669acpi_status
670acpi_ut_delete_caches (
671 void);
1da177e4
LT
672
673acpi_status
674acpi_ut_validate_buffer (
675 struct acpi_buffer *buffer);
676
677acpi_status
678acpi_ut_initialize_buffer (
679 struct acpi_buffer *buffer,
680 acpi_size required_length);
681
1da177e4
LT
682void *
683acpi_ut_allocate (
684 acpi_size size,
685 u32 component,
686 char *module,
687 u32 line);
688
689void *
690acpi_ut_callocate (
691 acpi_size size,
692 u32 component,
693 char *module,
694 u32 line);
695
1da177e4 696#ifdef ACPI_DBG_TRACK_ALLOCATIONS
1da177e4
LT
697void *
698acpi_ut_allocate_and_track (
699 acpi_size size,
700 u32 component,
701 char *module,
702 u32 line);
703
704void *
705acpi_ut_callocate_and_track (
706 acpi_size size,
707 u32 component,
708 char *module,
709 u32 line);
710
711void
712acpi_ut_free_and_track (
713 void *address,
714 u32 component,
715 char *module,
716 u32 line);
717
44f6c012 718#ifdef ACPI_FUTURE_USAGE
1da177e4
LT
719void
720acpi_ut_dump_allocation_info (
721 void);
44f6c012 722#endif /* ACPI_FUTURE_USAGE */
1da177e4
LT
723
724void
725acpi_ut_dump_allocations (
726 u32 component,
727 char *module);
728#endif
729
1da177e4 730#endif /* _ACUTILS_H */
This page took 0.100971 seconds and 5 git commands to generate.