]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - include/acpi/acutils.h
Linux-2.6.12-rc2
[mirror_ubuntu-bionic-kernel.git] / include / acpi / acutils.h
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
48 typedef
49 acpi_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
55 acpi_status
56 acpi_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
62 struct 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
84 void
85 acpi_ut_init_globals (
86 void);
87
88 void
89 acpi_ut_terminate (
90 void);
91
92
93 /*
94 * ut_init - miscellaneous initialization and shutdown
95 */
96
97 acpi_status
98 acpi_ut_hardware_initialize (
99 void);
100
101 void
102 acpi_ut_subsystem_shutdown (
103 void);
104
105 acpi_status
106 acpi_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
115 char *
116 acpi_ut_get_mutex_name (
117 u32 mutex_id);
118
119 #endif
120
121 char *
122 acpi_ut_get_type_name (
123 acpi_object_type type);
124
125 char *
126 acpi_ut_get_node_name (
127 void *object);
128
129 char *
130 acpi_ut_get_descriptor_name (
131 void *object);
132
133 char *
134 acpi_ut_get_object_type_name (
135 union acpi_operand_object *obj_desc);
136
137 char *
138 acpi_ut_get_region_name (
139 u8 space_id);
140
141 char *
142 acpi_ut_get_event_name (
143 u32 event_id);
144
145 char
146 acpi_ut_hex_to_ascii_char (
147 acpi_integer integer,
148 u32 position);
149
150 u8
151 acpi_ut_valid_object_type (
152 acpi_object_type type);
153
154 acpi_owner_id
155 acpi_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
165 acpi_size
166 acpi_ut_strlen (
167 const char *string);
168
169 char *
170 acpi_ut_strcpy (
171 char *dst_string,
172 const char *src_string);
173
174 char *
175 acpi_ut_strncpy (
176 char *dst_string,
177 const char *src_string,
178 acpi_size count);
179
180 int
181 acpi_ut_memcmp (
182 const char *buffer1,
183 const char *buffer2,
184 acpi_size count);
185
186 int
187 acpi_ut_strncmp (
188 const char *string1,
189 const char *string2,
190 acpi_size count);
191
192 int
193 acpi_ut_strcmp (
194 const char *string1,
195 const char *string2);
196
197 char *
198 acpi_ut_strcat (
199 char *dst_string,
200 const char *src_string);
201
202 char *
203 acpi_ut_strncat (
204 char *dst_string,
205 const char *src_string,
206 acpi_size count);
207
208 u32
209 acpi_ut_strtoul (
210 const char *string,
211 char **terminator,
212 u32 base);
213
214 char *
215 acpi_ut_strstr (
216 char *string1,
217 char *string2);
218
219 void *
220 acpi_ut_memcpy (
221 void *dest,
222 const void *src,
223 acpi_size count);
224
225 void *
226 acpi_ut_memset (
227 void *dest,
228 acpi_native_uint value,
229 acpi_size count);
230
231 int
232 acpi_ut_to_upper (
233 int c);
234
235 int
236 acpi_ut_to_lower (
237 int c);
238
239 extern 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
267 acpi_status
268 acpi_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
274 acpi_status
275 acpi_ut_build_package_object (
276 union acpi_operand_object *obj,
277 u8 *buffer,
278 u32 *space_used);
279
280 acpi_status
281 acpi_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
287 acpi_status
288 acpi_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
294 acpi_status
295 acpi_ut_copy_iobject_to_eobject (
296 union acpi_operand_object *obj,
297 struct acpi_buffer *ret_buffer);
298
299 acpi_status
300 acpi_ut_copy_esimple_to_isimple(
301 union acpi_object *user_obj,
302 union acpi_operand_object **return_obj);
303
304 acpi_status
305 acpi_ut_copy_eobject_to_iobject (
306 union acpi_object *obj,
307 union acpi_operand_object **internal_obj);
308
309 acpi_status
310 acpi_ut_copy_isimple_to_isimple (
311 union acpi_operand_object *source_obj,
312 union acpi_operand_object *dest_obj);
313
314 acpi_status
315 acpi_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
320 acpi_status
321 acpi_ut_copy_simple_object (
322 union acpi_operand_object *source_desc,
323 union acpi_operand_object *dest_desc);
324
325 acpi_status
326 acpi_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
336 acpi_status
337 acpi_ut_update_object_reference (
338 union acpi_operand_object *object,
339 u16 action);
340
341
342 /*
343 * ut_debug - Debug interfaces
344 */
345
346 void
347 acpi_ut_init_stack_ptr_trace (
348 void);
349
350 void
351 acpi_ut_track_stack_ptr (
352 void);
353
354 void
355 acpi_ut_trace (
356 u32 line_number,
357 struct acpi_debug_print_info *dbg_info);
358
359 void
360 acpi_ut_trace_ptr (
361 u32 line_number,
362 struct acpi_debug_print_info *dbg_info,
363 void *pointer);
364
365 void
366 acpi_ut_trace_u32 (
367 u32 line_number,
368 struct acpi_debug_print_info *dbg_info,
369 u32 integer);
370
371 void
372 acpi_ut_trace_str (
373 u32 line_number,
374 struct acpi_debug_print_info *dbg_info,
375 char *string);
376
377 void
378 acpi_ut_exit (
379 u32 line_number,
380 struct acpi_debug_print_info *dbg_info);
381
382 void
383 acpi_ut_status_exit (
384 u32 line_number,
385 struct acpi_debug_print_info *dbg_info,
386 acpi_status status);
387
388 void
389 acpi_ut_value_exit (
390 u32 line_number,
391 struct acpi_debug_print_info *dbg_info,
392 acpi_integer value);
393
394 void
395 acpi_ut_ptr_exit (
396 u32 line_number,
397 struct acpi_debug_print_info *dbg_info,
398 u8 *ptr);
399
400 void
401 acpi_ut_report_info (
402 char *module_name,
403 u32 line_number,
404 u32 component_id);
405
406 void
407 acpi_ut_report_error (
408 char *module_name,
409 u32 line_number,
410 u32 component_id);
411
412 void
413 acpi_ut_report_warning (
414 char *module_name,
415 u32 line_number,
416 u32 component_id);
417
418 void
419 acpi_ut_dump_buffer (
420 u8 *buffer,
421 u32 count,
422 u32 display,
423 u32 component_id);
424
425 void ACPI_INTERNAL_VAR_XFACE
426 acpi_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
433 void ACPI_INTERNAL_VAR_XFACE
434 acpi_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
446 void
447 acpi_ut_delete_internal_obj (
448 union acpi_operand_object *object);
449
450 void
451 acpi_ut_delete_internal_package_object (
452 union acpi_operand_object *object);
453
454 void
455 acpi_ut_delete_internal_simple_object (
456 union acpi_operand_object *object);
457
458 void
459 acpi_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
483 acpi_status
484 acpi_ut_osi_implementation (
485 struct acpi_walk_state *walk_state);
486
487 acpi_status
488 acpi_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
494 acpi_status
495 acpi_ut_evaluate_numeric_object (
496 char *object_name,
497 struct acpi_namespace_node *device_node,
498 acpi_integer *address);
499
500 acpi_status
501 acpi_ut_execute_HID (
502 struct acpi_namespace_node *device_node,
503 struct acpi_device_id *hid);
504
505 acpi_status
506 acpi_ut_execute_CID (
507 struct acpi_namespace_node *device_node,
508 struct acpi_compatible_id_list **return_cid_list);
509
510 acpi_status
511 acpi_ut_execute_STA (
512 struct acpi_namespace_node *device_node,
513 u32 *status_flags);
514
515 acpi_status
516 acpi_ut_execute_UID (
517 struct acpi_namespace_node *device_node,
518 struct acpi_device_id *uid);
519
520 acpi_status
521 acpi_ut_execute_sxds (
522 struct acpi_namespace_node *device_node,
523 u8 *highest);
524
525 /*
526 * ut_mutex - mutual exclusion interfaces
527 */
528
529 acpi_status
530 acpi_ut_mutex_initialize (
531 void);
532
533 void
534 acpi_ut_mutex_terminate (
535 void);
536
537 acpi_status
538 acpi_ut_create_mutex (
539 acpi_mutex_handle mutex_id);
540
541 acpi_status
542 acpi_ut_delete_mutex (
543 acpi_mutex_handle mutex_id);
544
545 acpi_status
546 acpi_ut_acquire_mutex (
547 acpi_mutex_handle mutex_id);
548
549 acpi_status
550 acpi_ut_release_mutex (
551 acpi_mutex_handle mutex_id);
552
553
554 /*
555 * ut_object - internal object create/delete/cache routines
556 */
557
558 union acpi_operand_object *
559 acpi_ut_create_internal_object_dbg (
560 char *module_name,
561 u32 line_number,
562 u32 component_id,
563 acpi_object_type type);
564
565 void *
566 acpi_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
574 void
575 acpi_ut_delete_object_desc (
576 union acpi_operand_object *object);
577
578 u8
579 acpi_ut_valid_internal_object (
580 void *object);
581
582 union acpi_operand_object *
583 acpi_ut_create_buffer_object (
584 acpi_size buffer_size);
585
586 union acpi_operand_object *
587 acpi_ut_create_string_object (
588 acpi_size string_size);
589
590
591 /*
592 * ut_ref_cnt - Object reference count management
593 */
594
595 void
596 acpi_ut_add_reference (
597 union acpi_operand_object *object);
598
599 void
600 acpi_ut_remove_reference (
601 union acpi_operand_object *object);
602
603 /*
604 * ut_size - Object size routines
605 */
606
607 acpi_status
608 acpi_ut_get_simple_object_size (
609 union acpi_operand_object *obj,
610 acpi_size *obj_length);
611
612 acpi_status
613 acpi_ut_get_package_object_size (
614 union acpi_operand_object *obj,
615 acpi_size *obj_length);
616
617 acpi_status
618 acpi_ut_get_object_size(
619 union acpi_operand_object *obj,
620 acpi_size *obj_length);
621
622 acpi_status
623 acpi_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
634 void
635 acpi_ut_push_generic_state (
636 union acpi_generic_state **list_head,
637 union acpi_generic_state *state);
638
639 union acpi_generic_state *
640 acpi_ut_pop_generic_state (
641 union acpi_generic_state **list_head);
642
643
644 union acpi_generic_state *
645 acpi_ut_create_generic_state (
646 void);
647
648 struct acpi_thread_state *
649 acpi_ut_create_thread_state (
650 void);
651
652 union acpi_generic_state *
653 acpi_ut_create_update_state (
654 union acpi_operand_object *object,
655 u16 action);
656
657 union acpi_generic_state *
658 acpi_ut_create_pkg_state (
659 void *internal_object,
660 void *external_object,
661 u16 index);
662
663 acpi_status
664 acpi_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
670 acpi_status
671 acpi_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
678 union acpi_generic_state *
679 acpi_ut_create_control_state (
680 void);
681
682 void
683 acpi_ut_delete_generic_state (
684 union acpi_generic_state *state);
685
686 #ifdef ACPI_ENABLE_OBJECT_CACHE
687 void
688 acpi_ut_delete_generic_state_cache (
689 void);
690
691 void
692 acpi_ut_delete_object_cache (
693 void);
694 #endif
695
696 /*
697 * utmisc
698 */
699
700 void
701 acpi_ut_print_string (
702 char *string,
703 u8 max_length);
704
705 acpi_status
706 acpi_ut_divide (
707 acpi_integer in_dividend,
708 acpi_integer in_divisor,
709 acpi_integer *out_quotient,
710 acpi_integer *out_remainder);
711
712 acpi_status
713 acpi_ut_short_divide (
714 acpi_integer in_dividend,
715 u32 divisor,
716 acpi_integer *out_quotient,
717 u32 *out_remainder);
718
719 u8
720 acpi_ut_valid_acpi_name (
721 u32 name);
722
723 u8
724 acpi_ut_valid_acpi_character (
725 char character);
726
727 acpi_status
728 acpi_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
738 char *
739 acpi_ut_strupr (
740 char *src_string);
741 #endif
742
743 u8 *
744 acpi_ut_get_resource_end_tag (
745 union acpi_operand_object *obj_desc);
746
747 u8
748 acpi_ut_generate_checksum (
749 u8 *buffer,
750 u32 length);
751
752 u32
753 acpi_ut_dword_byte_swap (
754 u32 value);
755
756 void
757 acpi_ut_set_integer_width (
758 u8 revision);
759
760 #ifdef ACPI_DEBUG_OUTPUT
761 void
762 acpi_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
774 void *
775 acpi_ut_acquire_from_cache (
776 u32 list_id);
777
778 void
779 acpi_ut_release_to_cache (
780 u32 list_id,
781 void *object);
782
783 #ifdef ACPI_ENABLE_OBJECT_CACHE
784 void
785 acpi_ut_delete_generic_cache (
786 u32 list_id);
787 #endif
788
789 acpi_status
790 acpi_ut_validate_buffer (
791 struct acpi_buffer *buffer);
792
793 acpi_status
794 acpi_ut_initialize_buffer (
795 struct acpi_buffer *buffer,
796 acpi_size required_length);
797
798
799 /* Memory allocation functions */
800
801 void *
802 acpi_ut_allocate (
803 acpi_size size,
804 u32 component,
805 char *module,
806 u32 line);
807
808 void *
809 acpi_ut_callocate (
810 acpi_size size,
811 u32 component,
812 char *module,
813 u32 line);
814
815
816 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
817
818 void *
819 acpi_ut_allocate_and_track (
820 acpi_size size,
821 u32 component,
822 char *module,
823 u32 line);
824
825 void *
826 acpi_ut_callocate_and_track (
827 acpi_size size,
828 u32 component,
829 char *module,
830 u32 line);
831
832 void
833 acpi_ut_free_and_track (
834 void *address,
835 u32 component,
836 char *module,
837 u32 line);
838
839 struct acpi_debug_mem_block *
840 acpi_ut_find_allocation (
841 u32 list_id,
842 void *allocation);
843
844 acpi_status
845 acpi_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
854 acpi_status
855 acpi_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
863 void
864 acpi_ut_dump_allocation_info (
865 void);
866 #endif
867
868 void
869 acpi_ut_dump_allocations (
870 u32 component,
871 char *module);
872 #endif
873
874
875 #endif /* _ACUTILS_H */