xref: /freebsd-src/sys/contrib/dev/acpica/components/utilities/utmath.c (revision 804fe2660352e090f4481f2c1d646b508859e79a)
1a159c266SJung-uk Kim /*******************************************************************************
2a159c266SJung-uk Kim  *
3a159c266SJung-uk Kim  * Module Name: utmath - Integer math support routines
4a159c266SJung-uk Kim  *
5a159c266SJung-uk Kim  ******************************************************************************/
6a159c266SJung-uk Kim 
70d84335fSJung-uk Kim /******************************************************************************
80d84335fSJung-uk Kim  *
90d84335fSJung-uk Kim  * 1. Copyright Notice
100d84335fSJung-uk Kim  *
11*804fe266SJung-uk Kim  * Some or all of this work - Copyright (c) 1999 - 2024, Intel Corp.
12a159c266SJung-uk Kim  * All rights reserved.
13a159c266SJung-uk Kim  *
140d84335fSJung-uk Kim  * 2. License
150d84335fSJung-uk Kim  *
160d84335fSJung-uk Kim  * 2.1. This is your license from Intel Corp. under its intellectual property
170d84335fSJung-uk Kim  * rights. You may have additional license terms from the party that provided
180d84335fSJung-uk Kim  * you this software, covering your right to use that party's intellectual
190d84335fSJung-uk Kim  * property rights.
200d84335fSJung-uk Kim  *
210d84335fSJung-uk Kim  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
220d84335fSJung-uk Kim  * copy of the source code appearing in this file ("Covered Code") an
230d84335fSJung-uk Kim  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
240d84335fSJung-uk Kim  * base code distributed originally by Intel ("Original Intel Code") to copy,
250d84335fSJung-uk Kim  * make derivatives, distribute, use and display any portion of the Covered
260d84335fSJung-uk Kim  * Code in any form, with the right to sublicense such rights; and
270d84335fSJung-uk Kim  *
280d84335fSJung-uk Kim  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
290d84335fSJung-uk Kim  * license (with the right to sublicense), under only those claims of Intel
300d84335fSJung-uk Kim  * patents that are infringed by the Original Intel Code, to make, use, sell,
310d84335fSJung-uk Kim  * offer to sell, and import the Covered Code and derivative works thereof
320d84335fSJung-uk Kim  * solely to the minimum extent necessary to exercise the above copyright
330d84335fSJung-uk Kim  * license, and in no event shall the patent license extend to any additions
340d84335fSJung-uk Kim  * to or modifications of the Original Intel Code. No other license or right
350d84335fSJung-uk Kim  * is granted directly or by implication, estoppel or otherwise;
360d84335fSJung-uk Kim  *
370d84335fSJung-uk Kim  * The above copyright and patent license is granted only if the following
380d84335fSJung-uk Kim  * conditions are met:
390d84335fSJung-uk Kim  *
400d84335fSJung-uk Kim  * 3. Conditions
410d84335fSJung-uk Kim  *
420d84335fSJung-uk Kim  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
430d84335fSJung-uk Kim  * Redistribution of source code of any substantial portion of the Covered
440d84335fSJung-uk Kim  * Code or modification with rights to further distribute source must include
450d84335fSJung-uk Kim  * the above Copyright Notice, the above License, this list of Conditions,
460d84335fSJung-uk Kim  * and the following Disclaimer and Export Compliance provision. In addition,
470d84335fSJung-uk Kim  * Licensee must cause all Covered Code to which Licensee contributes to
480d84335fSJung-uk Kim  * contain a file documenting the changes Licensee made to create that Covered
490d84335fSJung-uk Kim  * Code and the date of any change. Licensee must include in that file the
500d84335fSJung-uk Kim  * documentation of any changes made by any predecessor Licensee. Licensee
510d84335fSJung-uk Kim  * must include a prominent statement that the modification is derived,
520d84335fSJung-uk Kim  * directly or indirectly, from Original Intel Code.
530d84335fSJung-uk Kim  *
540d84335fSJung-uk Kim  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
550d84335fSJung-uk Kim  * Redistribution of source code of any substantial portion of the Covered
560d84335fSJung-uk Kim  * Code or modification without rights to further distribute source must
570d84335fSJung-uk Kim  * include the following Disclaimer and Export Compliance provision in the
580d84335fSJung-uk Kim  * documentation and/or other materials provided with distribution. In
590d84335fSJung-uk Kim  * addition, Licensee may not authorize further sublicense of source of any
600d84335fSJung-uk Kim  * portion of the Covered Code, and must include terms to the effect that the
610d84335fSJung-uk Kim  * license from Licensee to its licensee is limited to the intellectual
620d84335fSJung-uk Kim  * property embodied in the software Licensee provides to its licensee, and
630d84335fSJung-uk Kim  * not to intellectual property embodied in modifications its licensee may
640d84335fSJung-uk Kim  * make.
650d84335fSJung-uk Kim  *
660d84335fSJung-uk Kim  * 3.3. Redistribution of Executable. Redistribution in executable form of any
670d84335fSJung-uk Kim  * substantial portion of the Covered Code or modification must reproduce the
680d84335fSJung-uk Kim  * above Copyright Notice, and the following Disclaimer and Export Compliance
690d84335fSJung-uk Kim  * provision in the documentation and/or other materials provided with the
700d84335fSJung-uk Kim  * distribution.
710d84335fSJung-uk Kim  *
720d84335fSJung-uk Kim  * 3.4. Intel retains all right, title, and interest in and to the Original
730d84335fSJung-uk Kim  * Intel Code.
740d84335fSJung-uk Kim  *
750d84335fSJung-uk Kim  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
760d84335fSJung-uk Kim  * Intel shall be used in advertising or otherwise to promote the sale, use or
770d84335fSJung-uk Kim  * other dealings in products derived from or relating to the Covered Code
780d84335fSJung-uk Kim  * without prior written authorization from Intel.
790d84335fSJung-uk Kim  *
800d84335fSJung-uk Kim  * 4. Disclaimer and Export Compliance
810d84335fSJung-uk Kim  *
820d84335fSJung-uk Kim  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
830d84335fSJung-uk Kim  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
840d84335fSJung-uk Kim  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
850d84335fSJung-uk Kim  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
860d84335fSJung-uk Kim  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
870d84335fSJung-uk Kim  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
880d84335fSJung-uk Kim  * PARTICULAR PURPOSE.
890d84335fSJung-uk Kim  *
900d84335fSJung-uk Kim  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
910d84335fSJung-uk Kim  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
920d84335fSJung-uk Kim  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
930d84335fSJung-uk Kim  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
940d84335fSJung-uk Kim  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
950d84335fSJung-uk Kim  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
960d84335fSJung-uk Kim  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
970d84335fSJung-uk Kim  * LIMITED REMEDY.
980d84335fSJung-uk Kim  *
990d84335fSJung-uk Kim  * 4.3. Licensee shall not export, either directly or indirectly, any of this
1000d84335fSJung-uk Kim  * software or system incorporating such software without first obtaining any
1010d84335fSJung-uk Kim  * required license or other approval from the U. S. Department of Commerce or
1020d84335fSJung-uk Kim  * any other agency or department of the United States Government. In the
1030d84335fSJung-uk Kim  * event Licensee exports any such software from the United States or
1040d84335fSJung-uk Kim  * re-exports any such software from a foreign destination, Licensee shall
1050d84335fSJung-uk Kim  * ensure that the distribution and export/re-export of the software is in
1060d84335fSJung-uk Kim  * compliance with all laws, regulations, orders, or other restrictions of the
1070d84335fSJung-uk Kim  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
1080d84335fSJung-uk Kim  * any of its subsidiaries will export/re-export any technical data, process,
1090d84335fSJung-uk Kim  * software, or service, directly or indirectly, to any country for which the
1100d84335fSJung-uk Kim  * United States government or any agency thereof requires an export license,
1110d84335fSJung-uk Kim  * other governmental approval, or letter of assurance, without first obtaining
1120d84335fSJung-uk Kim  * such license, approval or letter.
1130d84335fSJung-uk Kim  *
1140d84335fSJung-uk Kim  *****************************************************************************
1150d84335fSJung-uk Kim  *
1160d84335fSJung-uk Kim  * Alternatively, you may choose to be licensed under the terms of the
1170d84335fSJung-uk Kim  * following license:
1180d84335fSJung-uk Kim  *
119a159c266SJung-uk Kim  * Redistribution and use in source and binary forms, with or without
120a159c266SJung-uk Kim  * modification, are permitted provided that the following conditions
121a159c266SJung-uk Kim  * are met:
122a159c266SJung-uk Kim  * 1. Redistributions of source code must retain the above copyright
123a159c266SJung-uk Kim  *    notice, this list of conditions, and the following disclaimer,
124a159c266SJung-uk Kim  *    without modification.
125a159c266SJung-uk Kim  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126a159c266SJung-uk Kim  *    substantially similar to the "NO WARRANTY" disclaimer below
127a159c266SJung-uk Kim  *    ("Disclaimer") and any redistribution must be conditioned upon
128a159c266SJung-uk Kim  *    including a substantially similar Disclaimer requirement for further
129a159c266SJung-uk Kim  *    binary redistribution.
130a159c266SJung-uk Kim  * 3. Neither the names of the above-listed copyright holders nor the names
131a159c266SJung-uk Kim  *    of any contributors may be used to endorse or promote products derived
132a159c266SJung-uk Kim  *    from this software without specific prior written permission.
133a159c266SJung-uk Kim  *
1340d84335fSJung-uk Kim  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1350d84335fSJung-uk Kim  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1360d84335fSJung-uk Kim  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1370d84335fSJung-uk Kim  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1380d84335fSJung-uk Kim  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1390d84335fSJung-uk Kim  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1400d84335fSJung-uk Kim  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1410d84335fSJung-uk Kim  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1420d84335fSJung-uk Kim  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1430d84335fSJung-uk Kim  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1440d84335fSJung-uk Kim  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1450d84335fSJung-uk Kim  *
1460d84335fSJung-uk Kim  * Alternatively, you may choose to be licensed under the terms of the
147a159c266SJung-uk Kim  * GNU General Public License ("GPL") version 2 as published by the Free
148a159c266SJung-uk Kim  * Software Foundation.
149a159c266SJung-uk Kim  *
1500d84335fSJung-uk Kim  *****************************************************************************/
151a159c266SJung-uk Kim 
152a159c266SJung-uk Kim #include <contrib/dev/acpica/include/acpi.h>
153a159c266SJung-uk Kim #include <contrib/dev/acpica/include/accommon.h>
154a159c266SJung-uk Kim 
155a159c266SJung-uk Kim 
156a159c266SJung-uk Kim #define _COMPONENT          ACPI_UTILITIES
157a159c266SJung-uk Kim         ACPI_MODULE_NAME    ("utmath")
158a159c266SJung-uk Kim 
159a159c266SJung-uk Kim /* Structures used only for 64-bit divide */
160a159c266SJung-uk Kim 
161a159c266SJung-uk Kim typedef struct uint64_struct
162a159c266SJung-uk Kim {
163a159c266SJung-uk Kim     UINT32                          Lo;
164a159c266SJung-uk Kim     UINT32                          Hi;
165a159c266SJung-uk Kim 
166a159c266SJung-uk Kim } UINT64_STRUCT;
167a159c266SJung-uk Kim 
168a159c266SJung-uk Kim typedef union uint64_overlay
169a159c266SJung-uk Kim {
170a159c266SJung-uk Kim     UINT64                          Full;
171a159c266SJung-uk Kim     UINT64_STRUCT                   Part;
172a159c266SJung-uk Kim 
173a159c266SJung-uk Kim } UINT64_OVERLAY;
174a159c266SJung-uk Kim 
1755f9b24faSJung-uk Kim /*
1765f9b24faSJung-uk Kim  * Optional support for 64-bit double-precision integer multiply and shift.
1775f9b24faSJung-uk Kim  * This code is configurable and is implemented in order to support 32-bit
1785f9b24faSJung-uk Kim  * kernel environments where a 64-bit double-precision math library is not
1795f9b24faSJung-uk Kim  * available.
1805f9b24faSJung-uk Kim  */
1815f9b24faSJung-uk Kim #ifndef ACPI_USE_NATIVE_MATH64
1825f9b24faSJung-uk Kim 
1835f9b24faSJung-uk Kim /*******************************************************************************
1845f9b24faSJung-uk Kim  *
1855f9b24faSJung-uk Kim  * FUNCTION:    AcpiUtShortMultiply
1865f9b24faSJung-uk Kim  *
1875f9b24faSJung-uk Kim  * PARAMETERS:  Multiplicand        - 64-bit multiplicand
1885f9b24faSJung-uk Kim  *              Multiplier          - 32-bit multiplier
1895f9b24faSJung-uk Kim  *              OutProduct          - Pointer to where the product is returned
1905f9b24faSJung-uk Kim  *
1915f9b24faSJung-uk Kim  * DESCRIPTION: Perform a short multiply.
1925f9b24faSJung-uk Kim  *
1935f9b24faSJung-uk Kim  ******************************************************************************/
1945f9b24faSJung-uk Kim 
1955f9b24faSJung-uk Kim ACPI_STATUS
1965f9b24faSJung-uk Kim AcpiUtShortMultiply (
1975f9b24faSJung-uk Kim     UINT64                  Multiplicand,
1985f9b24faSJung-uk Kim     UINT32                  Multiplier,
1995f9b24faSJung-uk Kim     UINT64                  *OutProduct)
2005f9b24faSJung-uk Kim {
2015f9b24faSJung-uk Kim     UINT64_OVERLAY          MultiplicandOvl;
2025f9b24faSJung-uk Kim     UINT64_OVERLAY          Product;
2035f9b24faSJung-uk Kim     UINT32                  Carry32;
2045f9b24faSJung-uk Kim 
2055f9b24faSJung-uk Kim 
2065f9b24faSJung-uk Kim     ACPI_FUNCTION_TRACE (UtShortMultiply);
2075f9b24faSJung-uk Kim 
2085f9b24faSJung-uk Kim 
2095f9b24faSJung-uk Kim     MultiplicandOvl.Full = Multiplicand;
2105f9b24faSJung-uk Kim 
2115f9b24faSJung-uk Kim     /*
2125f9b24faSJung-uk Kim      * The Product is 64 bits, the carry is always 32 bits,
2135f9b24faSJung-uk Kim      * and is generated by the second multiply.
2145f9b24faSJung-uk Kim      */
2155f9b24faSJung-uk Kim     ACPI_MUL_64_BY_32 (0, MultiplicandOvl.Part.Hi, Multiplier,
2165f9b24faSJung-uk Kim         Product.Part.Hi, Carry32);
2175f9b24faSJung-uk Kim 
2185f9b24faSJung-uk Kim     ACPI_MUL_64_BY_32 (0, MultiplicandOvl.Part.Lo, Multiplier,
2195f9b24faSJung-uk Kim         Product.Part.Lo, Carry32);
2205f9b24faSJung-uk Kim 
2215f9b24faSJung-uk Kim     Product.Part.Hi += Carry32;
2225f9b24faSJung-uk Kim 
2235f9b24faSJung-uk Kim     /* Return only what was requested */
2245f9b24faSJung-uk Kim 
2255f9b24faSJung-uk Kim     if (OutProduct)
2265f9b24faSJung-uk Kim     {
2275f9b24faSJung-uk Kim         *OutProduct = Product.Full;
2285f9b24faSJung-uk Kim     }
2295f9b24faSJung-uk Kim 
2305f9b24faSJung-uk Kim     return_ACPI_STATUS (AE_OK);
2315f9b24faSJung-uk Kim }
2325f9b24faSJung-uk Kim 
2335f9b24faSJung-uk Kim 
2345f9b24faSJung-uk Kim /*******************************************************************************
2355f9b24faSJung-uk Kim  *
2365f9b24faSJung-uk Kim  * FUNCTION:    AcpiUtShortShiftLeft
2375f9b24faSJung-uk Kim  *
2385f9b24faSJung-uk Kim  * PARAMETERS:  Operand             - 64-bit shift operand
2395f9b24faSJung-uk Kim  *              Count               - 32-bit shift count
2405f9b24faSJung-uk Kim  *              OutResult           - Pointer to where the result is returned
2415f9b24faSJung-uk Kim  *
2425f9b24faSJung-uk Kim  * DESCRIPTION: Perform a short left shift.
2435f9b24faSJung-uk Kim  *
2445f9b24faSJung-uk Kim  ******************************************************************************/
2455f9b24faSJung-uk Kim 
2465f9b24faSJung-uk Kim ACPI_STATUS
2475f9b24faSJung-uk Kim AcpiUtShortShiftLeft (
2485f9b24faSJung-uk Kim     UINT64                  Operand,
2495f9b24faSJung-uk Kim     UINT32                  Count,
2505f9b24faSJung-uk Kim     UINT64                  *OutResult)
2515f9b24faSJung-uk Kim {
2525f9b24faSJung-uk Kim     UINT64_OVERLAY          OperandOvl;
2535f9b24faSJung-uk Kim 
2545f9b24faSJung-uk Kim 
2555f9b24faSJung-uk Kim     ACPI_FUNCTION_TRACE (UtShortShiftLeft);
2565f9b24faSJung-uk Kim 
2575f9b24faSJung-uk Kim 
2585f9b24faSJung-uk Kim     OperandOvl.Full = Operand;
2595f9b24faSJung-uk Kim 
2605f9b24faSJung-uk Kim     if ((Count & 63) >= 32)
2615f9b24faSJung-uk Kim     {
2625f9b24faSJung-uk Kim         OperandOvl.Part.Hi = OperandOvl.Part.Lo;
26367d9aa44SJung-uk Kim         OperandOvl.Part.Lo = 0;
2645f9b24faSJung-uk Kim         Count = (Count & 63) - 32;
2655f9b24faSJung-uk Kim     }
2665f9b24faSJung-uk Kim     ACPI_SHIFT_LEFT_64_BY_32 (OperandOvl.Part.Hi,
2675f9b24faSJung-uk Kim         OperandOvl.Part.Lo, Count);
2685f9b24faSJung-uk Kim 
2695f9b24faSJung-uk Kim     /* Return only what was requested */
2705f9b24faSJung-uk Kim 
2715f9b24faSJung-uk Kim     if (OutResult)
2725f9b24faSJung-uk Kim     {
2735f9b24faSJung-uk Kim         *OutResult = OperandOvl.Full;
2745f9b24faSJung-uk Kim     }
2755f9b24faSJung-uk Kim 
2765f9b24faSJung-uk Kim     return_ACPI_STATUS (AE_OK);
2775f9b24faSJung-uk Kim }
2785f9b24faSJung-uk Kim 
2795f9b24faSJung-uk Kim /*******************************************************************************
2805f9b24faSJung-uk Kim  *
2815f9b24faSJung-uk Kim  * FUNCTION:    AcpiUtShortShiftRight
2825f9b24faSJung-uk Kim  *
2835f9b24faSJung-uk Kim  * PARAMETERS:  Operand             - 64-bit shift operand
2845f9b24faSJung-uk Kim  *              Count               - 32-bit shift count
2855f9b24faSJung-uk Kim  *              OutResult           - Pointer to where the result is returned
2865f9b24faSJung-uk Kim  *
2875f9b24faSJung-uk Kim  * DESCRIPTION: Perform a short right shift.
2885f9b24faSJung-uk Kim  *
2895f9b24faSJung-uk Kim  ******************************************************************************/
2905f9b24faSJung-uk Kim 
2915f9b24faSJung-uk Kim ACPI_STATUS
2925f9b24faSJung-uk Kim AcpiUtShortShiftRight (
2935f9b24faSJung-uk Kim     UINT64                  Operand,
2945f9b24faSJung-uk Kim     UINT32                  Count,
2955f9b24faSJung-uk Kim     UINT64                  *OutResult)
2965f9b24faSJung-uk Kim {
2975f9b24faSJung-uk Kim     UINT64_OVERLAY          OperandOvl;
2985f9b24faSJung-uk Kim 
2995f9b24faSJung-uk Kim 
3005f9b24faSJung-uk Kim     ACPI_FUNCTION_TRACE (UtShortShiftRight);
3015f9b24faSJung-uk Kim 
3025f9b24faSJung-uk Kim 
3035f9b24faSJung-uk Kim     OperandOvl.Full = Operand;
3045f9b24faSJung-uk Kim 
3055f9b24faSJung-uk Kim     if ((Count & 63) >= 32)
3065f9b24faSJung-uk Kim     {
3075f9b24faSJung-uk Kim         OperandOvl.Part.Lo = OperandOvl.Part.Hi;
30867d9aa44SJung-uk Kim         OperandOvl.Part.Hi = 0;
3095f9b24faSJung-uk Kim         Count = (Count & 63) - 32;
3105f9b24faSJung-uk Kim     }
3115f9b24faSJung-uk Kim     ACPI_SHIFT_RIGHT_64_BY_32 (OperandOvl.Part.Hi,
3125f9b24faSJung-uk Kim         OperandOvl.Part.Lo, Count);
3135f9b24faSJung-uk Kim 
3145f9b24faSJung-uk Kim     /* Return only what was requested */
3155f9b24faSJung-uk Kim 
3165f9b24faSJung-uk Kim     if (OutResult)
3175f9b24faSJung-uk Kim     {
3185f9b24faSJung-uk Kim         *OutResult = OperandOvl.Full;
3195f9b24faSJung-uk Kim     }
3205f9b24faSJung-uk Kim 
3215f9b24faSJung-uk Kim     return_ACPI_STATUS (AE_OK);
3225f9b24faSJung-uk Kim }
3235f9b24faSJung-uk Kim #else
3245f9b24faSJung-uk Kim 
3255f9b24faSJung-uk Kim /*******************************************************************************
3265f9b24faSJung-uk Kim  *
3275f9b24faSJung-uk Kim  * FUNCTION:    AcpiUtShortMultiply
3285f9b24faSJung-uk Kim  *
3295f9b24faSJung-uk Kim  * PARAMETERS:  See function headers above
3305f9b24faSJung-uk Kim  *
3315f9b24faSJung-uk Kim  * DESCRIPTION: Native version of the UtShortMultiply function.
3325f9b24faSJung-uk Kim  *
3335f9b24faSJung-uk Kim  ******************************************************************************/
3345f9b24faSJung-uk Kim 
3355f9b24faSJung-uk Kim ACPI_STATUS
3365f9b24faSJung-uk Kim AcpiUtShortMultiply (
3375f9b24faSJung-uk Kim     UINT64                  Multiplicand,
3385f9b24faSJung-uk Kim     UINT32                  Multiplier,
3395f9b24faSJung-uk Kim     UINT64                  *OutProduct)
3405f9b24faSJung-uk Kim {
3415f9b24faSJung-uk Kim 
3425f9b24faSJung-uk Kim     ACPI_FUNCTION_TRACE (UtShortMultiply);
3435f9b24faSJung-uk Kim 
3445f9b24faSJung-uk Kim 
3455f9b24faSJung-uk Kim     /* Return only what was requested */
3465f9b24faSJung-uk Kim 
3475f9b24faSJung-uk Kim     if (OutProduct)
3485f9b24faSJung-uk Kim     {
3495f9b24faSJung-uk Kim         *OutProduct = Multiplicand * Multiplier;
3505f9b24faSJung-uk Kim     }
3515f9b24faSJung-uk Kim 
3525f9b24faSJung-uk Kim     return_ACPI_STATUS (AE_OK);
3535f9b24faSJung-uk Kim }
3545f9b24faSJung-uk Kim 
3555f9b24faSJung-uk Kim /*******************************************************************************
3565f9b24faSJung-uk Kim  *
3575f9b24faSJung-uk Kim  * FUNCTION:    AcpiUtShortShiftLeft
3585f9b24faSJung-uk Kim  *
3595f9b24faSJung-uk Kim  * PARAMETERS:  See function headers above
3605f9b24faSJung-uk Kim  *
3615f9b24faSJung-uk Kim  * DESCRIPTION: Native version of the UtShortShiftLeft function.
3625f9b24faSJung-uk Kim  *
3635f9b24faSJung-uk Kim  ******************************************************************************/
3645f9b24faSJung-uk Kim 
3655f9b24faSJung-uk Kim ACPI_STATUS
3665f9b24faSJung-uk Kim AcpiUtShortShiftLeft (
3675f9b24faSJung-uk Kim     UINT64                  Operand,
3685f9b24faSJung-uk Kim     UINT32                  Count,
3695f9b24faSJung-uk Kim     UINT64                  *OutResult)
3705f9b24faSJung-uk Kim {
3715f9b24faSJung-uk Kim 
3725f9b24faSJung-uk Kim     ACPI_FUNCTION_TRACE (UtShortShiftLeft);
3735f9b24faSJung-uk Kim 
3745f9b24faSJung-uk Kim 
3755f9b24faSJung-uk Kim     /* Return only what was requested */
3765f9b24faSJung-uk Kim 
3775f9b24faSJung-uk Kim     if (OutResult)
3785f9b24faSJung-uk Kim     {
3795f9b24faSJung-uk Kim         *OutResult = Operand << Count;
3805f9b24faSJung-uk Kim     }
3815f9b24faSJung-uk Kim 
3825f9b24faSJung-uk Kim     return_ACPI_STATUS (AE_OK);
3835f9b24faSJung-uk Kim }
3845f9b24faSJung-uk Kim 
3855f9b24faSJung-uk Kim /*******************************************************************************
3865f9b24faSJung-uk Kim  *
3875f9b24faSJung-uk Kim  * FUNCTION:    AcpiUtShortShiftRight
3885f9b24faSJung-uk Kim  *
3895f9b24faSJung-uk Kim  * PARAMETERS:  See function headers above
3905f9b24faSJung-uk Kim  *
3915f9b24faSJung-uk Kim  * DESCRIPTION: Native version of the UtShortShiftRight function.
3925f9b24faSJung-uk Kim  *
3935f9b24faSJung-uk Kim  ******************************************************************************/
3945f9b24faSJung-uk Kim 
3955f9b24faSJung-uk Kim ACPI_STATUS
3965f9b24faSJung-uk Kim AcpiUtShortShiftRight (
3975f9b24faSJung-uk Kim     UINT64                  Operand,
3985f9b24faSJung-uk Kim     UINT32                  Count,
3995f9b24faSJung-uk Kim     UINT64                  *OutResult)
4005f9b24faSJung-uk Kim {
4015f9b24faSJung-uk Kim 
4025f9b24faSJung-uk Kim     ACPI_FUNCTION_TRACE (UtShortShiftRight);
4035f9b24faSJung-uk Kim 
4045f9b24faSJung-uk Kim 
4055f9b24faSJung-uk Kim     /* Return only what was requested */
4065f9b24faSJung-uk Kim 
4075f9b24faSJung-uk Kim     if (OutResult)
4085f9b24faSJung-uk Kim     {
4095f9b24faSJung-uk Kim         *OutResult = Operand >> Count;
4105f9b24faSJung-uk Kim     }
4115f9b24faSJung-uk Kim 
4125f9b24faSJung-uk Kim     return_ACPI_STATUS (AE_OK);
4135f9b24faSJung-uk Kim }
4145f9b24faSJung-uk Kim #endif
4155f9b24faSJung-uk Kim 
4165f9b24faSJung-uk Kim /*
4175f9b24faSJung-uk Kim  * Optional support for 64-bit double-precision integer divide. This code
4185f9b24faSJung-uk Kim  * is configurable and is implemented in order to support 32-bit kernel
4195f9b24faSJung-uk Kim  * environments where a 64-bit double-precision math library is not available.
4205f9b24faSJung-uk Kim  *
4215f9b24faSJung-uk Kim  * Support for a more normal 64-bit divide/modulo (with check for a divide-
4225f9b24faSJung-uk Kim  * by-zero) appears after this optional section of code.
4235f9b24faSJung-uk Kim  */
4245f9b24faSJung-uk Kim #ifndef ACPI_USE_NATIVE_DIVIDE
4255f9b24faSJung-uk Kim 
426a159c266SJung-uk Kim 
427a159c266SJung-uk Kim /*******************************************************************************
428a159c266SJung-uk Kim  *
429a159c266SJung-uk Kim  * FUNCTION:    AcpiUtShortDivide
430a159c266SJung-uk Kim  *
431a159c266SJung-uk Kim  * PARAMETERS:  Dividend            - 64-bit dividend
432a159c266SJung-uk Kim  *              Divisor             - 32-bit divisor
433a159c266SJung-uk Kim  *              OutQuotient         - Pointer to where the quotient is returned
434a159c266SJung-uk Kim  *              OutRemainder        - Pointer to where the remainder is returned
435a159c266SJung-uk Kim  *
436a159c266SJung-uk Kim  * RETURN:      Status (Checks for divide-by-zero)
437a159c266SJung-uk Kim  *
438a159c266SJung-uk Kim  * DESCRIPTION: Perform a short (maximum 64 bits divided by 32 bits)
439a159c266SJung-uk Kim  *              divide and modulo. The result is a 64-bit quotient and a
440a159c266SJung-uk Kim  *              32-bit remainder.
441a159c266SJung-uk Kim  *
442a159c266SJung-uk Kim  ******************************************************************************/
443a159c266SJung-uk Kim 
444a159c266SJung-uk Kim ACPI_STATUS
445a159c266SJung-uk Kim AcpiUtShortDivide (
446a159c266SJung-uk Kim     UINT64                  Dividend,
447a159c266SJung-uk Kim     UINT32                  Divisor,
448a159c266SJung-uk Kim     UINT64                  *OutQuotient,
449a159c266SJung-uk Kim     UINT32                  *OutRemainder)
450a159c266SJung-uk Kim {
451a159c266SJung-uk Kim     UINT64_OVERLAY          DividendOvl;
452a159c266SJung-uk Kim     UINT64_OVERLAY          Quotient;
453a159c266SJung-uk Kim     UINT32                  Remainder32;
454a159c266SJung-uk Kim 
455a159c266SJung-uk Kim 
456a159c266SJung-uk Kim     ACPI_FUNCTION_TRACE (UtShortDivide);
457a159c266SJung-uk Kim 
458a159c266SJung-uk Kim 
459a159c266SJung-uk Kim     /* Always check for a zero divisor */
460a159c266SJung-uk Kim 
461a159c266SJung-uk Kim     if (Divisor == 0)
462a159c266SJung-uk Kim     {
463a159c266SJung-uk Kim         ACPI_ERROR ((AE_INFO, "Divide by zero"));
464a159c266SJung-uk Kim         return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO);
465a159c266SJung-uk Kim     }
466a159c266SJung-uk Kim 
467a159c266SJung-uk Kim     DividendOvl.Full = Dividend;
468a159c266SJung-uk Kim 
469a159c266SJung-uk Kim     /*
470a159c266SJung-uk Kim      * The quotient is 64 bits, the remainder is always 32 bits,
471a159c266SJung-uk Kim      * and is generated by the second divide.
472a159c266SJung-uk Kim      */
473a159c266SJung-uk Kim     ACPI_DIV_64_BY_32 (0, DividendOvl.Part.Hi, Divisor,
474a159c266SJung-uk Kim         Quotient.Part.Hi, Remainder32);
475f8146b88SJung-uk Kim 
476a159c266SJung-uk Kim     ACPI_DIV_64_BY_32 (Remainder32, DividendOvl.Part.Lo, Divisor,
477a159c266SJung-uk Kim         Quotient.Part.Lo, Remainder32);
478a159c266SJung-uk Kim 
479a159c266SJung-uk Kim     /* Return only what was requested */
480a159c266SJung-uk Kim 
481a159c266SJung-uk Kim     if (OutQuotient)
482a159c266SJung-uk Kim     {
483a159c266SJung-uk Kim         *OutQuotient = Quotient.Full;
484a159c266SJung-uk Kim     }
485a159c266SJung-uk Kim     if (OutRemainder)
486a159c266SJung-uk Kim     {
487a159c266SJung-uk Kim         *OutRemainder = Remainder32;
488a159c266SJung-uk Kim     }
489a159c266SJung-uk Kim 
490a159c266SJung-uk Kim     return_ACPI_STATUS (AE_OK);
491a159c266SJung-uk Kim }
492a159c266SJung-uk Kim 
493a159c266SJung-uk Kim 
494a159c266SJung-uk Kim /*******************************************************************************
495a159c266SJung-uk Kim  *
496a159c266SJung-uk Kim  * FUNCTION:    AcpiUtDivide
497a159c266SJung-uk Kim  *
498a159c266SJung-uk Kim  * PARAMETERS:  InDividend          - Dividend
499a159c266SJung-uk Kim  *              InDivisor           - Divisor
500a159c266SJung-uk Kim  *              OutQuotient         - Pointer to where the quotient is returned
501a159c266SJung-uk Kim  *              OutRemainder        - Pointer to where the remainder is returned
502a159c266SJung-uk Kim  *
503a159c266SJung-uk Kim  * RETURN:      Status (Checks for divide-by-zero)
504a159c266SJung-uk Kim  *
505a159c266SJung-uk Kim  * DESCRIPTION: Perform a divide and modulo.
506a159c266SJung-uk Kim  *
507a159c266SJung-uk Kim  ******************************************************************************/
508a159c266SJung-uk Kim 
509a159c266SJung-uk Kim ACPI_STATUS
510a159c266SJung-uk Kim AcpiUtDivide (
511a159c266SJung-uk Kim     UINT64                  InDividend,
512a159c266SJung-uk Kim     UINT64                  InDivisor,
513a159c266SJung-uk Kim     UINT64                  *OutQuotient,
514a159c266SJung-uk Kim     UINT64                  *OutRemainder)
515a159c266SJung-uk Kim {
516a159c266SJung-uk Kim     UINT64_OVERLAY          Dividend;
517a159c266SJung-uk Kim     UINT64_OVERLAY          Divisor;
518a159c266SJung-uk Kim     UINT64_OVERLAY          Quotient;
519a159c266SJung-uk Kim     UINT64_OVERLAY          Remainder;
520a159c266SJung-uk Kim     UINT64_OVERLAY          NormalizedDividend;
521a159c266SJung-uk Kim     UINT64_OVERLAY          NormalizedDivisor;
522a159c266SJung-uk Kim     UINT32                  Partial1;
523a159c266SJung-uk Kim     UINT64_OVERLAY          Partial2;
524a159c266SJung-uk Kim     UINT64_OVERLAY          Partial3;
525a159c266SJung-uk Kim 
526a159c266SJung-uk Kim 
527a159c266SJung-uk Kim     ACPI_FUNCTION_TRACE (UtDivide);
528a159c266SJung-uk Kim 
529a159c266SJung-uk Kim 
530a159c266SJung-uk Kim     /* Always check for a zero divisor */
531a159c266SJung-uk Kim 
532a159c266SJung-uk Kim     if (InDivisor == 0)
533a159c266SJung-uk Kim     {
534a159c266SJung-uk Kim         ACPI_ERROR ((AE_INFO, "Divide by zero"));
535a159c266SJung-uk Kim         return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO);
536a159c266SJung-uk Kim     }
537a159c266SJung-uk Kim 
538a159c266SJung-uk Kim     Divisor.Full  = InDivisor;
539a159c266SJung-uk Kim     Dividend.Full = InDividend;
540a159c266SJung-uk Kim     if (Divisor.Part.Hi == 0)
541a159c266SJung-uk Kim     {
542a159c266SJung-uk Kim         /*
543a159c266SJung-uk Kim          * 1) Simplest case is where the divisor is 32 bits, we can
544a159c266SJung-uk Kim          * just do two divides
545a159c266SJung-uk Kim          */
546a159c266SJung-uk Kim         Remainder.Part.Hi = 0;
547a159c266SJung-uk Kim 
548a159c266SJung-uk Kim         /*
549a159c266SJung-uk Kim          * The quotient is 64 bits, the remainder is always 32 bits,
550a159c266SJung-uk Kim          * and is generated by the second divide.
551a159c266SJung-uk Kim          */
552a159c266SJung-uk Kim         ACPI_DIV_64_BY_32 (0, Dividend.Part.Hi, Divisor.Part.Lo,
553a159c266SJung-uk Kim             Quotient.Part.Hi, Partial1);
554f8146b88SJung-uk Kim 
555a159c266SJung-uk Kim         ACPI_DIV_64_BY_32 (Partial1, Dividend.Part.Lo, Divisor.Part.Lo,
556a159c266SJung-uk Kim             Quotient.Part.Lo, Remainder.Part.Lo);
557a159c266SJung-uk Kim     }
558a159c266SJung-uk Kim 
559a159c266SJung-uk Kim     else
560a159c266SJung-uk Kim     {
561a159c266SJung-uk Kim         /*
562a159c266SJung-uk Kim          * 2) The general case where the divisor is a full 64 bits
563a159c266SJung-uk Kim          * is more difficult
564a159c266SJung-uk Kim          */
565a159c266SJung-uk Kim         Quotient.Part.Hi   = 0;
566a159c266SJung-uk Kim         NormalizedDividend = Dividend;
567a159c266SJung-uk Kim         NormalizedDivisor  = Divisor;
568a159c266SJung-uk Kim 
569a159c266SJung-uk Kim         /* Normalize the operands (shift until the divisor is < 32 bits) */
570a159c266SJung-uk Kim 
571a159c266SJung-uk Kim         do
572a159c266SJung-uk Kim         {
573f8146b88SJung-uk Kim             ACPI_SHIFT_RIGHT_64 (
574f8146b88SJung-uk Kim                 NormalizedDivisor.Part.Hi, NormalizedDivisor.Part.Lo);
575f8146b88SJung-uk Kim             ACPI_SHIFT_RIGHT_64 (
576f8146b88SJung-uk Kim                 NormalizedDividend.Part.Hi, NormalizedDividend.Part.Lo);
577a159c266SJung-uk Kim 
578a159c266SJung-uk Kim         } while (NormalizedDivisor.Part.Hi != 0);
579a159c266SJung-uk Kim 
580a159c266SJung-uk Kim         /* Partial divide */
581a159c266SJung-uk Kim 
582f8146b88SJung-uk Kim         ACPI_DIV_64_BY_32 (
583f8146b88SJung-uk Kim             NormalizedDividend.Part.Hi, NormalizedDividend.Part.Lo,
584f8146b88SJung-uk Kim             NormalizedDivisor.Part.Lo, Quotient.Part.Lo, Partial1);
585a159c266SJung-uk Kim 
586a159c266SJung-uk Kim         /*
587f8146b88SJung-uk Kim          * The quotient is always 32 bits, and simply requires
588f8146b88SJung-uk Kim          * adjustment. The 64-bit remainder must be generated.
589a159c266SJung-uk Kim          */
590a159c266SJung-uk Kim         Partial1 = Quotient.Part.Lo * Divisor.Part.Hi;
591a159c266SJung-uk Kim         Partial2.Full = (UINT64) Quotient.Part.Lo * Divisor.Part.Lo;
592a159c266SJung-uk Kim         Partial3.Full = (UINT64) Partial2.Part.Hi + Partial1;
593a159c266SJung-uk Kim 
594a159c266SJung-uk Kim         Remainder.Part.Hi = Partial3.Part.Lo;
595a159c266SJung-uk Kim         Remainder.Part.Lo = Partial2.Part.Lo;
596a159c266SJung-uk Kim 
597a159c266SJung-uk Kim         if (Partial3.Part.Hi == 0)
598a159c266SJung-uk Kim         {
599a159c266SJung-uk Kim             if (Partial3.Part.Lo >= Dividend.Part.Hi)
600a159c266SJung-uk Kim             {
601a159c266SJung-uk Kim                 if (Partial3.Part.Lo == Dividend.Part.Hi)
602a159c266SJung-uk Kim                 {
603a159c266SJung-uk Kim                     if (Partial2.Part.Lo > Dividend.Part.Lo)
604a159c266SJung-uk Kim                     {
605a159c266SJung-uk Kim                         Quotient.Part.Lo--;
606a159c266SJung-uk Kim                         Remainder.Full -= Divisor.Full;
607a159c266SJung-uk Kim                     }
608a159c266SJung-uk Kim                 }
609a159c266SJung-uk Kim                 else
610a159c266SJung-uk Kim                 {
611a159c266SJung-uk Kim                     Quotient.Part.Lo--;
612a159c266SJung-uk Kim                     Remainder.Full -= Divisor.Full;
613a159c266SJung-uk Kim                 }
614a159c266SJung-uk Kim             }
615a159c266SJung-uk Kim 
616a159c266SJung-uk Kim             Remainder.Full = Remainder.Full - Dividend.Full;
617a159c266SJung-uk Kim             Remainder.Part.Hi = (UINT32) -((INT32) Remainder.Part.Hi);
618a159c266SJung-uk Kim             Remainder.Part.Lo = (UINT32) -((INT32) Remainder.Part.Lo);
619a159c266SJung-uk Kim 
620a159c266SJung-uk Kim             if (Remainder.Part.Lo)
621a159c266SJung-uk Kim             {
622a159c266SJung-uk Kim                 Remainder.Part.Hi--;
623a159c266SJung-uk Kim             }
624a159c266SJung-uk Kim         }
625a159c266SJung-uk Kim     }
626a159c266SJung-uk Kim 
627a159c266SJung-uk Kim     /* Return only what was requested */
628a159c266SJung-uk Kim 
629a159c266SJung-uk Kim     if (OutQuotient)
630a159c266SJung-uk Kim     {
631a159c266SJung-uk Kim         *OutQuotient = Quotient.Full;
632a159c266SJung-uk Kim     }
633a159c266SJung-uk Kim     if (OutRemainder)
634a159c266SJung-uk Kim     {
635a159c266SJung-uk Kim         *OutRemainder = Remainder.Full;
636a159c266SJung-uk Kim     }
637a159c266SJung-uk Kim 
638a159c266SJung-uk Kim     return_ACPI_STATUS (AE_OK);
639a159c266SJung-uk Kim }
640a159c266SJung-uk Kim 
641a159c266SJung-uk Kim #else
642a159c266SJung-uk Kim 
643a159c266SJung-uk Kim /*******************************************************************************
644a159c266SJung-uk Kim  *
645a159c266SJung-uk Kim  * FUNCTION:    AcpiUtShortDivide, AcpiUtDivide
646a159c266SJung-uk Kim  *
647a159c266SJung-uk Kim  * PARAMETERS:  See function headers above
648a159c266SJung-uk Kim  *
649a159c266SJung-uk Kim  * DESCRIPTION: Native versions of the UtDivide functions. Use these if either
650a159c266SJung-uk Kim  *              1) The target is a 64-bit platform and therefore 64-bit
651a159c266SJung-uk Kim  *                 integer math is supported directly by the machine.
652a159c266SJung-uk Kim  *              2) The target is a 32-bit or 16-bit platform, and the
653a159c266SJung-uk Kim  *                 double-precision integer math library is available to
654a159c266SJung-uk Kim  *                 perform the divide.
655a159c266SJung-uk Kim  *
656a159c266SJung-uk Kim  ******************************************************************************/
657a159c266SJung-uk Kim 
658a159c266SJung-uk Kim ACPI_STATUS
659a159c266SJung-uk Kim AcpiUtShortDivide (
660a159c266SJung-uk Kim     UINT64                  InDividend,
661a159c266SJung-uk Kim     UINT32                  Divisor,
662a159c266SJung-uk Kim     UINT64                  *OutQuotient,
663a159c266SJung-uk Kim     UINT32                  *OutRemainder)
664a159c266SJung-uk Kim {
665a159c266SJung-uk Kim 
666a159c266SJung-uk Kim     ACPI_FUNCTION_TRACE (UtShortDivide);
667a159c266SJung-uk Kim 
668a159c266SJung-uk Kim 
669a159c266SJung-uk Kim     /* Always check for a zero divisor */
670a159c266SJung-uk Kim 
671a159c266SJung-uk Kim     if (Divisor == 0)
672a159c266SJung-uk Kim     {
673a159c266SJung-uk Kim         ACPI_ERROR ((AE_INFO, "Divide by zero"));
674a159c266SJung-uk Kim         return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO);
675a159c266SJung-uk Kim     }
676a159c266SJung-uk Kim 
677a159c266SJung-uk Kim     /* Return only what was requested */
678a159c266SJung-uk Kim 
679a159c266SJung-uk Kim     if (OutQuotient)
680a159c266SJung-uk Kim     {
681a159c266SJung-uk Kim         *OutQuotient = InDividend / Divisor;
682a159c266SJung-uk Kim     }
683a159c266SJung-uk Kim     if (OutRemainder)
684a159c266SJung-uk Kim     {
685a159c266SJung-uk Kim         *OutRemainder = (UINT32) (InDividend % Divisor);
686a159c266SJung-uk Kim     }
687a159c266SJung-uk Kim 
688a159c266SJung-uk Kim     return_ACPI_STATUS (AE_OK);
689a159c266SJung-uk Kim }
690a159c266SJung-uk Kim 
691a159c266SJung-uk Kim ACPI_STATUS
692a159c266SJung-uk Kim AcpiUtDivide (
693a159c266SJung-uk Kim     UINT64                  InDividend,
694a159c266SJung-uk Kim     UINT64                  InDivisor,
695a159c266SJung-uk Kim     UINT64                  *OutQuotient,
696a159c266SJung-uk Kim     UINT64                  *OutRemainder)
697a159c266SJung-uk Kim {
698a159c266SJung-uk Kim     ACPI_FUNCTION_TRACE (UtDivide);
699a159c266SJung-uk Kim 
700a159c266SJung-uk Kim 
701a159c266SJung-uk Kim     /* Always check for a zero divisor */
702a159c266SJung-uk Kim 
703a159c266SJung-uk Kim     if (InDivisor == 0)
704a159c266SJung-uk Kim     {
705a159c266SJung-uk Kim         ACPI_ERROR ((AE_INFO, "Divide by zero"));
706a159c266SJung-uk Kim         return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO);
707a159c266SJung-uk Kim     }
708a159c266SJung-uk Kim 
709a159c266SJung-uk Kim 
710a159c266SJung-uk Kim     /* Return only what was requested */
711a159c266SJung-uk Kim 
712a159c266SJung-uk Kim     if (OutQuotient)
713a159c266SJung-uk Kim     {
714a159c266SJung-uk Kim         *OutQuotient = InDividend / InDivisor;
715a159c266SJung-uk Kim     }
716a159c266SJung-uk Kim     if (OutRemainder)
717a159c266SJung-uk Kim     {
718a159c266SJung-uk Kim         *OutRemainder = InDividend % InDivisor;
719a159c266SJung-uk Kim     }
720a159c266SJung-uk Kim 
721a159c266SJung-uk Kim     return_ACPI_STATUS (AE_OK);
722a159c266SJung-uk Kim }
723a159c266SJung-uk Kim 
724a159c266SJung-uk Kim #endif
725