2005-04-16 16:20:36 -06:00
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* Module Name: utmath - Integer math support routines
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
/*
|
2017-02-07 20:00:08 -07:00
|
|
|
* Copyright (C) 2000 - 2017, Intel Corp.
|
2005-04-16 16:20:36 -06:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions, and the following disclaimer,
|
|
|
|
* without modification.
|
|
|
|
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
|
|
|
|
* substantially similar to the "NO WARRANTY" disclaimer below
|
|
|
|
* ("Disclaimer") and any redistribution must be conditioned upon
|
|
|
|
* including a substantially similar Disclaimer requirement for further
|
|
|
|
* binary redistribution.
|
|
|
|
* 3. Neither the names of the above-listed copyright holders nor the names
|
|
|
|
* of any contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* Alternatively, this software may be distributed under the terms of the
|
|
|
|
* GNU General Public License ("GPL") version 2 as published by the Free
|
|
|
|
* Software Foundation.
|
|
|
|
*
|
|
|
|
* NO WARRANTY
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
|
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
|
|
|
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGES.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <acpi/acpi.h>
|
2009-01-08 22:30:03 -07:00
|
|
|
#include "accommon.h"
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
#define _COMPONENT ACPI_UTILITIES
|
2005-08-04 22:44:28 -06:00
|
|
|
ACPI_MODULE_NAME("utmath")
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/*
|
2010-09-15 00:00:53 -06:00
|
|
|
* Optional support for 64-bit double-precision integer divide. This code
|
|
|
|
* is configurable and is implemented in order to support 32-bit kernel
|
|
|
|
* environments where a 64-bit double-precision math library is not available.
|
|
|
|
*
|
|
|
|
* Support for a more normal 64-bit divide/modulo (with check for a divide-
|
|
|
|
* by-zero) appears after this optional section of code.
|
2005-04-16 16:20:36 -06:00
|
|
|
*/
|
|
|
|
#ifndef ACPI_USE_NATIVE_DIVIDE
|
2010-09-15 00:00:53 -06:00
|
|
|
/* Structures used only for 64-bit divide */
|
|
|
|
typedef struct uint64_struct {
|
|
|
|
u32 lo;
|
|
|
|
u32 hi;
|
|
|
|
|
|
|
|
} uint64_struct;
|
|
|
|
|
|
|
|
typedef union uint64_overlay {
|
|
|
|
u64 full;
|
|
|
|
struct uint64_struct part;
|
|
|
|
|
|
|
|
} uint64_overlay;
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ut_short_divide
|
|
|
|
*
|
2012-07-11 19:40:10 -06:00
|
|
|
* PARAMETERS: dividend - 64-bit dividend
|
|
|
|
* divisor - 32-bit divisor
|
2005-04-16 16:20:36 -06:00
|
|
|
* out_quotient - Pointer to where the quotient is returned
|
|
|
|
* out_remainder - Pointer to where the remainder is returned
|
|
|
|
*
|
|
|
|
* RETURN: Status (Checks for divide-by-zero)
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Perform a short (maximum 64 bits divided by 32 bits)
|
2012-10-30 20:26:55 -06:00
|
|
|
* divide and modulo. The result is a 64-bit quotient and a
|
2005-04-16 16:20:36 -06:00
|
|
|
* 32-bit remainder.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
2010-09-15 00:00:53 -06:00
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
acpi_status
|
2010-01-20 19:06:32 -07:00
|
|
|
acpi_ut_short_divide(u64 dividend,
|
|
|
|
u32 divisor, u64 *out_quotient, u32 *out_remainder)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2005-08-04 22:44:28 -06:00
|
|
|
union uint64_overlay dividend_ovl;
|
|
|
|
union uint64_overlay quotient;
|
|
|
|
u32 remainder32;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
ACPI: ACPICA 20060421
Removed a device initialization optimization introduced in
20051216 where the _STA method was not run unless an _INI
was also present for the same device. This optimization
could cause problems because it could allow _INI methods
to be run within a not-present device subtree (If a
not-present device had no _INI, _STA would not be run,
the not-present status would not be discovered, and the
children of the device would be incorrectly traversed.)
Implemented a new _STA optimization where namespace
subtrees that do not contain _INI are identified and
ignored during device initialization. Selectively running
_STA can significantly improve boot time on large machines
(with assistance from Len Brown.)
Implemented support for the device initialization case
where the returned _STA flags indicate a device not-present
but functioning. In this case, _INI is not run, but the
device children are examined for presence, as per the
ACPI specification.
Implemented an additional change to the IndexField support
in order to conform to MS behavior. The value written to
the Index Register is not simply a byte offset, it is a
byte offset in units of the access width of the parent
Index Field. (Fiodor Suietov)
Defined and deployed a new OSL interface,
acpi_os_validate_address(). This interface is called during
the creation of all AML operation regions, and allows
the host OS to exert control over what addresses it will
allow the AML code to access. Operation Regions whose
addresses are disallowed will cause a runtime exception
when they are actually accessed (will not affect or abort
table loading.)
Defined and deployed a new OSL interface,
acpi_os_validate_interface(). This interface allows the host OS
to match the various "optional" interface/behavior strings
for the _OSI predefined control method as appropriate
(with assistance from Bjorn Helgaas.)
Restructured and corrected various problems in the
exception handling code paths within DsCallControlMethod
and DsTerminateControlMethod in dsmethod (with assistance
from Takayoshi Kochi.)
Modified the Linux source converter to ignore quoted string
literals while converting identifiers from mixed to lower
case. This will correct problems with the disassembler
and other areas where such strings must not be modified.
The ACPI_FUNCTION_* macros no longer require quotes around
the function name. This allows the Linux source converter
to convert the names, now that the converter ignores
quoted strings.
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2006-04-21 15:15:00 -06:00
|
|
|
ACPI_FUNCTION_TRACE(ut_short_divide);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* Always check for a zero divisor */
|
|
|
|
|
|
|
|
if (divisor == 0) {
|
2006-01-27 14:43:00 -07:00
|
|
|
ACPI_ERROR((AE_INFO, "Divide by zero"));
|
2005-08-04 22:44:28 -06:00
|
|
|
return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
dividend_ovl.full = dividend;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The quotient is 64 bits, the remainder is always 32 bits,
|
|
|
|
* and is generated by the second divide.
|
|
|
|
*/
|
2005-08-04 22:44:28 -06:00
|
|
|
ACPI_DIV_64_BY_32(0, dividend_ovl.part.hi, divisor,
|
2005-04-16 16:20:36 -06:00
|
|
|
quotient.part.hi, remainder32);
|
2015-12-28 22:54:36 -07:00
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
ACPI_DIV_64_BY_32(remainder32, dividend_ovl.part.lo, divisor,
|
2005-04-16 16:20:36 -06:00
|
|
|
quotient.part.lo, remainder32);
|
|
|
|
|
|
|
|
/* Return only what was requested */
|
|
|
|
|
|
|
|
if (out_quotient) {
|
|
|
|
*out_quotient = quotient.full;
|
|
|
|
}
|
|
|
|
if (out_remainder) {
|
|
|
|
*out_remainder = remainder32;
|
|
|
|
}
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
return_ACPI_STATUS(AE_OK);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ut_divide
|
|
|
|
*
|
|
|
|
* PARAMETERS: in_dividend - Dividend
|
|
|
|
* in_divisor - Divisor
|
|
|
|
* out_quotient - Pointer to where the quotient is returned
|
|
|
|
* out_remainder - Pointer to where the remainder is returned
|
|
|
|
*
|
|
|
|
* RETURN: Status (Checks for divide-by-zero)
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Perform a divide and modulo.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
acpi_status
|
2010-01-20 19:06:32 -07:00
|
|
|
acpi_ut_divide(u64 in_dividend,
|
|
|
|
u64 in_divisor, u64 *out_quotient, u64 *out_remainder)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2005-08-04 22:44:28 -06:00
|
|
|
union uint64_overlay dividend;
|
|
|
|
union uint64_overlay divisor;
|
|
|
|
union uint64_overlay quotient;
|
|
|
|
union uint64_overlay remainder;
|
|
|
|
union uint64_overlay normalized_dividend;
|
|
|
|
union uint64_overlay normalized_divisor;
|
|
|
|
u32 partial1;
|
|
|
|
union uint64_overlay partial2;
|
|
|
|
union uint64_overlay partial3;
|
|
|
|
|
ACPI: ACPICA 20060421
Removed a device initialization optimization introduced in
20051216 where the _STA method was not run unless an _INI
was also present for the same device. This optimization
could cause problems because it could allow _INI methods
to be run within a not-present device subtree (If a
not-present device had no _INI, _STA would not be run,
the not-present status would not be discovered, and the
children of the device would be incorrectly traversed.)
Implemented a new _STA optimization where namespace
subtrees that do not contain _INI are identified and
ignored during device initialization. Selectively running
_STA can significantly improve boot time on large machines
(with assistance from Len Brown.)
Implemented support for the device initialization case
where the returned _STA flags indicate a device not-present
but functioning. In this case, _INI is not run, but the
device children are examined for presence, as per the
ACPI specification.
Implemented an additional change to the IndexField support
in order to conform to MS behavior. The value written to
the Index Register is not simply a byte offset, it is a
byte offset in units of the access width of the parent
Index Field. (Fiodor Suietov)
Defined and deployed a new OSL interface,
acpi_os_validate_address(). This interface is called during
the creation of all AML operation regions, and allows
the host OS to exert control over what addresses it will
allow the AML code to access. Operation Regions whose
addresses are disallowed will cause a runtime exception
when they are actually accessed (will not affect or abort
table loading.)
Defined and deployed a new OSL interface,
acpi_os_validate_interface(). This interface allows the host OS
to match the various "optional" interface/behavior strings
for the _OSI predefined control method as appropriate
(with assistance from Bjorn Helgaas.)
Restructured and corrected various problems in the
exception handling code paths within DsCallControlMethod
and DsTerminateControlMethod in dsmethod (with assistance
from Takayoshi Kochi.)
Modified the Linux source converter to ignore quoted string
literals while converting identifiers from mixed to lower
case. This will correct problems with the disassembler
and other areas where such strings must not be modified.
The ACPI_FUNCTION_* macros no longer require quotes around
the function name. This allows the Linux source converter
to convert the names, now that the converter ignores
quoted strings.
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2006-04-21 15:15:00 -06:00
|
|
|
ACPI_FUNCTION_TRACE(ut_divide);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* Always check for a zero divisor */
|
|
|
|
|
|
|
|
if (in_divisor == 0) {
|
2006-01-27 14:43:00 -07:00
|
|
|
ACPI_ERROR((AE_INFO, "Divide by zero"));
|
2005-08-04 22:44:28 -06:00
|
|
|
return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
divisor.full = in_divisor;
|
2005-04-16 16:20:36 -06:00
|
|
|
dividend.full = in_dividend;
|
|
|
|
if (divisor.part.hi == 0) {
|
|
|
|
/*
|
|
|
|
* 1) Simplest case is where the divisor is 32 bits, we can
|
|
|
|
* just do two divides
|
|
|
|
*/
|
|
|
|
remainder.part.hi = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The quotient is 64 bits, the remainder is always 32 bits,
|
|
|
|
* and is generated by the second divide.
|
|
|
|
*/
|
2005-08-04 22:44:28 -06:00
|
|
|
ACPI_DIV_64_BY_32(0, dividend.part.hi, divisor.part.lo,
|
2005-04-16 16:20:36 -06:00
|
|
|
quotient.part.hi, partial1);
|
2015-12-28 22:54:36 -07:00
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
ACPI_DIV_64_BY_32(partial1, dividend.part.lo, divisor.part.lo,
|
2005-04-16 16:20:36 -06:00
|
|
|
quotient.part.lo, remainder.part.lo);
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
/*
|
|
|
|
* 2) The general case where the divisor is a full 64 bits
|
|
|
|
* is more difficult
|
|
|
|
*/
|
2005-08-04 22:44:28 -06:00
|
|
|
quotient.part.hi = 0;
|
2005-04-16 16:20:36 -06:00
|
|
|
normalized_dividend = dividend;
|
|
|
|
normalized_divisor = divisor;
|
|
|
|
|
|
|
|
/* Normalize the operands (shift until the divisor is < 32 bits) */
|
|
|
|
|
|
|
|
do {
|
2005-08-04 22:44:28 -06:00
|
|
|
ACPI_SHIFT_RIGHT_64(normalized_divisor.part.hi,
|
|
|
|
normalized_divisor.part.lo);
|
|
|
|
ACPI_SHIFT_RIGHT_64(normalized_dividend.part.hi,
|
|
|
|
normalized_dividend.part.lo);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
} while (normalized_divisor.part.hi != 0);
|
|
|
|
|
|
|
|
/* Partial divide */
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
ACPI_DIV_64_BY_32(normalized_dividend.part.hi,
|
2005-04-16 16:20:36 -06:00
|
|
|
normalized_dividend.part.lo,
|
2015-12-28 22:54:36 -07:00
|
|
|
normalized_divisor.part.lo, quotient.part.lo,
|
|
|
|
partial1);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/*
|
2015-12-28 22:54:36 -07:00
|
|
|
* The quotient is always 32 bits, and simply requires
|
|
|
|
* adjustment. The 64-bit remainder must be generated.
|
2005-04-16 16:20:36 -06:00
|
|
|
*/
|
2005-08-04 22:44:28 -06:00
|
|
|
partial1 = quotient.part.lo * divisor.part.hi;
|
2010-01-20 19:06:32 -07:00
|
|
|
partial2.full = (u64) quotient.part.lo * divisor.part.lo;
|
|
|
|
partial3.full = (u64) partial2.part.hi + partial1;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
remainder.part.hi = partial3.part.lo;
|
|
|
|
remainder.part.lo = partial2.part.lo;
|
|
|
|
|
|
|
|
if (partial3.part.hi == 0) {
|
|
|
|
if (partial3.part.lo >= dividend.part.hi) {
|
|
|
|
if (partial3.part.lo == dividend.part.hi) {
|
|
|
|
if (partial2.part.lo > dividend.part.lo) {
|
|
|
|
quotient.part.lo--;
|
|
|
|
remainder.full -= divisor.full;
|
|
|
|
}
|
2005-08-04 22:44:28 -06:00
|
|
|
} else {
|
2005-04-16 16:20:36 -06:00
|
|
|
quotient.part.lo--;
|
|
|
|
remainder.full -= divisor.full;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
remainder.full = remainder.full - dividend.full;
|
2016-05-04 22:57:53 -06:00
|
|
|
remainder.part.hi = (u32)-((s32)remainder.part.hi);
|
|
|
|
remainder.part.lo = (u32)-((s32)remainder.part.lo);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
if (remainder.part.lo) {
|
|
|
|
remainder.part.hi--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return only what was requested */
|
|
|
|
|
|
|
|
if (out_quotient) {
|
|
|
|
*out_quotient = quotient.full;
|
|
|
|
}
|
|
|
|
if (out_remainder) {
|
|
|
|
*out_remainder = remainder.full;
|
|
|
|
}
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
return_ACPI_STATUS(AE_OK);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ut_short_divide, acpi_ut_divide
|
|
|
|
*
|
2005-04-18 20:49:35 -06:00
|
|
|
* PARAMETERS: See function headers above
|
|
|
|
*
|
2005-04-16 16:20:36 -06:00
|
|
|
* DESCRIPTION: Native versions of the ut_divide functions. Use these if either
|
|
|
|
* 1) The target is a 64-bit platform and therefore 64-bit
|
|
|
|
* integer math is supported directly by the machine.
|
|
|
|
* 2) The target is a 32-bit or 16-bit platform, and the
|
|
|
|
* double-precision integer math library is available to
|
|
|
|
* perform the divide.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
acpi_status
|
2010-01-20 19:06:32 -07:00
|
|
|
acpi_ut_short_divide(u64 in_dividend,
|
|
|
|
u32 divisor, u64 *out_quotient, u32 *out_remainder)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
|
ACPI: ACPICA 20060421
Removed a device initialization optimization introduced in
20051216 where the _STA method was not run unless an _INI
was also present for the same device. This optimization
could cause problems because it could allow _INI methods
to be run within a not-present device subtree (If a
not-present device had no _INI, _STA would not be run,
the not-present status would not be discovered, and the
children of the device would be incorrectly traversed.)
Implemented a new _STA optimization where namespace
subtrees that do not contain _INI are identified and
ignored during device initialization. Selectively running
_STA can significantly improve boot time on large machines
(with assistance from Len Brown.)
Implemented support for the device initialization case
where the returned _STA flags indicate a device not-present
but functioning. In this case, _INI is not run, but the
device children are examined for presence, as per the
ACPI specification.
Implemented an additional change to the IndexField support
in order to conform to MS behavior. The value written to
the Index Register is not simply a byte offset, it is a
byte offset in units of the access width of the parent
Index Field. (Fiodor Suietov)
Defined and deployed a new OSL interface,
acpi_os_validate_address(). This interface is called during
the creation of all AML operation regions, and allows
the host OS to exert control over what addresses it will
allow the AML code to access. Operation Regions whose
addresses are disallowed will cause a runtime exception
when they are actually accessed (will not affect or abort
table loading.)
Defined and deployed a new OSL interface,
acpi_os_validate_interface(). This interface allows the host OS
to match the various "optional" interface/behavior strings
for the _OSI predefined control method as appropriate
(with assistance from Bjorn Helgaas.)
Restructured and corrected various problems in the
exception handling code paths within DsCallControlMethod
and DsTerminateControlMethod in dsmethod (with assistance
from Takayoshi Kochi.)
Modified the Linux source converter to ignore quoted string
literals while converting identifiers from mixed to lower
case. This will correct problems with the disassembler
and other areas where such strings must not be modified.
The ACPI_FUNCTION_* macros no longer require quotes around
the function name. This allows the Linux source converter
to convert the names, now that the converter ignores
quoted strings.
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2006-04-21 15:15:00 -06:00
|
|
|
ACPI_FUNCTION_TRACE(ut_short_divide);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* Always check for a zero divisor */
|
|
|
|
|
|
|
|
if (divisor == 0) {
|
2006-01-27 14:43:00 -07:00
|
|
|
ACPI_ERROR((AE_INFO, "Divide by zero"));
|
2005-08-04 22:44:28 -06:00
|
|
|
return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Return only what was requested */
|
|
|
|
|
|
|
|
if (out_quotient) {
|
|
|
|
*out_quotient = in_dividend / divisor;
|
|
|
|
}
|
|
|
|
if (out_remainder) {
|
2008-04-10 09:06:40 -06:00
|
|
|
*out_remainder = (u32) (in_dividend % divisor);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
return_ACPI_STATUS(AE_OK);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
acpi_status
|
2010-01-20 19:06:32 -07:00
|
|
|
acpi_ut_divide(u64 in_dividend,
|
|
|
|
u64 in_divisor, u64 *out_quotient, u64 *out_remainder)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
ACPI: ACPICA 20060421
Removed a device initialization optimization introduced in
20051216 where the _STA method was not run unless an _INI
was also present for the same device. This optimization
could cause problems because it could allow _INI methods
to be run within a not-present device subtree (If a
not-present device had no _INI, _STA would not be run,
the not-present status would not be discovered, and the
children of the device would be incorrectly traversed.)
Implemented a new _STA optimization where namespace
subtrees that do not contain _INI are identified and
ignored during device initialization. Selectively running
_STA can significantly improve boot time on large machines
(with assistance from Len Brown.)
Implemented support for the device initialization case
where the returned _STA flags indicate a device not-present
but functioning. In this case, _INI is not run, but the
device children are examined for presence, as per the
ACPI specification.
Implemented an additional change to the IndexField support
in order to conform to MS behavior. The value written to
the Index Register is not simply a byte offset, it is a
byte offset in units of the access width of the parent
Index Field. (Fiodor Suietov)
Defined and deployed a new OSL interface,
acpi_os_validate_address(). This interface is called during
the creation of all AML operation regions, and allows
the host OS to exert control over what addresses it will
allow the AML code to access. Operation Regions whose
addresses are disallowed will cause a runtime exception
when they are actually accessed (will not affect or abort
table loading.)
Defined and deployed a new OSL interface,
acpi_os_validate_interface(). This interface allows the host OS
to match the various "optional" interface/behavior strings
for the _OSI predefined control method as appropriate
(with assistance from Bjorn Helgaas.)
Restructured and corrected various problems in the
exception handling code paths within DsCallControlMethod
and DsTerminateControlMethod in dsmethod (with assistance
from Takayoshi Kochi.)
Modified the Linux source converter to ignore quoted string
literals while converting identifiers from mixed to lower
case. This will correct problems with the disassembler
and other areas where such strings must not be modified.
The ACPI_FUNCTION_* macros no longer require quotes around
the function name. This allows the Linux source converter
to convert the names, now that the converter ignores
quoted strings.
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2006-04-21 15:15:00 -06:00
|
|
|
ACPI_FUNCTION_TRACE(ut_divide);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* Always check for a zero divisor */
|
|
|
|
|
|
|
|
if (in_divisor == 0) {
|
2006-01-27 14:43:00 -07:00
|
|
|
ACPI_ERROR((AE_INFO, "Divide by zero"));
|
2005-08-04 22:44:28 -06:00
|
|
|
return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Return only what was requested */
|
|
|
|
|
|
|
|
if (out_quotient) {
|
|
|
|
*out_quotient = in_dividend / in_divisor;
|
|
|
|
}
|
|
|
|
if (out_remainder) {
|
|
|
|
*out_remainder = in_dividend % in_divisor;
|
|
|
|
}
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
return_ACPI_STATUS(AE_OK);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|