aboutsummaryrefslogtreecommitdiffstats
path: root/include/acpi/acutils.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/acpi/acutils.h
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'include/acpi/acutils.h')
-rw-r--r--include/acpi/acutils.h875
1 files changed, 875 insertions, 0 deletions
diff --git a/include/acpi/acutils.h b/include/acpi/acutils.h
new file mode 100644
index 000000000000..0de26b8f1028
--- /dev/null
+++ b/include/acpi/acutils.h
@@ -0,0 +1,875 @@
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
55acpi_status
56acpi_ut_walk_package_tree (
57 union acpi_operand_object *source_object,
58 void *target_object,
59 acpi_pkg_callback walk_callback,
60 void *context);
61
62struct acpi_pkg_info
63{
64 u8 *free_space;
65 acpi_size length;
66 u32 object_space;
67 u32 num_packages;
68};
69
70#define REF_INCREMENT (u16) 0
71#define REF_DECREMENT (u16) 1
72#define REF_FORCE_DELETE (u16) 2
73
74/* acpi_ut_dump_buffer */
75
76#define DB_BYTE_DISPLAY 1
77#define DB_WORD_DISPLAY 2
78#define DB_DWORD_DISPLAY 4
79#define DB_QWORD_DISPLAY 8
80
81
82/* Global initialization interfaces */
83
84void
85acpi_ut_init_globals (
86 void);
87
88void
89acpi_ut_terminate (
90 void);
91
92
93/*
94 * ut_init - miscellaneous initialization and shutdown
95 */
96
97acpi_status
98acpi_ut_hardware_initialize (
99 void);
100
101void
102acpi_ut_subsystem_shutdown (
103 void);
104
105acpi_status
106acpi_ut_validate_fadt (
107 void);
108
109/*
110 * ut_global - Global data structures and procedures
111 */
112
113#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
114
115char *
116acpi_ut_get_mutex_name (
117 u32 mutex_id);
118
119#endif
120
121char *
122acpi_ut_get_type_name (
123 acpi_object_type type);
124
125char *
126acpi_ut_get_node_name (
127 void *object);
128
129char *
130acpi_ut_get_descriptor_name (
131 void *object);
132
133char *
134acpi_ut_get_object_type_name (
135 union acpi_operand_object *obj_desc);
136
137char *
138acpi_ut_get_region_name (
139 u8 space_id);
140
141char *
142acpi_ut_get_event_name (
143 u32 event_id);
144
145char
146acpi_ut_hex_to_ascii_char (
147 acpi_integer integer,
148 u32 position);
149
150u8
151acpi_ut_valid_object_type (
152 acpi_object_type type);
153
154acpi_owner_id
155acpi_ut_allocate_owner_id (
156 u32 id_type);
157
158
159/*
160 * ut_clib - Local implementations of C library functions
161 */
162
163#ifndef ACPI_USE_SYSTEM_CLIBRARY
164
165acpi_size
166acpi_ut_strlen (
167 const char *string);
168
169char *
170acpi_ut_strcpy (
171 char *dst_string,
172 const char *src_string);
173
174char *
175acpi_ut_strncpy (
176 char *dst_string,
177 const char *src_string,
178 acpi_size count);
179
180int
181acpi_ut_memcmp (
182 const char *buffer1,
183 const char *buffer2,
184 acpi_size count);
185
186int
187acpi_ut_strncmp (
188 const char *string1,
189 const char *string2,
190 acpi_size count);
191
192int
193acpi_ut_strcmp (
194 const char *string1,
195 const char *string2);
196
197char *
198acpi_ut_strcat (
199 char *dst_string,
200 const char *src_string);
201
202char *
203acpi_ut_strncat (
204 char *dst_string,
205 const char *src_string,
206 acpi_size count);
207
208u32
209acpi_ut_strtoul (
210 const char *string,
211 char **terminator,
212 u32 base);
213
214char *
215acpi_ut_strstr (
216 char *string1,
217 char *string2);
218
219void *
220acpi_ut_memcpy (
221 void *dest,
222 const void *src,
223 acpi_size count);
224
225void *
226acpi_ut_memset (
227 void *dest,
228 acpi_native_uint value,
229 acpi_size count);
230
231int
232acpi_ut_to_upper (
233 int c);
234
235int
236acpi_ut_to_lower (
237 int c);
238
239extern const u8 _acpi_ctype[];
240
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' */
251
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)
260
261#endif /* ACPI_USE_SYSTEM_CLIBRARY */
262
263/*
264 * ut_copy - Object construction and conversion interfaces
265 */
266
267acpi_status
268acpi_ut_build_simple_object(
269 union acpi_operand_object *obj,
270 union acpi_object *user_obj,
271 u8 *data_space,
272 u32 *buffer_space_used);
273
274acpi_status
275acpi_ut_build_package_object (
276 union acpi_operand_object *obj,
277 u8 *buffer,
278 u32 *space_used);
279
280acpi_status
281acpi_ut_copy_ielement_to_eelement (
282 u8 object_type,
283 union acpi_operand_object *source_object,
284 union acpi_generic_state *state,
285 void *context);
286
287acpi_status
288acpi_ut_copy_ielement_to_ielement (
289 u8 object_type,
290 union acpi_operand_object *source_object,
291 union acpi_generic_state *state,
292 void *context);
293
294acpi_status
295acpi_ut_copy_iobject_to_eobject (
296 union acpi_operand_object *obj,
297 struct acpi_buffer *ret_buffer);
298
299acpi_status
300acpi_ut_copy_esimple_to_isimple(
301 union acpi_object *user_obj,
302 union acpi_operand_object **return_obj);
303
304acpi_status
305acpi_ut_copy_eobject_to_iobject (
306 union acpi_object *obj,
307 union acpi_operand_object **internal_obj);
308
309acpi_status
310acpi_ut_copy_isimple_to_isimple (
311 union acpi_operand_object *source_obj,
312 union acpi_operand_object *dest_obj);
313
314acpi_status
315acpi_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);
319
320acpi_status
321acpi_ut_copy_simple_object (
322 union acpi_operand_object *source_desc,
323 union acpi_operand_object *dest_desc);
324
325acpi_status
326acpi_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);
330
331
332/*
333 * ut_create - Object creation
334 */
335
336acpi_status
337acpi_ut_update_object_reference (
338 union acpi_operand_object *object,
339 u16 action);
340
341
342/*
343 * ut_debug - Debug interfaces
344 */
345
346void
347acpi_ut_init_stack_ptr_trace (
348 void);
349
350void
351acpi_ut_track_stack_ptr (
352 void);
353
354void
355acpi_ut_trace (
356 u32 line_number,
357 struct acpi_debug_print_info *dbg_info);
358
359void
360acpi_ut_trace_ptr (
361 u32 line_number,
362 struct acpi_debug_print_info *dbg_info,
363 void *pointer);
364
365void
366acpi_ut_trace_u32 (
367 u32 line_number,
368 struct acpi_debug_print_info *dbg_info,
369 u32 integer);
370
371void
372acpi_ut_trace_str (
373 u32 line_number,
374 struct acpi_debug_print_info *dbg_info,
375 char *string);
376
377void
378acpi_ut_exit (
379 u32 line_number,
380 struct acpi_debug_print_info *dbg_info);
381
382void
383acpi_ut_status_exit (
384 u32 line_number,
385 struct acpi_debug_print_info *dbg_info,
386 acpi_status status);
387
388void
389acpi_ut_value_exit (
390 u32 line_number,
391 struct acpi_debug_print_info *dbg_info,
392 acpi_integer value);
393
394void
395acpi_ut_ptr_exit (
396 u32 line_number,
397 struct acpi_debug_print_info *dbg_info,
398 u8 *ptr);
399
400void
401acpi_ut_report_info (
402 char *module_name,
403 u32 line_number,
404 u32 component_id);
405
406void
407acpi_ut_report_error (
408 char *module_name,
409 u32 line_number,
410 u32 component_id);
411
412void
413acpi_ut_report_warning (
414 char *module_name,
415 u32 line_number,
416 u32 component_id);
417
418void
419acpi_ut_dump_buffer (
420 u8 *buffer,
421 u32 count,
422 u32 display,
423 u32 component_id);
424
425void ACPI_INTERNAL_VAR_XFACE
426acpi_ut_debug_print (
427 u32 requested_debug_level,
428 u32 line_number,
429 struct acpi_debug_print_info *dbg_info,
430 char *format,
431 ...) ACPI_PRINTF_LIKE_FUNC;
432
433void ACPI_INTERNAL_VAR_XFACE
434acpi_ut_debug_print_raw (
435 u32 requested_debug_level,
436 u32 line_number,
437 struct acpi_debug_print_info *dbg_info,
438 char *format,
439 ...) ACPI_PRINTF_LIKE_FUNC;
440
441
442/*
443 * ut_delete - Object deletion
444 */
445
446void
447acpi_ut_delete_internal_obj (
448 union acpi_operand_object *object);
449
450void
451acpi_ut_delete_internal_package_object (
452 union acpi_operand_object *object);
453
454void
455acpi_ut_delete_internal_simple_object (
456 union acpi_operand_object *object);
457
458void
459acpi_ut_delete_internal_object_list (
460 union acpi_operand_object **obj_list);
461
462
463/*
464 * ut_eval - object evaluation
465 */
466
467/* Method name strings */
468
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"
481
482
483acpi_status
484acpi_ut_osi_implementation (
485 struct acpi_walk_state *walk_state);
486
487acpi_status
488acpi_ut_evaluate_object (
489 struct acpi_namespace_node *prefix_node,
490 char *path,
491 u32 expected_return_btypes,
492 union acpi_operand_object **return_desc);
493
494acpi_status
495acpi_ut_evaluate_numeric_object (
496 char *object_name,
497 struct acpi_namespace_node *device_node,
498 acpi_integer *address);
499
500acpi_status
501acpi_ut_execute_HID (
502 struct acpi_namespace_node *device_node,
503 struct acpi_device_id *hid);
504
505acpi_status
506acpi_ut_execute_CID (
507 struct acpi_namespace_node *device_node,
508 struct acpi_compatible_id_list **return_cid_list);
509
510acpi_status
511acpi_ut_execute_STA (
512 struct acpi_namespace_node *device_node,
513 u32 *status_flags);
514
515acpi_status
516acpi_ut_execute_UID (
517 struct acpi_namespace_node *device_node,
518 struct acpi_device_id *uid);
519
520acpi_status
521acpi_ut_execute_sxds (
522 struct acpi_namespace_node *device_node,
523 u8 *highest);
524
525/*
526 * ut_mutex - mutual exclusion interfaces
527 */
528
529acpi_status
530acpi_ut_mutex_initialize (
531 void);
532
533void
534acpi_ut_mutex_terminate (
535 void);
536
537acpi_status
538acpi_ut_create_mutex (
539 acpi_mutex_handle mutex_id);
540
541acpi_status
542acpi_ut_delete_mutex (
543 acpi_mutex_handle mutex_id);
544
545acpi_status
546acpi_ut_acquire_mutex (
547 acpi_mutex_handle mutex_id);
548
549acpi_status
550acpi_ut_release_mutex (
551 acpi_mutex_handle mutex_id);
552
553
554/*
555 * ut_object - internal object create/delete/cache routines
556 */
557
558union acpi_operand_object *
559acpi_ut_create_internal_object_dbg (
560 char *module_name,
561 u32 line_number,
562 u32 component_id,
563 acpi_object_type type);
564
565void *
566acpi_ut_allocate_object_desc_dbg (
567 char *module_name,
568 u32 line_number,
569 u32 component_id);
570
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)
573
574void
575acpi_ut_delete_object_desc (
576 union acpi_operand_object *object);
577
578u8
579acpi_ut_valid_internal_object (
580 void *object);
581
582union acpi_operand_object *
583acpi_ut_create_buffer_object (
584 acpi_size buffer_size);
585
586union acpi_operand_object *
587acpi_ut_create_string_object (
588 acpi_size string_size);
589
590
591/*
592 * ut_ref_cnt - Object reference count management
593 */
594
595void
596acpi_ut_add_reference (
597 union acpi_operand_object *object);
598
599void
600acpi_ut_remove_reference (
601 union acpi_operand_object *object);
602
603/*
604 * ut_size - Object size routines
605 */
606
607acpi_status
608acpi_ut_get_simple_object_size (
609 union acpi_operand_object *obj,
610 acpi_size *obj_length);
611
612acpi_status
613acpi_ut_get_package_object_size (
614 union acpi_operand_object *obj,
615 acpi_size *obj_length);
616
617acpi_status
618acpi_ut_get_object_size(
619 union acpi_operand_object *obj,
620 acpi_size *obj_length);
621
622acpi_status
623acpi_ut_get_element_length (
624 u8 object_type,
625 union acpi_operand_object *source_object,
626 union acpi_generic_state *state,
627 void *context);
628
629
630/*
631 * ut_state - Generic state creation/cache routines
632 */
633
634void
635acpi_ut_push_generic_state (
636 union acpi_generic_state **list_head,
637 union acpi_generic_state *state);
638
639union acpi_generic_state *
640acpi_ut_pop_generic_state (
641 union acpi_generic_state **list_head);
642
643
644union acpi_generic_state *
645acpi_ut_create_generic_state (
646 void);
647
648struct acpi_thread_state *
649acpi_ut_create_thread_state (
650 void);
651
652union acpi_generic_state *
653acpi_ut_create_update_state (
654 union acpi_operand_object *object,
655 u16 action);
656
657union acpi_generic_state *
658acpi_ut_create_pkg_state (
659 void *internal_object,
660 void *external_object,
661 u16 index);
662
663acpi_status
664acpi_ut_create_update_state_and_push (
665 union acpi_operand_object *object,
666 u16 action,
667 union acpi_generic_state **state_list);
668
669#ifdef ACPI_FUTURE_USAGE
670acpi_status
671acpi_ut_create_pkg_state_and_push (
672 void *internal_object,
673 void *external_object,
674 u16 index,
675 union acpi_generic_state **state_list);
676#endif
677
678union acpi_generic_state *
679acpi_ut_create_control_state (
680 void);
681
682void
683acpi_ut_delete_generic_state (
684 union acpi_generic_state *state);
685
686#ifdef ACPI_ENABLE_OBJECT_CACHE
687void
688acpi_ut_delete_generic_state_cache (
689 void);
690
691void
692acpi_ut_delete_object_cache (
693 void);
694#endif
695
696/*
697 * utmisc
698 */
699
700void
701acpi_ut_print_string (
702 char *string,
703 u8 max_length);
704
705acpi_status
706acpi_ut_divide (
707 acpi_integer in_dividend,
708 acpi_integer in_divisor,
709 acpi_integer *out_quotient,
710 acpi_integer *out_remainder);
711
712acpi_status
713acpi_ut_short_divide (
714 acpi_integer in_dividend,
715 u32 divisor,
716 acpi_integer *out_quotient,
717 u32 *out_remainder);
718
719u8
720acpi_ut_valid_acpi_name (
721 u32 name);
722
723u8
724acpi_ut_valid_acpi_character (
725 char character);
726
727acpi_status
728acpi_ut_strtoul64 (
729 char *string,
730 u32 base,
731 acpi_integer *ret_integer);
732
733/* Values for Base above (16=Hex, 10=Decimal) */
734
735#define ACPI_ANY_BASE 0
736
737#ifdef ACPI_FUTURE_USAGE
738char *
739acpi_ut_strupr (
740 char *src_string);
741#endif
742
743u8 *
744acpi_ut_get_resource_end_tag (
745 union acpi_operand_object *obj_desc);
746
747u8
748acpi_ut_generate_checksum (
749 u8 *buffer,
750 u32 length);
751
752u32
753acpi_ut_dword_byte_swap (
754 u32 value);
755
756void
757acpi_ut_set_integer_width (
758 u8 revision);
759
760#ifdef ACPI_DEBUG_OUTPUT
761void
762acpi_ut_display_init_pathname (
763 u8 type,
764 struct acpi_namespace_node *obj_handle,
765 char *path);
766
767#endif
768
769
770/*
771 * Utalloc - memory allocation and object caching
772 */
773
774void *
775acpi_ut_acquire_from_cache (
776 u32 list_id);
777
778void
779acpi_ut_release_to_cache (
780 u32 list_id,
781 void *object);
782
783#ifdef ACPI_ENABLE_OBJECT_CACHE
784void
785acpi_ut_delete_generic_cache (
786 u32 list_id);
787#endif
788
789acpi_status
790acpi_ut_validate_buffer (
791 struct acpi_buffer *buffer);
792
793acpi_status
794acpi_ut_initialize_buffer (
795 struct acpi_buffer *buffer,
796 acpi_size required_length);
797
798
799/* Memory allocation functions */
800
801void *
802acpi_ut_allocate (
803 acpi_size size,
804 u32 component,
805 char *module,
806 u32 line);
807
808void *
809acpi_ut_callocate (
810 acpi_size size,
811 u32 component,
812 char *module,
813 u32 line);
814
815
816#ifdef ACPI_DBG_TRACK_ALLOCATIONS
817
818void *
819acpi_ut_allocate_and_track (
820 acpi_size size,
821 u32 component,
822 char *module,
823 u32 line);
824
825void *
826acpi_ut_callocate_and_track (
827 acpi_size size,
828 u32 component,
829 char *module,
830 u32 line);
831
832void
833acpi_ut_free_and_track (
834 void *address,
835 u32 component,
836 char *module,
837 u32 line);
838
839struct acpi_debug_mem_block *
840acpi_ut_find_allocation (
841 u32 list_id,
842 void *allocation);
843
844acpi_status
845acpi_ut_track_allocation (
846 u32 list_id,
847 struct acpi_debug_mem_block *address,
848 acpi_size size,
849 u8 alloc_type,
850 u32 component,
851 char *module,
852 u32 line);
853
854acpi_status
855acpi_ut_remove_allocation (
856 u32 list_id,
857 struct acpi_debug_mem_block *address,
858 u32 component,
859 char *module,
860 u32 line);
861
862#ifdef ACPI_FUTURE_USAGE
863void
864acpi_ut_dump_allocation_info (
865 void);
866#endif
867
868void
869acpi_ut_dump_allocations (
870 u32 component,
871 char *module);
872#endif
873
874
875#endif /* _ACUTILS_H */