exutils.c revision 102550
167754Smsmith
267754Smsmith/******************************************************************************
367754Smsmith *
477424Smsmith * Module Name: exutils - interpreter/scanner utilities
5102550Siwasaki *              $Revision: 103 $
667754Smsmith *
767754Smsmith *****************************************************************************/
867754Smsmith
967754Smsmith/******************************************************************************
1067754Smsmith *
1167754Smsmith * 1. Copyright Notice
1267754Smsmith *
1391116Smsmith * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp.
1470243Smsmith * All rights reserved.
1567754Smsmith *
1667754Smsmith * 2. License
1767754Smsmith *
1867754Smsmith * 2.1. This is your license from Intel Corp. under its intellectual property
1967754Smsmith * rights.  You may have additional license terms from the party that provided
2067754Smsmith * you this software, covering your right to use that party's intellectual
2167754Smsmith * property rights.
2267754Smsmith *
2367754Smsmith * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
2467754Smsmith * copy of the source code appearing in this file ("Covered Code") an
2567754Smsmith * irrevocable, perpetual, worldwide license under Intel's copyrights in the
2667754Smsmith * base code distributed originally by Intel ("Original Intel Code") to copy,
2767754Smsmith * make derivatives, distribute, use and display any portion of the Covered
2867754Smsmith * Code in any form, with the right to sublicense such rights; and
2967754Smsmith *
3067754Smsmith * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
3167754Smsmith * license (with the right to sublicense), under only those claims of Intel
3267754Smsmith * patents that are infringed by the Original Intel Code, to make, use, sell,
3367754Smsmith * offer to sell, and import the Covered Code and derivative works thereof
3467754Smsmith * solely to the minimum extent necessary to exercise the above copyright
3567754Smsmith * license, and in no event shall the patent license extend to any additions
3667754Smsmith * to or modifications of the Original Intel Code.  No other license or right
3767754Smsmith * is granted directly or by implication, estoppel or otherwise;
3867754Smsmith *
3967754Smsmith * The above copyright and patent license is granted only if the following
4067754Smsmith * conditions are met:
4167754Smsmith *
4267754Smsmith * 3. Conditions
4367754Smsmith *
4467754Smsmith * 3.1. Redistribution of Source with Rights to Further Distribute Source.
4567754Smsmith * Redistribution of source code of any substantial portion of the Covered
4667754Smsmith * Code or modification with rights to further distribute source must include
4767754Smsmith * the above Copyright Notice, the above License, this list of Conditions,
4867754Smsmith * and the following Disclaimer and Export Compliance provision.  In addition,
4967754Smsmith * Licensee must cause all Covered Code to which Licensee contributes to
5067754Smsmith * contain a file documenting the changes Licensee made to create that Covered
5167754Smsmith * Code and the date of any change.  Licensee must include in that file the
5267754Smsmith * documentation of any changes made by any predecessor Licensee.  Licensee
5367754Smsmith * must include a prominent statement that the modification is derived,
5467754Smsmith * directly or indirectly, from Original Intel Code.
5567754Smsmith *
5667754Smsmith * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
5767754Smsmith * Redistribution of source code of any substantial portion of the Covered
5867754Smsmith * Code or modification without rights to further distribute source must
5967754Smsmith * include the following Disclaimer and Export Compliance provision in the
6067754Smsmith * documentation and/or other materials provided with distribution.  In
6167754Smsmith * addition, Licensee may not authorize further sublicense of source of any
6267754Smsmith * portion of the Covered Code, and must include terms to the effect that the
6367754Smsmith * license from Licensee to its licensee is limited to the intellectual
6467754Smsmith * property embodied in the software Licensee provides to its licensee, and
6567754Smsmith * not to intellectual property embodied in modifications its licensee may
6667754Smsmith * make.
6767754Smsmith *
6867754Smsmith * 3.3. Redistribution of Executable. Redistribution in executable form of any
6967754Smsmith * substantial portion of the Covered Code or modification must reproduce the
7067754Smsmith * above Copyright Notice, and the following Disclaimer and Export Compliance
7167754Smsmith * provision in the documentation and/or other materials provided with the
7267754Smsmith * distribution.
7367754Smsmith *
7467754Smsmith * 3.4. Intel retains all right, title, and interest in and to the Original
7567754Smsmith * Intel Code.
7667754Smsmith *
7767754Smsmith * 3.5. Neither the name Intel nor any other trademark owned or controlled by
7867754Smsmith * Intel shall be used in advertising or otherwise to promote the sale, use or
7967754Smsmith * other dealings in products derived from or relating to the Covered Code
8067754Smsmith * without prior written authorization from Intel.
8167754Smsmith *
8267754Smsmith * 4. Disclaimer and Export Compliance
8367754Smsmith *
8467754Smsmith * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
8567754Smsmith * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
8667754Smsmith * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
8767754Smsmith * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
8867754Smsmith * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
8967754Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
9067754Smsmith * PARTICULAR PURPOSE.
9167754Smsmith *
9267754Smsmith * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
9367754Smsmith * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
9467754Smsmith * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
9567754Smsmith * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
9667754Smsmith * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
9767754Smsmith * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
9867754Smsmith * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
9967754Smsmith * LIMITED REMEDY.
10067754Smsmith *
10167754Smsmith * 4.3. Licensee shall not export, either directly or indirectly, any of this
10267754Smsmith * software or system incorporating such software without first obtaining any
10367754Smsmith * required license or other approval from the U. S. Department of Commerce or
10467754Smsmith * any other agency or department of the United States Government.  In the
10567754Smsmith * event Licensee exports any such software from the United States or
10667754Smsmith * re-exports any such software from a foreign destination, Licensee shall
10767754Smsmith * ensure that the distribution and export/re-export of the software is in
10867754Smsmith * compliance with all laws, regulations, orders, or other restrictions of the
10967754Smsmith * U.S. Export Administration Regulations. Licensee agrees that neither it nor
11067754Smsmith * any of its subsidiaries will export/re-export any technical data, process,
11167754Smsmith * software, or service, directly or indirectly, to any country for which the
11267754Smsmith * United States government or any agency thereof requires an export license,
11367754Smsmith * other governmental approval, or letter of assurance, without first obtaining
11467754Smsmith * such license, approval or letter.
11567754Smsmith *
11667754Smsmith *****************************************************************************/
11767754Smsmith
11877424Smsmith#define __EXUTILS_C__
11967754Smsmith
12083174Smsmith/*
12183174Smsmith * DEFINE_AML_GLOBALS is tested in amlcode.h
12283174Smsmith * to determine whether certain global names should be "defined" or only
12383174Smsmith * "declared" in the current compilation.  This enhances maintainability
12483174Smsmith * by enabling a single header file to embody all knowledge of the names
12583174Smsmith * in question.
12683174Smsmith *
12783174Smsmith * Exactly one module of any executable should #define DEFINE_GLOBALS
12883174Smsmith * before #including the header files which use this convention.  The
12983174Smsmith * names in question will be defined and initialized in that module,
13083174Smsmith * and declared as extern in all other modules which #include those
13183174Smsmith * header files.
13283174Smsmith */
13383174Smsmith
13483174Smsmith#define DEFINE_AML_GLOBALS
13583174Smsmith
13667754Smsmith#include "acpi.h"
13767754Smsmith#include "acinterp.h"
13867754Smsmith#include "amlcode.h"
13967754Smsmith#include "acevents.h"
14067754Smsmith
14177424Smsmith#define _COMPONENT          ACPI_EXECUTER
14291116Smsmith        ACPI_MODULE_NAME    ("exutils")
14367754Smsmith
14467754Smsmith
14567754Smsmith/*******************************************************************************
14667754Smsmith *
147100966Siwasaki * FUNCTION:    AcpiExValidateObjectType
148100966Siwasaki *
149100966Siwasaki * PARAMETERS:  Type            Object type to validate
150100966Siwasaki *
151100966Siwasaki * DESCRIPTION: Determine if a type is a valid ACPI object type
152100966Siwasaki *
153100966Siwasaki ******************************************************************************/
154100966Siwasaki
155100966SiwasakiBOOLEAN
156100966SiwasakiAcpiExValidateObjectType (
157100966Siwasaki    ACPI_OBJECT_TYPE        Type)
158100966Siwasaki{
159100966Siwasaki
160100966Siwasaki    ACPI_FUNCTION_ENTRY ();
161100966Siwasaki
162100966Siwasaki
163100966Siwasaki    if ((Type > ACPI_TYPE_MAX && Type < INTERNAL_TYPE_BEGIN) ||
164100966Siwasaki        (Type > INTERNAL_TYPE_MAX))
165100966Siwasaki    {
166100966Siwasaki        return (FALSE);
167100966Siwasaki    }
168100966Siwasaki
169100966Siwasaki    return (TRUE);
170100966Siwasaki}
171100966Siwasaki
172100966Siwasaki#ifndef ACPI_NO_METHOD_EXECUTION
173100966Siwasaki
174100966Siwasaki/*******************************************************************************
175100966Siwasaki *
17677424Smsmith * FUNCTION:    AcpiExEnterInterpreter
17767754Smsmith *
17867754Smsmith * PARAMETERS:  None
17967754Smsmith *
18091116Smsmith * DESCRIPTION: Enter the interpreter execution region.  Failure to enter
18191116Smsmith *              the interpreter region is a fatal system error
18267754Smsmith *
18367754Smsmith ******************************************************************************/
18467754Smsmith
18577424SmsmithACPI_STATUS
18677424SmsmithAcpiExEnterInterpreter (void)
18767754Smsmith{
18877424Smsmith    ACPI_STATUS             Status;
18967754Smsmith
19091116Smsmith    ACPI_FUNCTION_TRACE ("ExEnterInterpreter");
19167754Smsmith
19267754Smsmith
19377424Smsmith    Status = AcpiUtAcquireMutex (ACPI_MTX_EXECUTE);
19491116Smsmith    if (ACPI_FAILURE (Status))
19591116Smsmith    {
19699679Siwasaki        ACPI_REPORT_ERROR (("Could not acquire interpreter mutex\n"));
19791116Smsmith    }
19891116Smsmith
19977424Smsmith    return_ACPI_STATUS (Status);
20067754Smsmith}
20167754Smsmith
20267754Smsmith
20367754Smsmith/*******************************************************************************
20467754Smsmith *
20577424Smsmith * FUNCTION:    AcpiExExitInterpreter
20667754Smsmith *
20767754Smsmith * PARAMETERS:  None
20867754Smsmith *
20967754Smsmith * DESCRIPTION: Exit the interpreter execution region
21067754Smsmith *
21167754Smsmith * Cases where the interpreter is unlocked:
21267754Smsmith *      1) Completion of the execution of a control method
21367754Smsmith *      2) Method blocked on a Sleep() AML opcode
21467754Smsmith *      3) Method blocked on an Acquire() AML opcode
21567754Smsmith *      4) Method blocked on a Wait() AML opcode
21667754Smsmith *      5) Method blocked to acquire the global lock
21767754Smsmith *      6) Method blocked to execute a serialized control method that is
21867754Smsmith *          already executing
21967754Smsmith *      7) About to invoke a user-installed opregion handler
22067754Smsmith *
22167754Smsmith ******************************************************************************/
22267754Smsmith
22367754Smsmithvoid
22477424SmsmithAcpiExExitInterpreter (void)
22567754Smsmith{
22691116Smsmith    ACPI_STATUS             Status;
22767754Smsmith
22867754Smsmith
22991116Smsmith    ACPI_FUNCTION_TRACE ("ExExitInterpreter");
23067754Smsmith
23191116Smsmith
23291116Smsmith    Status = AcpiUtReleaseMutex (ACPI_MTX_EXECUTE);
23399679Siwasaki    if (ACPI_FAILURE (Status))
23499679Siwasaki    {
23599679Siwasaki        ACPI_REPORT_ERROR (("Could not release interpreter mutex\n"));
23699679Siwasaki    }
23791116Smsmith
23867754Smsmith    return_VOID;
23967754Smsmith}
24067754Smsmith
24167754Smsmith
24267754Smsmith/*******************************************************************************
24367754Smsmith *
24477424Smsmith * FUNCTION:    AcpiExTruncateFor32bitTable
24567754Smsmith *
24669450Smsmith * PARAMETERS:  ObjDesc         - Object to be truncated
24767754Smsmith *
24869450Smsmith * RETURN:      none
24967754Smsmith *
25069450Smsmith * DESCRIPTION: Truncate a number to 32-bits if the currently executing method
25169450Smsmith *              belongs to a 32-bit ACPI table.
25267754Smsmith *
25367754Smsmith ******************************************************************************/
25467754Smsmith
25569450Smsmithvoid
25677424SmsmithAcpiExTruncateFor32bitTable (
25799679Siwasaki    ACPI_OPERAND_OBJECT     *ObjDesc)
25867754Smsmith{
25967754Smsmith
26091116Smsmith    ACPI_FUNCTION_ENTRY ();
26183174Smsmith
26283174Smsmith
26369450Smsmith    /*
26469450Smsmith     * Object must be a valid number and we must be executing
26569450Smsmith     * a control method
26669450Smsmith     */
26769450Smsmith    if ((!ObjDesc) ||
26899679Siwasaki        (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_INTEGER))
26969450Smsmith    {
27069450Smsmith        return;
27169450Smsmith    }
27269450Smsmith
27399679Siwasaki    if (AcpiGbl_IntegerByteWidth == 4)
27469450Smsmith    {
27569450Smsmith        /*
27669450Smsmith         * We are running a method that exists in a 32-bit ACPI table.
27769450Smsmith         * Truncate the value to 32 bits by zeroing out the upper 32-bit field
27869450Smsmith         */
27971867Smsmith        ObjDesc->Integer.Value &= (ACPI_INTEGER) ACPI_UINT32_MAX;
28069450Smsmith    }
28167754Smsmith}
28267754Smsmith
28367754Smsmith
28467754Smsmith/*******************************************************************************
28567754Smsmith *
28677424Smsmith * FUNCTION:    AcpiExAcquireGlobalLock
28767754Smsmith *
28891116Smsmith * PARAMETERS:  FieldFlags            - Flags with Lock rule:
28987031Smsmith *                                      AlwaysLock or NeverLock
29067754Smsmith *
29167754Smsmith * RETURN:      TRUE/FALSE indicating whether the lock was actually acquired
29267754Smsmith *
29367754Smsmith * DESCRIPTION: Obtain the global lock and keep track of this fact via two
29467754Smsmith *              methods.  A global variable keeps the state of the lock, and
29567754Smsmith *              the state is returned to the caller.
29667754Smsmith *
29767754Smsmith ******************************************************************************/
29867754Smsmith
29967754SmsmithBOOLEAN
30077424SmsmithAcpiExAcquireGlobalLock (
30187031Smsmith    UINT32                  FieldFlags)
30267754Smsmith{
30367754Smsmith    BOOLEAN                 Locked = FALSE;
30467754Smsmith    ACPI_STATUS             Status;
30567754Smsmith
30667754Smsmith
30791116Smsmith    ACPI_FUNCTION_TRACE ("ExAcquireGlobalLock");
30867754Smsmith
30967754Smsmith
31087031Smsmith    /* Only attempt lock if the AlwaysLock bit is set */
31167754Smsmith
31287031Smsmith    if (FieldFlags & AML_FIELD_LOCK_RULE_MASK)
31367754Smsmith    {
31491116Smsmith        /* We should attempt to get the lock, wait forever */
31567754Smsmith
31691116Smsmith        Status = AcpiEvAcquireGlobalLock (ACPI_UINT32_MAX);
31777424Smsmith        if (ACPI_SUCCESS (Status))
31867754Smsmith        {
31977424Smsmith            Locked = TRUE;
32067754Smsmith        }
32177424Smsmith        else
32267754Smsmith        {
32382367Smsmith            ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not acquire Global Lock, %s\n",
32480062Smsmith                AcpiFormatException (Status)));
32567754Smsmith        }
32667754Smsmith    }
32767754Smsmith
32867754Smsmith    return_VALUE (Locked);
32967754Smsmith}
33067754Smsmith
33167754Smsmith
33267754Smsmith/*******************************************************************************
33367754Smsmith *
33477424Smsmith * FUNCTION:    AcpiExReleaseGlobalLock
33567754Smsmith *
33667754Smsmith * PARAMETERS:  LockedByMe      - Return value from corresponding call to
33767754Smsmith *                                AcquireGlobalLock.
33867754Smsmith *
33967754Smsmith * RETURN:      Status
34067754Smsmith *
34167754Smsmith * DESCRIPTION: Release the global lock if it is locked.
34267754Smsmith *
34367754Smsmith ******************************************************************************/
34467754Smsmith
34599679Siwasakivoid
34677424SmsmithAcpiExReleaseGlobalLock (
34767754Smsmith    BOOLEAN                 LockedByMe)
34867754Smsmith{
34999679Siwasaki    ACPI_STATUS             Status;
35067754Smsmith
35199679Siwasaki
35291116Smsmith    ACPI_FUNCTION_TRACE ("ExReleaseGlobalLock");
35367754Smsmith
35467754Smsmith
35567754Smsmith    /* Only attempt unlock if the caller locked it */
35667754Smsmith
35767754Smsmith    if (LockedByMe)
35867754Smsmith    {
35977424Smsmith        /* OK, now release the lock */
36067754Smsmith
36199679Siwasaki        Status = AcpiEvReleaseGlobalLock ();
36299679Siwasaki        if (ACPI_FAILURE (Status))
36399679Siwasaki        {
36499679Siwasaki            /* Report the error, but there isn't much else we can do */
36599679Siwasaki
366102550Siwasaki            ACPI_REPORT_ERROR (("Could not release ACPI Global Lock, %s\n",
367102550Siwasaki                AcpiFormatException (Status)));
36899679Siwasaki        }
36967754Smsmith    }
370100966Siwasaki
371100966Siwasaki    return_VOID;
37267754Smsmith}
37367754Smsmith
37467754Smsmith
37567754Smsmith/*******************************************************************************
37667754Smsmith *
37777424Smsmith * FUNCTION:    AcpiExDigitsNeeded
37867754Smsmith *
37984491Smsmith * PARAMETERS:  Value           - Value to be represented
38084491Smsmith *              Base            - Base of representation
38167754Smsmith *
38284491Smsmith * RETURN:      the number of digits needed to represent Value in Base
38367754Smsmith *
38467754Smsmith ******************************************************************************/
38567754Smsmith
38667754SmsmithUINT32
38777424SmsmithAcpiExDigitsNeeded (
38884491Smsmith    ACPI_INTEGER            Value,
38984491Smsmith    UINT32                  Base)
39067754Smsmith{
39199679Siwasaki    UINT32                  NumDigits;
39299679Siwasaki    ACPI_INTEGER            CurrentValue;
39399679Siwasaki    ACPI_INTEGER            Quotient;
39467754Smsmith
39567754Smsmith
39691116Smsmith    ACPI_FUNCTION_TRACE ("ExDigitsNeeded");
39767754Smsmith
39867754Smsmith
39999679Siwasaki    /*
40099679Siwasaki     * ACPI_INTEGER is unsigned, so we don't worry about a '-'
40199679Siwasaki     */
40299679Siwasaki    CurrentValue = Value;
40399679Siwasaki    NumDigits = 0;
40499679Siwasaki
40599679Siwasaki    while (CurrentValue)
40667754Smsmith    {
40799679Siwasaki        (void) AcpiUtShortDivide (&CurrentValue, Base, &Quotient, NULL);
40899679Siwasaki        NumDigits++;
40999679Siwasaki        CurrentValue = Quotient;
41067754Smsmith    }
41167754Smsmith
41267754Smsmith    return_VALUE (NumDigits);
41367754Smsmith}
41467754Smsmith
41567754Smsmith
41667754Smsmith/*******************************************************************************
41767754Smsmith *
41877424Smsmith * FUNCTION:    AcpiExEisaIdToString
41967754Smsmith *
42067754Smsmith * PARAMETERS:  NumericId       - EISA ID to be converted
42167754Smsmith *              OutString       - Where to put the converted string (8 bytes)
42267754Smsmith *
42367754Smsmith * DESCRIPTION: Convert a numeric EISA ID to string representation
42467754Smsmith *
42567754Smsmith ******************************************************************************/
42667754Smsmith
42799679Siwasakivoid
42877424SmsmithAcpiExEisaIdToString (
42967754Smsmith    UINT32                  NumericId,
43067754Smsmith    NATIVE_CHAR             *OutString)
43167754Smsmith{
43299679Siwasaki    UINT32                  EisaId;
43367754Smsmith
43483174Smsmith
43591116Smsmith    ACPI_FUNCTION_ENTRY ();
43683174Smsmith
43783174Smsmith
43899679Siwasaki    /* Swap ID to big-endian to get contiguous bits */
43967754Smsmith
44099679Siwasaki    EisaId = AcpiUtDwordByteSwap (NumericId);
44167754Smsmith
44299679Siwasaki    OutString[0] = (char) ('@' + ((EisaId >> 26) & 0x1f));
44399679Siwasaki    OutString[1] = (char) ('@' + ((EisaId >> 21) & 0x1f));
44499679Siwasaki    OutString[2] = (char) ('@' + ((EisaId >> 16) & 0x1f));
44599679Siwasaki    OutString[3] = AcpiUtHexToAsciiChar ((ACPI_INTEGER) EisaId, 12);
44699679Siwasaki    OutString[4] = AcpiUtHexToAsciiChar ((ACPI_INTEGER) EisaId, 8);
44799679Siwasaki    OutString[5] = AcpiUtHexToAsciiChar ((ACPI_INTEGER) EisaId, 4);
44899679Siwasaki    OutString[6] = AcpiUtHexToAsciiChar ((ACPI_INTEGER) EisaId, 0);
44967754Smsmith    OutString[7] = 0;
45067754Smsmith}
45167754Smsmith
45267754Smsmith
45367754Smsmith/*******************************************************************************
45467754Smsmith *
45577424Smsmith * FUNCTION:    AcpiExUnsignedIntegerToString
45667754Smsmith *
45767754Smsmith * PARAMETERS:  Value           - Value to be converted
45867754Smsmith *              OutString       - Where to put the converted string (8 bytes)
45967754Smsmith *
46067754Smsmith * RETURN:      Convert a number to string representation
46167754Smsmith *
46267754Smsmith ******************************************************************************/
46367754Smsmith
46499679Siwasakivoid
46577424SmsmithAcpiExUnsignedIntegerToString (
46667754Smsmith    ACPI_INTEGER            Value,
46767754Smsmith    NATIVE_CHAR             *OutString)
46867754Smsmith{
46967754Smsmith    UINT32                  Count;
47067754Smsmith    UINT32                  DigitsNeeded;
47184491Smsmith    UINT32                  Remainder;
47299679Siwasaki    ACPI_INTEGER            Quotient;
47367754Smsmith
47467754Smsmith
47591116Smsmith    ACPI_FUNCTION_ENTRY ();
47683174Smsmith
47783174Smsmith
47877424Smsmith    DigitsNeeded = AcpiExDigitsNeeded (Value, 10);
47984491Smsmith    OutString[DigitsNeeded] = 0;
48067754Smsmith
48167754Smsmith    for (Count = DigitsNeeded; Count > 0; Count--)
48267754Smsmith    {
48399679Siwasaki        (void) AcpiUtShortDivide (&Value, 10, &Quotient, &Remainder);
48499679Siwasaki        OutString[Count-1] = (NATIVE_CHAR) ('0' + Remainder);\
48599679Siwasaki        Value = Quotient;
48667754Smsmith    }
48767754Smsmith}
48867754Smsmith
489100966Siwasaki#endif
490