File: /usr/src/linux/drivers/acpi/include/acutils.h
1 /******************************************************************************
2 *
3 * Name: acutils.h -- prototypes for the common (subsystem-wide) procedures
4 * $Revision: 113 $
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 ...);
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 ...);
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
393
394 acpi_status
395 acpi_ut_evaluate_numeric_object (
396 NATIVE_CHAR *object_name,
397 acpi_namespace_node *device_node,
398 acpi_integer *address);
399
400 acpi_status
401 acpi_ut_execute_HID (
402 acpi_namespace_node *device_node,
403 ACPI_DEVICE_ID *hid);
404
405 acpi_status
406 acpi_ut_execute_STA (
407 acpi_namespace_node *device_node,
408 u32 *status_flags);
409
410 acpi_status
411 acpi_ut_execute_UID (
412 acpi_namespace_node *device_node,
413 ACPI_DEVICE_ID *uid);
414
415
416 /*
417 * Ut_mutex - mutual exclusion interfaces
418 */
419
420 acpi_status
421 acpi_ut_mutex_initialize (
422 void);
423
424 void
425 acpi_ut_mutex_terminate (
426 void);
427
428 acpi_status
429 acpi_ut_create_mutex (
430 ACPI_MUTEX_HANDLE mutex_id);
431
432 acpi_status
433 acpi_ut_delete_mutex (
434 ACPI_MUTEX_HANDLE mutex_id);
435
436 acpi_status
437 acpi_ut_acquire_mutex (
438 ACPI_MUTEX_HANDLE mutex_id);
439
440 acpi_status
441 acpi_ut_release_mutex (
442 ACPI_MUTEX_HANDLE mutex_id);
443
444
445 /*
446 * Ut_object - internal object create/delete/cache routines
447 */
448
449 acpi_operand_object *
450 acpi_ut_create_internal_object_dbg (
451 NATIVE_CHAR *module_name,
452 u32 line_number,
453 u32 component_id,
454 acpi_object_type8 type);
455
456 void *
457 acpi_ut_allocate_object_desc_dbg (
458 NATIVE_CHAR *module_name,
459 u32 line_number,
460 u32 component_id);
461
462 #define acpi_ut_create_internal_object(t) acpi_ut_create_internal_object_dbg (_THIS_MODULE,__LINE__,_COMPONENT,t)
463 #define acpi_ut_allocate_object_desc() acpi_ut_allocate_object_desc_dbg (_THIS_MODULE,__LINE__,_COMPONENT)
464
465 void
466 acpi_ut_delete_object_desc (
467 acpi_operand_object *object);
468
469 u8
470 acpi_ut_valid_internal_object (
471 void *object);
472
473
474 /*
475 * Ut_ref_cnt - Object reference count management
476 */
477
478 void
479 acpi_ut_add_reference (
480 acpi_operand_object *object);
481
482 void
483 acpi_ut_remove_reference (
484 acpi_operand_object *object);
485
486 /*
487 * Ut_size - Object size routines
488 */
489
490 acpi_status
491 acpi_ut_get_simple_object_size (
492 acpi_operand_object *obj,
493 u32 *obj_length);
494
495 acpi_status
496 acpi_ut_get_package_object_size (
497 acpi_operand_object *obj,
498 u32 *obj_length);
499
500 acpi_status
501 acpi_ut_get_object_size(
502 acpi_operand_object *obj,
503 u32 *obj_length);
504
505
506 /*
507 * Ut_state - Generic state creation/cache routines
508 */
509
510 void
511 acpi_ut_push_generic_state (
512 acpi_generic_state **list_head,
513 acpi_generic_state *state);
514
515 acpi_generic_state *
516 acpi_ut_pop_generic_state (
517 acpi_generic_state **list_head);
518
519
520 acpi_generic_state *
521 acpi_ut_create_generic_state (
522 void);
523
524 acpi_generic_state *
525 acpi_ut_create_update_state (
526 acpi_operand_object *object,
527 u16 action);
528
529 acpi_generic_state *
530 acpi_ut_create_pkg_state (
531 void *internal_object,
532 void *external_object,
533 u16 index);
534
535 acpi_status
536 acpi_ut_create_update_state_and_push (
537 acpi_operand_object *object,
538 u16 action,
539 acpi_generic_state **state_list);
540
541 acpi_status
542 acpi_ut_create_pkg_state_and_push (
543 void *internal_object,
544 void *external_object,
545 u16 index,
546 acpi_generic_state **state_list);
547
548 acpi_generic_state *
549 acpi_ut_create_control_state (
550 void);
551
552 void
553 acpi_ut_delete_generic_state (
554 acpi_generic_state *state);
555
556 void
557 acpi_ut_delete_generic_state_cache (
558 void);
559
560 void
561 acpi_ut_delete_object_cache (
562 void);
563
564 /*
565 * Ututils
566 */
567
568 u8
569 acpi_ut_valid_acpi_name (
570 u32 name);
571
572 u8
573 acpi_ut_valid_acpi_character (
574 NATIVE_CHAR character);
575
576 NATIVE_CHAR *
577 acpi_ut_strupr (
578 NATIVE_CHAR *src_string);
579
580 acpi_status
581 acpi_ut_resolve_package_references (
582 acpi_operand_object *obj_desc);
583
584
585 #ifdef ACPI_DEBUG
586 void
587 acpi_ut_display_init_pathname (
588 acpi_handle obj_handle,
589 char *path);
590
591 #endif
592
593
594 /*
595 * Utalloc - memory allocation and object caching
596 */
597
598 void *
599 acpi_ut_acquire_from_cache (
600 u32 list_id);
601
602 void
603 acpi_ut_release_to_cache (
604 u32 list_id,
605 void *object);
606
607 void
608 acpi_ut_delete_generic_cache (
609 u32 list_id);
610
611
612 /* Debug Memory allocation functions */
613
614 void *
615 acpi_ut_allocate (
616 u32 size,
617 u32 component,
618 NATIVE_CHAR *module,
619 u32 line);
620
621 void *
622 acpi_ut_callocate (
623 u32 size,
624 u32 component,
625 NATIVE_CHAR *module,
626 u32 line);
627
628 void
629 acpi_ut_free (
630 void *address,
631 u32 component,
632 NATIVE_CHAR *module,
633 u32 line);
634
635 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
636 void
637 acpi_ut_dump_allocation_info (
638 void);
639
640 void
641 acpi_ut_dump_current_allocations (
642 u32 component,
643 NATIVE_CHAR *module);
644 #endif
645
646
647 #endif /* _ACUTILS_H */
648