1 /****************************************************************************** 2 * 3 * Name: acutils.h -- prototypes for the common (subsystem-wide) procedures 4 * 5 *****************************************************************************/ 6 7 /* 8 * Copyright (C) 2000 - 2007, 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 /* Types for Resource descriptor entries */ 48 49 #define ACPI_INVALID_RESOURCE 0 50 #define ACPI_FIXED_LENGTH 1 51 #define ACPI_VARIABLE_LENGTH 2 52 #define ACPI_SMALL_VARIABLE_LENGTH 3 53 54 /* 55 * utglobal - Global data structures and procedures 56 */ 57 const char *acpi_ut_get_region_name(u8 space_id); 58 59 /* 60 * utclib - Local implementations of C library functions 61 */ 62 #ifndef ACPI_USE_SYSTEM_CLIBRARY 63 64 acpi_size acpi_ut_strlen(const char *string); 65 66 char *acpi_ut_strcpy(char *dst_string, const char *src_string); 67 68 char *acpi_ut_strncpy(char *dst_string, 69 const char *src_string, acpi_size count); 70 71 int acpi_ut_memcmp(const char *buffer1, const char *buffer2, acpi_size count); 72 73 int acpi_ut_strncmp(const char *string1, const char *string2, acpi_size count); 74 75 int acpi_ut_strcmp(const char *string1, const char *string2); 76 77 char *acpi_ut_strcat(char *dst_string, const char *src_string); 78 79 char *acpi_ut_strncat(char *dst_string, 80 const char *src_string, acpi_size count); 81 82 u32 acpi_ut_strtoul(const char *string, char **terminator, u32 base); 83 84 char *acpi_ut_strstr(char *string1, char *string2); 85 86 void *acpi_ut_memcpy(void *dest, const void *src, acpi_size count); 87 88 void *acpi_ut_memset(void *dest, acpi_native_uint value, acpi_size count); 89 90 int acpi_ut_to_upper(int c); 91 92 int acpi_ut_to_lower(int c); 93 94 extern const u8 _acpi_ctype[]; 95 96 #define _ACPI_XA 0x00 /* extra alphabetic - not supported */ 97 #define _ACPI_XS 0x40 /* extra space */ 98 #define _ACPI_BB 0x00 /* BEL, BS, etc. - not supported */ 99 #define _ACPI_CN 0x20 /* CR, FF, HT, NL, VT */ 100 #define _ACPI_DI 0x04 /* '0'-'9' */ 101 #define _ACPI_LO 0x02 /* 'a'-'z' */ 102 #define _ACPI_PU 0x10 /* punctuation */ 103 #define _ACPI_SP 0x08 /* space */ 104 #define _ACPI_UP 0x01 /* 'A'-'Z' */ 105 #define _ACPI_XD 0x80 /* '0'-'9', 'A'-'F', 'a'-'f' */ 106 107 #define ACPI_IS_DIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_DI)) 108 #define ACPI_IS_SPACE(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_SP)) 109 #define ACPI_IS_XDIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_XD)) 110 #define ACPI_IS_UPPER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_UP)) 111 #define ACPI_IS_LOWER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO)) 112 #define ACPI_IS_PRINT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_SP | _ACPI_PU)) 113 #define ACPI_IS_ALPHA(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP)) 114 115 #endif /* ACPI_USE_SYSTEM_CLIBRARY */ 116 117 /* 118 * utdebug - Debug interfaces 119 */ 120 void acpi_ut_track_stack_ptr(void); 121 122 void 123 acpi_ut_trace(u32 line_number, 124 const char *function_name, const char *module_name, u32 component_id); 125 126 void 127 acpi_ut_trace_ptr(u32 line_number, 128 const char *function_name, 129 const char *module_name, u32 component_id, void *pointer); 130 131 void 132 acpi_ut_trace_u32(u32 line_number, 133 const char *function_name, 134 const char *module_name, u32 component_id, u32 integer); 135 136 void 137 acpi_ut_trace_str(u32 line_number, 138 const char *function_name, 139 const char *module_name, u32 component_id, char *string); 140 141 void 142 acpi_ut_exit(u32 line_number, 143 const char *function_name, const char *module_name, u32 component_id); 144 145 void 146 acpi_ut_status_exit(u32 line_number, 147 const char *function_name, 148 const char *module_name, u32 component_id, acpi_status status); 149 150 void 151 acpi_ut_value_exit(u32 line_number, 152 const char *function_name, 153 const char *module_name, u32 component_id, acpi_integer value); 154 155 void 156 acpi_ut_ptr_exit(u32 line_number, 157 const char *function_name, 158 const char *module_name, u32 component_id, u8 * ptr); 159 160 /* Error and message reporting interfaces */ 161 162 void ACPI_INTERNAL_VAR_XFACE 163 acpi_ut_debug_print(u32 requested_debug_level, 164 u32 line_number, 165 const char *function_name, 166 const char *module_name, 167 u32 component_id, char *format, ...) ACPI_PRINTF_LIKE(6); 168 169 void ACPI_INTERNAL_VAR_XFACE 170 acpi_ut_debug_print_raw(u32 requested_debug_level, 171 u32 line_number, 172 const char *function_name, 173 const char *module_name, 174 u32 component_id, 175 char *format, ...) ACPI_PRINTF_LIKE(6); 176 177 void ACPI_INTERNAL_VAR_XFACE 178 acpi_ut_error(const char *module_name, 179 u32 line_number, char *format, ...) ACPI_PRINTF_LIKE(3); 180 181 void ACPI_INTERNAL_VAR_XFACE 182 acpi_ut_exception(const char *module_name, 183 u32 line_number, 184 acpi_status status, char *format, ...) ACPI_PRINTF_LIKE(4); 185 186 void ACPI_INTERNAL_VAR_XFACE 187 acpi_ut_warning(const char *module_name, 188 u32 line_number, char *format, ...) ACPI_PRINTF_LIKE(3); 189 190 void ACPI_INTERNAL_VAR_XFACE 191 acpi_ut_info(const char *module_name, 192 u32 line_number, char *format, ...) ACPI_PRINTF_LIKE(3); 193 194 /* 195 * utmisc 196 */ 197 const char *acpi_ut_validate_exception(acpi_status status); 198 199 #endif /* _ACUTILS_H */ 200