2005-04-16 16:20:36 -06:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Module Name: exfldio - Aml Field I/O
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/*
|
2018-01-04 11:06:38 -07:00
|
|
|
* Copyright (C) 2000 - 2018, 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"
|
|
|
|
#include "acinterp.h"
|
|
|
|
#include "amlcode.h"
|
|
|
|
#include "acevents.h"
|
|
|
|
#include "acdispat.h"
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
#define _COMPONENT ACPI_EXECUTER
|
2005-08-04 22:44:28 -06:00
|
|
|
ACPI_MODULE_NAME("exfldio")
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2005-04-18 20:49:35 -06:00
|
|
|
/* Local prototypes */
|
|
|
|
static acpi_status
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_ex_field_datum_io(union acpi_operand_object *obj_desc,
|
2012-10-30 20:25:45 -06:00
|
|
|
u32 field_datum_byte_offset, u64 *value, u32 read_write);
|
2005-04-18 20:49:35 -06:00
|
|
|
|
|
|
|
static u8
|
2010-01-20 19:06:32 -07:00
|
|
|
acpi_ex_register_overflow(union acpi_operand_object *obj_desc, u64 value);
|
2005-04-18 20:49:35 -06:00
|
|
|
|
|
|
|
static acpi_status
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_ex_setup_region(union acpi_operand_object *obj_desc,
|
|
|
|
u32 field_datum_byte_offset);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ex_setup_region
|
|
|
|
*
|
2005-04-18 20:49:35 -06:00
|
|
|
* PARAMETERS: obj_desc - Field to be read or written
|
2005-04-16 16:20:36 -06:00
|
|
|
* field_datum_byte_offset - Byte offset of this datum within the
|
|
|
|
* parent field
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Common processing for acpi_ex_extract_from_field and
|
|
|
|
* acpi_ex_insert_into_field. Initialize the Region if necessary and
|
|
|
|
* validate the request.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2005-04-18 20:49:35 -06:00
|
|
|
static acpi_status
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_ex_setup_region(union acpi_operand_object *obj_desc,
|
|
|
|
u32 field_datum_byte_offset)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_status status = AE_OK;
|
|
|
|
union acpi_operand_object *rgn_desc;
|
2011-11-29 18:35:05 -07:00
|
|
|
u8 space_id;
|
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_U32(ex_setup_region, field_datum_byte_offset);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
rgn_desc = obj_desc->common_field.region_obj;
|
|
|
|
|
|
|
|
/* We must have a valid region */
|
|
|
|
|
2009-02-17 23:44:03 -07:00
|
|
|
if (rgn_desc->common.type != ACPI_TYPE_REGION) {
|
2010-03-05 02:56:40 -07:00
|
|
|
ACPI_ERROR((AE_INFO, "Needed Region, found type 0x%X (%s)",
|
2009-02-17 23:44:03 -07:00
|
|
|
rgn_desc->common.type,
|
2006-01-27 14:43:00 -07:00
|
|
|
acpi_ut_get_object_type_name(rgn_desc)));
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
2011-11-29 18:35:05 -07:00
|
|
|
space_id = rgn_desc->region.space_id;
|
|
|
|
|
|
|
|
/* Validate the Space ID */
|
|
|
|
|
|
|
|
if (!acpi_is_valid_space_id(space_id)) {
|
|
|
|
ACPI_ERROR((AE_INFO,
|
|
|
|
"Invalid/unknown Address Space ID: 0x%2.2X",
|
|
|
|
space_id));
|
|
|
|
return_ACPI_STATUS(AE_AML_INVALID_SPACE_ID);
|
|
|
|
}
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
/*
|
|
|
|
* If the Region Address and Length have not been previously evaluated,
|
|
|
|
* evaluate them now and save the results.
|
|
|
|
*/
|
|
|
|
if (!(rgn_desc->common.flags & AOPOBJ_DATA_VALID)) {
|
2005-08-04 22:44:28 -06:00
|
|
|
status = acpi_ds_get_region_arguments(rgn_desc);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
return_ACPI_STATUS(status);
|
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
|
|
|
/*
|
2011-11-15 23:14:32 -07:00
|
|
|
* Exit now for SMBus, GSBus or IPMI address space, it has a non-linear
|
2010-08-05 19:09:33 -06:00
|
|
|
* address space and the request cannot be directly validated
|
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
|
|
|
*/
|
2011-11-29 18:35:05 -07:00
|
|
|
if (space_id == ACPI_ADR_SPACE_SMBUS ||
|
2011-11-15 23:14:32 -07:00
|
|
|
space_id == ACPI_ADR_SPACE_GSBUS ||
|
2011-11-29 18:35:05 -07:00
|
|
|
space_id == ACPI_ADR_SPACE_IPMI) {
|
2006-10-01 22:00:00 -06:00
|
|
|
|
2009-06-23 21:32:04 -06:00
|
|
|
/* SMBus or IPMI has a non-linear address space */
|
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
|
|
|
}
|
|
|
|
#ifdef ACPI_UNDER_DEVELOPMENT
|
|
|
|
/*
|
|
|
|
* If the Field access is any_acc, we can now compute the optimal
|
|
|
|
* access (because we know know the length of the parent region)
|
|
|
|
*/
|
|
|
|
if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) {
|
2005-08-04 22:44:28 -06:00
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
2012-10-30 20:26:55 -06:00
|
|
|
* Validate the request. The entire request from the byte offset for a
|
2005-04-16 16:20:36 -06:00
|
|
|
* length of one field datum (access width) must fit within the region.
|
|
|
|
* (Region length is specified in bytes)
|
|
|
|
*/
|
2006-05-26 14:36:00 -06:00
|
|
|
if (rgn_desc->region.length <
|
2010-08-05 19:09:33 -06:00
|
|
|
(obj_desc->common_field.base_byte_offset + field_datum_byte_offset +
|
2006-05-26 14:36:00 -06:00
|
|
|
obj_desc->common_field.access_byte_width)) {
|
2005-04-16 16:20:36 -06:00
|
|
|
if (acpi_gbl_enable_interpreter_slack) {
|
|
|
|
/*
|
|
|
|
* Slack mode only: We will go ahead and allow access to this
|
|
|
|
* field if it is within the region length rounded up to the next
|
2008-06-09 23:42:13 -06:00
|
|
|
* access width boundary. acpi_size cast for 64-bit compile.
|
2005-04-16 16:20:36 -06:00
|
|
|
*/
|
2005-08-04 22:44:28 -06:00
|
|
|
if (ACPI_ROUND_UP(rgn_desc->region.length,
|
|
|
|
obj_desc->common_field.
|
|
|
|
access_byte_width) >=
|
2016-05-04 22:57:53 -06:00
|
|
|
((acpi_size)obj_desc->common_field.
|
2008-06-09 23:42:13 -06:00
|
|
|
base_byte_offset +
|
|
|
|
obj_desc->common_field.access_byte_width +
|
|
|
|
field_datum_byte_offset)) {
|
2005-08-04 22:44:28 -06:00
|
|
|
return_ACPI_STATUS(AE_OK);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
if (rgn_desc->region.length <
|
|
|
|
obj_desc->common_field.access_byte_width) {
|
2005-04-16 16:20:36 -06:00
|
|
|
/*
|
|
|
|
* This is the case where the access_type (acc_word, etc.) is wider
|
2012-10-30 20:26:55 -06:00
|
|
|
* than the region itself. For example, a region of length one
|
2005-04-16 16:20:36 -06:00
|
|
|
* byte, and a field with Dword access specified.
|
|
|
|
*/
|
2006-01-27 14:43:00 -07:00
|
|
|
ACPI_ERROR((AE_INFO,
|
2015-12-28 22:54:36 -07:00
|
|
|
"Field [%4.4s] access width (%u bytes) "
|
|
|
|
"too large for region [%4.4s] (length %u)",
|
2006-01-27 14:43:00 -07:00
|
|
|
acpi_ut_get_node_name(obj_desc->
|
|
|
|
common_field.node),
|
|
|
|
obj_desc->common_field.access_byte_width,
|
|
|
|
acpi_ut_get_node_name(rgn_desc->region.
|
|
|
|
node),
|
|
|
|
rgn_desc->region.length));
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Offset rounded up to next multiple of field width
|
|
|
|
* exceeds region length, indicate an error
|
|
|
|
*/
|
2006-01-27 14:43:00 -07:00
|
|
|
ACPI_ERROR((AE_INFO,
|
2015-12-28 22:54:36 -07:00
|
|
|
"Field [%4.4s] Base+Offset+Width %u+%u+%u "
|
|
|
|
"is beyond end of region [%4.4s] (length %u)",
|
2006-01-27 14:43:00 -07:00
|
|
|
acpi_ut_get_node_name(obj_desc->common_field.node),
|
|
|
|
obj_desc->common_field.base_byte_offset,
|
|
|
|
field_datum_byte_offset,
|
|
|
|
obj_desc->common_field.access_byte_width,
|
|
|
|
acpi_ut_get_node_name(rgn_desc->region.node),
|
|
|
|
rgn_desc->region.length));
|
2005-08-04 22:44:28 -06:00
|
|
|
|
|
|
|
return_ACPI_STATUS(AE_AML_REGION_LIMIT);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ex_access_region
|
|
|
|
*
|
2005-04-18 20:49:35 -06:00
|
|
|
* PARAMETERS: obj_desc - Field to be read
|
2005-04-16 16:20:36 -06:00
|
|
|
* field_datum_byte_offset - Byte offset of this datum within the
|
|
|
|
* parent field
|
2012-07-11 19:40:10 -06:00
|
|
|
* value - Where to store value (must at least
|
2010-01-20 19:06:32 -07:00
|
|
|
* 64 bits)
|
2012-07-11 19:40:10 -06:00
|
|
|
* function - Read or Write flag plus other region-
|
2005-04-16 16:20:36 -06:00
|
|
|
* dependent flags
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Read or Write a single field datum to an Operation Region.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
acpi_status
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_ex_access_region(union acpi_operand_object *obj_desc,
|
2010-01-20 19:06:32 -07:00
|
|
|
u32 field_datum_byte_offset, u64 *value, u32 function)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_status status;
|
|
|
|
union acpi_operand_object *rgn_desc;
|
2009-05-20 20:56:52 -06:00
|
|
|
u32 region_offset;
|
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(ex_access_region);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Ensure that the region operands are fully evaluated and verify
|
|
|
|
* the validity of the request
|
|
|
|
*/
|
2005-08-04 22:44:28 -06:00
|
|
|
status = acpi_ex_setup_region(obj_desc, field_datum_byte_offset);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The physical address of this field datum is:
|
|
|
|
*
|
|
|
|
* 1) The base of the region, plus
|
|
|
|
* 2) The base offset of the field, plus
|
|
|
|
* 3) The current offset into the field
|
|
|
|
*/
|
|
|
|
rgn_desc = obj_desc->common_field.region_obj;
|
2009-05-20 20:56:52 -06:00
|
|
|
region_offset =
|
2005-08-04 22:44:28 -06:00
|
|
|
obj_desc->common_field.base_byte_offset + field_datum_byte_offset;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
if ((function & ACPI_IO_MASK) == ACPI_READ) {
|
2005-08-04 22:44:28 -06:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, "[READ]"));
|
|
|
|
} else {
|
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, "[WRITE]"));
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
ACPI_DEBUG_PRINT_RAW((ACPI_DB_BFIELD,
|
2015-04-12 21:48:46 -06:00
|
|
|
" Region [%s:%X], Width %X, ByteBase %X, Offset %X at %8.8X%8.8X\n",
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_ut_get_region_name(rgn_desc->region.
|
|
|
|
space_id),
|
|
|
|
rgn_desc->region.space_id,
|
|
|
|
obj_desc->common_field.access_byte_width,
|
|
|
|
obj_desc->common_field.base_byte_offset,
|
2015-04-12 21:48:46 -06:00
|
|
|
field_datum_byte_offset,
|
|
|
|
ACPI_FORMAT_UINT64(rgn_desc->region.address +
|
|
|
|
region_offset)));
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* Invoke the appropriate address_space/op_region handler */
|
|
|
|
|
2011-11-15 22:39:07 -07:00
|
|
|
status = acpi_ev_address_space_dispatch(rgn_desc, obj_desc,
|
|
|
|
function, region_offset,
|
|
|
|
ACPI_MUL_8(obj_desc->
|
|
|
|
common_field.
|
|
|
|
access_byte_width),
|
|
|
|
value);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
if (ACPI_FAILURE(status)) {
|
2005-04-16 16:20:36 -06:00
|
|
|
if (status == AE_NOT_IMPLEMENTED) {
|
2006-01-27 14:43:00 -07:00
|
|
|
ACPI_ERROR((AE_INFO,
|
2011-02-14 00:52:56 -07:00
|
|
|
"Region %s (ID=%u) not implemented",
|
2006-01-27 14:43:00 -07:00
|
|
|
acpi_ut_get_region_name(rgn_desc->region.
|
|
|
|
space_id),
|
|
|
|
rgn_desc->region.space_id));
|
2005-08-04 22:44:28 -06:00
|
|
|
} else if (status == AE_NOT_EXIST) {
|
2006-01-27 14:43:00 -07:00
|
|
|
ACPI_ERROR((AE_INFO,
|
2011-02-14 00:52:56 -07:00
|
|
|
"Region %s (ID=%u) has no handler",
|
2006-01-27 14:43:00 -07:00
|
|
|
acpi_ut_get_region_name(rgn_desc->region.
|
|
|
|
space_id),
|
|
|
|
rgn_desc->region.space_id));
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ex_register_overflow
|
|
|
|
*
|
2005-04-18 20:49:35 -06:00
|
|
|
* PARAMETERS: obj_desc - Register(Field) to be written
|
2012-07-11 19:40:10 -06:00
|
|
|
* value - Value to be stored
|
2005-04-16 16:20:36 -06:00
|
|
|
*
|
|
|
|
* RETURN: TRUE if value overflows the field, FALSE otherwise
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Check if a value is out of range of the field being written.
|
|
|
|
* Used to check if the values written to Index and Bank registers
|
2012-10-30 20:26:55 -06:00
|
|
|
* are out of range. Normally, the value is simply truncated
|
2005-04-16 16:20:36 -06:00
|
|
|
* to fit the field, but this case is most likely a serious
|
|
|
|
* coding error in the ASL.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2005-04-18 20:49:35 -06:00
|
|
|
static u8
|
2010-01-20 19:06:32 -07:00
|
|
|
acpi_ex_register_overflow(union acpi_operand_object *obj_desc, u64 value)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
|
|
|
|
if (obj_desc->common_field.bit_length >= ACPI_INTEGER_BIT_SIZE) {
|
|
|
|
/*
|
|
|
|
* The field is large enough to hold the maximum integer, so we can
|
|
|
|
* never overflow it.
|
|
|
|
*/
|
|
|
|
return (FALSE);
|
|
|
|
}
|
|
|
|
|
2010-01-20 19:06:32 -07:00
|
|
|
if (value >= ((u64) 1 << obj_desc->common_field.bit_length)) {
|
2005-04-16 16:20:36 -06:00
|
|
|
/*
|
|
|
|
* The Value is larger than the maximum value that can fit into
|
|
|
|
* the register.
|
|
|
|
*/
|
2011-11-27 19:10:10 -07:00
|
|
|
ACPI_ERROR((AE_INFO,
|
|
|
|
"Index value 0x%8.8X%8.8X overflows field width 0x%X",
|
|
|
|
ACPI_FORMAT_UINT64(value),
|
|
|
|
obj_desc->common_field.bit_length));
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
return (TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The Value will fit into the field with no truncation */
|
|
|
|
|
|
|
|
return (FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ex_field_datum_io
|
|
|
|
*
|
2005-04-18 20:49:35 -06:00
|
|
|
* PARAMETERS: obj_desc - Field to be read
|
2005-04-16 16:20:36 -06:00
|
|
|
* field_datum_byte_offset - Byte offset of this datum within the
|
|
|
|
* parent field
|
2012-07-11 19:40:10 -06:00
|
|
|
* value - Where to store value (must be 64 bits)
|
2005-04-16 16:20:36 -06:00
|
|
|
* read_write - Read or Write flag
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
2012-10-30 20:26:55 -06:00
|
|
|
* DESCRIPTION: Read or Write a single datum of a field. The field_type is
|
2005-04-16 16:20:36 -06:00
|
|
|
* demultiplexed here to handle the different types of fields
|
|
|
|
* (buffer_field, region_field, index_field, bank_field)
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2005-04-18 20:49:35 -06:00
|
|
|
static acpi_status
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_ex_field_datum_io(union acpi_operand_object *obj_desc,
|
2010-01-20 19:06:32 -07:00
|
|
|
u32 field_datum_byte_offset, u64 *value, u32 read_write)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_status status;
|
2010-01-20 19:06:32 -07:00
|
|
|
u64 local_value;
|
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_U32(ex_field_datum_io, field_datum_byte_offset);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
if (read_write == ACPI_READ) {
|
|
|
|
if (!value) {
|
|
|
|
local_value = 0;
|
2005-04-18 20:49:35 -06:00
|
|
|
|
|
|
|
/* To support reads without saving return value */
|
|
|
|
value = &local_value;
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Clear the entire return buffer first, [Very Important!] */
|
|
|
|
|
|
|
|
*value = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The four types of fields are:
|
|
|
|
*
|
|
|
|
* buffer_field - Read/write from/to a Buffer
|
|
|
|
* region_field - Read/write from/to a Operation Region.
|
2005-04-18 20:49:35 -06:00
|
|
|
* bank_field - Write to a Bank Register, then read/write from/to an
|
|
|
|
* operation_region
|
|
|
|
* index_field - Write to an Index Register, then read/write from/to a
|
|
|
|
* Data Register
|
2005-04-16 16:20:36 -06:00
|
|
|
*/
|
2009-02-17 23:44:03 -07:00
|
|
|
switch (obj_desc->common.type) {
|
2005-04-16 16:20:36 -06:00
|
|
|
case ACPI_TYPE_BUFFER_FIELD:
|
|
|
|
/*
|
|
|
|
* If the buffer_field arguments have not been previously evaluated,
|
|
|
|
* evaluate them now and save the results.
|
|
|
|
*/
|
|
|
|
if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) {
|
2005-08-04 22:44:28 -06:00
|
|
|
status = acpi_ds_get_buffer_field_arguments(obj_desc);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (read_write == ACPI_READ) {
|
|
|
|
/*
|
|
|
|
* Copy the data from the source buffer.
|
|
|
|
* Length is the field width in bytes.
|
|
|
|
*/
|
2015-07-01 00:45:11 -06:00
|
|
|
memcpy(value,
|
|
|
|
(obj_desc->buffer_field.buffer_obj)->buffer.
|
|
|
|
pointer +
|
|
|
|
obj_desc->buffer_field.base_byte_offset +
|
|
|
|
field_datum_byte_offset,
|
|
|
|
obj_desc->common_field.access_byte_width);
|
2005-08-04 22:44:28 -06:00
|
|
|
} else {
|
2005-04-16 16:20:36 -06:00
|
|
|
/*
|
|
|
|
* Copy the data to the target buffer.
|
|
|
|
* Length is the field width in bytes.
|
|
|
|
*/
|
2015-07-01 00:45:11 -06:00
|
|
|
memcpy((obj_desc->buffer_field.buffer_obj)->buffer.
|
|
|
|
pointer +
|
|
|
|
obj_desc->buffer_field.base_byte_offset +
|
|
|
|
field_datum_byte_offset, value,
|
|
|
|
obj_desc->common_field.access_byte_width);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
status = AE_OK;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ACPI_TYPE_LOCAL_BANK_FIELD:
|
2005-04-18 20:49:35 -06:00
|
|
|
/*
|
|
|
|
* Ensure that the bank_value is not beyond the capacity of
|
|
|
|
* the register
|
|
|
|
*/
|
2005-08-04 22:44:28 -06:00
|
|
|
if (acpi_ex_register_overflow(obj_desc->bank_field.bank_obj,
|
2010-01-20 19:06:32 -07:00
|
|
|
(u64) obj_desc->bank_field.
|
|
|
|
value)) {
|
2005-08-04 22:44:28 -06:00
|
|
|
return_ACPI_STATUS(AE_AML_REGISTER_LIMIT);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* For bank_fields, we must write the bank_value to the bank_register
|
|
|
|
* (itself a region_field) before we can access the data.
|
|
|
|
*/
|
2005-08-04 22:44:28 -06:00
|
|
|
status =
|
|
|
|
acpi_ex_insert_into_field(obj_desc->bank_field.bank_obj,
|
|
|
|
&obj_desc->bank_field.value,
|
|
|
|
sizeof(obj_desc->bank_field.
|
|
|
|
value));
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now that the Bank has been selected, fall through to the
|
|
|
|
* region_field case and write the datum to the Operation Region
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*lint -fallthrough */
|
|
|
|
|
|
|
|
case ACPI_TYPE_LOCAL_REGION_FIELD:
|
|
|
|
/*
|
|
|
|
* For simple region_fields, we just directly access the owning
|
|
|
|
* Operation Region.
|
|
|
|
*/
|
2005-08-04 22:44:28 -06:00
|
|
|
status =
|
|
|
|
acpi_ex_access_region(obj_desc, field_datum_byte_offset,
|
|
|
|
value, read_write);
|
2005-04-16 16:20:36 -06:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ACPI_TYPE_LOCAL_INDEX_FIELD:
|
2005-04-18 20:49:35 -06:00
|
|
|
/*
|
|
|
|
* Ensure that the index_value is not beyond the capacity of
|
|
|
|
* the register
|
|
|
|
*/
|
2005-08-04 22:44:28 -06:00
|
|
|
if (acpi_ex_register_overflow(obj_desc->index_field.index_obj,
|
2010-01-20 19:06:32 -07:00
|
|
|
(u64) obj_desc->index_field.
|
|
|
|
value)) {
|
2005-08-04 22:44:28 -06:00
|
|
|
return_ACPI_STATUS(AE_AML_REGISTER_LIMIT);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Write the index value to the index_register (itself a region_field) */
|
|
|
|
|
|
|
|
field_datum_byte_offset += obj_desc->index_field.value;
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
|
|
|
|
"Write to Index Register: Value %8.8X\n",
|
|
|
|
field_datum_byte_offset));
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
status =
|
|
|
|
acpi_ex_insert_into_field(obj_desc->index_field.index_obj,
|
|
|
|
&field_datum_byte_offset,
|
|
|
|
sizeof(field_datum_byte_offset));
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
if (read_write == ACPI_READ) {
|
2006-10-01 22:00:00 -06:00
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
/* Read the datum from the data_register */
|
|
|
|
|
2008-11-12 00:16:49 -07:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
|
|
|
|
"Read from Data Register\n"));
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
status =
|
|
|
|
acpi_ex_extract_from_field(obj_desc->index_field.
|
|
|
|
data_obj, value,
|
2010-01-20 19:06:32 -07:00
|
|
|
sizeof(u64));
|
2005-08-04 22:44:28 -06:00
|
|
|
} else {
|
2005-04-16 16:20:36 -06:00
|
|
|
/* Write the datum to the data_register */
|
|
|
|
|
2008-11-12 00:16:49 -07:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
|
|
|
|
"Write to Data Register: Value %8.8X%8.8X\n",
|
|
|
|
ACPI_FORMAT_UINT64(*value)));
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
status =
|
|
|
|
acpi_ex_insert_into_field(obj_desc->index_field.
|
|
|
|
data_obj, value,
|
2010-01-20 19:06:32 -07:00
|
|
|
sizeof(u64));
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
2010-03-05 02:56:40 -07:00
|
|
|
ACPI_ERROR((AE_INFO, "Wrong object type in field I/O %u",
|
2009-02-17 23:44:03 -07:00
|
|
|
obj_desc->common.type));
|
2005-04-16 16:20:36 -06:00
|
|
|
status = AE_AML_INTERNAL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
if (ACPI_SUCCESS(status)) {
|
2005-04-16 16:20:36 -06:00
|
|
|
if (read_write == ACPI_READ) {
|
2005-08-04 22:44:28 -06:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
|
2010-05-25 21:47:13 -06:00
|
|
|
"Value Read %8.8X%8.8X, Width %u\n",
|
2005-08-04 22:44:28 -06:00
|
|
|
ACPI_FORMAT_UINT64(*value),
|
|
|
|
obj_desc->common_field.
|
|
|
|
access_byte_width));
|
|
|
|
} else {
|
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
|
2010-05-25 21:47:13 -06:00
|
|
|
"Value Written %8.8X%8.8X, Width %u\n",
|
2005-08-04 22:44:28 -06:00
|
|
|
ACPI_FORMAT_UINT64(*value),
|
|
|
|
obj_desc->common_field.
|
|
|
|
access_byte_width));
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ex_write_with_update_rule
|
|
|
|
*
|
2005-04-18 20:49:35 -06:00
|
|
|
* PARAMETERS: obj_desc - Field to be written
|
2012-07-11 19:40:10 -06:00
|
|
|
* mask - bitmask within field datum
|
2005-04-18 20:49:35 -06:00
|
|
|
* field_value - Value to write
|
|
|
|
* field_datum_byte_offset - Offset of datum within field
|
2005-04-16 16:20:36 -06:00
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Apply the field update rule to a field write
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
acpi_status
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_ex_write_with_update_rule(union acpi_operand_object *obj_desc,
|
2010-01-20 19:06:32 -07:00
|
|
|
u64 mask,
|
|
|
|
u64 field_value, u32 field_datum_byte_offset)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_status status = AE_OK;
|
2010-01-20 19:06:32 -07:00
|
|
|
u64 merged_value;
|
|
|
|
u64 current_value;
|
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_U32(ex_write_with_update_rule, mask);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* Start with the new bits */
|
|
|
|
|
|
|
|
merged_value = field_value;
|
|
|
|
|
|
|
|
/* If the mask is all ones, we don't need to worry about the update rule */
|
|
|
|
|
2010-01-20 19:06:32 -07:00
|
|
|
if (mask != ACPI_UINT64_MAX) {
|
2006-10-01 22:00:00 -06:00
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
/* Decode the update rule */
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
switch (obj_desc->common_field.
|
|
|
|
field_flags & AML_FIELD_UPDATE_RULE_MASK) {
|
2005-04-16 16:20:36 -06:00
|
|
|
case AML_FIELD_UPDATE_PRESERVE:
|
|
|
|
/*
|
|
|
|
* Check if update rule needs to be applied (not if mask is all
|
|
|
|
* ones) The left shift drops the bits we want to ignore.
|
|
|
|
*/
|
2005-08-04 22:44:28 -06:00
|
|
|
if ((~mask << (ACPI_MUL_8(sizeof(mask)) -
|
|
|
|
ACPI_MUL_8(obj_desc->common_field.
|
|
|
|
access_byte_width))) != 0) {
|
2005-04-16 16:20:36 -06:00
|
|
|
/*
|
|
|
|
* Read the current contents of the byte/word/dword containing
|
|
|
|
* the field, and merge with the new field value.
|
|
|
|
*/
|
2005-08-04 22:44:28 -06:00
|
|
|
status =
|
|
|
|
acpi_ex_field_datum_io(obj_desc,
|
|
|
|
field_datum_byte_offset,
|
|
|
|
¤t_value,
|
|
|
|
ACPI_READ);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
merged_value |= (current_value & ~mask);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AML_FIELD_UPDATE_WRITE_AS_ONES:
|
|
|
|
|
|
|
|
/* Set positions outside the field to all ones */
|
|
|
|
|
|
|
|
merged_value |= ~mask;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AML_FIELD_UPDATE_WRITE_AS_ZEROS:
|
|
|
|
|
|
|
|
/* Set positions outside the field to all zeros */
|
|
|
|
|
|
|
|
merged_value &= mask;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
2006-01-27 14:43:00 -07:00
|
|
|
ACPI_ERROR((AE_INFO,
|
2010-03-05 02:56:40 -07:00
|
|
|
"Unknown UpdateRule value: 0x%X",
|
2015-12-28 22:54:36 -07:00
|
|
|
(obj_desc->common_field.field_flags &
|
2006-01-27 14:43:00 -07:00
|
|
|
AML_FIELD_UPDATE_RULE_MASK)));
|
2005-08-04 22:44:28 -06:00
|
|
|
return_ACPI_STATUS(AE_AML_OPERAND_VALUE);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
|
2015-12-28 22:54:36 -07:00
|
|
|
"Mask %8.8X%8.8X, DatumOffset %X, Width %X, "
|
|
|
|
"Value %8.8X%8.8X, MergedValue %8.8X%8.8X\n",
|
2005-08-04 22:44:28 -06:00
|
|
|
ACPI_FORMAT_UINT64(mask),
|
|
|
|
field_datum_byte_offset,
|
|
|
|
obj_desc->common_field.access_byte_width,
|
|
|
|
ACPI_FORMAT_UINT64(field_value),
|
|
|
|
ACPI_FORMAT_UINT64(merged_value)));
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* Write the merged value */
|
|
|
|
|
2015-12-28 22:54:36 -07:00
|
|
|
status =
|
|
|
|
acpi_ex_field_datum_io(obj_desc, field_datum_byte_offset,
|
|
|
|
&merged_value, ACPI_WRITE);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ex_extract_from_field
|
|
|
|
*
|
|
|
|
* PARAMETERS: obj_desc - Field to be read
|
2012-07-11 19:40:10 -06:00
|
|
|
* buffer - Where to store the field data
|
2005-04-16 16:20:36 -06:00
|
|
|
* buffer_length - Length of Buffer
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Retrieve the current value of the given field
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
acpi_status
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_ex_extract_from_field(union acpi_operand_object *obj_desc,
|
|
|
|
void *buffer, u32 buffer_length)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_status status;
|
2010-01-20 19:06:32 -07:00
|
|
|
u64 raw_datum;
|
|
|
|
u64 merged_datum;
|
2005-08-04 22:44:28 -06:00
|
|
|
u32 field_offset = 0;
|
|
|
|
u32 buffer_offset = 0;
|
|
|
|
u32 buffer_tail_bits;
|
|
|
|
u32 datum_count;
|
|
|
|
u32 field_datum_count;
|
2010-08-05 19:09:33 -06:00
|
|
|
u32 access_bit_width;
|
2005-08-04 22:44:28 -06:00
|
|
|
u32 i;
|
|
|
|
|
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(ex_extract_from_field);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* Validate target buffer and clear it */
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
if (buffer_length <
|
|
|
|
ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->common_field.bit_length)) {
|
2006-01-27 14:43:00 -07:00
|
|
|
ACPI_ERROR((AE_INFO,
|
2010-03-05 02:56:40 -07:00
|
|
|
"Field size %u (bits) is too large for buffer (%u)",
|
2006-01-27 14:43:00 -07:00
|
|
|
obj_desc->common_field.bit_length, buffer_length));
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
return_ACPI_STATUS(AE_BUFFER_OVERFLOW);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
2010-08-05 19:09:33 -06:00
|
|
|
|
2015-07-01 00:45:11 -06:00
|
|
|
memset(buffer, 0, buffer_length);
|
2010-08-05 19:09:33 -06:00
|
|
|
access_bit_width = ACPI_MUL_8(obj_desc->common_field.access_byte_width);
|
|
|
|
|
|
|
|
/* Handle the simple case here */
|
|
|
|
|
|
|
|
if ((obj_desc->common_field.start_field_bit_offset == 0) &&
|
|
|
|
(obj_desc->common_field.bit_length == access_bit_width)) {
|
2013-05-07 22:01:15 -06:00
|
|
|
if (buffer_length >= sizeof(u64)) {
|
|
|
|
status =
|
|
|
|
acpi_ex_field_datum_io(obj_desc, 0, buffer,
|
|
|
|
ACPI_READ);
|
|
|
|
} else {
|
|
|
|
/* Use raw_datum (u64) to handle buffers < 64 bits */
|
|
|
|
|
|
|
|
status =
|
|
|
|
acpi_ex_field_datum_io(obj_desc, 0, &raw_datum,
|
|
|
|
ACPI_READ);
|
2015-07-01 00:45:11 -06:00
|
|
|
memcpy(buffer, &raw_datum, buffer_length);
|
2013-05-07 22:01:15 -06:00
|
|
|
}
|
|
|
|
|
2010-08-05 19:09:33 -06:00
|
|
|
return_ACPI_STATUS(status);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* TBD: Move to common setup code */
|
|
|
|
|
|
|
|
/* Field algorithm is limited to sizeof(u64), truncate if needed */
|
|
|
|
|
|
|
|
if (obj_desc->common_field.access_byte_width > sizeof(u64)) {
|
|
|
|
obj_desc->common_field.access_byte_width = sizeof(u64);
|
|
|
|
access_bit_width = sizeof(u64) * 8;
|
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* Compute the number of datums (access width data items) */
|
|
|
|
|
2010-08-05 19:09:33 -06:00
|
|
|
datum_count =
|
|
|
|
ACPI_ROUND_UP_TO(obj_desc->common_field.bit_length,
|
|
|
|
access_bit_width);
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
field_datum_count = ACPI_ROUND_UP_TO(obj_desc->common_field.bit_length +
|
|
|
|
obj_desc->common_field.
|
|
|
|
start_field_bit_offset,
|
|
|
|
access_bit_width);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* Priming read from the field */
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
status =
|
|
|
|
acpi_ex_field_datum_io(obj_desc, field_offset, &raw_datum,
|
|
|
|
ACPI_READ);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
2005-08-04 22:44:28 -06:00
|
|
|
merged_datum =
|
|
|
|
raw_datum >> obj_desc->common_field.start_field_bit_offset;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* Read the rest of the field */
|
|
|
|
|
|
|
|
for (i = 1; i < field_datum_count; i++) {
|
2006-10-01 22:00:00 -06:00
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
/* Get next input datum from the field */
|
|
|
|
|
|
|
|
field_offset += obj_desc->common_field.access_byte_width;
|
2015-12-28 22:54:36 -07:00
|
|
|
status =
|
|
|
|
acpi_ex_field_datum_io(obj_desc, field_offset, &raw_datum,
|
|
|
|
ACPI_READ);
|
2005-08-04 22:44:28 -06:00
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
2006-06-23 15:04:00 -06:00
|
|
|
/*
|
|
|
|
* Merge with previous datum if necessary.
|
|
|
|
*
|
|
|
|
* Note: Before the shift, check if the shift value will be larger than
|
|
|
|
* the integer size. If so, there is no need to perform the operation.
|
|
|
|
* This avoids the differences in behavior between different compilers
|
|
|
|
* concerning shift values larger than the target data width.
|
|
|
|
*/
|
2010-08-05 19:09:33 -06:00
|
|
|
if (access_bit_width -
|
|
|
|
obj_desc->common_field.start_field_bit_offset <
|
2006-06-23 15:04:00 -06:00
|
|
|
ACPI_INTEGER_BIT_SIZE) {
|
|
|
|
merged_datum |=
|
2010-08-05 19:09:33 -06:00
|
|
|
raw_datum << (access_bit_width -
|
2006-06-23 15:04:00 -06:00
|
|
|
obj_desc->common_field.
|
|
|
|
start_field_bit_offset);
|
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
if (i == datum_count) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Write merged datum to target buffer */
|
|
|
|
|
2015-07-01 00:45:11 -06:00
|
|
|
memcpy(((char *)buffer) + buffer_offset, &merged_datum,
|
|
|
|
ACPI_MIN(obj_desc->common_field.access_byte_width,
|
|
|
|
buffer_length - buffer_offset));
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
buffer_offset += obj_desc->common_field.access_byte_width;
|
2005-08-04 22:44:28 -06:00
|
|
|
merged_datum =
|
|
|
|
raw_datum >> obj_desc->common_field.start_field_bit_offset;
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Mask off any extra bits in the last datum */
|
|
|
|
|
2010-08-05 19:09:33 -06:00
|
|
|
buffer_tail_bits = obj_desc->common_field.bit_length % access_bit_width;
|
2005-04-16 16:20:36 -06:00
|
|
|
if (buffer_tail_bits) {
|
2005-08-04 22:44:28 -06:00
|
|
|
merged_datum &= ACPI_MASK_BITS_ABOVE(buffer_tail_bits);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Write the last datum to the buffer */
|
|
|
|
|
2015-07-01 00:45:11 -06:00
|
|
|
memcpy(((char *)buffer) + buffer_offset, &merged_datum,
|
|
|
|
ACPI_MIN(obj_desc->common_field.access_byte_width,
|
|
|
|
buffer_length - buffer_offset));
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ex_insert_into_field
|
|
|
|
*
|
|
|
|
* PARAMETERS: obj_desc - Field to be written
|
2012-07-11 19:40:10 -06:00
|
|
|
* buffer - Data to be written
|
2005-04-16 16:20:36 -06:00
|
|
|
* buffer_length - Length of Buffer
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Store the Buffer contents into the given field
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
acpi_status
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_ex_insert_into_field(union acpi_operand_object *obj_desc,
|
|
|
|
void *buffer, u32 buffer_length)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2010-08-05 19:09:33 -06:00
|
|
|
void *new_buffer;
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_status status;
|
2010-01-20 19:06:32 -07:00
|
|
|
u64 mask;
|
|
|
|
u64 width_mask;
|
|
|
|
u64 merged_datum;
|
|
|
|
u64 raw_datum = 0;
|
2005-08-04 22:44:28 -06:00
|
|
|
u32 field_offset = 0;
|
|
|
|
u32 buffer_offset = 0;
|
|
|
|
u32 buffer_tail_bits;
|
|
|
|
u32 datum_count;
|
|
|
|
u32 field_datum_count;
|
2010-08-05 19:09:33 -06:00
|
|
|
u32 access_bit_width;
|
2008-04-10 09:06:41 -06:00
|
|
|
u32 required_length;
|
2010-08-05 19:09:33 -06:00
|
|
|
u32 i;
|
2005-08-04 22:44:28 -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(ex_insert_into_field);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* Validate input buffer */
|
|
|
|
|
2008-04-10 09:06:41 -06:00
|
|
|
new_buffer = NULL;
|
|
|
|
required_length =
|
|
|
|
ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->common_field.bit_length);
|
2015-12-28 22:54:36 -07:00
|
|
|
|
2008-04-10 09:06:41 -06:00
|
|
|
/*
|
|
|
|
* We must have a buffer that is at least as long as the field
|
2012-10-30 20:26:55 -06:00
|
|
|
* we are writing to. This is because individual fields are
|
2008-04-10 09:06:41 -06:00
|
|
|
* indivisible and partial writes are not supported -- as per
|
|
|
|
* the ACPI specification.
|
|
|
|
*/
|
|
|
|
if (buffer_length < required_length) {
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2008-04-10 09:06:41 -06:00
|
|
|
/* We need to create a new buffer */
|
|
|
|
|
|
|
|
new_buffer = ACPI_ALLOCATE_ZEROED(required_length);
|
|
|
|
if (!new_buffer) {
|
|
|
|
return_ACPI_STATUS(AE_NO_MEMORY);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copy the original data to the new buffer, starting
|
2012-10-30 20:26:55 -06:00
|
|
|
* at Byte zero. All unused (upper) bytes of the
|
2008-04-10 09:06:41 -06:00
|
|
|
* buffer will be 0.
|
|
|
|
*/
|
2015-07-01 00:45:11 -06:00
|
|
|
memcpy((char *)new_buffer, (char *)buffer, buffer_length);
|
2008-04-10 09:06:41 -06:00
|
|
|
buffer = new_buffer;
|
|
|
|
buffer_length = required_length;
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
2010-08-05 19:09:33 -06:00
|
|
|
/* TBD: Move to common setup code */
|
|
|
|
|
|
|
|
/* Algo is limited to sizeof(u64), so cut the access_byte_width */
|
|
|
|
if (obj_desc->common_field.access_byte_width > sizeof(u64)) {
|
|
|
|
obj_desc->common_field.access_byte_width = sizeof(u64);
|
|
|
|
}
|
|
|
|
|
|
|
|
access_bit_width = ACPI_MUL_8(obj_desc->common_field.access_byte_width);
|
|
|
|
|
2016-05-04 22:58:45 -06:00
|
|
|
/* Create the bitmasks used for bit insertion */
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2016-05-04 22:58:45 -06:00
|
|
|
width_mask = ACPI_MASK_BITS_ABOVE_64(access_bit_width);
|
2006-06-23 15:04:00 -06:00
|
|
|
mask = width_mask &
|
|
|
|
ACPI_MASK_BITS_BELOW(obj_desc->common_field.start_field_bit_offset);
|
|
|
|
|
|
|
|
/* Compute the number of datums (access width data items) */
|
2006-05-26 14:36:00 -06:00
|
|
|
|
|
|
|
datum_count = ACPI_ROUND_UP_TO(obj_desc->common_field.bit_length,
|
2010-08-05 19:09:33 -06:00
|
|
|
access_bit_width);
|
2006-05-26 14:36:00 -06:00
|
|
|
|
|
|
|
field_datum_count = ACPI_ROUND_UP_TO(obj_desc->common_field.bit_length +
|
|
|
|
obj_desc->common_field.
|
|
|
|
start_field_bit_offset,
|
|
|
|
access_bit_width);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* Get initial Datum from the input buffer */
|
|
|
|
|
2015-07-01 00:45:11 -06:00
|
|
|
memcpy(&raw_datum, buffer,
|
|
|
|
ACPI_MIN(obj_desc->common_field.access_byte_width,
|
|
|
|
buffer_length - buffer_offset));
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
merged_datum =
|
|
|
|
raw_datum << obj_desc->common_field.start_field_bit_offset;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* Write the entire field */
|
|
|
|
|
|
|
|
for (i = 1; i < field_datum_count; i++) {
|
2006-10-01 22:00:00 -06:00
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
/* Write merged datum to the target field */
|
|
|
|
|
|
|
|
merged_datum &= mask;
|
2015-12-28 22:54:36 -07:00
|
|
|
status =
|
|
|
|
acpi_ex_write_with_update_rule(obj_desc, mask, merged_datum,
|
|
|
|
field_offset);
|
2005-08-04 22:44:28 -06:00
|
|
|
if (ACPI_FAILURE(status)) {
|
2008-04-10 09:06:41 -06:00
|
|
|
goto exit;
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
field_offset += obj_desc->common_field.access_byte_width;
|
2006-06-23 15:04:00 -06:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Start new output datum by merging with previous input datum
|
|
|
|
* if necessary.
|
|
|
|
*
|
|
|
|
* Note: Before the shift, check if the shift value will be larger than
|
|
|
|
* the integer size. If so, there is no need to perform the operation.
|
|
|
|
* This avoids the differences in behavior between different compilers
|
|
|
|
* concerning shift values larger than the target data width.
|
|
|
|
*/
|
2010-08-05 19:09:33 -06:00
|
|
|
if ((access_bit_width -
|
2006-06-23 15:04:00 -06:00
|
|
|
obj_desc->common_field.start_field_bit_offset) <
|
|
|
|
ACPI_INTEGER_BIT_SIZE) {
|
|
|
|
merged_datum =
|
2010-08-05 19:09:33 -06:00
|
|
|
raw_datum >> (access_bit_width -
|
2006-06-23 15:04:00 -06:00
|
|
|
obj_desc->common_field.
|
|
|
|
start_field_bit_offset);
|
|
|
|
} else {
|
|
|
|
merged_datum = 0;
|
|
|
|
}
|
|
|
|
|
2006-06-08 14:29:00 -06:00
|
|
|
mask = width_mask;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
if (i == datum_count) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the next input datum from the buffer */
|
|
|
|
|
|
|
|
buffer_offset += obj_desc->common_field.access_byte_width;
|
2015-07-01 00:45:11 -06:00
|
|
|
memcpy(&raw_datum, ((char *)buffer) + buffer_offset,
|
|
|
|
ACPI_MIN(obj_desc->common_field.access_byte_width,
|
|
|
|
buffer_length - buffer_offset));
|
2010-08-05 19:09:33 -06:00
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
merged_datum |=
|
|
|
|
raw_datum << obj_desc->common_field.start_field_bit_offset;
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Mask off any extra bits in the last datum */
|
|
|
|
|
|
|
|
buffer_tail_bits = (obj_desc->common_field.bit_length +
|
2005-08-04 22:44:28 -06:00
|
|
|
obj_desc->common_field.start_field_bit_offset) %
|
2010-08-05 19:09:33 -06:00
|
|
|
access_bit_width;
|
2005-04-16 16:20:36 -06:00
|
|
|
if (buffer_tail_bits) {
|
2005-08-04 22:44:28 -06:00
|
|
|
mask &= ACPI_MASK_BITS_ABOVE(buffer_tail_bits);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Write the last datum to the field */
|
|
|
|
|
|
|
|
merged_datum &= mask;
|
2015-12-28 22:54:36 -07:00
|
|
|
status =
|
|
|
|
acpi_ex_write_with_update_rule(obj_desc, mask, merged_datum,
|
|
|
|
field_offset);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2013-10-28 19:30:02 -06:00
|
|
|
exit:
|
2008-04-10 09:06:41 -06:00
|
|
|
/* Free temporary buffer if we used one */
|
|
|
|
|
|
|
|
if (new_buffer) {
|
|
|
|
ACPI_FREE(new_buffer);
|
|
|
|
}
|
2005-08-04 22:44:28 -06:00
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|