1*4882a593Smuzhiyun // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
2*4882a593Smuzhiyun /******************************************************************************
3*4882a593Smuzhiyun *
4*4882a593Smuzhiyun * Module Name: exutils - interpreter/scanner utilities
5*4882a593Smuzhiyun *
6*4882a593Smuzhiyun * Copyright (C) 2000 - 2020, Intel Corp.
7*4882a593Smuzhiyun *
8*4882a593Smuzhiyun *****************************************************************************/
9*4882a593Smuzhiyun
10*4882a593Smuzhiyun /*
11*4882a593Smuzhiyun * DEFINE_AML_GLOBALS is tested in amlcode.h
12*4882a593Smuzhiyun * to determine whether certain global names should be "defined" or only
13*4882a593Smuzhiyun * "declared" in the current compilation. This enhances maintainability
14*4882a593Smuzhiyun * by enabling a single header file to embody all knowledge of the names
15*4882a593Smuzhiyun * in question.
16*4882a593Smuzhiyun *
17*4882a593Smuzhiyun * Exactly one module of any executable should #define DEFINE_GLOBALS
18*4882a593Smuzhiyun * before #including the header files which use this convention. The
19*4882a593Smuzhiyun * names in question will be defined and initialized in that module,
20*4882a593Smuzhiyun * and declared as extern in all other modules which #include those
21*4882a593Smuzhiyun * header files.
22*4882a593Smuzhiyun */
23*4882a593Smuzhiyun
24*4882a593Smuzhiyun #define DEFINE_AML_GLOBALS
25*4882a593Smuzhiyun
26*4882a593Smuzhiyun #include <acpi/acpi.h>
27*4882a593Smuzhiyun #include "accommon.h"
28*4882a593Smuzhiyun #include "acinterp.h"
29*4882a593Smuzhiyun #include "amlcode.h"
30*4882a593Smuzhiyun
31*4882a593Smuzhiyun #define _COMPONENT ACPI_EXECUTER
32*4882a593Smuzhiyun ACPI_MODULE_NAME("exutils")
33*4882a593Smuzhiyun
34*4882a593Smuzhiyun /* Local prototypes */
35*4882a593Smuzhiyun static u32 acpi_ex_digits_needed(u64 value, u32 base);
36*4882a593Smuzhiyun
37*4882a593Smuzhiyun /*******************************************************************************
38*4882a593Smuzhiyun *
39*4882a593Smuzhiyun * FUNCTION: acpi_ex_enter_interpreter
40*4882a593Smuzhiyun *
41*4882a593Smuzhiyun * PARAMETERS: None
42*4882a593Smuzhiyun *
43*4882a593Smuzhiyun * RETURN: None
44*4882a593Smuzhiyun *
45*4882a593Smuzhiyun * DESCRIPTION: Enter the interpreter execution region. Failure to enter
46*4882a593Smuzhiyun * the interpreter region is a fatal system error. Used in
47*4882a593Smuzhiyun * conjunction with exit_interpreter.
48*4882a593Smuzhiyun *
49*4882a593Smuzhiyun ******************************************************************************/
50*4882a593Smuzhiyun
acpi_ex_enter_interpreter(void)51*4882a593Smuzhiyun void acpi_ex_enter_interpreter(void)
52*4882a593Smuzhiyun {
53*4882a593Smuzhiyun acpi_status status;
54*4882a593Smuzhiyun
55*4882a593Smuzhiyun ACPI_FUNCTION_TRACE(ex_enter_interpreter);
56*4882a593Smuzhiyun
57*4882a593Smuzhiyun status = acpi_ut_acquire_mutex(ACPI_MTX_INTERPRETER);
58*4882a593Smuzhiyun if (ACPI_FAILURE(status)) {
59*4882a593Smuzhiyun ACPI_ERROR((AE_INFO,
60*4882a593Smuzhiyun "Could not acquire AML Interpreter mutex"));
61*4882a593Smuzhiyun }
62*4882a593Smuzhiyun status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
63*4882a593Smuzhiyun if (ACPI_FAILURE(status)) {
64*4882a593Smuzhiyun ACPI_ERROR((AE_INFO, "Could not acquire AML Namespace mutex"));
65*4882a593Smuzhiyun }
66*4882a593Smuzhiyun
67*4882a593Smuzhiyun return_VOID;
68*4882a593Smuzhiyun }
69*4882a593Smuzhiyun
70*4882a593Smuzhiyun /*******************************************************************************
71*4882a593Smuzhiyun *
72*4882a593Smuzhiyun * FUNCTION: acpi_ex_exit_interpreter
73*4882a593Smuzhiyun *
74*4882a593Smuzhiyun * PARAMETERS: None
75*4882a593Smuzhiyun *
76*4882a593Smuzhiyun * RETURN: None
77*4882a593Smuzhiyun *
78*4882a593Smuzhiyun * DESCRIPTION: Exit the interpreter execution region. This is the top level
79*4882a593Smuzhiyun * routine used to exit the interpreter when all processing has
80*4882a593Smuzhiyun * been completed, or when the method blocks.
81*4882a593Smuzhiyun *
82*4882a593Smuzhiyun * Cases where the interpreter is unlocked internally:
83*4882a593Smuzhiyun * 1) Method will be blocked on a Sleep() AML opcode
84*4882a593Smuzhiyun * 2) Method will be blocked on an Acquire() AML opcode
85*4882a593Smuzhiyun * 3) Method will be blocked on a Wait() AML opcode
86*4882a593Smuzhiyun * 4) Method will be blocked to acquire the global lock
87*4882a593Smuzhiyun * 5) Method will be blocked waiting to execute a serialized control
88*4882a593Smuzhiyun * method that is currently executing
89*4882a593Smuzhiyun * 6) About to invoke a user-installed opregion handler
90*4882a593Smuzhiyun *
91*4882a593Smuzhiyun ******************************************************************************/
92*4882a593Smuzhiyun
acpi_ex_exit_interpreter(void)93*4882a593Smuzhiyun void acpi_ex_exit_interpreter(void)
94*4882a593Smuzhiyun {
95*4882a593Smuzhiyun acpi_status status;
96*4882a593Smuzhiyun
97*4882a593Smuzhiyun ACPI_FUNCTION_TRACE(ex_exit_interpreter);
98*4882a593Smuzhiyun
99*4882a593Smuzhiyun status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
100*4882a593Smuzhiyun if (ACPI_FAILURE(status)) {
101*4882a593Smuzhiyun ACPI_ERROR((AE_INFO, "Could not release AML Namespace mutex"));
102*4882a593Smuzhiyun }
103*4882a593Smuzhiyun status = acpi_ut_release_mutex(ACPI_MTX_INTERPRETER);
104*4882a593Smuzhiyun if (ACPI_FAILURE(status)) {
105*4882a593Smuzhiyun ACPI_ERROR((AE_INFO,
106*4882a593Smuzhiyun "Could not release AML Interpreter mutex"));
107*4882a593Smuzhiyun }
108*4882a593Smuzhiyun
109*4882a593Smuzhiyun return_VOID;
110*4882a593Smuzhiyun }
111*4882a593Smuzhiyun
112*4882a593Smuzhiyun /*******************************************************************************
113*4882a593Smuzhiyun *
114*4882a593Smuzhiyun * FUNCTION: acpi_ex_truncate_for32bit_table
115*4882a593Smuzhiyun *
116*4882a593Smuzhiyun * PARAMETERS: obj_desc - Object to be truncated
117*4882a593Smuzhiyun *
118*4882a593Smuzhiyun * RETURN: TRUE if a truncation was performed, FALSE otherwise.
119*4882a593Smuzhiyun *
120*4882a593Smuzhiyun * DESCRIPTION: Truncate an ACPI Integer to 32 bits if the execution mode is
121*4882a593Smuzhiyun * 32-bit, as determined by the revision of the DSDT.
122*4882a593Smuzhiyun *
123*4882a593Smuzhiyun ******************************************************************************/
124*4882a593Smuzhiyun
acpi_ex_truncate_for32bit_table(union acpi_operand_object * obj_desc)125*4882a593Smuzhiyun u8 acpi_ex_truncate_for32bit_table(union acpi_operand_object *obj_desc)
126*4882a593Smuzhiyun {
127*4882a593Smuzhiyun
128*4882a593Smuzhiyun ACPI_FUNCTION_ENTRY();
129*4882a593Smuzhiyun
130*4882a593Smuzhiyun /*
131*4882a593Smuzhiyun * Object must be a valid number and we must be executing
132*4882a593Smuzhiyun * a control method. Object could be NS node for AML_INT_NAMEPATH_OP.
133*4882a593Smuzhiyun */
134*4882a593Smuzhiyun if ((!obj_desc) ||
135*4882a593Smuzhiyun (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) != ACPI_DESC_TYPE_OPERAND) ||
136*4882a593Smuzhiyun (obj_desc->common.type != ACPI_TYPE_INTEGER)) {
137*4882a593Smuzhiyun return (FALSE);
138*4882a593Smuzhiyun }
139*4882a593Smuzhiyun
140*4882a593Smuzhiyun if ((acpi_gbl_integer_byte_width == 4) &&
141*4882a593Smuzhiyun (obj_desc->integer.value > (u64)ACPI_UINT32_MAX)) {
142*4882a593Smuzhiyun /*
143*4882a593Smuzhiyun * We are executing in a 32-bit ACPI table. Truncate
144*4882a593Smuzhiyun * the value to 32 bits by zeroing out the upper 32-bit field
145*4882a593Smuzhiyun */
146*4882a593Smuzhiyun obj_desc->integer.value &= (u64)ACPI_UINT32_MAX;
147*4882a593Smuzhiyun return (TRUE);
148*4882a593Smuzhiyun }
149*4882a593Smuzhiyun
150*4882a593Smuzhiyun return (FALSE);
151*4882a593Smuzhiyun }
152*4882a593Smuzhiyun
153*4882a593Smuzhiyun /*******************************************************************************
154*4882a593Smuzhiyun *
155*4882a593Smuzhiyun * FUNCTION: acpi_ex_acquire_global_lock
156*4882a593Smuzhiyun *
157*4882a593Smuzhiyun * PARAMETERS: field_flags - Flags with Lock rule:
158*4882a593Smuzhiyun * always_lock or never_lock
159*4882a593Smuzhiyun *
160*4882a593Smuzhiyun * RETURN: None
161*4882a593Smuzhiyun *
162*4882a593Smuzhiyun * DESCRIPTION: Obtain the ACPI hardware Global Lock, only if the field
163*4882a593Smuzhiyun * flags specify that it is to be obtained before field access.
164*4882a593Smuzhiyun *
165*4882a593Smuzhiyun ******************************************************************************/
166*4882a593Smuzhiyun
acpi_ex_acquire_global_lock(u32 field_flags)167*4882a593Smuzhiyun void acpi_ex_acquire_global_lock(u32 field_flags)
168*4882a593Smuzhiyun {
169*4882a593Smuzhiyun acpi_status status;
170*4882a593Smuzhiyun
171*4882a593Smuzhiyun ACPI_FUNCTION_TRACE(ex_acquire_global_lock);
172*4882a593Smuzhiyun
173*4882a593Smuzhiyun /* Only use the lock if the always_lock bit is set */
174*4882a593Smuzhiyun
175*4882a593Smuzhiyun if (!(field_flags & AML_FIELD_LOCK_RULE_MASK)) {
176*4882a593Smuzhiyun return_VOID;
177*4882a593Smuzhiyun }
178*4882a593Smuzhiyun
179*4882a593Smuzhiyun /* Attempt to get the global lock, wait forever */
180*4882a593Smuzhiyun
181*4882a593Smuzhiyun status = acpi_ex_acquire_mutex_object(ACPI_WAIT_FOREVER,
182*4882a593Smuzhiyun acpi_gbl_global_lock_mutex,
183*4882a593Smuzhiyun acpi_os_get_thread_id());
184*4882a593Smuzhiyun
185*4882a593Smuzhiyun if (ACPI_FAILURE(status)) {
186*4882a593Smuzhiyun ACPI_EXCEPTION((AE_INFO, status,
187*4882a593Smuzhiyun "Could not acquire Global Lock"));
188*4882a593Smuzhiyun }
189*4882a593Smuzhiyun
190*4882a593Smuzhiyun return_VOID;
191*4882a593Smuzhiyun }
192*4882a593Smuzhiyun
193*4882a593Smuzhiyun /*******************************************************************************
194*4882a593Smuzhiyun *
195*4882a593Smuzhiyun * FUNCTION: acpi_ex_release_global_lock
196*4882a593Smuzhiyun *
197*4882a593Smuzhiyun * PARAMETERS: field_flags - Flags with Lock rule:
198*4882a593Smuzhiyun * always_lock or never_lock
199*4882a593Smuzhiyun *
200*4882a593Smuzhiyun * RETURN: None
201*4882a593Smuzhiyun *
202*4882a593Smuzhiyun * DESCRIPTION: Release the ACPI hardware Global Lock
203*4882a593Smuzhiyun *
204*4882a593Smuzhiyun ******************************************************************************/
205*4882a593Smuzhiyun
acpi_ex_release_global_lock(u32 field_flags)206*4882a593Smuzhiyun void acpi_ex_release_global_lock(u32 field_flags)
207*4882a593Smuzhiyun {
208*4882a593Smuzhiyun acpi_status status;
209*4882a593Smuzhiyun
210*4882a593Smuzhiyun ACPI_FUNCTION_TRACE(ex_release_global_lock);
211*4882a593Smuzhiyun
212*4882a593Smuzhiyun /* Only use the lock if the always_lock bit is set */
213*4882a593Smuzhiyun
214*4882a593Smuzhiyun if (!(field_flags & AML_FIELD_LOCK_RULE_MASK)) {
215*4882a593Smuzhiyun return_VOID;
216*4882a593Smuzhiyun }
217*4882a593Smuzhiyun
218*4882a593Smuzhiyun /* Release the global lock */
219*4882a593Smuzhiyun
220*4882a593Smuzhiyun status = acpi_ex_release_mutex_object(acpi_gbl_global_lock_mutex);
221*4882a593Smuzhiyun if (ACPI_FAILURE(status)) {
222*4882a593Smuzhiyun
223*4882a593Smuzhiyun /* Report the error, but there isn't much else we can do */
224*4882a593Smuzhiyun
225*4882a593Smuzhiyun ACPI_EXCEPTION((AE_INFO, status,
226*4882a593Smuzhiyun "Could not release Global Lock"));
227*4882a593Smuzhiyun }
228*4882a593Smuzhiyun
229*4882a593Smuzhiyun return_VOID;
230*4882a593Smuzhiyun }
231*4882a593Smuzhiyun
232*4882a593Smuzhiyun /*******************************************************************************
233*4882a593Smuzhiyun *
234*4882a593Smuzhiyun * FUNCTION: acpi_ex_digits_needed
235*4882a593Smuzhiyun *
236*4882a593Smuzhiyun * PARAMETERS: value - Value to be represented
237*4882a593Smuzhiyun * base - Base of representation
238*4882a593Smuzhiyun *
239*4882a593Smuzhiyun * RETURN: The number of digits.
240*4882a593Smuzhiyun *
241*4882a593Smuzhiyun * DESCRIPTION: Calculate the number of digits needed to represent the Value
242*4882a593Smuzhiyun * in the given Base (Radix)
243*4882a593Smuzhiyun *
244*4882a593Smuzhiyun ******************************************************************************/
245*4882a593Smuzhiyun
acpi_ex_digits_needed(u64 value,u32 base)246*4882a593Smuzhiyun static u32 acpi_ex_digits_needed(u64 value, u32 base)
247*4882a593Smuzhiyun {
248*4882a593Smuzhiyun u32 num_digits;
249*4882a593Smuzhiyun u64 current_value;
250*4882a593Smuzhiyun
251*4882a593Smuzhiyun ACPI_FUNCTION_TRACE(ex_digits_needed);
252*4882a593Smuzhiyun
253*4882a593Smuzhiyun /* u64 is unsigned, so we don't worry about a '-' prefix */
254*4882a593Smuzhiyun
255*4882a593Smuzhiyun if (value == 0) {
256*4882a593Smuzhiyun return_UINT32(1);
257*4882a593Smuzhiyun }
258*4882a593Smuzhiyun
259*4882a593Smuzhiyun current_value = value;
260*4882a593Smuzhiyun num_digits = 0;
261*4882a593Smuzhiyun
262*4882a593Smuzhiyun /* Count the digits in the requested base */
263*4882a593Smuzhiyun
264*4882a593Smuzhiyun while (current_value) {
265*4882a593Smuzhiyun (void)acpi_ut_short_divide(current_value, base, ¤t_value,
266*4882a593Smuzhiyun NULL);
267*4882a593Smuzhiyun num_digits++;
268*4882a593Smuzhiyun }
269*4882a593Smuzhiyun
270*4882a593Smuzhiyun return_UINT32(num_digits);
271*4882a593Smuzhiyun }
272*4882a593Smuzhiyun
273*4882a593Smuzhiyun /*******************************************************************************
274*4882a593Smuzhiyun *
275*4882a593Smuzhiyun * FUNCTION: acpi_ex_eisa_id_to_string
276*4882a593Smuzhiyun *
277*4882a593Smuzhiyun * PARAMETERS: out_string - Where to put the converted string (8 bytes)
278*4882a593Smuzhiyun * compressed_id - EISAID to be converted
279*4882a593Smuzhiyun *
280*4882a593Smuzhiyun * RETURN: None
281*4882a593Smuzhiyun *
282*4882a593Smuzhiyun * DESCRIPTION: Convert a numeric EISAID to string representation. Return
283*4882a593Smuzhiyun * buffer must be large enough to hold the string. The string
284*4882a593Smuzhiyun * returned is always exactly of length ACPI_EISAID_STRING_SIZE
285*4882a593Smuzhiyun * (includes null terminator). The EISAID is always 32 bits.
286*4882a593Smuzhiyun *
287*4882a593Smuzhiyun ******************************************************************************/
288*4882a593Smuzhiyun
acpi_ex_eisa_id_to_string(char * out_string,u64 compressed_id)289*4882a593Smuzhiyun void acpi_ex_eisa_id_to_string(char *out_string, u64 compressed_id)
290*4882a593Smuzhiyun {
291*4882a593Smuzhiyun u32 swapped_id;
292*4882a593Smuzhiyun
293*4882a593Smuzhiyun ACPI_FUNCTION_ENTRY();
294*4882a593Smuzhiyun
295*4882a593Smuzhiyun /* The EISAID should be a 32-bit integer */
296*4882a593Smuzhiyun
297*4882a593Smuzhiyun if (compressed_id > ACPI_UINT32_MAX) {
298*4882a593Smuzhiyun ACPI_WARNING((AE_INFO,
299*4882a593Smuzhiyun "Expected EISAID is larger than 32 bits: "
300*4882a593Smuzhiyun "0x%8.8X%8.8X, truncating",
301*4882a593Smuzhiyun ACPI_FORMAT_UINT64(compressed_id)));
302*4882a593Smuzhiyun }
303*4882a593Smuzhiyun
304*4882a593Smuzhiyun /* Swap ID to big-endian to get contiguous bits */
305*4882a593Smuzhiyun
306*4882a593Smuzhiyun swapped_id = acpi_ut_dword_byte_swap((u32)compressed_id);
307*4882a593Smuzhiyun
308*4882a593Smuzhiyun /* First 3 bytes are uppercase letters. Next 4 bytes are hexadecimal */
309*4882a593Smuzhiyun
310*4882a593Smuzhiyun out_string[0] =
311*4882a593Smuzhiyun (char)(0x40 + (((unsigned long)swapped_id >> 26) & 0x1F));
312*4882a593Smuzhiyun out_string[1] = (char)(0x40 + ((swapped_id >> 21) & 0x1F));
313*4882a593Smuzhiyun out_string[2] = (char)(0x40 + ((swapped_id >> 16) & 0x1F));
314*4882a593Smuzhiyun out_string[3] = acpi_ut_hex_to_ascii_char((u64) swapped_id, 12);
315*4882a593Smuzhiyun out_string[4] = acpi_ut_hex_to_ascii_char((u64) swapped_id, 8);
316*4882a593Smuzhiyun out_string[5] = acpi_ut_hex_to_ascii_char((u64) swapped_id, 4);
317*4882a593Smuzhiyun out_string[6] = acpi_ut_hex_to_ascii_char((u64) swapped_id, 0);
318*4882a593Smuzhiyun out_string[7] = 0;
319*4882a593Smuzhiyun }
320*4882a593Smuzhiyun
321*4882a593Smuzhiyun /*******************************************************************************
322*4882a593Smuzhiyun *
323*4882a593Smuzhiyun * FUNCTION: acpi_ex_integer_to_string
324*4882a593Smuzhiyun *
325*4882a593Smuzhiyun * PARAMETERS: out_string - Where to put the converted string. At least
326*4882a593Smuzhiyun * 21 bytes are needed to hold the largest
327*4882a593Smuzhiyun * possible 64-bit integer.
328*4882a593Smuzhiyun * value - Value to be converted
329*4882a593Smuzhiyun *
330*4882a593Smuzhiyun * RETURN: Converted string in out_string
331*4882a593Smuzhiyun *
332*4882a593Smuzhiyun * DESCRIPTION: Convert a 64-bit integer to decimal string representation.
333*4882a593Smuzhiyun * Assumes string buffer is large enough to hold the string. The
334*4882a593Smuzhiyun * largest string is (ACPI_MAX64_DECIMAL_DIGITS + 1).
335*4882a593Smuzhiyun *
336*4882a593Smuzhiyun ******************************************************************************/
337*4882a593Smuzhiyun
acpi_ex_integer_to_string(char * out_string,u64 value)338*4882a593Smuzhiyun void acpi_ex_integer_to_string(char *out_string, u64 value)
339*4882a593Smuzhiyun {
340*4882a593Smuzhiyun u32 count;
341*4882a593Smuzhiyun u32 digits_needed;
342*4882a593Smuzhiyun u32 remainder;
343*4882a593Smuzhiyun
344*4882a593Smuzhiyun ACPI_FUNCTION_ENTRY();
345*4882a593Smuzhiyun
346*4882a593Smuzhiyun digits_needed = acpi_ex_digits_needed(value, 10);
347*4882a593Smuzhiyun out_string[digits_needed] = 0;
348*4882a593Smuzhiyun
349*4882a593Smuzhiyun for (count = digits_needed; count > 0; count--) {
350*4882a593Smuzhiyun (void)acpi_ut_short_divide(value, 10, &value, &remainder);
351*4882a593Smuzhiyun out_string[count - 1] = (char)('0' + remainder);
352*4882a593Smuzhiyun }
353*4882a593Smuzhiyun }
354*4882a593Smuzhiyun
355*4882a593Smuzhiyun /*******************************************************************************
356*4882a593Smuzhiyun *
357*4882a593Smuzhiyun * FUNCTION: acpi_ex_pci_cls_to_string
358*4882a593Smuzhiyun *
359*4882a593Smuzhiyun * PARAMETERS: out_string - Where to put the converted string (7 bytes)
360*4882a593Smuzhiyun * class_code - PCI class code to be converted (3 bytes)
361*4882a593Smuzhiyun *
362*4882a593Smuzhiyun * RETURN: Converted string in out_string
363*4882a593Smuzhiyun *
364*4882a593Smuzhiyun * DESCRIPTION: Convert 3-bytes PCI class code to string representation.
365*4882a593Smuzhiyun * Return buffer must be large enough to hold the string. The
366*4882a593Smuzhiyun * string returned is always exactly of length
367*4882a593Smuzhiyun * ACPI_PCICLS_STRING_SIZE (includes null terminator).
368*4882a593Smuzhiyun *
369*4882a593Smuzhiyun ******************************************************************************/
370*4882a593Smuzhiyun
acpi_ex_pci_cls_to_string(char * out_string,u8 class_code[3])371*4882a593Smuzhiyun void acpi_ex_pci_cls_to_string(char *out_string, u8 class_code[3])
372*4882a593Smuzhiyun {
373*4882a593Smuzhiyun
374*4882a593Smuzhiyun ACPI_FUNCTION_ENTRY();
375*4882a593Smuzhiyun
376*4882a593Smuzhiyun /* All 3 bytes are hexadecimal */
377*4882a593Smuzhiyun
378*4882a593Smuzhiyun out_string[0] = acpi_ut_hex_to_ascii_char((u64)class_code[0], 4);
379*4882a593Smuzhiyun out_string[1] = acpi_ut_hex_to_ascii_char((u64)class_code[0], 0);
380*4882a593Smuzhiyun out_string[2] = acpi_ut_hex_to_ascii_char((u64)class_code[1], 4);
381*4882a593Smuzhiyun out_string[3] = acpi_ut_hex_to_ascii_char((u64)class_code[1], 0);
382*4882a593Smuzhiyun out_string[4] = acpi_ut_hex_to_ascii_char((u64)class_code[2], 4);
383*4882a593Smuzhiyun out_string[5] = acpi_ut_hex_to_ascii_char((u64)class_code[2], 0);
384*4882a593Smuzhiyun out_string[6] = 0;
385*4882a593Smuzhiyun }
386*4882a593Smuzhiyun
387*4882a593Smuzhiyun /*******************************************************************************
388*4882a593Smuzhiyun *
389*4882a593Smuzhiyun * FUNCTION: acpi_is_valid_space_id
390*4882a593Smuzhiyun *
391*4882a593Smuzhiyun * PARAMETERS: space_id - ID to be validated
392*4882a593Smuzhiyun *
393*4882a593Smuzhiyun * RETURN: TRUE if space_id is a valid/supported ID.
394*4882a593Smuzhiyun *
395*4882a593Smuzhiyun * DESCRIPTION: Validate an operation region space_ID.
396*4882a593Smuzhiyun *
397*4882a593Smuzhiyun ******************************************************************************/
398*4882a593Smuzhiyun
acpi_is_valid_space_id(u8 space_id)399*4882a593Smuzhiyun u8 acpi_is_valid_space_id(u8 space_id)
400*4882a593Smuzhiyun {
401*4882a593Smuzhiyun
402*4882a593Smuzhiyun if ((space_id >= ACPI_NUM_PREDEFINED_REGIONS) &&
403*4882a593Smuzhiyun (space_id < ACPI_USER_REGION_BEGIN) &&
404*4882a593Smuzhiyun (space_id != ACPI_ADR_SPACE_DATA_TABLE) &&
405*4882a593Smuzhiyun (space_id != ACPI_ADR_SPACE_FIXED_HARDWARE)) {
406*4882a593Smuzhiyun return (FALSE);
407*4882a593Smuzhiyun }
408*4882a593Smuzhiyun
409*4882a593Smuzhiyun return (TRUE);
410*4882a593Smuzhiyun }
411