1 /*******************************************************************************
2 *
3 * Module Name: utmisc - common utility procedures
4 *
5 ******************************************************************************/
6
7 /*
8 * Copyright (C) 2000 - 2008, Intel Corp.
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 #include <xen/init.h>
45 #include <acpi/acpi.h>
46
47 #define _COMPONENT ACPI_UTILITIES
48 ACPI_MODULE_NAME("utmisc")
49
50 /*******************************************************************************
51 *
52 * FUNCTION: acpi_ut_validate_exception
53 *
54 * PARAMETERS: Status - The acpi_status code to be formatted
55 *
56 * RETURN: A string containing the exception text. NULL if exception is
57 * not valid.
58 *
59 * DESCRIPTION: This function validates and translates an ACPI exception into
60 * an ASCII string.
61 *
62 ******************************************************************************/
acpi_ut_validate_exception(acpi_status status)63 const char *__init acpi_ut_validate_exception(acpi_status status)
64 {
65 acpi_status sub_status;
66 const char *exception = NULL;
67
68 ACPI_FUNCTION_ENTRY();
69
70 /*
71 * Status is composed of two parts, a "type" and an actual code
72 */
73 sub_status = (status & ~AE_CODE_MASK);
74
75 switch (status & AE_CODE_MASK) {
76 case AE_CODE_ENVIRONMENTAL:
77
78 if (sub_status <= AE_CODE_ENV_MAX) {
79 exception = acpi_gbl_exception_names_env[sub_status];
80 }
81 break;
82
83 case AE_CODE_PROGRAMMER:
84
85 if (sub_status <= AE_CODE_PGM_MAX) {
86 exception =
87 acpi_gbl_exception_names_pgm[sub_status - 1];
88 }
89 break;
90
91 case AE_CODE_ACPI_TABLES:
92
93 if (sub_status <= AE_CODE_TBL_MAX) {
94 exception =
95 acpi_gbl_exception_names_tbl[sub_status - 1];
96 }
97 break;
98
99 case AE_CODE_AML:
100
101 if (sub_status <= AE_CODE_AML_MAX) {
102 exception =
103 acpi_gbl_exception_names_aml[sub_status - 1];
104 }
105 break;
106
107 case AE_CODE_CONTROL:
108
109 if (sub_status <= AE_CODE_CTRL_MAX) {
110 exception =
111 acpi_gbl_exception_names_ctrl[sub_status - 1];
112 }
113 break;
114
115 default:
116 break;
117 }
118
119 return (ACPI_CAST_PTR(const char, exception));
120 }
121
122 /*******************************************************************************
123 *
124 * FUNCTION: acpi_ut_error, acpi_ut_warning, acpi_ut_info
125 *
126 * PARAMETERS: module_name - Caller's module name (for error output)
127 * line_number - Caller's line number (for error output)
128 * Format - Printf format string + additional args
129 *
130 * RETURN: None
131 *
132 * DESCRIPTION: Print message with module/line/version info
133 *
134 ******************************************************************************/
135
136 void ACPI_INTERNAL_VAR_XFACE __init
acpi_ut_error(const char * module_name,u32 line_number,char * format,...)137 acpi_ut_error(const char *module_name, u32 line_number, char *format, ...)
138 {
139 va_list args;
140
141 acpi_os_printf("ACPI Error (%s-%04d): ", module_name, line_number);
142
143 va_start(args, format);
144 acpi_os_vprintf(format, args);
145 acpi_os_printf(" [%X]\n", ACPI_CA_VERSION);
146 va_end(args);
147 }
148
149 void ACPI_INTERNAL_VAR_XFACE __init
acpi_ut_warning(const char * module_name,u32 line_number,char * format,...)150 acpi_ut_warning(const char *module_name, u32 line_number, char *format, ...)
151 {
152 va_list args;
153
154 acpi_os_printf("ACPI Warning (%s-%04d): ", module_name, line_number);
155
156 va_start(args, format);
157 acpi_os_vprintf(format, args);
158 acpi_os_printf(" [%X]\n", ACPI_CA_VERSION);
159 va_end(args);
160 va_end(args);
161 }
162
163 void ACPI_INTERNAL_VAR_XFACE __init
acpi_ut_info(const char * module_name,u32 line_number,char * format,...)164 acpi_ut_info(const char *module_name, u32 line_number, char *format, ...)
165 {
166 va_list args;
167
168 /*
169 * Removed module_name, line_number, and acpica version, not needed
170 * for info output
171 */
172 acpi_os_printf("ACPI: ");
173
174 va_start(args, format);
175 acpi_os_vprintf(format, args);
176 acpi_os_printf("\n");
177 va_end(args);
178 }
179