本文整理汇总了C++中ACPI_ROUND_BITS_UP_TO_BYTES函数的典型用法代码示例。如果您正苦于以下问题:C++ ACPI_ROUND_BITS_UP_TO_BYTES函数的具体用法?C++ ACPI_ROUND_BITS_UP_TO_BYTES怎么用?C++ ACPI_ROUND_BITS_UP_TO_BYTES使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ACPI_ROUND_BITS_UP_TO_BYTES函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: AcpiDbTestFieldUnitType
static ACPI_STATUS
AcpiDbTestFieldUnitType (
ACPI_OPERAND_OBJECT *ObjDesc)
{
ACPI_OPERAND_OBJECT *RegionObj;
UINT32 BitLength = 0;
UINT32 ByteLength = 0;
ACPI_STATUS Status = AE_OK;
ACPI_OPERAND_OBJECT *RetBufferDesc;
/* Supported spaces are memory/io/pci_config */
RegionObj = ObjDesc->Field.RegionObj;
switch (RegionObj->Region.SpaceId)
{
case ACPI_ADR_SPACE_SYSTEM_MEMORY:
case ACPI_ADR_SPACE_SYSTEM_IO:
case ACPI_ADR_SPACE_PCI_CONFIG:
/* Need the interpreter to execute */
AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER);
AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
/* Exercise read-then-write */
Status = AcpiExReadDataFromField (NULL, ObjDesc, &RetBufferDesc);
if (Status == AE_OK)
{
AcpiExWriteDataToField (RetBufferDesc, ObjDesc, NULL);
AcpiUtRemoveReference (RetBufferDesc);
}
AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER);
BitLength = ObjDesc->CommonField.BitLength;
ByteLength = ACPI_ROUND_BITS_UP_TO_BYTES (BitLength);
AcpiOsPrintf (ACPI_DEBUG_LENGTH_FORMAT " [%s]", BitLength,
ByteLength, AcpiUtGetRegionName (RegionObj->Region.SpaceId));
return (Status);
default:
AcpiOsPrintf (
" %s address space is not supported in this command [%4.4s]",
AcpiUtGetRegionName (RegionObj->Region.SpaceId),
RegionObj->Region.Node->Name.Ascii);
return (AE_OK);
}
}
开发者ID:ColinIanKing,项目名称:fwts,代码行数:53,代码来源:dbtest.c
示例2: AcpiDbTestIntegerType
static ACPI_STATUS
AcpiDbTestIntegerType (
ACPI_NAMESPACE_NODE *Node,
UINT32 BitLength)
{
ACPI_OBJECT *Temp1 = NULL;
ACPI_OBJECT *Temp2 = NULL;
ACPI_OBJECT *Temp3 = NULL;
ACPI_OBJECT WriteValue;
UINT64 ValueToWrite;
ACPI_STATUS Status;
if (BitLength > 64)
{
AcpiOsPrintf (" Invalid length for an Integer: %u", BitLength);
return (AE_OK);
}
/* Read the original value */
Status = AcpiDbReadFromObject (Node, ACPI_TYPE_INTEGER, &Temp1);
if (ACPI_FAILURE (Status))
{
return (Status);
}
AcpiOsPrintf (" (%4.4X/%3.3X) %8.8X%8.8X",
BitLength, ACPI_ROUND_BITS_UP_TO_BYTES (BitLength),
ACPI_FORMAT_UINT64 (Temp1->Integer.Value));
ValueToWrite = ACPI_UINT64_MAX >> (64 - BitLength);
if (Temp1->Integer.Value == ValueToWrite)
{
ValueToWrite = 0;
}
/* Write a new value */
WriteValue.Type = ACPI_TYPE_INTEGER;
WriteValue.Integer.Value = ValueToWrite;
Status = AcpiDbWriteToObject (Node, &WriteValue);
if (ACPI_FAILURE (Status))
{
goto Exit;
}
/* Ensure that we can read back the new value */
Status = AcpiDbReadFromObject (Node, ACPI_TYPE_INTEGER, &Temp2);
if (ACPI_FAILURE (Status))
{
goto Exit;
}
if (Temp2->Integer.Value != ValueToWrite)
{
AcpiOsPrintf (" MISMATCH 2: %8.8X%8.8X, expecting %8.8X%8.8X",
ACPI_FORMAT_UINT64 (Temp2->Integer.Value),
ACPI_FORMAT_UINT64 (ValueToWrite));
}
/* Write back the original value */
WriteValue.Integer.Value = Temp1->Integer.Value;
Status = AcpiDbWriteToObject (Node, &WriteValue);
if (ACPI_FAILURE (Status))
{
goto Exit;
}
/* Ensure that we can read back the original value */
Status = AcpiDbReadFromObject (Node, ACPI_TYPE_INTEGER, &Temp3);
if (ACPI_FAILURE (Status))
{
goto Exit;
}
if (Temp3->Integer.Value != Temp1->Integer.Value)
{
AcpiOsPrintf (" MISMATCH 3: %8.8X%8.8X, expecting %8.8X%8.8X",
ACPI_FORMAT_UINT64 (Temp3->Integer.Value),
ACPI_FORMAT_UINT64 (Temp1->Integer.Value));
}
Exit:
if (Temp1) {AcpiOsFree (Temp1);}
if (Temp2) {AcpiOsFree (Temp2);}
if (Temp3) {AcpiOsFree (Temp3);}
return (AE_OK);
}
开发者ID:fjdoria76,项目名称:acpica,代码行数:92,代码来源:dbtest.c
示例3: AcpiDbTestOneObject
static ACPI_STATUS
AcpiDbTestOneObject (
ACPI_HANDLE ObjHandle,
UINT32 NestingLevel,
void *Context,
void **ReturnValue)
{
ACPI_NAMESPACE_NODE *Node;
ACPI_OPERAND_OBJECT *ObjDesc;
ACPI_OPERAND_OBJECT *RegionObj;
ACPI_OBJECT_TYPE LocalType;
UINT32 BitLength = 0;
UINT32 ByteLength = 0;
ACPI_STATUS Status = AE_OK;
Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);
ObjDesc = Node->Object;
/*
* For the supported types, get the actual bit length or
* byte length. Map the type to one of Integer/String/Buffer.
*/
switch (Node->Type)
{
case ACPI_TYPE_INTEGER:
/* Integer width is either 32 or 64 */
LocalType = ACPI_TYPE_INTEGER;
BitLength = AcpiGbl_IntegerBitWidth;
break;
case ACPI_TYPE_STRING:
LocalType = ACPI_TYPE_STRING;
ByteLength = ObjDesc->String.Length;
break;
case ACPI_TYPE_BUFFER:
LocalType = ACPI_TYPE_BUFFER;
ByteLength = ObjDesc->Buffer.Length;
BitLength = ByteLength * 8;
break;
case ACPI_TYPE_FIELD_UNIT:
case ACPI_TYPE_BUFFER_FIELD:
case ACPI_TYPE_LOCAL_REGION_FIELD:
case ACPI_TYPE_LOCAL_INDEX_FIELD:
case ACPI_TYPE_LOCAL_BANK_FIELD:
LocalType = ACPI_TYPE_INTEGER;
if (ObjDesc)
{
/*
* Returned object will be a Buffer if the field length
* is larger than the size of an Integer (32 or 64 bits
* depending on the DSDT version).
*/
BitLength = ObjDesc->CommonField.BitLength;
ByteLength = ACPI_ROUND_BITS_UP_TO_BYTES (BitLength);
if (BitLength > AcpiGbl_IntegerBitWidth)
{
LocalType = ACPI_TYPE_BUFFER;
}
}
break;
default:
/* Ignore all other types */
return (AE_OK);
}
/* Emit the common prefix: Type:Name */
AcpiOsPrintf ("%14s: %4.4s",
AcpiUtGetTypeName (Node->Type), Node->Name.Ascii);
if (!ObjDesc)
{
AcpiOsPrintf (" Ignoring, no attached object\n");
return (AE_OK);
}
/*
* Check for unsupported region types. Note: AcpiExec simulates
* access to SystemMemory, SystemIO, PCI_Config, and EC.
*/
switch (Node->Type)
{
case ACPI_TYPE_LOCAL_REGION_FIELD:
RegionObj = ObjDesc->Field.RegionObj;
switch (RegionObj->Region.SpaceId)
{
case ACPI_ADR_SPACE_SYSTEM_MEMORY:
case ACPI_ADR_SPACE_SYSTEM_IO:
case ACPI_ADR_SPACE_PCI_CONFIG:
//.........这里部分代码省略.........
开发者ID:fjdoria76,项目名称:acpica,代码行数:101,代码来源:dbtest.c
示例4: AcpiExInsertIntoField
ACPI_STATUS
AcpiExInsertIntoField (
ACPI_OPERAND_OBJECT *ObjDesc,
void *Buffer,
UINT32 BufferLength)
{
void *NewBuffer;
ACPI_STATUS Status;
UINT64 Mask;
UINT64 WidthMask;
UINT64 MergedDatum;
UINT64 RawDatum = 0;
UINT32 FieldOffset = 0;
UINT32 BufferOffset = 0;
UINT32 BufferTailBits;
UINT32 DatumCount;
UINT32 FieldDatumCount;
UINT32 AccessBitWidth;
UINT32 RequiredLength;
UINT32 i;
ACPI_FUNCTION_TRACE (ExInsertIntoField);
/* Validate input buffer */
NewBuffer = NULL;
RequiredLength = ACPI_ROUND_BITS_UP_TO_BYTES (
ObjDesc->CommonField.BitLength);
/*
* We must have a buffer that is at least as long as the field
* we are writing to. This is because individual fields are
* indivisible and partial writes are not supported -- as per
* the ACPI specification.
*/
if (BufferLength < RequiredLength)
{
/* We need to create a new buffer */
NewBuffer = ACPI_ALLOCATE_ZEROED (RequiredLength);
if (!NewBuffer)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
/*
* Copy the original data to the new buffer, starting
* at Byte zero. All unused (upper) bytes of the
* buffer will be 0.
*/
memcpy ((char *) NewBuffer, (char *) Buffer, BufferLength);
Buffer = NewBuffer;
BufferLength = RequiredLength;
}
/* TBD: Move to common setup code */
/* Algo is limited to sizeof(UINT64), so cut the AccessByteWidth */
if (ObjDesc->CommonField.AccessByteWidth > sizeof (UINT64))
{
ObjDesc->CommonField.AccessByteWidth = sizeof (UINT64);
}
AccessBitWidth = ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth);
/*
* Create the bitmasks used for bit insertion.
* Note: This if/else is used to bypass compiler differences with the
* shift operator
*/
if (AccessBitWidth == ACPI_INTEGER_BIT_SIZE)
{
WidthMask = ACPI_UINT64_MAX;
}
else
{
WidthMask = ACPI_MASK_BITS_ABOVE (AccessBitWidth);
}
Mask = WidthMask &
ACPI_MASK_BITS_BELOW (ObjDesc->CommonField.StartFieldBitOffset);
/* Compute the number of datums (access width data items) */
DatumCount = ACPI_ROUND_UP_TO (ObjDesc->CommonField.BitLength,
AccessBitWidth);
FieldDatumCount = ACPI_ROUND_UP_TO (ObjDesc->CommonField.BitLength +
ObjDesc->CommonField.StartFieldBitOffset,
AccessBitWidth);
/* Get initial Datum from the input buffer */
memcpy (&RawDatum, Buffer,
ACPI_MIN(ObjDesc->CommonField.AccessByteWidth,
BufferLength - BufferOffset));
MergedDatum = RawDatum << ObjDesc->CommonField.StartFieldBitOffset;
//.........这里部分代码省略.........
开发者ID:yazshel,项目名称:netbsd-kernel,代码行数:101,代码来源:exfldio.c
示例5: acpi_ex_prep_field_value
acpi_status acpi_ex_prep_field_value(struct acpi_create_field_info *info)
{
union acpi_operand_object *obj_desc;
union acpi_operand_object *second_desc = NULL;
acpi_status status;
u32 access_byte_width;
u32 type;
ACPI_FUNCTION_TRACE(ex_prep_field_value);
/* */
if (info->field_type != ACPI_TYPE_LOCAL_INDEX_FIELD) {
if (!info->region_node) {
ACPI_ERROR((AE_INFO, "Null RegionNode"));
return_ACPI_STATUS(AE_AML_NO_OPERAND);
}
type = acpi_ns_get_type(info->region_node);
if (type != ACPI_TYPE_REGION) {
ACPI_ERROR((AE_INFO,
"Needed Region, found type 0x%X (%s)", type,
acpi_ut_get_type_name(type)));
return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
}
}
/* */
obj_desc = acpi_ut_create_internal_object(info->field_type);
if (!obj_desc) {
return_ACPI_STATUS(AE_NO_MEMORY);
}
/* */
obj_desc->common_field.node = info->field_node;
status = acpi_ex_prep_common_field_object(obj_desc,
info->field_flags,
info->attribute,
info->field_bit_position,
info->field_bit_length);
if (ACPI_FAILURE(status)) {
acpi_ut_delete_object_desc(obj_desc);
return_ACPI_STATUS(status);
}
/* */
switch (info->field_type) {
case ACPI_TYPE_LOCAL_REGION_FIELD:
obj_desc->field.region_obj =
acpi_ns_get_attached_object(info->region_node);
/* */
obj_desc->field.access_length = info->access_length;
if (info->connection_node) {
second_desc = info->connection_node->object;
if (!(second_desc->common.flags & AOPOBJ_DATA_VALID)) {
status =
acpi_ds_get_buffer_arguments(second_desc);
if (ACPI_FAILURE(status)) {
acpi_ut_delete_object_desc(obj_desc);
return_ACPI_STATUS(status);
}
}
obj_desc->field.resource_buffer =
second_desc->buffer.pointer;
obj_desc->field.resource_length =
(u16)second_desc->buffer.length;
} else if (info->resource_buffer) {
obj_desc->field.resource_buffer = info->resource_buffer;
obj_desc->field.resource_length = info->resource_length;
}
/* */
if ((obj_desc->field.region_obj->region.space_id ==
ACPI_ADR_SPACE_EC)
&& (obj_desc->common_field.bit_length > 8)) {
access_byte_width =
ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->common_field.
bit_length);
/* */
if (access_byte_width < 256) {
obj_desc->common_field.access_byte_width =
(u8)access_byte_width;
}
}
/* */
acpi_ut_add_reference(obj_desc->field.region_obj);
//.........这里部分代码省略.........
开发者ID:romanbb,项目名称:android_kernel_lge_d851,代码行数:101,代码来源:exprep.c
示例6: acpi_ex_extract_from_field
acpi_status
acpi_ex_extract_from_field (
union acpi_operand_object *obj_desc,
void *buffer,
u32 buffer_length)
{
acpi_status status;
u32 field_datum_byte_offset;
u32 datum_offset;
acpi_integer previous_raw_datum;
acpi_integer this_raw_datum = 0;
acpi_integer merged_datum = 0;
u32 byte_field_length;
u32 datum_count;
ACPI_FUNCTION_TRACE ("ex_extract_from_field");
/*
* The field must fit within the caller's buffer
*/
byte_field_length = ACPI_ROUND_BITS_UP_TO_BYTES (obj_desc->common_field.bit_length);
if (byte_field_length > buffer_length) {
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
"Field size %X (bytes) too large for buffer (%X)\n",
byte_field_length, buffer_length));
return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
}
/* Convert field byte count to datum count, round up if necessary */
datum_count = ACPI_ROUND_UP_TO (byte_field_length,
obj_desc->common_field.access_byte_width);
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
"byte_len %X, datum_len %X, byte_gran %X\n",
byte_field_length, datum_count,obj_desc->common_field.access_byte_width));
/*
* Clear the caller's buffer (the whole buffer length as given)
* This is very important, especially in the cases where a byte is read,
* but the buffer is really a u32 (4 bytes).
*/
ACPI_MEMSET (buffer, 0, buffer_length);
/* Read the first raw datum to prime the loop */
field_datum_byte_offset = 0;
datum_offset= 0;
status = acpi_ex_field_datum_io (obj_desc, field_datum_byte_offset,
&previous_raw_datum, ACPI_READ);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
/* We might actually be done if the request fits in one datum */
if ((datum_count == 1) &&
(obj_desc->common_field.flags & AOPOBJ_SINGLE_DATUM)) {
/* 1) Shift the valid data bits down to start at bit 0 */
merged_datum = (previous_raw_datum >> obj_desc->common_field.start_field_bit_offset);
/* 2) Mask off any upper unused bits (bits not part of the field) */
if (obj_desc->common_field.end_buffer_valid_bits) {
merged_datum &= ACPI_MASK_BITS_ABOVE (obj_desc->common_field.end_buffer_valid_bits);
}
/* Store the datum to the caller buffer */
acpi_ex_set_buffer_datum (merged_datum, buffer, buffer_length,
obj_desc->common_field.access_byte_width, datum_offset);
return_ACPI_STATUS (AE_OK);
}
开发者ID:iPodLinux,项目名称:linux-2.4.24-ipod,代码行数:80,代码来源:exfldio.c
示例7: acpi_ex_read_data_from_field
/*******************************************************************************
*
* FUNCTION: acpi_ex_read_data_from_field
*
* PARAMETERS: walk_state - Current execution state
* obj_desc - The named field
* ret_buffer_desc - Where the return data object is stored
*
* RETURN: Status
*
* DESCRIPTION: Read from a named field. Returns either an Integer or a
* Buffer, depending on the size of the field.
*
******************************************************************************/
acpi_status
acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state,
union acpi_operand_object *obj_desc,
union acpi_operand_object **ret_buffer_desc)
{
acpi_status status;
union acpi_operand_object *buffer_desc;
acpi_size length;
void *buffer;
ACPI_FUNCTION_TRACE_PTR(ex_read_data_from_field, obj_desc);
/* Parameter validation */
if (!obj_desc) {
return_ACPI_STATUS(AE_AML_NO_OPERAND);
}
if (!ret_buffer_desc) {
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
if (ACPI_GET_OBJECT_TYPE(obj_desc) == 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)) {
status = acpi_ds_get_buffer_field_arguments(obj_desc);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
}
} else
if ((ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_REGION_FIELD)
&& (obj_desc->field.region_obj->region.space_id ==
ACPI_ADR_SPACE_SMBUS)) {
/*
* This is an SMBus read. We must create a buffer to hold the data
* and directly access the region handler.
*/
buffer_desc =
acpi_ut_create_buffer_object(ACPI_SMBUS_BUFFER_SIZE);
if (!buffer_desc) {
return_ACPI_STATUS(AE_NO_MEMORY);
}
/* Lock entire transaction if requested */
acpi_ex_acquire_global_lock(obj_desc->common_field.field_flags);
/*
* Perform the read.
* Note: Smbus protocol value is passed in upper 16-bits of Function
*/
status = acpi_ex_access_region(obj_desc, 0,
ACPI_CAST_PTR(acpi_integer,
buffer_desc->
buffer.pointer),
ACPI_READ | (obj_desc->field.
attribute << 16));
acpi_ex_release_global_lock(obj_desc->common_field.field_flags);
goto exit;
}
/*
* Allocate a buffer for the contents of the field.
*
* If the field is larger than the size of an acpi_integer, create
* a BUFFER to hold it. Otherwise, use an INTEGER. This allows
* the use of arithmetic operators on the returned value if the
* field size is equal or smaller than an Integer.
*
* Note: Field.length is in bits.
*/
length =
(acpi_size) ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->field.bit_length);
if (length > acpi_gbl_integer_byte_width) {
/* Field is too large for an Integer, create a Buffer instead */
buffer_desc = acpi_ut_create_buffer_object(length);
if (!buffer_desc) {
return_ACPI_STATUS(AE_NO_MEMORY);
}
buffer = buffer_desc->buffer.pointer;
} else {
//.........这里部分代码省略.........
开发者ID:10x-Amin,项目名称:x10_Th_kernel,代码行数:101,代码来源:exfield.c
示例8: acpi_ex_insert_into_field
acpi_status
acpi_ex_insert_into_field (
union acpi_operand_object *obj_desc,
void *buffer,
u32 buffer_length)
{
acpi_status status;
acpi_integer mask;
acpi_integer merged_datum;
acpi_integer raw_datum = 0;
u32 field_offset = 0;
u32 buffer_offset = 0;
u32 buffer_tail_bits;
u32 datum_count;
u32 field_datum_count;
u32 i;
ACPI_FUNCTION_TRACE ("ex_insert_into_field");
/* Validate input buffer */
if (buffer_length < ACPI_ROUND_BITS_UP_TO_BYTES (
obj_desc->common_field.bit_length)) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Field size %X (bits) is too large for buffer (%X)\n",
obj_desc->common_field.bit_length, buffer_length));
return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
}
/* Compute the number of datums (access width data items) */
mask = ACPI_MASK_BITS_BELOW (obj_desc->common_field.start_field_bit_offset);
datum_count = ACPI_ROUND_UP_TO (obj_desc->common_field.bit_length,
obj_desc->common_field.access_bit_width);
field_datum_count = ACPI_ROUND_UP_TO (obj_desc->common_field.bit_length +
obj_desc->common_field.start_field_bit_offset,
obj_desc->common_field.access_bit_width);
/* Get initial Datum from the input buffer */
ACPI_MEMCPY (&raw_datum, buffer,
ACPI_MIN(obj_desc->common_field.access_byte_width,
buffer_length - buffer_offset));
merged_datum = raw_datum << obj_desc->common_field.start_field_bit_offset;
/* Write the entire field */
for (i = 1; i < field_datum_count; i++) {
/* Write merged datum to the target field */
merged_datum &= mask;
status = acpi_ex_write_with_update_rule (obj_desc, mask, merged_datum, field_offset);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
/* Start new output datum by merging with previous input datum */
field_offset += obj_desc->common_field.access_byte_width;
merged_datum = raw_datum >>
(obj_desc->common_field.access_bit_width - obj_desc->common_field.start_field_bit_offset);
mask = ACPI_INTEGER_MAX;
if (i == datum_count) {
break;
}
/* Get the next input datum from the buffer */
buffer_offset += obj_desc->common_field.access_byte_width;
ACPI_MEMCPY (&raw_datum, ((char *) buffer) + buffer_offset,
ACPI_MIN(obj_desc->common_field.access_byte_width,
buffer_length - buffer_offset));
merged_datum |= raw_datum << obj_desc->common_field.start_field_bit_offset;
}
/* Mask off any extra bits in the last datum */
buffer_tail_bits = (obj_desc->common_field.bit_length +
obj_desc->common_field.start_field_bit_offset) % obj_desc->common_field.access_bit_width;
if (buffer_tail_bits) {
mask &= ACPI_MASK_BITS_ABOVE (buffer_tail_bits);
}
/* Write the last datum to the field */
merged_datum &= mask;
status = acpi_ex_write_with_update_rule (obj_desc, mask, merged_datum, field_offset);
return_ACPI_STATUS (status);
}
开发者ID:Antonio-Zhou,项目名称:Linux-2.6.11,代码行数:95,代码来源:exfldio.c
示例9: acpi_ex_write_data_to_field
//.........这里部分代码省略.........
buffer = buffer_desc->buffer.pointer;
ACPI_MEMCPY (buffer, source_desc->buffer.pointer, ACPI_SMBUS_BUFFER_SIZE);
/* Lock entire transaction if requested */
locked = acpi_ex_acquire_global_lock (obj_desc->common_field.field_flags);
/*
* Perform the write (returns status and perhaps data in the same buffer)
* Note: SMBus protocol type is passed in upper 16-bits of Function.
*/
status = acpi_ex_access_region (obj_desc, 0,
(acpi_integer *) buffer,
ACPI_WRITE | (obj_desc->field.attribute << 16));
acpi_ex_release_global_lock (locked);
*result_desc = buffer_desc;
return_ACPI_STATUS (status);
}
/*
* Get a pointer to the data to be written
*/
switch (ACPI_GET_OBJECT_TYPE (source_desc)) {
case ACPI_TYPE_INTEGER:
buffer = &source_desc->integer.value;
length = sizeof (source_desc->integer.value);
break;
case ACPI_TYPE_BUFFER:
buffer = source_desc->buffer.pointer;
length = source_desc->buffer.length;
break;
case ACPI_TYPE_STRING:
buffer = source_desc->string.pointer;
length = source_desc->string.length;
break;
default:
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
/*
* We must have a buffer that is at least as long as the field
* we are writing to. This is because individual fields are
* indivisible and partial writes are not supported -- as per
* the ACPI specification.
*/
new_buffer = NULL;
required_length = ACPI_ROUND_BITS_UP_TO_BYTES (obj_desc->common_field.bit_length);
if (length < required_length) {
/* We need to create a new buffer */
new_buffer = ACPI_MEM_CALLOCATE (required_length);
if (!new_buffer) {
return_ACPI_STATUS (AE_NO_MEMORY);
}
/*
* Copy the original data to the new buffer, starting
* at Byte zero. All unused (upper) bytes of the
* buffer will be 0.
*/
ACPI_MEMCPY ((char *) new_buffer, (char *) buffer, length);
buffer = new_buffer;
length = required_length;
}
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
"field_write [FROM]: Obj %p (%s:%X), Buf %p, byte_len %X\n",
source_desc, acpi_ut_get_type_name (ACPI_GET_OBJECT_TYPE (source_desc)),
ACPI_GET_OBJECT_TYPE (source_desc), buffer, length));
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
"field_write [TO]: Obj %p (%s:%X), bit_len %X, bit_off %X, byte_off %X\n",
obj_desc, acpi_ut_get_type_name (ACPI_GET_OBJECT_TYPE (obj_desc)),
ACPI_GET_OBJECT_TYPE (obj_desc),
obj_desc->common_field.bit_length,
obj_desc->common_field.start_field_bit_offset,
obj_desc->common_field.base_byte_offset));
/* Lock entire transaction if requested */
locked = acpi_ex_acquire_global_lock (obj_desc->common_field.field_flags);
/* Write to the field */
status = acpi_ex_insert_into_field (obj_desc, buffer, length);
acpi_ex_release_global_lock (locked);
/* Free temporary buffer if we used one */
if (new_buffer) {
ACPI_MEM_FREE (new_buffer);
}
return_ACPI_STATUS (status);
}
开发者ID:Brainiarc7,项目名称:ralink_sdk,代码行数:101,代码来源:exfield.c
示例10: acpi_ex_read_data_from_field
acpi_status
acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state,
union acpi_operand_object *obj_desc,
union acpi_operand_object **ret_buffer_desc)
{
acpi_status status;
union acpi_operand_object *buffer_desc;
acpi_size length;
void *buffer;
u32 function;
ACPI_FUNCTION_TRACE_PTR(ex_read_data_from_field, obj_desc);
if (!obj_desc) {
return_ACPI_STATUS(AE_AML_NO_OPERAND);
}
if (!ret_buffer_desc) {
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
if (obj_desc->common.type == ACPI_TYPE_BUFFER_FIELD) {
if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) {
status = acpi_ds_get_buffer_field_arguments(obj_desc);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
}
} else if ((obj_desc->common.type == ACPI_TYPE_LOCAL_REGION_FIELD) &&
(obj_desc->field.region_obj->region.space_id ==
ACPI_ADR_SPACE_SMBUS
|| obj_desc->field.region_obj->region.space_id ==
ACPI_ADR_SPACE_GSBUS
|| obj_desc->field.region_obj->region.space_id ==
ACPI_ADR_SPACE_IPMI)) {
if (obj_desc->field.region_obj->region.space_id ==
ACPI_ADR_SPACE_SMBUS) {
length = ACPI_SMBUS_BUFFER_SIZE;
function =
ACPI_READ | (obj_desc->field.attribute << 16);
} else if (obj_desc->field.region_obj->region.space_id ==
ACPI_ADR_SPACE_GSBUS) {
length = ACPI_GSBUS_BUFFER_SIZE;
function =
ACPI_READ | (obj_desc->field.attribute << 16);
} else {
length = ACPI_IPMI_BUFFER_SIZE;
function = ACPI_READ;
}
buffer_desc = acpi_ut_create_buffer_object(length);
if (!buffer_desc) {
return_ACPI_STATUS(AE_NO_MEMORY);
}
acpi_ex_acquire_global_lock(obj_desc->common_field.field_flags);
status = acpi_ex_access_region(obj_desc, 0,
ACPI_CAST_PTR(u64,
buffer_desc->
buffer.pointer),
function);
acpi_ex_release_global_lock(obj_desc->common_field.field_flags);
goto exit;
}
length =
(acpi_size) ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->field.bit_length);
if (length > acpi_gbl_integer_byte_width) {
buffer_desc = acpi_ut_create_buffer_object(length);
if (!buffer_desc) {
return_ACPI_STATUS(AE_NO_MEMORY);
}
buffer = buffer_desc->buffer.pointer;
} else {
buffer_desc = acpi_ut_create_integer_object((u64) 0);
if (!buffer_desc) {
return_ACPI_STATUS(AE_NO_MEMORY);
}
length = acpi_gbl_integer_byte_width;
buffer = &buffer_desc->integer.value;
}
ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
"FieldRead [TO]: Obj %p, Type %X, Buf %p, ByteLen %X\n",
obj_desc, obj_desc->common.type, buffer,
(u32) length));
ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
//.........这里部分代码省略.........
开发者ID:DirtyDroidX,项目名称:android_kernel_htc_m8ul,代码行数:101,代码来源:exfield.c
示例11: acpi_ex_extract_from_field
acpi_status
acpi_ex_extract_from_field(union acpi_operand_object *obj_desc,
void *buffer, u32 buffer_length)
{
acpi_status status;
u64 raw_datum;
u64 merged_datum;
u32 field_offset = 0;
u32 buffer_offset = 0;
u32 buffer_tail_bits;
u32 datum_count;
u32 field_datum_count;
u32 access_bit_width;
u32 i;
ACPI_FUNCTION_TRACE(ex_extract_from_field);
/* Validate target buffer and clear it */
if (buffer_length <
ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->common_field.bit_length)) {
ACPI_ERROR((AE_INFO,
"Field size %u (bits) is too large for buffer (%u)",
obj_desc->common_field.bit_length, buffer_length));
return_ACPI_STATUS(AE_BUFFER_OVERFLOW);
}
ACPI_MEMSET(buffer, 0, buffer_length);
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)) {
status = acpi_ex_field_datum_io(obj_desc, 0, buffer, ACPI_READ);
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;
}
/* Compute the number of datums (access width data items) */
datum_count =
ACPI_ROUND_UP_TO(obj_desc->common_field.bit_length,
access_bit_width);
field_datum_count = ACPI_ROUND_UP_TO(obj_desc->common_field.bit_length +
obj_desc->common_field.
start_field_bit_offset,
access_bit_width);
/* Priming read from the field */
status =
acpi_ex_field_datum_io(obj_desc, field_offset, &raw_datum,
ACPI_READ);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
merged_datum =
raw_datum >> obj_desc->common_field.start_field_bit_offset;
/* Read the rest of the field */
for (i = 1; i < field_datum_count; i++) {
/* Get next input datum from the field */
field_offset += obj_desc->common_field.access_byte_width;
status = acpi_ex_field_datum_io(obj_desc, field_offset,
&raw_datum, ACPI_READ);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/*
* 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.
*/
if (access_bit_width -
obj_desc->common_field.start_field_bit_offset <
ACPI_INTEGER_BIT_SIZE) {
merged_datum |=
raw_datum << (access_bit_width -
obj_desc->common_field.
start_field_bit_offset);
}
//.........这里部分代码省略.........
开发者ID:AiWinters,项目名称:linux,代码行数:101,代码来源:exfldio.c
示例12: AcpiExReadDataFromField
ACPI_STATUS
AcpiExReadDataFromField (
ACPI_WALK_STATE *WalkState,
ACPI_OPERAND_OBJECT *ObjDesc,
ACPI_OPERAND_OBJECT **RetBufferDesc)
{
ACPI_STATUS Status;
ACPI_OPERAND_OBJECT *BufferDesc;
ACPI_SIZE Length;
void *Buffer;
UINT32 Function;
ACPI_FUNCTION_TRACE_PTR (ExReadDataFromField, ObjDesc);
/* Parameter validation */
if (!ObjDesc)
{
return_ACPI_STATUS (AE_AML_NO_OPERAND);
}
if (!RetBufferDesc)
{
return_ACPI_STATUS (AE_BAD_PARAMETER);
}
if (ObjDesc->Common.Type == ACPI_TYPE_BUFFER_FIELD)
{
/*
* If the BufferField arguments have not been previously evaluated,
* evaluate them now and save the results.
*/
if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID))
{
Status = AcpiDsGetBufferFieldArguments (ObjDesc);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
}
}
else if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REGION_FIELD) &&
(ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS ||
ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GSBUS ||
ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_IPMI))
{
/*
* This is an SMBus, GSBus or IPMI read. We must create a buffer to hold
* the data and then directly access the region handler.
*
* Note: SMBus and GSBus protocol value is passed in upper 16-bits of Function
*/
if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS)
{
Length = ACPI_SMBUS_BUFFER_SIZE;
Function = ACPI_READ | (ObjDesc->Field.Attribute << 16);
}
else if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GSBUS)
{
Length = ACPI_GSBUS_BUFFER_SIZE;
Function = ACPI_READ | (ObjDesc->Field.Attribute << 16);
}
else /* IPMI */
{
Length = ACPI_IPMI_BUFFER_SIZE;
Function = ACPI_READ;
}
BufferDesc = AcpiUtCreateBufferObject (Length);
if (!BufferDesc)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
/* Lock entire transaction if requested */
AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags);
/* Call the region handler for the read */
Status = AcpiExAccessRegion (ObjDesc, 0,
ACPI_CAST_PTR (UINT64, BufferDesc->Buffer.Pointer),
Function);
AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags);
goto Exit;
}
/*
* Allocate a buffer for the contents of the field.
*
* If the field is larger than the current integer width, create
* a BUFFER to hold it. Otherwise, use an INTEGER. This allows
* the use of arithmetic operators on the returned value if the
* field size is equal or smaller than an Integer.
*
* Note: Field.length is in bits.
*/
Length = (ACPI_SIZE) ACPI_ROUND_BITS_UP_TO_BYTES (ObjDesc->Field.BitLength);
if (Length > AcpiGbl_IntegerByteWidth)
//.........这里部分代码省略.........
开发者ID:ksashtekar,项目名称:Ganoid,代码行数:101,代码来源:exfield.c
示例13: acpi_ex_extract_from_field
acpi_status
acpi_ex_extract_from_field (
union acpi_operand_object *obj_desc,
void *buffer,
u32 buffer_length)
{
acpi_status status;
acpi_integer raw_datum;
acpi_integer merged_datum;
u32 field_offset = 0;
u32 buffer_offset = 0;
u32 buffer_tail_bits;
u32 datum_count;
u32 field_datum_count;
u32 i;
ACPI_FUNCTION_TRACE ("ex_extract_from_field");
/* Validate target buffer and clear it */
if (buffer_length < ACPI_ROUND_BITS_UP_TO_BYTES (
obj_desc->common_field.bit_length)) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Field size %X (bits) is too large for buffer (%X)\n",
obj_desc->common_field.bit_length, buffer_length));
return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
}
ACPI_MEMSET (buffer, 0, buffer_length);
/* Compute the number of datums (access width data items) */
datum_count = ACPI_ROUND_UP_TO (
obj_desc->common_field.bit_length,
obj_desc->common_field.access_bit_width);
field_datum_count = ACPI_ROUND_UP_TO (
obj_desc->common_field.bit_length +
obj_desc->common_field.start_field_bit_offset,
obj_desc->common_field.access_bit_width);
/* Priming read from the field */
status = acpi_ex_field_datum_io (obj_desc, field_offset, &raw_datum, ACPI_READ);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
merged_datum = raw_datum >> obj_desc->common_field.start_field_bit_offset;
/* Read the rest of the field */
for (i = 1; i < field_datum_count; i++) {
/* Get next input datum from the field */
field_offset += obj_desc->common_field.access_byte_width;
status = acpi_ex_field_datum_io (obj_desc, field_offset,
&raw_datum, ACPI_READ);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
/* Merge with previous datum if necessary */
merged_datum |= raw_datum <<
(obj_desc->common_field.access_bit_width - obj_desc->common_field.start_field_bit_offset);
if (i == datum_count) {
break;
}
/* Write merged datum to target buffer */
ACPI_MEMCPY (((char *) buffer) + buffer_offset, &merged_datum,
ACPI_MIN(obj_desc->common_field.access_byte_width,
buffer_length - buffer_offset));
buffer_offset += obj_desc->common_field.access_byte_width;
merged_datum = raw_datum >> obj_desc->common_field.start_field_bit_offset;
}
/* Mask off any extra bits in the last datum */
buffer_tail_bits = obj_desc->common_field.bit_length % obj_desc->common_field.access_bit_width;
if (buffer_tail_bits) {
merged_datum &= ACPI_MASK_BITS_ABOVE (buffer_tail_bits);
}
/* Write the last datum to the buffer */
ACPI_MEMCPY (((char *) buffer) + buffer_offset, &merged_datum,
ACPI_MIN(obj_desc->common_field.access_byte_width,
buffer_length - buffer_offset));
return_ACPI_STATUS (AE_OK);
}
开发者ID:Antonio-Zhou,项目名称:Linux-2.6.11,代码行数:96,代码来源:exfldio.c
示例14: acpi_ex_insert_into_field
acpi_status
acpi_ex_insert_into_field(union acpi_operand_object *obj_desc,
void *buffer, u32 buffer_length)
{
acpi_status status;
acpi_integer mask;
acpi_integer width_mask;
acpi_integer merged_datum;
acpi_integer raw_datum = 0;
u32 field_offset = 0;
u32 buffer_offset = 0;
u32 buffer_tail_bits;
u32 datum_count;
u32 field_datum_count;
u32 i;
ACPI_FUNCTION_TRACE(ex_insert_into_field);
/* Validate input buffer */
if (buffer_length <
ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->common_field.bit_length)) {
ACPI_ERROR((AE_INFO,
"Field size %X (bits) is too large for buffer (%X)",
obj_desc->common_field.bit_length, buffer_length));
return_ACPI_STATUS(AE_BUFFER_OVERFLOW);
}
/*
* Create the bitmasks used for bit insertion.
* Note: This if/else is used to bypass compiler differences with the
* shift operator
*/
if (obj_desc->common_field.access_bit_width == ACPI_INTEGER_BIT_SIZE) {
width_mask = ACPI_INTEGER_MAX;
} else {
width_mask =
ACPI_MASK_BITS_ABOVE(obj_desc->common_field.
access_bit_width);
}
mask = width_mask &
ACPI_MASK_BITS_BELOW(obj_desc->common_field.start_field_bit_offset);
/* Compute the number of datums (access width data items) */
datum_count = ACPI_ROUND_UP_TO(obj_desc->common_field.bit_length,
obj_desc->common_field.access_bit_width);
field_datum_count = ACPI_ROUND_UP_TO(obj_desc->common_field.bit_length +
obj_desc->common_field.
start_field_bit_offset,
obj_desc->common_field.
access_bit_width);
/* Get initial Datum from the input buffer */
ACPI_MEMCPY(&raw_datum, buffer,
ACPI_MIN(obj_desc->common_field.access_byte_width,
buffer_length - buffer_offset));
merged_datum =
raw_datum << obj_desc->common_field.start_field_bit_offset;
/* Write the entire field */
for (i = 1; i < field_datum_count; i++) {
/* Write merged datum to the target field */
merged_datum &= mask;
status = acpi_ex_write_with_update_rule(obj_desc, mask,
merged_datum,
field_offset);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
field_offset += obj_desc->common_field.access_byte_width;
/*
* 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.
*/
if ((obj_desc->common_field.access_bit_width -
obj_desc->common_field.start_field_bit_offset) <
ACPI_INTEGER_BIT_SIZE) {
merged_datum =
raw_datum >> (obj_desc->common_field.
access_bit_width -
obj_desc->common_field.
start_field_bit_offset);
} else {
开发者ID:3sOx,项目名称:asuswrt-merlin,代码行数:99,代码来源:exfldio.c
示例15: AcpiDbTestBufferType
static ACPI_STATUS
AcpiDbTestBufferType (
ACPI_NAMESPACE_NODE *Node,
UINT32 BitLength)
{
ACPI_OBJECT *Temp1 = NULL;
ACPI_OBJECT *Temp2 = NULL;
ACPI_OBJECT *Temp3 = NULL;
UINT8 *Buffer;
ACPI_OBJECT WriteValue;
ACPI_STATUS Status;
UINT32 ByteLength;
UINT32 i;
UINT8 ExtraBits;
ByteLength = ACPI_ROUND_BITS_UP_TO_BYTES (BitLength);
if (ByteLength == 0)
{
AcpiOsPrintf (" Ignoring zero length buffer");
return (AE_OK);
}
/* Allocate a local buffer */
Buffer = ACPI_ALLOCATE_ZEROED (ByteLength);
if (!Buffer)
{
return (AE_NO_MEMORY);
}
/* Read the original value */
Status = AcpiDbReadFromObject (Node, ACPI_TYPE_BUFFER, &Temp1);
if (ACPI_FAILURE (Status))
{
goto Exit;
}
/* Emit a few bytes of the buffer */
AcpiOsPrintf (" (%4.4X/%3.3X)", BitLength, Temp1->Buffer.Length);
for (i = 0; ((i < 4) && (i < ByteLength)); i++)
{
AcpiOsPrintf (" %2.2X", Temp1->Buffer.Pointer[i]);
}
AcpiOsPrintf ("... ");
/*
* Write a new value.
*
* Handle possible extra bits at the end of the buffer. Can
* happen for FieldUnits larger than an integer, but the bit
* count is not an integral number of bytes. Zero out the
* unused bits.
*/
memset (Buffer, BUFFER_FILL_VALUE, ByteLength);
ExtraBits = BitLength % 8;
if (ExtraBits)
{
Buffer [ByteLength - 1] = ACPI_MASK_BITS_ABOVE (ExtraBits);
}
WriteValue.Type = ACPI_TYPE_BUFFER;
WriteValue.Buffer.Length = ByteLength;
WriteValue.Buffer.Pointer = Buffer;
Status = AcpiDbWriteToObject (Node, &WriteValue);
if (ACPI_FAILURE (Status))
{
goto Exit;
}
/* Ensure that we can read back the new value */
Status = AcpiDbReadFromObject (Node, ACPI_TYPE_BUFFER, &Temp2);
if (ACPI_FAILURE (Status))
{
goto Exit;
}
if (memcmp (Temp2->Buffer.Pointer, Buffer, ByteLength))
{
AcpiOsPrintf (" MISMATCH 2: New buffer value");
}
/* Write back the original value */
WriteValue.Buffer.Length = ByteLength;
WriteValue.Buffer.Pointer = Temp1->Buffer.Pointer;
Status = AcpiDbWriteToObject (Node, &WriteValue);
if (ACPI_FAILURE (Status))
{
goto Exit;
}
/* Ensure that we can read back the original value */
Status = AcpiDbReadFrom
|
请发表评论