make oldconfig will rebuild these...
[linux-2.4.21-pre4.git] / drivers / acpi / include / acutils.h
1 /******************************************************************************
2  *
3  * Name: acutils.h -- prototypes for the common (subsystem-wide) procedures
4  *       $Revision: 1.1.1.1 $
5  *
6  *****************************************************************************/
7
8 /*
9  *  Copyright (C) 2000, 2001 R. Byron Moore
10  *
11  *  This program is free software; you can redistribute it and/or modify
12  *  it under the terms of the GNU General Public License as published by
13  *  the Free Software Foundation; either version 2 of the License, or
14  *  (at your option) any later version.
15  *
16  *  This program is distributed in the hope that it will be useful,
17  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  *  GNU General Public License for more details.
20  *
21  *  You should have received a copy of the GNU General Public License
22  *  along with this program; if not, write to the Free Software
23  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
24  */
25
26 #ifndef _ACUTILS_H
27 #define _ACUTILS_H
28
29
30 typedef
31 acpi_status (*ACPI_PKG_CALLBACK) (
32         u8                      object_type,
33         acpi_operand_object     *source_object,
34         acpi_generic_state      *state,
35         void                    *context);
36
37
38 acpi_status
39 acpi_ut_walk_package_tree (
40         acpi_operand_object     *source_object,
41         void                    *target_object,
42         ACPI_PKG_CALLBACK       walk_callback,
43         void                    *context);
44
45
46 typedef struct acpi_pkg_info
47 {
48         u8                      *free_space;
49         u32                     length;
50         u32                     object_space;
51         u32                     num_packages;
52 } acpi_pkg_info;
53
54 #define REF_INCREMENT       (u16) 0
55 #define REF_DECREMENT       (u16) 1
56 #define REF_FORCE_DELETE    (u16) 2
57
58 /* Acpi_ut_dump_buffer */
59
60 #define DB_BYTE_DISPLAY     1
61 #define DB_WORD_DISPLAY     2
62 #define DB_DWORD_DISPLAY    4
63 #define DB_QWORD_DISPLAY    8
64
65
66 /* Global initialization interfaces */
67
68 void
69 acpi_ut_init_globals (
70         void);
71
72 void
73 acpi_ut_terminate (
74         void);
75
76
77 /*
78  * Ut_init - miscellaneous initialization and shutdown
79  */
80
81 acpi_status
82 acpi_ut_hardware_initialize (
83         void);
84
85 acpi_status
86 acpi_ut_subsystem_shutdown (
87         void);
88
89 acpi_status
90 acpi_ut_validate_fadt (
91         void);
92
93 /*
94  * Ut_global - Global data structures and procedures
95  */
96
97 #ifdef ACPI_DEBUG
98
99 NATIVE_CHAR *
100 acpi_ut_get_mutex_name (
101         u32                     mutex_id);
102
103 NATIVE_CHAR *
104 acpi_ut_get_type_name (
105         u32                     type);
106
107 NATIVE_CHAR *
108 acpi_ut_get_region_name (
109         u8                      space_id);
110
111 #endif
112
113
114 u8
115 acpi_ut_hex_to_ascii_char (
116         acpi_integer            integer,
117         u32                     position);
118
119 u8
120 acpi_ut_valid_object_type (
121         u32                     type);
122
123 acpi_owner_id
124 acpi_ut_allocate_owner_id (
125         u32                     id_type);
126
127
128 /*
129  * Ut_clib - Local implementations of C library functions
130  */
131
132 #ifndef ACPI_USE_SYSTEM_CLIBRARY
133
134 u32
135 acpi_ut_strlen (
136         const NATIVE_CHAR       *string);
137
138 NATIVE_CHAR *
139 acpi_ut_strcpy (
140         NATIVE_CHAR             *dst_string,
141         const NATIVE_CHAR       *src_string);
142
143 NATIVE_CHAR *
144 acpi_ut_strncpy (
145         NATIVE_CHAR             *dst_string,
146         const NATIVE_CHAR       *src_string,
147         NATIVE_UINT             count);
148
149 u32
150 acpi_ut_strncmp (
151         const NATIVE_CHAR       *string1,
152         const NATIVE_CHAR       *string2,
153         NATIVE_UINT             count);
154
155 u32
156 acpi_ut_strcmp (
157         const NATIVE_CHAR       *string1,
158         const NATIVE_CHAR       *string2);
159
160 NATIVE_CHAR *
161 acpi_ut_strcat (
162         NATIVE_CHAR             *dst_string,
163         const NATIVE_CHAR       *src_string);
164
165 NATIVE_CHAR *
166 acpi_ut_strncat (
167         NATIVE_CHAR             *dst_string,
168         const NATIVE_CHAR       *src_string,
169         NATIVE_UINT             count);
170
171 u32
172 acpi_ut_strtoul (
173         const NATIVE_CHAR       *string,
174         NATIVE_CHAR             **terminator,
175         u32                     base);
176
177 NATIVE_CHAR *
178 acpi_ut_strstr (
179         NATIVE_CHAR             *string1,
180         NATIVE_CHAR             *string2);
181
182 void *
183 acpi_ut_memcpy (
184         void                    *dest,
185         const void              *src,
186         NATIVE_UINT             count);
187
188 void *
189 acpi_ut_memset (
190         void                    *dest,
191         NATIVE_UINT             value,
192         NATIVE_UINT             count);
193
194 u32
195 acpi_ut_to_upper (
196         u32                     c);
197
198 u32
199 acpi_ut_to_lower (
200         u32                     c);
201
202 #endif /* ACPI_USE_SYSTEM_CLIBRARY */
203
204 /*
205  * Ut_copy - Object construction and conversion interfaces
206  */
207
208 acpi_status
209 acpi_ut_build_simple_object(
210         acpi_operand_object     *obj,
211         acpi_object             *user_obj,
212         u8                      *data_space,
213         u32                     *buffer_space_used);
214
215 acpi_status
216 acpi_ut_build_package_object (
217         acpi_operand_object     *obj,
218         u8                      *buffer,
219         u32                     *space_used);
220
221 acpi_status
222 acpi_ut_copy_iobject_to_eobject (
223         acpi_operand_object     *obj,
224         acpi_buffer             *ret_buffer);
225
226 acpi_status
227 acpi_ut_copy_esimple_to_isimple(
228         acpi_object             *user_obj,
229         acpi_operand_object     **return_obj);
230
231 acpi_status
232 acpi_ut_copy_eobject_to_iobject (
233         acpi_object             *obj,
234         acpi_operand_object     **internal_obj);
235
236 acpi_status
237 acpi_ut_copy_isimple_to_isimple (
238         acpi_operand_object     *source_obj,
239         acpi_operand_object     *dest_obj);
240
241 acpi_status
242 acpi_ut_copy_ipackage_to_ipackage (
243         acpi_operand_object     *source_obj,
244         acpi_operand_object     *dest_obj,
245         acpi_walk_state         *walk_state);
246
247
248 /*
249  * Ut_create - Object creation
250  */
251
252 acpi_status
253 acpi_ut_update_object_reference (
254         acpi_operand_object     *object,
255         u16                     action);
256
257
258 /*
259  * Ut_debug - Debug interfaces
260  */
261
262 void
263 acpi_ut_init_stack_ptr_trace (
264         void);
265
266 void
267 acpi_ut_track_stack_ptr (
268         void);
269
270 void
271 acpi_ut_trace (
272         u32                     line_number,
273         acpi_debug_print_info   *dbg_info);
274
275 void
276 acpi_ut_trace_ptr (
277         u32                     line_number,
278         acpi_debug_print_info   *dbg_info,
279         void                    *pointer);
280
281 void
282 acpi_ut_trace_u32 (
283         u32                     line_number,
284         acpi_debug_print_info   *dbg_info,
285         u32                     integer);
286
287 void
288 acpi_ut_trace_str (
289         u32                     line_number,
290         acpi_debug_print_info   *dbg_info,
291         NATIVE_CHAR             *string);
292
293 void
294 acpi_ut_exit (
295         u32                     line_number,
296         acpi_debug_print_info   *dbg_info);
297
298 void
299 acpi_ut_status_exit (
300         u32                     line_number,
301         acpi_debug_print_info   *dbg_info,
302         acpi_status             status);
303
304 void
305 acpi_ut_value_exit (
306         u32                     line_number,
307         acpi_debug_print_info   *dbg_info,
308         acpi_integer            value);
309
310 void
311 acpi_ut_ptr_exit (
312         u32                     line_number,
313         acpi_debug_print_info   *dbg_info,
314         u8                      *ptr);
315
316 void
317 acpi_ut_report_info (
318         NATIVE_CHAR             *module_name,
319         u32                     line_number,
320         u32                     component_id);
321
322 void
323 acpi_ut_report_error (
324         NATIVE_CHAR             *module_name,
325         u32                     line_number,
326         u32                     component_id);
327
328 void
329 acpi_ut_report_warning (
330         NATIVE_CHAR             *module_name,
331         u32                     line_number,
332         u32                     component_id);
333
334 void
335 acpi_ut_dump_buffer (
336         u8                      *buffer,
337         u32                     count,
338         u32                     display,
339         u32                     component_id);
340
341 void
342 acpi_ut_debug_print (
343         u32                     requested_debug_level,
344         u32                     line_number,
345         acpi_debug_print_info   *dbg_info,
346         char                    *format,
347         ...) ACPI_PRINTF_LIKE_FUNC;
348
349 void
350 acpi_ut_debug_print_raw (
351         u32                     requested_debug_level,
352         u32                     line_number,
353         acpi_debug_print_info   *dbg_info,
354         char                    *format,
355         ...) ACPI_PRINTF_LIKE_FUNC;
356
357
358 /*
359  * Ut_delete - Object deletion
360  */
361
362 void
363 acpi_ut_delete_internal_obj (
364         acpi_operand_object     *object);
365
366 void
367 acpi_ut_delete_internal_package_object (
368         acpi_operand_object     *object);
369
370 void
371 acpi_ut_delete_internal_simple_object (
372         acpi_operand_object     *object);
373
374 acpi_status
375 acpi_ut_delete_internal_object_list (
376         acpi_operand_object     **obj_list);
377
378
379 /*
380  * Ut_eval - object evaluation
381  */
382
383 /* Method name strings */
384
385 #define METHOD_NAME__HID        "_HID"
386 #define METHOD_NAME__UID        "_UID"
387 #define METHOD_NAME__ADR        "_ADR"
388 #define METHOD_NAME__STA        "_STA"
389 #define METHOD_NAME__REG        "_REG"
390 #define METHOD_NAME__SEG        "_SEG"
391 #define METHOD_NAME__BBN        "_BBN"
392 #define METHOD_NAME__PRT        "_PRT"
393
394
395 acpi_status
396 acpi_ut_evaluate_numeric_object (
397         NATIVE_CHAR             *object_name,
398         acpi_namespace_node     *device_node,
399         acpi_integer            *address);
400
401 acpi_status
402 acpi_ut_execute_HID (
403         acpi_namespace_node     *device_node,
404         acpi_device_id          *hid);
405
406 acpi_status
407 acpi_ut_execute_STA (
408         acpi_namespace_node     *device_node,
409         u32                     *status_flags);
410
411 acpi_status
412 acpi_ut_execute_UID (
413         acpi_namespace_node     *device_node,
414         acpi_device_id          *uid);
415
416
417 /*
418  * Ut_mutex - mutual exclusion interfaces
419  */
420
421 acpi_status
422 acpi_ut_mutex_initialize (
423         void);
424
425 void
426 acpi_ut_mutex_terminate (
427         void);
428
429 acpi_status
430 acpi_ut_create_mutex (
431         ACPI_MUTEX_HANDLE       mutex_id);
432
433 acpi_status
434 acpi_ut_delete_mutex (
435         ACPI_MUTEX_HANDLE       mutex_id);
436
437 acpi_status
438 acpi_ut_acquire_mutex (
439         ACPI_MUTEX_HANDLE       mutex_id);
440
441 acpi_status
442 acpi_ut_release_mutex (
443         ACPI_MUTEX_HANDLE       mutex_id);
444
445
446 /*
447  * Ut_object - internal object create/delete/cache routines
448  */
449
450 acpi_operand_object  *
451 acpi_ut_create_internal_object_dbg (
452         NATIVE_CHAR             *module_name,
453         u32                     line_number,
454         u32                     component_id,
455         acpi_object_type8       type);
456
457 void *
458 acpi_ut_allocate_object_desc_dbg (
459         NATIVE_CHAR             *module_name,
460         u32                     line_number,
461         u32                     component_id);
462
463 #define acpi_ut_create_internal_object(t) acpi_ut_create_internal_object_dbg (_THIS_MODULE,__LINE__,_COMPONENT,t)
464 #define acpi_ut_allocate_object_desc()  acpi_ut_allocate_object_desc_dbg (_THIS_MODULE,__LINE__,_COMPONENT)
465
466 void
467 acpi_ut_delete_object_desc (
468         acpi_operand_object     *object);
469
470 u8
471 acpi_ut_valid_internal_object (
472         void                    *object);
473
474
475 /*
476  * Ut_ref_cnt - Object reference count management
477  */
478
479 void
480 acpi_ut_add_reference (
481         acpi_operand_object     *object);
482
483 void
484 acpi_ut_remove_reference (
485         acpi_operand_object     *object);
486
487 /*
488  * Ut_size - Object size routines
489  */
490
491 acpi_status
492 acpi_ut_get_simple_object_size (
493         acpi_operand_object     *obj,
494         u32                     *obj_length);
495
496 acpi_status
497 acpi_ut_get_package_object_size (
498         acpi_operand_object     *obj,
499         u32                     *obj_length);
500
501 acpi_status
502 acpi_ut_get_object_size(
503         acpi_operand_object     *obj,
504         u32                     *obj_length);
505
506
507 /*
508  * Ut_state - Generic state creation/cache routines
509  */
510
511 void
512 acpi_ut_push_generic_state (
513         acpi_generic_state      **list_head,
514         acpi_generic_state      *state);
515
516 acpi_generic_state *
517 acpi_ut_pop_generic_state (
518         acpi_generic_state      **list_head);
519
520
521 acpi_generic_state *
522 acpi_ut_create_generic_state (
523         void);
524
525 acpi_generic_state *
526 acpi_ut_create_update_state (
527         acpi_operand_object     *object,
528         u16                     action);
529
530 acpi_generic_state *
531 acpi_ut_create_pkg_state (
532         void                    *internal_object,
533         void                    *external_object,
534         u16                     index);
535
536 acpi_status
537 acpi_ut_create_update_state_and_push (
538         acpi_operand_object     *object,
539         u16                     action,
540         acpi_generic_state      **state_list);
541
542 acpi_status
543 acpi_ut_create_pkg_state_and_push (
544         void                    *internal_object,
545         void                    *external_object,
546         u16                     index,
547         acpi_generic_state      **state_list);
548
549 acpi_generic_state *
550 acpi_ut_create_control_state (
551         void);
552
553 void
554 acpi_ut_delete_generic_state (
555         acpi_generic_state      *state);
556
557 void
558 acpi_ut_delete_generic_state_cache (
559         void);
560
561 void
562 acpi_ut_delete_object_cache (
563         void);
564
565 /*
566  * utmisc
567  */
568
569 acpi_status
570 acpi_ut_divide (
571         acpi_integer            *in_dividend,
572         acpi_integer            *in_divisor,
573         acpi_integer            *out_quotient,
574         acpi_integer            *out_remainder);
575
576 acpi_status
577 acpi_ut_short_divide (
578         acpi_integer            *in_dividend,
579         u32                     divisor,
580         acpi_integer            *out_quotient,
581         u32                     *out_remainder);
582
583 u8
584 acpi_ut_valid_acpi_name (
585         u32                     name);
586
587 u8
588 acpi_ut_valid_acpi_character (
589         NATIVE_CHAR             character);
590
591 NATIVE_CHAR *
592 acpi_ut_strupr (
593         NATIVE_CHAR             *src_string);
594
595 acpi_status
596 acpi_ut_resolve_package_references (
597         acpi_operand_object     *obj_desc);
598
599
600 #ifdef ACPI_DEBUG
601 void
602 acpi_ut_display_init_pathname (
603         acpi_handle             obj_handle,
604         char                    *path);
605
606 #endif
607
608
609 /*
610  * Utalloc - memory allocation and object caching
611  */
612
613 void *
614 acpi_ut_acquire_from_cache (
615         u32                     list_id);
616
617 void
618 acpi_ut_release_to_cache (
619         u32                     list_id,
620         void                    *object);
621
622 void
623 acpi_ut_delete_generic_cache (
624         u32                     list_id);
625
626
627 /* Debug Memory allocation functions */
628
629 void *
630 acpi_ut_allocate (
631         u32                     size,
632         u32                     component,
633         NATIVE_CHAR             *module,
634         u32                     line);
635
636 void *
637 acpi_ut_callocate (
638         u32                     size,
639         u32                     component,
640         NATIVE_CHAR             *module,
641         u32                     line);
642
643 void
644 acpi_ut_free (
645         void                    *address,
646         u32                     component,
647         NATIVE_CHAR             *module,
648         u32                     line);
649
650 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
651 void
652 acpi_ut_dump_allocation_info (
653         void);
654
655 void
656 acpi_ut_dump_allocations (
657         u32                     component,
658         NATIVE_CHAR             *module);
659 #endif
660
661
662 #endif /* _ACUTILS_H */