167754Smsmith/******************************************************************************
267754Smsmith *
377424Smsmith * Module Name: exutils - interpreter/scanner utilities
467754Smsmith *
567754Smsmith *****************************************************************************/
667754Smsmith
7217365Sjkim/*
8245582Sjkim * Copyright (C) 2000 - 2013, Intel Corp.
970243Smsmith * All rights reserved.
1067754Smsmith *
11217365Sjkim * Redistribution and use in source and binary forms, with or without
12217365Sjkim * modification, are permitted provided that the following conditions
13217365Sjkim * are met:
14217365Sjkim * 1. Redistributions of source code must retain the above copyright
15217365Sjkim *    notice, this list of conditions, and the following disclaimer,
16217365Sjkim *    without modification.
17217365Sjkim * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18217365Sjkim *    substantially similar to the "NO WARRANTY" disclaimer below
19217365Sjkim *    ("Disclaimer") and any redistribution must be conditioned upon
20217365Sjkim *    including a substantially similar Disclaimer requirement for further
21217365Sjkim *    binary redistribution.
22217365Sjkim * 3. Neither the names of the above-listed copyright holders nor the names
23217365Sjkim *    of any contributors may be used to endorse or promote products derived
24217365Sjkim *    from this software without specific prior written permission.
2567754Smsmith *
26217365Sjkim * Alternatively, this software may be distributed under the terms of the
27217365Sjkim * GNU General Public License ("GPL") version 2 as published by the Free
28217365Sjkim * Software Foundation.
2967754Smsmith *
30217365Sjkim * NO WARRANTY
31217365Sjkim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32217365Sjkim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33217365Sjkim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34217365Sjkim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35217365Sjkim * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36217365Sjkim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37217365Sjkim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38217365Sjkim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39217365Sjkim * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40217365Sjkim * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41217365Sjkim * POSSIBILITY OF SUCH DAMAGES.
42217365Sjkim */
4367754Smsmith
4477424Smsmith#define __EXUTILS_C__
4567754Smsmith
4683174Smsmith/*
4783174Smsmith * DEFINE_AML_GLOBALS is tested in amlcode.h
4883174Smsmith * to determine whether certain global names should be "defined" or only
49241973Sjkim * "declared" in the current compilation. This enhances maintainability
5083174Smsmith * by enabling a single header file to embody all knowledge of the names
5183174Smsmith * in question.
5283174Smsmith *
5383174Smsmith * Exactly one module of any executable should #define DEFINE_GLOBALS
54241973Sjkim * before #including the header files which use this convention. The
5583174Smsmith * names in question will be defined and initialized in that module,
5683174Smsmith * and declared as extern in all other modules which #include those
5783174Smsmith * header files.
5883174Smsmith */
5983174Smsmith
6083174Smsmith#define DEFINE_AML_GLOBALS
6183174Smsmith
62193341Sjkim#include <contrib/dev/acpica/include/acpi.h>
63193341Sjkim#include <contrib/dev/acpica/include/accommon.h>
64193341Sjkim#include <contrib/dev/acpica/include/acinterp.h>
65193341Sjkim#include <contrib/dev/acpica/include/amlcode.h>
6667754Smsmith
6777424Smsmith#define _COMPONENT          ACPI_EXECUTER
6891116Smsmith        ACPI_MODULE_NAME    ("exutils")
6967754Smsmith
70151937Sjkim/* Local prototypes */
7167754Smsmith
72151937Sjkimstatic UINT32
73151937SjkimAcpiExDigitsNeeded (
74202771Sjkim    UINT64                  Value,
75151937Sjkim    UINT32                  Base);
76151937Sjkim
77151937Sjkim
78100966Siwasaki#ifndef ACPI_NO_METHOD_EXECUTION
79100966Siwasaki/*******************************************************************************
80100966Siwasaki *
8177424Smsmith * FUNCTION:    AcpiExEnterInterpreter
8267754Smsmith *
8367754Smsmith * PARAMETERS:  None
8467754Smsmith *
85167802Sjkim * RETURN:      None
86151937Sjkim *
87167802Sjkim * DESCRIPTION: Enter the interpreter execution region. Failure to enter
88167802Sjkim *              the interpreter region is a fatal system error. Used in
89167802Sjkim *              conjunction with ExitInterpreter.
9067754Smsmith *
9167754Smsmith ******************************************************************************/
9267754Smsmith
93167802Sjkimvoid
94151937SjkimAcpiExEnterInterpreter (
95151937Sjkim    void)
9667754Smsmith{
9777424Smsmith    ACPI_STATUS             Status;
9867754Smsmith
9967754Smsmith
100167802Sjkim    ACPI_FUNCTION_TRACE (ExEnterInterpreter);
10167754Smsmith
102167802Sjkim
103167802Sjkim    Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER);
10491116Smsmith    if (ACPI_FAILURE (Status))
10591116Smsmith    {
106167802Sjkim        ACPI_ERROR ((AE_INFO, "Could not acquire AML Interpreter mutex"));
10791116Smsmith    }
10891116Smsmith
109167802Sjkim    return_VOID;
11067754Smsmith}
11167754Smsmith
11267754Smsmith
11367754Smsmith/*******************************************************************************
11467754Smsmith *
115167802Sjkim * FUNCTION:    AcpiExReacquireInterpreter
116167802Sjkim *
117167802Sjkim * PARAMETERS:  None
118167802Sjkim *
119167802Sjkim * RETURN:      None
120167802Sjkim *
121167802Sjkim * DESCRIPTION: Reacquire the interpreter execution region from within the
122167802Sjkim *              interpreter code. Failure to enter the interpreter region is a
123238381Sjkim *              fatal system error. Used in conjunction with
124167802Sjkim *              RelinquishInterpreter
125167802Sjkim *
126167802Sjkim ******************************************************************************/
127167802Sjkim
128167802Sjkimvoid
129167802SjkimAcpiExReacquireInterpreter (
130167802Sjkim    void)
131167802Sjkim{
132167802Sjkim    ACPI_FUNCTION_TRACE (ExReacquireInterpreter);
133167802Sjkim
134167802Sjkim
135167802Sjkim    /*
136167802Sjkim     * If the global serialized flag is set, do not release the interpreter,
137167802Sjkim     * since it was not actually released by AcpiExRelinquishInterpreter.
138167802Sjkim     * This forces the interpreter to be single threaded.
139167802Sjkim     */
140167802Sjkim    if (!AcpiGbl_AllMethodsSerialized)
141167802Sjkim    {
142167802Sjkim        AcpiExEnterInterpreter ();
143167802Sjkim    }
144167802Sjkim
145167802Sjkim    return_VOID;
146167802Sjkim}
147167802Sjkim
148167802Sjkim
149167802Sjkim/*******************************************************************************
150167802Sjkim *
15177424Smsmith * FUNCTION:    AcpiExExitInterpreter
15267754Smsmith *
15367754Smsmith * PARAMETERS:  None
15467754Smsmith *
155151937Sjkim * RETURN:      None
156151937Sjkim *
157167802Sjkim * DESCRIPTION: Exit the interpreter execution region. This is the top level
158167802Sjkim *              routine used to exit the interpreter when all processing has
159167802Sjkim *              been completed.
16067754Smsmith *
16167754Smsmith ******************************************************************************/
16267754Smsmith
16367754Smsmithvoid
164151937SjkimAcpiExExitInterpreter (
165151937Sjkim    void)
16667754Smsmith{
16791116Smsmith    ACPI_STATUS             Status;
16867754Smsmith
16967754Smsmith
170167802Sjkim    ACPI_FUNCTION_TRACE (ExExitInterpreter);
17167754Smsmith
17291116Smsmith
173167802Sjkim    Status = AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER);
17499679Siwasaki    if (ACPI_FAILURE (Status))
17599679Siwasaki    {
176167802Sjkim        ACPI_ERROR ((AE_INFO, "Could not release AML Interpreter mutex"));
17799679Siwasaki    }
17891116Smsmith
17967754Smsmith    return_VOID;
18067754Smsmith}
18167754Smsmith
18267754Smsmith
18367754Smsmith/*******************************************************************************
18467754Smsmith *
185167802Sjkim * FUNCTION:    AcpiExRelinquishInterpreter
186167802Sjkim *
187167802Sjkim * PARAMETERS:  None
188167802Sjkim *
189167802Sjkim * RETURN:      None
190167802Sjkim *
191167802Sjkim * DESCRIPTION: Exit the interpreter execution region, from within the
192167802Sjkim *              interpreter - before attempting an operation that will possibly
193167802Sjkim *              block the running thread.
194167802Sjkim *
195167802Sjkim * Cases where the interpreter is unlocked internally
196167802Sjkim *      1) Method to be blocked on a Sleep() AML opcode
197167802Sjkim *      2) Method to be blocked on an Acquire() AML opcode
198167802Sjkim *      3) Method to be blocked on a Wait() AML opcode
199167802Sjkim *      4) Method to be blocked to acquire the global lock
200167802Sjkim *      5) Method to be blocked waiting to execute a serialized control method
201167802Sjkim *          that is currently executing
202167802Sjkim *      6) About to invoke a user-installed opregion handler
203167802Sjkim *
204167802Sjkim ******************************************************************************/
205167802Sjkim
206167802Sjkimvoid
207167802SjkimAcpiExRelinquishInterpreter (
208167802Sjkim    void)
209167802Sjkim{
210167802Sjkim    ACPI_FUNCTION_TRACE (ExRelinquishInterpreter);
211167802Sjkim
212167802Sjkim
213167802Sjkim    /*
214167802Sjkim     * If the global serialized flag is set, do not release the interpreter.
215167802Sjkim     * This forces the interpreter to be single threaded.
216167802Sjkim     */
217167802Sjkim    if (!AcpiGbl_AllMethodsSerialized)
218167802Sjkim    {
219167802Sjkim        AcpiExExitInterpreter ();
220167802Sjkim    }
221167802Sjkim
222167802Sjkim    return_VOID;
223167802Sjkim}
224167802Sjkim
225167802Sjkim
226167802Sjkim/*******************************************************************************
227167802Sjkim *
22877424Smsmith * FUNCTION:    AcpiExTruncateFor32bitTable
22967754Smsmith *
23069450Smsmith * PARAMETERS:  ObjDesc         - Object to be truncated
23167754Smsmith *
232245582Sjkim * RETURN:      TRUE if a truncation was performed, FALSE otherwise.
23367754Smsmith *
234167802Sjkim * DESCRIPTION: Truncate an ACPI Integer to 32 bits if the execution mode is
235167802Sjkim *              32-bit, as determined by the revision of the DSDT.
23667754Smsmith *
23767754Smsmith ******************************************************************************/
23867754Smsmith
239245582SjkimBOOLEAN
24077424SmsmithAcpiExTruncateFor32bitTable (
24199679Siwasaki    ACPI_OPERAND_OBJECT     *ObjDesc)
24267754Smsmith{
24367754Smsmith
24491116Smsmith    ACPI_FUNCTION_ENTRY ();
24583174Smsmith
24683174Smsmith
24769450Smsmith    /*
24869450Smsmith     * Object must be a valid number and we must be executing
249245582Sjkim     * a control method. Object could be NS node for AML_INT_NAMEPATH_OP.
25069450Smsmith     */
25169450Smsmith    if ((!ObjDesc) ||
252167802Sjkim        (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND) ||
253193267Sjkim        (ObjDesc->Common.Type != ACPI_TYPE_INTEGER))
25469450Smsmith    {
255245582Sjkim        return (FALSE);
25669450Smsmith    }
25769450Smsmith
258245582Sjkim    if ((AcpiGbl_IntegerByteWidth == 4) &&
259245582Sjkim        (ObjDesc->Integer.Value > (UINT64) ACPI_UINT32_MAX))
26069450Smsmith    {
26169450Smsmith        /*
262245582Sjkim         * We are executing in a 32-bit ACPI table.
26369450Smsmith         * Truncate the value to 32 bits by zeroing out the upper 32-bit field
26469450Smsmith         */
265202771Sjkim        ObjDesc->Integer.Value &= (UINT64) ACPI_UINT32_MAX;
266245582Sjkim        return (TRUE);
26769450Smsmith    }
268245582Sjkim
269245582Sjkim    return (FALSE);
27067754Smsmith}
27167754Smsmith
27267754Smsmith
27367754Smsmith/*******************************************************************************
27467754Smsmith *
27577424Smsmith * FUNCTION:    AcpiExAcquireGlobalLock
27667754Smsmith *
27791116Smsmith * PARAMETERS:  FieldFlags            - Flags with Lock rule:
27887031Smsmith *                                      AlwaysLock or NeverLock
27967754Smsmith *
280167802Sjkim * RETURN:      None
28167754Smsmith *
282167802Sjkim * DESCRIPTION: Obtain the ACPI hardware Global Lock, only if the field
283167802Sjkim *              flags specifiy that it is to be obtained before field access.
28467754Smsmith *
28567754Smsmith ******************************************************************************/
28667754Smsmith
287167802Sjkimvoid
28877424SmsmithAcpiExAcquireGlobalLock (
28987031Smsmith    UINT32                  FieldFlags)
29067754Smsmith{
29167754Smsmith    ACPI_STATUS             Status;
29267754Smsmith
29367754Smsmith
294167802Sjkim    ACPI_FUNCTION_TRACE (ExAcquireGlobalLock);
29567754Smsmith
29667754Smsmith
297167802Sjkim    /* Only use the lock if the AlwaysLock bit is set */
29867754Smsmith
299167802Sjkim    if (!(FieldFlags & AML_FIELD_LOCK_RULE_MASK))
30067754Smsmith    {
301167802Sjkim        return_VOID;
302167802Sjkim    }
30367754Smsmith
304167802Sjkim    /* Attempt to get the global lock, wait forever */
305167802Sjkim
306167802Sjkim    Status = AcpiExAcquireMutexObject (ACPI_WAIT_FOREVER,
307167802Sjkim                AcpiGbl_GlobalLockMutex, AcpiOsGetThreadId ());
308167802Sjkim
309167802Sjkim    if (ACPI_FAILURE (Status))
310167802Sjkim    {
311167802Sjkim        ACPI_EXCEPTION ((AE_INFO, Status,
312167802Sjkim            "Could not acquire Global Lock"));
31367754Smsmith    }
31467754Smsmith
315167802Sjkim    return_VOID;
31667754Smsmith}
31767754Smsmith
31867754Smsmith
31967754Smsmith/*******************************************************************************
32067754Smsmith *
32177424Smsmith * FUNCTION:    AcpiExReleaseGlobalLock
32267754Smsmith *
323167802Sjkim * PARAMETERS:  FieldFlags            - Flags with Lock rule:
324167802Sjkim *                                      AlwaysLock or NeverLock
32567754Smsmith *
326151937Sjkim * RETURN:      None
32767754Smsmith *
328167802Sjkim * DESCRIPTION: Release the ACPI hardware Global Lock
32967754Smsmith *
33067754Smsmith ******************************************************************************/
33167754Smsmith
33299679Siwasakivoid
33377424SmsmithAcpiExReleaseGlobalLock (
334167802Sjkim    UINT32                  FieldFlags)
33567754Smsmith{
33699679Siwasaki    ACPI_STATUS             Status;
33767754Smsmith
33899679Siwasaki
339167802Sjkim    ACPI_FUNCTION_TRACE (ExReleaseGlobalLock);
34067754Smsmith
34167754Smsmith
342167802Sjkim    /* Only use the lock if the AlwaysLock bit is set */
34367754Smsmith
344167802Sjkim    if (!(FieldFlags & AML_FIELD_LOCK_RULE_MASK))
34567754Smsmith    {
346167802Sjkim        return_VOID;
347167802Sjkim    }
34867754Smsmith
349167802Sjkim    /* Release the global lock */
35099679Siwasaki
351167802Sjkim    Status = AcpiExReleaseMutexObject (AcpiGbl_GlobalLockMutex);
352167802Sjkim    if (ACPI_FAILURE (Status))
353167802Sjkim    {
354167802Sjkim        /* Report the error, but there isn't much else we can do */
355167802Sjkim
356167802Sjkim        ACPI_EXCEPTION ((AE_INFO, Status,
357167802Sjkim            "Could not release Global Lock"));
35867754Smsmith    }
359100966Siwasaki
360100966Siwasaki    return_VOID;
36167754Smsmith}
36267754Smsmith
36367754Smsmith
36467754Smsmith/*******************************************************************************
36567754Smsmith *
36677424Smsmith * FUNCTION:    AcpiExDigitsNeeded
36767754Smsmith *
36884491Smsmith * PARAMETERS:  Value           - Value to be represented
36984491Smsmith *              Base            - Base of representation
37067754Smsmith *
371151937Sjkim * RETURN:      The number of digits.
37267754Smsmith *
373151937Sjkim * DESCRIPTION: Calculate the number of digits needed to represent the Value
374151937Sjkim *              in the given Base (Radix)
375151937Sjkim *
37667754Smsmith ******************************************************************************/
37767754Smsmith
378151937Sjkimstatic UINT32
37977424SmsmithAcpiExDigitsNeeded (
380202771Sjkim    UINT64                  Value,
38184491Smsmith    UINT32                  Base)
38267754Smsmith{
38399679Siwasaki    UINT32                  NumDigits;
384202771Sjkim    UINT64                  CurrentValue;
38567754Smsmith
38667754Smsmith
387167802Sjkim    ACPI_FUNCTION_TRACE (ExDigitsNeeded);
38867754Smsmith
38967754Smsmith
390202771Sjkim    /* UINT64 is unsigned, so we don't worry about a '-' prefix */
391138287Smarks
392138287Smarks    if (Value == 0)
393117521Snjl    {
394246849Sjkim        return_UINT32 (1);
395117521Snjl    }
396117521Snjl
397138287Smarks    CurrentValue = Value;
39899679Siwasaki    NumDigits = 0;
39999679Siwasaki
400138287Smarks    /* Count the digits in the requested base */
401138287Smarks
40299679Siwasaki    while (CurrentValue)
40367754Smsmith    {
404138287Smarks        (void) AcpiUtShortDivide (CurrentValue, Base, &CurrentValue, NULL);
40599679Siwasaki        NumDigits++;
40667754Smsmith    }
40767754Smsmith
408246849Sjkim    return_UINT32 (NumDigits);
40967754Smsmith}
41067754Smsmith
41167754Smsmith
41267754Smsmith/*******************************************************************************
41367754Smsmith *
41477424Smsmith * FUNCTION:    AcpiExEisaIdToString
41567754Smsmith *
416197104Sjkim * PARAMETERS:  CompressedId    - EISAID to be converted
41767754Smsmith *              OutString       - Where to put the converted string (8 bytes)
41867754Smsmith *
419151937Sjkim * RETURN:      None
420151937Sjkim *
421197104Sjkim * DESCRIPTION: Convert a numeric EISAID to string representation. Return
422197104Sjkim *              buffer must be large enough to hold the string. The string
423197104Sjkim *              returned is always exactly of length ACPI_EISAID_STRING_SIZE
424197104Sjkim *              (includes null terminator). The EISAID is always 32 bits.
42567754Smsmith *
42667754Smsmith ******************************************************************************/
42767754Smsmith
42899679Siwasakivoid
42977424SmsmithAcpiExEisaIdToString (
430197104Sjkim    char                    *OutString,
431202771Sjkim    UINT64                  CompressedId)
43267754Smsmith{
433197104Sjkim    UINT32                  SwappedId;
43467754Smsmith
43583174Smsmith
43691116Smsmith    ACPI_FUNCTION_ENTRY ();
43783174Smsmith
43883174Smsmith
439197104Sjkim    /* The EISAID should be a 32-bit integer */
440197104Sjkim
441197104Sjkim    if (CompressedId > ACPI_UINT32_MAX)
442197104Sjkim    {
443197104Sjkim        ACPI_WARNING ((AE_INFO,
444197104Sjkim            "Expected EISAID is larger than 32 bits: 0x%8.8X%8.8X, truncating",
445197104Sjkim            ACPI_FORMAT_UINT64 (CompressedId)));
446197104Sjkim    }
447197104Sjkim
44899679Siwasaki    /* Swap ID to big-endian to get contiguous bits */
44967754Smsmith
450197104Sjkim    SwappedId = AcpiUtDwordByteSwap ((UINT32) CompressedId);
45167754Smsmith
452197104Sjkim    /* First 3 bytes are uppercase letters. Next 4 bytes are hexadecimal */
453197104Sjkim
454197104Sjkim    OutString[0] = (char) (0x40 + (((unsigned long) SwappedId >> 26) & 0x1F));
455197104Sjkim    OutString[1] = (char) (0x40 + ((SwappedId >> 21) & 0x1F));
456197104Sjkim    OutString[2] = (char) (0x40 + ((SwappedId >> 16) & 0x1F));
457202771Sjkim    OutString[3] = AcpiUtHexToAsciiChar ((UINT64) SwappedId, 12);
458202771Sjkim    OutString[4] = AcpiUtHexToAsciiChar ((UINT64) SwappedId, 8);
459202771Sjkim    OutString[5] = AcpiUtHexToAsciiChar ((UINT64) SwappedId, 4);
460202771Sjkim    OutString[6] = AcpiUtHexToAsciiChar ((UINT64) SwappedId, 0);
46167754Smsmith    OutString[7] = 0;
46267754Smsmith}
46367754Smsmith
46467754Smsmith
46567754Smsmith/*******************************************************************************
46667754Smsmith *
467197104Sjkim * FUNCTION:    AcpiExIntegerToString
46867754Smsmith *
469197104Sjkim * PARAMETERS:  OutString       - Where to put the converted string. At least
470197104Sjkim *                                21 bytes are needed to hold the largest
471197104Sjkim *                                possible 64-bit integer.
472197104Sjkim *              Value           - Value to be converted
47367754Smsmith *
474151937Sjkim * RETURN:      None, string
47567754Smsmith *
476197104Sjkim * DESCRIPTION: Convert a 64-bit integer to decimal string representation.
477197104Sjkim *              Assumes string buffer is large enough to hold the string. The
478197104Sjkim *              largest string is (ACPI_MAX64_DECIMAL_DIGITS + 1).
479151937Sjkim *
48067754Smsmith ******************************************************************************/
48167754Smsmith
48299679Siwasakivoid
483197104SjkimAcpiExIntegerToString (
484197104Sjkim    char                    *OutString,
485202771Sjkim    UINT64                  Value)
48667754Smsmith{
48767754Smsmith    UINT32                  Count;
48867754Smsmith    UINT32                  DigitsNeeded;
48984491Smsmith    UINT32                  Remainder;
49067754Smsmith
49167754Smsmith
49291116Smsmith    ACPI_FUNCTION_ENTRY ();
49383174Smsmith
49483174Smsmith
49577424Smsmith    DigitsNeeded = AcpiExDigitsNeeded (Value, 10);
49684491Smsmith    OutString[DigitsNeeded] = 0;
49767754Smsmith
49867754Smsmith    for (Count = DigitsNeeded; Count > 0; Count--)
49967754Smsmith    {
500138287Smarks        (void) AcpiUtShortDivide (Value, 10, &Value, &Remainder);
501114237Snjl        OutString[Count-1] = (char) ('0' + Remainder);\
50267754Smsmith    }
50367754Smsmith}
50467754Smsmith
505228110Sjkim
506228110Sjkim/*******************************************************************************
507228110Sjkim *
508228110Sjkim * FUNCTION:    AcpiIsValidSpaceId
509228110Sjkim *
510228110Sjkim * PARAMETERS:  SpaceId             - ID to be validated
511228110Sjkim *
512228110Sjkim * RETURN:      TRUE if valid/supported ID.
513228110Sjkim *
514228110Sjkim * DESCRIPTION: Validate an operation region SpaceID.
515228110Sjkim *
516228110Sjkim ******************************************************************************/
517228110Sjkim
518228110SjkimBOOLEAN
519228110SjkimAcpiIsValidSpaceId (
520228110Sjkim    UINT8                   SpaceId)
521228110Sjkim{
522228110Sjkim
523228110Sjkim    if ((SpaceId >= ACPI_NUM_PREDEFINED_REGIONS) &&
524228110Sjkim        (SpaceId < ACPI_USER_REGION_BEGIN) &&
525228110Sjkim        (SpaceId != ACPI_ADR_SPACE_DATA_TABLE) &&
526228110Sjkim        (SpaceId != ACPI_ADR_SPACE_FIXED_HARDWARE))
527228110Sjkim    {
528228110Sjkim        return (FALSE);
529228110Sjkim    }
530228110Sjkim
531228110Sjkim    return (TRUE);
532228110Sjkim}
533228110Sjkim
534228110Sjkim
535100966Siwasaki#endif
536