ia64/xen-unstable

view xen/drivers/acpi/utilities/utmisc.c @ 18887:3db54d2aa8bd

powernow: implement struct cpufreq_driver.verify

Without this, under rare conditions hypervisor crashes are possible
due to this method being called without checking against NULL.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Dec 05 15:22:21 2008 +0000 (2008-12-05)
parents 9af7a535225f
children
line source
1 /*******************************************************************************
2 *
3 * Module Name: utmisc - common utility procedures
4 *
5 ******************************************************************************/
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 */
44 #include <xen/config.h>
45 #include <xen/init.h>
46 #include <acpi/acpi.h>
48 #define _COMPONENT ACPI_UTILITIES
49 ACPI_MODULE_NAME("utmisc")
51 /*******************************************************************************
52 *
53 * FUNCTION: acpi_ut_validate_exception
54 *
55 * PARAMETERS: Status - The acpi_status code to be formatted
56 *
57 * RETURN: A string containing the exception text. NULL if exception is
58 * not valid.
59 *
60 * DESCRIPTION: This function validates and translates an ACPI exception into
61 * an ASCII string.
62 *
63 ******************************************************************************/
64 const char *acpi_ut_validate_exception(acpi_status status)
65 {
66 acpi_status sub_status;
67 const char *exception = NULL;
69 ACPI_FUNCTION_ENTRY();
71 /*
72 * Status is composed of two parts, a "type" and an actual code
73 */
74 sub_status = (status & ~AE_CODE_MASK);
76 switch (status & AE_CODE_MASK) {
77 case AE_CODE_ENVIRONMENTAL:
79 if (sub_status <= AE_CODE_ENV_MAX) {
80 exception = acpi_gbl_exception_names_env[sub_status];
81 }
82 break;
84 case AE_CODE_PROGRAMMER:
86 if (sub_status <= AE_CODE_PGM_MAX) {
87 exception =
88 acpi_gbl_exception_names_pgm[sub_status - 1];
89 }
90 break;
92 case AE_CODE_ACPI_TABLES:
94 if (sub_status <= AE_CODE_TBL_MAX) {
95 exception =
96 acpi_gbl_exception_names_tbl[sub_status - 1];
97 }
98 break;
100 case AE_CODE_AML:
102 if (sub_status <= AE_CODE_AML_MAX) {
103 exception =
104 acpi_gbl_exception_names_aml[sub_status - 1];
105 }
106 break;
108 case AE_CODE_CONTROL:
110 if (sub_status <= AE_CODE_CTRL_MAX) {
111 exception =
112 acpi_gbl_exception_names_ctrl[sub_status - 1];
113 }
114 break;
116 default:
117 break;
118 }
120 return (ACPI_CAST_PTR(const char, exception));
121 }
123 /*******************************************************************************
124 *
125 * FUNCTION: acpi_ut_set_integer_width
126 *
127 * PARAMETERS: Revision From DSDT header
128 *
129 * RETURN: None
130 *
131 * DESCRIPTION: Set the global integer bit width based upon the revision
132 * of the DSDT. For Revision 1 and 0, Integers are 32 bits.
133 * For Revision 2 and above, Integers are 64 bits. Yes, this
134 * makes a difference.
135 *
136 ******************************************************************************/
138 void acpi_ut_set_integer_width(u8 revision)
139 {
141 if (revision < 2) {
143 /* 32-bit case */
145 acpi_gbl_integer_bit_width = 32;
146 acpi_gbl_integer_nybble_width = 8;
147 acpi_gbl_integer_byte_width = 4;
148 } else {
149 /* 64-bit case (ACPI 2.0+) */
151 acpi_gbl_integer_bit_width = 64;
152 acpi_gbl_integer_nybble_width = 16;
153 acpi_gbl_integer_byte_width = 8;
154 }
155 }
157 /*******************************************************************************
158 *
159 * FUNCTION: acpi_ut_error, acpi_ut_warning, acpi_ut_info
160 *
161 * PARAMETERS: module_name - Caller's module name (for error output)
162 * line_number - Caller's line number (for error output)
163 * Format - Printf format string + additional args
164 *
165 * RETURN: None
166 *
167 * DESCRIPTION: Print message with module/line/version info
168 *
169 ******************************************************************************/
171 void ACPI_INTERNAL_VAR_XFACE
172 acpi_ut_error(char *module_name, u32 line_number, char *format, ...)
173 {
174 va_list args;
176 acpi_os_printf("ACPI Error (%s-%04d): ", module_name, line_number);
178 va_start(args, format);
179 acpi_os_vprintf(format, args);
180 acpi_os_printf(" [%X]\n", ACPI_CA_VERSION);
181 va_end(args);
182 }
184 void ACPI_INTERNAL_VAR_XFACE
185 acpi_ut_exception(char *module_name,
186 u32 line_number, acpi_status status, char *format, ...)
187 {
188 va_list args;
190 acpi_os_printf("ACPI Exception (%s-%04d): %s, ", module_name,
191 line_number, acpi_format_exception(status));
193 va_start(args, format);
194 acpi_os_vprintf(format, args);
195 acpi_os_printf(" [%X]\n", ACPI_CA_VERSION);
196 }
198 EXPORT_SYMBOL(acpi_ut_exception);
200 void ACPI_INTERNAL_VAR_XFACE
201 acpi_ut_warning(char *module_name, u32 line_number, char *format, ...)
202 {
203 va_list args;
205 acpi_os_printf("ACPI Warning (%s-%04d): ", module_name, line_number);
207 va_start(args, format);
208 acpi_os_vprintf(format, args);
209 acpi_os_printf(" [%X]\n", ACPI_CA_VERSION);
210 va_end(args);
211 va_end(args);
212 }
214 void ACPI_INTERNAL_VAR_XFACE
215 acpi_ut_info(char *module_name, u32 line_number, char *format, ...)
216 {
217 va_list args;
219 /*
220 * Removed module_name, line_number, and acpica version, not needed
221 * for info output
222 */
223 acpi_os_printf("ACPI: ");
225 va_start(args, format);
226 acpi_os_vprintf(format, args);
227 acpi_os_printf("\n");
228 va_end(args);
229 }