Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 1497 → Rev 1498

/drivers/devman/acpica/resources/rsaddr.c
0,0 → 1,479
/*******************************************************************************
*
* Module Name: rsaddr - Address resource descriptors (16/32/64)
*
******************************************************************************/
 
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* Code in any form, with the right to sublicense such rights; and
*
* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
* license (with the right to sublicense), under only those claims of Intel
* patents that are infringed by the Original Intel Code, to make, use, sell,
* offer to sell, and import the Covered Code and derivative works thereof
* solely to the minimum extent necessary to exercise the above copyright
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************/
 
#define __RSADDR_C__
 
#include "acpi.h"
#include "accommon.h"
#include "acresrc.h"
 
#define _COMPONENT ACPI_RESOURCES
ACPI_MODULE_NAME ("rsaddr")
 
 
/*******************************************************************************
*
* AcpiRsConvertAddress16 - All WORD (16-bit) address resources
*
******************************************************************************/
 
ACPI_RSCONVERT_INFO AcpiRsConvertAddress16[5] =
{
{ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS16,
ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS16),
ACPI_RSC_TABLE_SIZE (AcpiRsConvertAddress16)},
 
{ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS16,
sizeof (AML_RESOURCE_ADDRESS16),
0},
 
/* Resource Type, General Flags, and Type-Specific Flags */
 
{ACPI_RSC_ADDRESS, 0, 0, 0},
 
/*
* These fields are contiguous in both the source and destination:
* Address Granularity
* Address Range Minimum
* Address Range Maximum
* Address Translation Offset
* Address Length
*/
{ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.Address16.Granularity),
AML_OFFSET (Address16.Granularity),
5},
 
/* Optional ResourceSource (Index and String) */
 
{ACPI_RSC_SOURCE, ACPI_RS_OFFSET (Data.Address16.ResourceSource),
0,
sizeof (AML_RESOURCE_ADDRESS16)}
};
 
 
/*******************************************************************************
*
* AcpiRsConvertAddress32 - All DWORD (32-bit) address resources
*
******************************************************************************/
 
ACPI_RSCONVERT_INFO AcpiRsConvertAddress32[5] =
{
{ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS32,
ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS32),
ACPI_RSC_TABLE_SIZE (AcpiRsConvertAddress32)},
 
{ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS32,
sizeof (AML_RESOURCE_ADDRESS32),
0},
 
/* Resource Type, General Flags, and Type-Specific Flags */
 
{ACPI_RSC_ADDRESS, 0, 0, 0},
 
/*
* These fields are contiguous in both the source and destination:
* Address Granularity
* Address Range Minimum
* Address Range Maximum
* Address Translation Offset
* Address Length
*/
{ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.Address32.Granularity),
AML_OFFSET (Address32.Granularity),
5},
 
/* Optional ResourceSource (Index and String) */
 
{ACPI_RSC_SOURCE, ACPI_RS_OFFSET (Data.Address32.ResourceSource),
0,
sizeof (AML_RESOURCE_ADDRESS32)}
};
 
 
/*******************************************************************************
*
* AcpiRsConvertAddress64 - All QWORD (64-bit) address resources
*
******************************************************************************/
 
ACPI_RSCONVERT_INFO AcpiRsConvertAddress64[5] =
{
{ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS64,
ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS64),
ACPI_RSC_TABLE_SIZE (AcpiRsConvertAddress64)},
 
{ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS64,
sizeof (AML_RESOURCE_ADDRESS64),
0},
 
/* Resource Type, General Flags, and Type-Specific Flags */
 
{ACPI_RSC_ADDRESS, 0, 0, 0},
 
/*
* These fields are contiguous in both the source and destination:
* Address Granularity
* Address Range Minimum
* Address Range Maximum
* Address Translation Offset
* Address Length
*/
{ACPI_RSC_MOVE64, ACPI_RS_OFFSET (Data.Address64.Granularity),
AML_OFFSET (Address64.Granularity),
5},
 
/* Optional ResourceSource (Index and String) */
 
{ACPI_RSC_SOURCE, ACPI_RS_OFFSET (Data.Address64.ResourceSource),
0,
sizeof (AML_RESOURCE_ADDRESS64)}
};
 
 
/*******************************************************************************
*
* AcpiRsConvertExtAddress64 - All Extended (64-bit) address resources
*
******************************************************************************/
 
ACPI_RSCONVERT_INFO AcpiRsConvertExtAddress64[5] =
{
{ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64,
ACPI_RS_SIZE (ACPI_RESOURCE_EXTENDED_ADDRESS64),
ACPI_RSC_TABLE_SIZE (AcpiRsConvertExtAddress64)},
 
{ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64,
sizeof (AML_RESOURCE_EXTENDED_ADDRESS64),
0},
 
/* Resource Type, General Flags, and Type-Specific Flags */
 
{ACPI_RSC_ADDRESS, 0, 0, 0},
 
/* Revision ID */
 
{ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.ExtAddress64.RevisionID),
AML_OFFSET (ExtAddress64.RevisionID),
1},
/*
* These fields are contiguous in both the source and destination:
* Address Granularity
* Address Range Minimum
* Address Range Maximum
* Address Translation Offset
* Address Length
* Type-Specific Attribute
*/
{ACPI_RSC_MOVE64, ACPI_RS_OFFSET (Data.ExtAddress64.Granularity),
AML_OFFSET (ExtAddress64.Granularity),
6}
};
 
 
/*******************************************************************************
*
* AcpiRsConvertGeneralFlags - Flags common to all address descriptors
*
******************************************************************************/
 
static ACPI_RSCONVERT_INFO AcpiRsConvertGeneralFlags[6] =
{
{ACPI_RSC_FLAGINIT, 0, AML_OFFSET (Address.Flags),
ACPI_RSC_TABLE_SIZE (AcpiRsConvertGeneralFlags)},
 
/* Resource Type (Memory, Io, BusNumber, etc.) */
 
{ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Address.ResourceType),
AML_OFFSET (Address.ResourceType),
1},
 
/* General Flags - Consume, Decode, MinFixed, MaxFixed */
 
{ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.ProducerConsumer),
AML_OFFSET (Address.Flags),
0},
 
{ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Decode),
AML_OFFSET (Address.Flags),
1},
 
{ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.MinAddressFixed),
AML_OFFSET (Address.Flags),
2},
 
{ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.MaxAddressFixed),
AML_OFFSET (Address.Flags),
3}
};
 
 
/*******************************************************************************
*
* AcpiRsConvertMemFlags - Flags common to Memory address descriptors
*
******************************************************************************/
 
static ACPI_RSCONVERT_INFO AcpiRsConvertMemFlags[5] =
{
{ACPI_RSC_FLAGINIT, 0, AML_OFFSET (Address.SpecificFlags),
ACPI_RSC_TABLE_SIZE (AcpiRsConvertMemFlags)},
 
/* Memory-specific flags */
 
{ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.WriteProtect),
AML_OFFSET (Address.SpecificFlags),
0},
 
{ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.Caching),
AML_OFFSET (Address.SpecificFlags),
1},
 
{ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.RangeType),
AML_OFFSET (Address.SpecificFlags),
3},
 
{ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.Translation),
AML_OFFSET (Address.SpecificFlags),
5}
};
 
 
/*******************************************************************************
*
* AcpiRsConvertIoFlags - Flags common to I/O address descriptors
*
******************************************************************************/
 
static ACPI_RSCONVERT_INFO AcpiRsConvertIoFlags[4] =
{
{ACPI_RSC_FLAGINIT, 0, AML_OFFSET (Address.SpecificFlags),
ACPI_RSC_TABLE_SIZE (AcpiRsConvertIoFlags)},
 
/* I/O-specific flags */
 
{ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Io.RangeType),
AML_OFFSET (Address.SpecificFlags),
0},
 
{ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Io.Translation),
AML_OFFSET (Address.SpecificFlags),
4},
 
{ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Io.TranslationType),
AML_OFFSET (Address.SpecificFlags),
5}
};
 
 
/*******************************************************************************
*
* FUNCTION: AcpiRsGetAddressCommon
*
* PARAMETERS: Resource - Pointer to the internal resource struct
* Aml - Pointer to the AML resource descriptor
*
* RETURN: TRUE if the ResourceType field is OK, FALSE otherwise
*
* DESCRIPTION: Convert common flag fields from a raw AML resource descriptor
* to an internal resource descriptor
*
******************************************************************************/
 
BOOLEAN
AcpiRsGetAddressCommon (
ACPI_RESOURCE *Resource,
AML_RESOURCE *Aml)
{
ACPI_FUNCTION_ENTRY ();
 
 
/* Validate the Resource Type */
 
if ((Aml->Address.ResourceType > 2) && (Aml->Address.ResourceType < 0xC0))
{
return (FALSE);
}
 
/* Get the Resource Type and General Flags */
 
(void) AcpiRsConvertAmlToResource (Resource, Aml, AcpiRsConvertGeneralFlags);
 
/* Get the Type-Specific Flags (Memory and I/O descriptors only) */
 
if (Resource->Data.Address.ResourceType == ACPI_MEMORY_RANGE)
{
(void) AcpiRsConvertAmlToResource (Resource, Aml, AcpiRsConvertMemFlags);
}
else if (Resource->Data.Address.ResourceType == ACPI_IO_RANGE)
{
(void) AcpiRsConvertAmlToResource (Resource, Aml, AcpiRsConvertIoFlags);
}
else
{
/* Generic resource type, just grab the TypeSpecific byte */
 
Resource->Data.Address.Info.TypeSpecific = Aml->Address.SpecificFlags;
}
 
return (TRUE);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiRsSetAddressCommon
*
* PARAMETERS: Aml - Pointer to the AML resource descriptor
* Resource - Pointer to the internal resource struct
*
* RETURN: None
*
* DESCRIPTION: Convert common flag fields from a resource descriptor to an
* AML descriptor
*
******************************************************************************/
 
void
AcpiRsSetAddressCommon (
AML_RESOURCE *Aml,
ACPI_RESOURCE *Resource)
{
ACPI_FUNCTION_ENTRY ();
 
 
/* Set the Resource Type and General Flags */
 
(void) AcpiRsConvertResourceToAml (Resource, Aml, AcpiRsConvertGeneralFlags);
 
/* Set the Type-Specific Flags (Memory and I/O descriptors only) */
 
if (Resource->Data.Address.ResourceType == ACPI_MEMORY_RANGE)
{
(void) AcpiRsConvertResourceToAml (Resource, Aml, AcpiRsConvertMemFlags);
}
else if (Resource->Data.Address.ResourceType == ACPI_IO_RANGE)
{
(void) AcpiRsConvertResourceToAml (Resource, Aml, AcpiRsConvertIoFlags);
}
else
{
/* Generic resource type, just copy the TypeSpecific byte */
 
Aml->Address.SpecificFlags = Resource->Data.Address.Info.TypeSpecific;
}
}
 
 
/drivers/devman/acpica/resources/rscalc.c
0,0 → 1,745
/*******************************************************************************
*
* Module Name: rscalc - Calculate stream and list lengths
*
******************************************************************************/
 
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* Code in any form, with the right to sublicense such rights; and
*
* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
* license (with the right to sublicense), under only those claims of Intel
* patents that are infringed by the Original Intel Code, to make, use, sell,
* offer to sell, and import the Covered Code and derivative works thereof
* solely to the minimum extent necessary to exercise the above copyright
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************/
 
#define __RSCALC_C__
 
#include "acpi.h"
#include "accommon.h"
#include "acresrc.h"
#include "acnamesp.h"
 
 
#define _COMPONENT ACPI_RESOURCES
ACPI_MODULE_NAME ("rscalc")
 
 
/* Local prototypes */
 
static UINT8
AcpiRsCountSetBits (
UINT16 BitField);
 
static ACPI_RS_LENGTH
AcpiRsStructOptionLength (
ACPI_RESOURCE_SOURCE *ResourceSource);
 
static UINT32
AcpiRsStreamOptionLength (
UINT32 ResourceLength,
UINT32 MinimumTotalLength);
 
 
/*******************************************************************************
*
* FUNCTION: AcpiRsCountSetBits
*
* PARAMETERS: BitField - Field in which to count bits
*
* RETURN: Number of bits set within the field
*
* DESCRIPTION: Count the number of bits set in a resource field. Used for
* (Short descriptor) interrupt and DMA lists.
*
******************************************************************************/
 
static UINT8
AcpiRsCountSetBits (
UINT16 BitField)
{
UINT8 BitsSet;
 
 
ACPI_FUNCTION_ENTRY ();
 
 
for (BitsSet = 0; BitField; BitsSet++)
{
/* Zero the least significant bit that is set */
 
BitField &= (UINT16) (BitField - 1);
}
 
return (BitsSet);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiRsStructOptionLength
*
* PARAMETERS: ResourceSource - Pointer to optional descriptor field
*
* RETURN: Status
*
* DESCRIPTION: Common code to handle optional ResourceSourceIndex and
* ResourceSource fields in some Large descriptors. Used during
* list-to-stream conversion
*
******************************************************************************/
 
static ACPI_RS_LENGTH
AcpiRsStructOptionLength (
ACPI_RESOURCE_SOURCE *ResourceSource)
{
ACPI_FUNCTION_ENTRY ();
 
 
/*
* If the ResourceSource string is valid, return the size of the string
* (StringLength includes the NULL terminator) plus the size of the
* ResourceSourceIndex (1).
*/
if (ResourceSource->StringPtr)
{
return ((ACPI_RS_LENGTH) (ResourceSource->StringLength + 1));
}
 
return (0);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiRsStreamOptionLength
*
* PARAMETERS: ResourceLength - Length from the resource header
* MinimumTotalLength - Minimum length of this resource, before
* any optional fields. Includes header size
*
* RETURN: Length of optional string (0 if no string present)
*
* DESCRIPTION: Common code to handle optional ResourceSourceIndex and
* ResourceSource fields in some Large descriptors. Used during
* stream-to-list conversion
*
******************************************************************************/
 
static UINT32
AcpiRsStreamOptionLength (
UINT32 ResourceLength,
UINT32 MinimumAmlResourceLength)
{
UINT32 StringLength = 0;
 
 
ACPI_FUNCTION_ENTRY ();
 
 
/*
* The ResourceSourceIndex and ResourceSource are optional elements of some
* Large-type resource descriptors.
*/
 
/*
* If the length of the actual resource descriptor is greater than the ACPI
* spec-defined minimum length, it means that a ResourceSourceIndex exists
* and is followed by a (required) null terminated string. The string length
* (including the null terminator) is the resource length minus the minimum
* length, minus one byte for the ResourceSourceIndex itself.
*/
if (ResourceLength > MinimumAmlResourceLength)
{
/* Compute the length of the optional string */
 
StringLength = ResourceLength - MinimumAmlResourceLength - 1;
}
 
/*
* Round the length up to a multiple of the native word in order to
* guarantee that the entire resource descriptor is native word aligned
*/
return ((UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (StringLength));
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiRsGetAmlLength
*
* PARAMETERS: Resource - Pointer to the resource linked list
* SizeNeeded - Where the required size is returned
*
* RETURN: Status
*
* DESCRIPTION: Takes a linked list of internal resource descriptors and
* calculates the size buffer needed to hold the corresponding
* external resource byte stream.
*
******************************************************************************/
 
ACPI_STATUS
AcpiRsGetAmlLength (
ACPI_RESOURCE *Resource,
ACPI_SIZE *SizeNeeded)
{
ACPI_SIZE AmlSizeNeeded = 0;
ACPI_RS_LENGTH TotalSize;
 
 
ACPI_FUNCTION_TRACE (RsGetAmlLength);
 
 
/* Traverse entire list of internal resource descriptors */
 
while (Resource)
{
/* Validate the descriptor type */
 
if (Resource->Type > ACPI_RESOURCE_TYPE_MAX)
{
return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
}
 
/* Get the base size of the (external stream) resource descriptor */
 
TotalSize = AcpiGbl_AmlResourceSizes [Resource->Type];
 
/*
* Augment the base size for descriptors with optional and/or
* variable-length fields
*/
switch (Resource->Type)
{
case ACPI_RESOURCE_TYPE_IRQ:
 
/* Length can be 3 or 2 */
 
if (Resource->Data.Irq.DescriptorLength == 2)
{
TotalSize--;
}
break;
 
 
case ACPI_RESOURCE_TYPE_START_DEPENDENT:
 
/* Length can be 1 or 0 */
 
if (Resource->Data.Irq.DescriptorLength == 0)
{
TotalSize--;
}
break;
 
 
case ACPI_RESOURCE_TYPE_VENDOR:
/*
* Vendor Defined Resource:
* For a Vendor Specific resource, if the Length is between 1 and 7
* it will be created as a Small Resource data type, otherwise it
* is a Large Resource data type.
*/
if (Resource->Data.Vendor.ByteLength > 7)
{
/* Base size of a Large resource descriptor */
 
TotalSize = sizeof (AML_RESOURCE_LARGE_HEADER);
}
 
/* Add the size of the vendor-specific data */
 
TotalSize = (ACPI_RS_LENGTH)
(TotalSize + Resource->Data.Vendor.ByteLength);
break;
 
 
case ACPI_RESOURCE_TYPE_END_TAG:
/*
* End Tag:
* We are done -- return the accumulated total size.
*/
*SizeNeeded = AmlSizeNeeded + TotalSize;
 
/* Normal exit */
 
return_ACPI_STATUS (AE_OK);
 
 
case ACPI_RESOURCE_TYPE_ADDRESS16:
/*
* 16-Bit Address Resource:
* Add the size of the optional ResourceSource info
*/
TotalSize = (ACPI_RS_LENGTH)
(TotalSize + AcpiRsStructOptionLength (
&Resource->Data.Address16.ResourceSource));
break;
 
 
case ACPI_RESOURCE_TYPE_ADDRESS32:
/*
* 32-Bit Address Resource:
* Add the size of the optional ResourceSource info
*/
TotalSize = (ACPI_RS_LENGTH)
(TotalSize + AcpiRsStructOptionLength (
&Resource->Data.Address32.ResourceSource));
break;
 
 
case ACPI_RESOURCE_TYPE_ADDRESS64:
/*
* 64-Bit Address Resource:
* Add the size of the optional ResourceSource info
*/
TotalSize = (ACPI_RS_LENGTH)
(TotalSize + AcpiRsStructOptionLength (
&Resource->Data.Address64.ResourceSource));
break;
 
 
case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
/*
* Extended IRQ Resource:
* Add the size of each additional optional interrupt beyond the
* required 1 (4 bytes for each UINT32 interrupt number)
*/
TotalSize = (ACPI_RS_LENGTH)
(TotalSize +
((Resource->Data.ExtendedIrq.InterruptCount - 1) * 4) +
 
/* Add the size of the optional ResourceSource info */
 
AcpiRsStructOptionLength (
&Resource->Data.ExtendedIrq.ResourceSource));
break;
 
 
default:
break;
}
 
/* Update the total */
 
AmlSizeNeeded += TotalSize;
 
/* Point to the next object */
 
Resource = ACPI_ADD_PTR (ACPI_RESOURCE, Resource, Resource->Length);
}
 
/* Did not find an EndTag resource descriptor */
 
return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiRsGetListLength
*
* PARAMETERS: AmlBuffer - Pointer to the resource byte stream
* AmlBufferLength - Size of AmlBuffer
* SizeNeeded - Where the size needed is returned
*
* RETURN: Status
*
* DESCRIPTION: Takes an external resource byte stream and calculates the size
* buffer needed to hold the corresponding internal resource
* descriptor linked list.
*
******************************************************************************/
 
ACPI_STATUS
AcpiRsGetListLength (
UINT8 *AmlBuffer,
UINT32 AmlBufferLength,
ACPI_SIZE *SizeNeeded)
{
ACPI_STATUS Status;
UINT8 *EndAml;
UINT8 *Buffer;
UINT32 BufferSize;
UINT16 Temp16;
UINT16 ResourceLength;
UINT32 ExtraStructBytes;
UINT8 ResourceIndex;
UINT8 MinimumAmlResourceLength;
 
 
ACPI_FUNCTION_TRACE (RsGetListLength);
 
 
*SizeNeeded = 0;
EndAml = AmlBuffer + AmlBufferLength;
 
/* Walk the list of AML resource descriptors */
 
while (AmlBuffer < EndAml)
{
/* Validate the Resource Type and Resource Length */
 
Status = AcpiUtValidateResource (AmlBuffer, &ResourceIndex);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
 
/* Get the resource length and base (minimum) AML size */
 
ResourceLength = AcpiUtGetResourceLength (AmlBuffer);
MinimumAmlResourceLength = AcpiGbl_ResourceAmlSizes[ResourceIndex];
 
/*
* Augment the size for descriptors with optional
* and/or variable length fields
*/
ExtraStructBytes = 0;
Buffer = AmlBuffer + AcpiUtGetResourceHeaderLength (AmlBuffer);
 
switch (AcpiUtGetResourceType (AmlBuffer))
{
case ACPI_RESOURCE_NAME_IRQ:
/*
* IRQ Resource:
* Get the number of bits set in the 16-bit IRQ mask
*/
ACPI_MOVE_16_TO_16 (&Temp16, Buffer);
ExtraStructBytes = AcpiRsCountSetBits (Temp16);
break;
 
 
case ACPI_RESOURCE_NAME_DMA:
/*
* DMA Resource:
* Get the number of bits set in the 8-bit DMA mask
*/
ExtraStructBytes = AcpiRsCountSetBits (*Buffer);
break;
 
 
case ACPI_RESOURCE_NAME_VENDOR_SMALL:
case ACPI_RESOURCE_NAME_VENDOR_LARGE:
/*
* Vendor Resource:
* Get the number of vendor data bytes
*/
ExtraStructBytes = ResourceLength;
break;
 
 
case ACPI_RESOURCE_NAME_END_TAG:
/*
* End Tag:
* This is the normal exit, add size of EndTag
*/
*SizeNeeded += ACPI_RS_SIZE_MIN;
return_ACPI_STATUS (AE_OK);
 
 
case ACPI_RESOURCE_NAME_ADDRESS32:
case ACPI_RESOURCE_NAME_ADDRESS16:
case ACPI_RESOURCE_NAME_ADDRESS64:
/*
* Address Resource:
* Add the size of the optional ResourceSource
*/
ExtraStructBytes = AcpiRsStreamOptionLength (
ResourceLength, MinimumAmlResourceLength);
break;
 
 
case ACPI_RESOURCE_NAME_EXTENDED_IRQ:
/*
* Extended IRQ Resource:
* Using the InterruptTableLength, add 4 bytes for each additional
* interrupt. Note: at least one interrupt is required and is
* included in the minimum descriptor size (reason for the -1)
*/
ExtraStructBytes = (Buffer[1] - 1) * sizeof (UINT32);
 
/* Add the size of the optional ResourceSource */
 
ExtraStructBytes += AcpiRsStreamOptionLength (
ResourceLength - ExtraStructBytes, MinimumAmlResourceLength);
break;
 
 
default:
break;
}
 
/*
* Update the required buffer size for the internal descriptor structs
*
* Important: Round the size up for the appropriate alignment. This
* is a requirement on IA64.
*/
BufferSize = AcpiGbl_ResourceStructSizes[ResourceIndex] +
ExtraStructBytes;
BufferSize = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (BufferSize);
 
*SizeNeeded += BufferSize;
 
ACPI_DEBUG_PRINT ((ACPI_DB_RESOURCES,
"Type %.2X, AmlLength %.2X InternalLength %.2X\n",
AcpiUtGetResourceType (AmlBuffer),
AcpiUtGetDescriptorLength (AmlBuffer), BufferSize));
 
/*
* Point to the next resource within the AML stream using the length
* contained in the resource descriptor header
*/
AmlBuffer += AcpiUtGetDescriptorLength (AmlBuffer);
}
 
/* Did not find an EndTag resource descriptor */
 
return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiRsGetPciRoutingTableLength
*
* PARAMETERS: PackageObject - Pointer to the package object
* BufferSizeNeeded - UINT32 pointer of the size buffer
* needed to properly return the
* parsed data
*
* RETURN: Status
*
* DESCRIPTION: Given a package representing a PCI routing table, this
* calculates the size of the corresponding linked list of
* descriptions.
*
******************************************************************************/
 
ACPI_STATUS
AcpiRsGetPciRoutingTableLength (
ACPI_OPERAND_OBJECT *PackageObject,
ACPI_SIZE *BufferSizeNeeded)
{
UINT32 NumberOfElements;
ACPI_SIZE TempSizeNeeded = 0;
ACPI_OPERAND_OBJECT **TopObjectList;
UINT32 Index;
ACPI_OPERAND_OBJECT *PackageElement;
ACPI_OPERAND_OBJECT **SubObjectList;
BOOLEAN NameFound;
UINT32 TableIndex;
 
 
ACPI_FUNCTION_TRACE (RsGetPciRoutingTableLength);
 
 
NumberOfElements = PackageObject->Package.Count;
 
/*
* Calculate the size of the return buffer.
* The base size is the number of elements * the sizes of the
* structures. Additional space for the strings is added below.
* The minus one is to subtract the size of the UINT8 Source[1]
* member because it is added below.
*
* But each PRT_ENTRY structure has a pointer to a string and
* the size of that string must be found.
*/
TopObjectList = PackageObject->Package.Elements;
 
for (Index = 0; Index < NumberOfElements; Index++)
{
/* Dereference the sub-package */
 
PackageElement = *TopObjectList;
 
/* We must have a valid Package object */
 
if (!PackageElement ||
(PackageElement->Common.Type != ACPI_TYPE_PACKAGE))
{
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
 
/*
* The SubObjectList will now point to an array of the
* four IRQ elements: Address, Pin, Source and SourceIndex
*/
SubObjectList = PackageElement->Package.Elements;
 
/* Scan the IrqTableElements for the Source Name String */
 
NameFound = FALSE;
 
for (TableIndex = 0; TableIndex < 4 && !NameFound; TableIndex++)
{
if (*SubObjectList && /* Null object allowed */
 
((ACPI_TYPE_STRING ==
(*SubObjectList)->Common.Type) ||
 
((ACPI_TYPE_LOCAL_REFERENCE ==
(*SubObjectList)->Common.Type) &&
 
((*SubObjectList)->Reference.Class ==
ACPI_REFCLASS_NAME))))
{
NameFound = TRUE;
}
else
{
/* Look at the next element */
 
SubObjectList++;
}
}
 
TempSizeNeeded += (sizeof (ACPI_PCI_ROUTING_TABLE) - 4);
 
/* Was a String type found? */
 
if (NameFound)
{
if ((*SubObjectList)->Common.Type == ACPI_TYPE_STRING)
{
/*
* The length String.Length field does not include the
* terminating NULL, add 1
*/
TempSizeNeeded += ((ACPI_SIZE)
(*SubObjectList)->String.Length + 1);
}
else
{
TempSizeNeeded += AcpiNsGetPathnameLength (
(*SubObjectList)->Reference.Node);
}
}
else
{
/*
* If no name was found, then this is a NULL, which is
* translated as a UINT32 zero.
*/
TempSizeNeeded += sizeof (UINT32);
}
 
/* Round up the size since each element must be aligned */
 
TempSizeNeeded = ACPI_ROUND_UP_TO_64BIT (TempSizeNeeded);
 
/* Point to the next ACPI_OPERAND_OBJECT */
 
TopObjectList++;
}
 
/*
* Add an extra element to the end of the list, essentially a
* NULL terminator
*/
*BufferSizeNeeded = TempSizeNeeded + sizeof (ACPI_PCI_ROUTING_TABLE);
return_ACPI_STATUS (AE_OK);
}
/drivers/devman/acpica/resources/rscreate.c
0,0 → 1,533
/*******************************************************************************
*
* Module Name: rscreate - Create resource lists/tables
*
******************************************************************************/
 
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* Code in any form, with the right to sublicense such rights; and
*
* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
* license (with the right to sublicense), under only those claims of Intel
* patents that are infringed by the Original Intel Code, to make, use, sell,
* offer to sell, and import the Covered Code and derivative works thereof
* solely to the minimum extent necessary to exercise the above copyright
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************/
 
#define __RSCREATE_C__
 
#include "acpi.h"
#include "accommon.h"
#include "acresrc.h"
#include "acnamesp.h"
 
#define _COMPONENT ACPI_RESOURCES
ACPI_MODULE_NAME ("rscreate")
 
 
/*******************************************************************************
*
* FUNCTION: AcpiRsCreateResourceList
*
* PARAMETERS: AmlBuffer - Pointer to the resource byte stream
* OutputBuffer - Pointer to the user's buffer
*
* RETURN: Status: AE_OK if okay, else a valid ACPI_STATUS code
* If OutputBuffer is not large enough, OutputBufferLength
* indicates how large OutputBuffer should be, else it
* indicates how may UINT8 elements of OutputBuffer are valid.
*
* DESCRIPTION: Takes the byte stream returned from a _CRS, _PRS control method
* execution and parses the stream to create a linked list
* of device resources.
*
******************************************************************************/
 
ACPI_STATUS
AcpiRsCreateResourceList (
ACPI_OPERAND_OBJECT *AmlBuffer,
ACPI_BUFFER *OutputBuffer)
{
 
ACPI_STATUS Status;
UINT8 *AmlStart;
ACPI_SIZE ListSizeNeeded = 0;
UINT32 AmlBufferLength;
void *Resource;
 
 
ACPI_FUNCTION_TRACE (RsCreateResourceList);
 
 
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AmlBuffer = %p\n",
AmlBuffer));
 
/* Params already validated, so we don't re-validate here */
 
AmlBufferLength = AmlBuffer->Buffer.Length;
AmlStart = AmlBuffer->Buffer.Pointer;
 
/*
* Pass the AmlBuffer into a module that can calculate
* the buffer size needed for the linked list
*/
Status = AcpiRsGetListLength (AmlStart, AmlBufferLength,
&ListSizeNeeded);
 
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Status=%X ListSizeNeeded=%X\n",
Status, (UINT32) ListSizeNeeded));
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
 
/* Validate/Allocate/Clear caller buffer */
 
Status = AcpiUtInitializeBuffer (OutputBuffer, ListSizeNeeded);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
 
/* Do the conversion */
 
Resource = OutputBuffer->Pointer;
Status = AcpiUtWalkAmlResources (AmlStart, AmlBufferLength,
AcpiRsConvertAmlToResources, &Resource);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
 
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n",
OutputBuffer->Pointer, (UINT32) OutputBuffer->Length));
return_ACPI_STATUS (AE_OK);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiRsCreatePciRoutingTable
*
* PARAMETERS: PackageObject - Pointer to an ACPI_OPERAND_OBJECT
* package
* OutputBuffer - Pointer to the user's buffer
*
* RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code.
* If the OutputBuffer is too small, the error will be
* AE_BUFFER_OVERFLOW and OutputBuffer->Length will point
* to the size buffer needed.
*
* DESCRIPTION: Takes the ACPI_OPERAND_OBJECT package and creates a
* linked list of PCI interrupt descriptions
*
* NOTE: It is the caller's responsibility to ensure that the start of the
* output buffer is aligned properly (if necessary).
*
******************************************************************************/
 
ACPI_STATUS
AcpiRsCreatePciRoutingTable (
ACPI_OPERAND_OBJECT *PackageObject,
ACPI_BUFFER *OutputBuffer)
{
UINT8 *Buffer;
ACPI_OPERAND_OBJECT **TopObjectList;
ACPI_OPERAND_OBJECT **SubObjectList;
ACPI_OPERAND_OBJECT *ObjDesc;
ACPI_SIZE BufferSizeNeeded = 0;
UINT32 NumberOfElements;
UINT32 Index;
ACPI_PCI_ROUTING_TABLE *UserPrt;
ACPI_NAMESPACE_NODE *Node;
ACPI_STATUS Status;
ACPI_BUFFER PathBuffer;
 
 
ACPI_FUNCTION_TRACE (RsCreatePciRoutingTable);
 
 
/* Params already validated, so we don't re-validate here */
 
/* Get the required buffer length */
 
Status = AcpiRsGetPciRoutingTableLength (PackageObject,
&BufferSizeNeeded);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
 
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "BufferSizeNeeded = %X\n",
(UINT32) BufferSizeNeeded));
 
/* Validate/Allocate/Clear caller buffer */
 
Status = AcpiUtInitializeBuffer (OutputBuffer, BufferSizeNeeded);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
 
/*
* Loop through the ACPI_INTERNAL_OBJECTS - Each object should be a
* package that in turn contains an UINT64 Address, a UINT8 Pin,
* a Name, and a UINT8 SourceIndex.
*/
TopObjectList = PackageObject->Package.Elements;
NumberOfElements = PackageObject->Package.Count;
Buffer = OutputBuffer->Pointer;
UserPrt = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer);
 
for (Index = 0; Index < NumberOfElements; Index++)
{
/*
* Point UserPrt past this current structure
*
* NOTE: On the first iteration, UserPrt->Length will
* be zero because we cleared the return buffer earlier
*/
Buffer += UserPrt->Length;
UserPrt = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer);
 
/*
* Fill in the Length field with the information we have at this point.
* The minus four is to subtract the size of the UINT8 Source[4] member
* because it is added below.
*/
UserPrt->Length = (sizeof (ACPI_PCI_ROUTING_TABLE) - 4);
 
/* Each element of the top-level package must also be a package */
 
if ((*TopObjectList)->Common.Type != ACPI_TYPE_PACKAGE)
{
ACPI_ERROR ((AE_INFO,
"(PRT[%u]) Need sub-package, found %s",
Index, AcpiUtGetObjectTypeName (*TopObjectList)));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
 
/* Each sub-package must be of length 4 */
 
if ((*TopObjectList)->Package.Count != 4)
{
ACPI_ERROR ((AE_INFO,
"(PRT[%u]) Need package of length 4, found length %u",
Index, (*TopObjectList)->Package.Count));
return_ACPI_STATUS (AE_AML_PACKAGE_LIMIT);
}
 
/*
* Dereference the sub-package.
* The SubObjectList will now point to an array of the four IRQ
* elements: [Address, Pin, Source, SourceIndex]
*/
SubObjectList = (*TopObjectList)->Package.Elements;
 
/* 1) First subobject: Dereference the PRT.Address */
 
ObjDesc = SubObjectList[0];
if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER)
{
ACPI_ERROR ((AE_INFO, "(PRT[%u].Address) Need Integer, found %s",
Index, AcpiUtGetObjectTypeName (ObjDesc)));
return_ACPI_STATUS (AE_BAD_DATA);
}
 
UserPrt->Address = ObjDesc->Integer.Value;
 
/* 2) Second subobject: Dereference the PRT.Pin */
 
ObjDesc = SubObjectList[1];
if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER)
{
ACPI_ERROR ((AE_INFO, "(PRT[%u].Pin) Need Integer, found %s",
Index, AcpiUtGetObjectTypeName (ObjDesc)));
return_ACPI_STATUS (AE_BAD_DATA);
}
 
UserPrt->Pin = (UINT32) ObjDesc->Integer.Value;
 
/*
* If the BIOS has erroneously reversed the _PRT SourceName (index 2)
* and the SourceIndex (index 3), fix it. _PRT is important enough to
* workaround this BIOS error. This also provides compatibility with
* other ACPI implementations.
*/
ObjDesc = SubObjectList[3];
if (!ObjDesc || (ObjDesc->Common.Type != ACPI_TYPE_INTEGER))
{
SubObjectList[3] = SubObjectList[2];
SubObjectList[2] = ObjDesc;
 
ACPI_WARNING ((AE_INFO,
"(PRT[%X].Source) SourceName and SourceIndex are reversed, fixed",
Index));
}
 
/*
* 3) Third subobject: Dereference the PRT.SourceName
* The name may be unresolved (slack mode), so allow a null object
*/
ObjDesc = SubObjectList[2];
if (ObjDesc)
{
switch (ObjDesc->Common.Type)
{
case ACPI_TYPE_LOCAL_REFERENCE:
 
if (ObjDesc->Reference.Class != ACPI_REFCLASS_NAME)
{
ACPI_ERROR ((AE_INFO,
"(PRT[%u].Source) Need name, found Reference Class 0x%X",
Index, ObjDesc->Reference.Class));
return_ACPI_STATUS (AE_BAD_DATA);
}
 
Node = ObjDesc->Reference.Node;
 
/* Use *remaining* length of the buffer as max for pathname */
 
PathBuffer.Length = OutputBuffer->Length -
(UINT32) ((UINT8 *) UserPrt->Source -
(UINT8 *) OutputBuffer->Pointer);
PathBuffer.Pointer = UserPrt->Source;
 
Status = AcpiNsHandleToPathname ((ACPI_HANDLE) Node, &PathBuffer);
 
/* +1 to include null terminator */
 
UserPrt->Length += (UINT32) ACPI_STRLEN (UserPrt->Source) + 1;
break;
 
 
case ACPI_TYPE_STRING:
 
ACPI_STRCPY (UserPrt->Source, ObjDesc->String.Pointer);
 
/*
* Add to the Length field the length of the string
* (add 1 for terminator)
*/
UserPrt->Length += ObjDesc->String.Length + 1;
break;
 
 
case ACPI_TYPE_INTEGER:
/*
* If this is a number, then the Source Name is NULL, since the
* entire buffer was zeroed out, we can leave this alone.
*
* Add to the Length field the length of the UINT32 NULL
*/
UserPrt->Length += sizeof (UINT32);
break;
 
 
default:
 
ACPI_ERROR ((AE_INFO,
"(PRT[%u].Source) Need Ref/String/Integer, found %s",
Index, AcpiUtGetObjectTypeName (ObjDesc)));
return_ACPI_STATUS (AE_BAD_DATA);
}
}
 
/* Now align the current length */
 
UserPrt->Length = (UINT32) ACPI_ROUND_UP_TO_64BIT (UserPrt->Length);
 
/* 4) Fourth subobject: Dereference the PRT.SourceIndex */
 
ObjDesc = SubObjectList[3];
if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER)
{
ACPI_ERROR ((AE_INFO,
"(PRT[%u].SourceIndex) Need Integer, found %s",
Index, AcpiUtGetObjectTypeName (ObjDesc)));
return_ACPI_STATUS (AE_BAD_DATA);
}
 
UserPrt->SourceIndex = (UINT32) ObjDesc->Integer.Value;
 
/* Point to the next ACPI_OPERAND_OBJECT in the top level package */
 
TopObjectList++;
}
 
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n",
OutputBuffer->Pointer, (UINT32) OutputBuffer->Length));
return_ACPI_STATUS (AE_OK);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiRsCreateAmlResources
*
* PARAMETERS: LinkedListBuffer - Pointer to the resource linked list
* OutputBuffer - Pointer to the user's buffer
*
* RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code.
* If the OutputBuffer is too small, the error will be
* AE_BUFFER_OVERFLOW and OutputBuffer->Length will point
* to the size buffer needed.
*
* DESCRIPTION: Takes the linked list of device resources and
* creates a bytestream to be used as input for the
* _SRS control method.
*
******************************************************************************/
 
ACPI_STATUS
AcpiRsCreateAmlResources (
ACPI_RESOURCE *LinkedListBuffer,
ACPI_BUFFER *OutputBuffer)
{
ACPI_STATUS Status;
ACPI_SIZE AmlSizeNeeded = 0;
 
 
ACPI_FUNCTION_TRACE (RsCreateAmlResources);
 
 
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "LinkedListBuffer = %p\n",
LinkedListBuffer));
 
/*
* Params already validated, so we don't re-validate here
*
* Pass the LinkedListBuffer into a module that calculates
* the buffer size needed for the byte stream.
*/
Status = AcpiRsGetAmlLength (LinkedListBuffer,
&AmlSizeNeeded);
 
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AmlSizeNeeded=%X, %s\n",
(UINT32) AmlSizeNeeded, AcpiFormatException (Status)));
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
 
/* Validate/Allocate/Clear caller buffer */
 
Status = AcpiUtInitializeBuffer (OutputBuffer, AmlSizeNeeded);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
 
/* Do the conversion */
 
Status = AcpiRsConvertResourcesToAml (LinkedListBuffer, AmlSizeNeeded,
OutputBuffer->Pointer);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
 
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n",
OutputBuffer->Pointer, (UINT32) OutputBuffer->Length));
return_ACPI_STATUS (AE_OK);
}
 
/drivers/devman/acpica/resources/rsdump.c
0,0 → 1,872
/*******************************************************************************
*
* Module Name: rsdump - Functions to display the resource structures.
*
******************************************************************************/
 
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* Code in any form, with the right to sublicense such rights; and
*
* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
* license (with the right to sublicense), under only those claims of Intel
* patents that are infringed by the Original Intel Code, to make, use, sell,
* offer to sell, and import the Covered Code and derivative works thereof
* solely to the minimum extent necessary to exercise the above copyright
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************/
 
 
#define __RSDUMP_C__
 
#include "acpi.h"
#include "accommon.h"
#include "acresrc.h"
 
#define _COMPONENT ACPI_RESOURCES
ACPI_MODULE_NAME ("rsdump")
 
 
#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
 
/* Local prototypes */
 
static void
AcpiRsOutString (
char *Title,
char *Value);
 
static void
AcpiRsOutInteger8 (
char *Title,
UINT8 Value);
 
static void
AcpiRsOutInteger16 (
char *Title,
UINT16 Value);
 
static void
AcpiRsOutInteger32 (
char *Title,
UINT32 Value);
 
static void
AcpiRsOutInteger64 (
char *Title,
UINT64 Value);
 
static void
AcpiRsOutTitle (
char *Title);
 
static void
AcpiRsDumpByteList (
UINT16 Length,
UINT8 *Data);
 
static void
AcpiRsDumpDwordList (
UINT8 Length,
UINT32 *Data);
 
static void
AcpiRsDumpShortByteList (
UINT8 Length,
UINT8 *Data);
 
static void
AcpiRsDumpResourceSource (
ACPI_RESOURCE_SOURCE *ResourceSource);
 
static void
AcpiRsDumpAddressCommon (
ACPI_RESOURCE_DATA *Resource);
 
static void
AcpiRsDumpDescriptor (
void *Resource,
ACPI_RSDUMP_INFO *Table);
 
 
#define ACPI_RSD_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_RESOURCE_DATA,f)
#define ACPI_PRT_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_PCI_ROUTING_TABLE,f)
#define ACPI_RSD_TABLE_SIZE(name) (sizeof(name) / sizeof (ACPI_RSDUMP_INFO))
 
 
/*******************************************************************************
*
* Resource Descriptor info tables
*
* Note: The first table entry must be a Title or Literal and must contain
* the table length (number of table entries)
*
******************************************************************************/
 
ACPI_RSDUMP_INFO AcpiRsDumpIrq[7] =
{
{ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpIrq), "IRQ", NULL},
{ACPI_RSD_UINT8 , ACPI_RSD_OFFSET (Irq.DescriptorLength), "Descriptor Length", NULL},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Irq.Triggering), "Triggering", AcpiGbl_HeDecode},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Irq.Polarity), "Polarity", AcpiGbl_LlDecode},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Irq.Sharable), "Sharing", AcpiGbl_ShrDecode},
{ACPI_RSD_UINT8 , ACPI_RSD_OFFSET (Irq.InterruptCount), "Interrupt Count", NULL},
{ACPI_RSD_SHORTLIST,ACPI_RSD_OFFSET (Irq.Interrupts[0]), "Interrupt List", NULL}
};
 
ACPI_RSDUMP_INFO AcpiRsDumpDma[6] =
{
{ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpDma), "DMA", NULL},
{ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Dma.Type), "Speed", AcpiGbl_TypDecode},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Dma.BusMaster), "Mastering", AcpiGbl_BmDecode},
{ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Dma.Transfer), "Transfer Type", AcpiGbl_SizDecode},
{ACPI_RSD_UINT8, ACPI_RSD_OFFSET (Dma.ChannelCount), "Channel Count", NULL},
{ACPI_RSD_SHORTLIST,ACPI_RSD_OFFSET (Dma.Channels[0]), "Channel List", NULL}
};
 
ACPI_RSDUMP_INFO AcpiRsDumpStartDpf[4] =
{
{ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpStartDpf), "Start-Dependent-Functions",NULL},
{ACPI_RSD_UINT8 , ACPI_RSD_OFFSET (StartDpf.DescriptorLength), "Descriptor Length", NULL},
{ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (StartDpf.CompatibilityPriority), "Compatibility Priority", AcpiGbl_ConfigDecode},
{ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (StartDpf.PerformanceRobustness), "Performance/Robustness", AcpiGbl_ConfigDecode}
};
 
ACPI_RSDUMP_INFO AcpiRsDumpEndDpf[1] =
{
{ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpEndDpf), "End-Dependent-Functions", NULL}
};
 
ACPI_RSDUMP_INFO AcpiRsDumpIo[6] =
{
{ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpIo), "I/O", NULL},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Io.IoDecode), "Address Decoding", AcpiGbl_IoDecode},
{ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Io.Minimum), "Address Minimum", NULL},
{ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Io.Maximum), "Address Maximum", NULL},
{ACPI_RSD_UINT8, ACPI_RSD_OFFSET (Io.Alignment), "Alignment", NULL},
{ACPI_RSD_UINT8, ACPI_RSD_OFFSET (Io.AddressLength), "Address Length", NULL}
};
 
ACPI_RSDUMP_INFO AcpiRsDumpFixedIo[3] =
{
{ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpFixedIo), "Fixed I/O", NULL},
{ACPI_RSD_UINT16, ACPI_RSD_OFFSET (FixedIo.Address), "Address", NULL},
{ACPI_RSD_UINT8, ACPI_RSD_OFFSET (FixedIo.AddressLength), "Address Length", NULL}
};
 
ACPI_RSDUMP_INFO AcpiRsDumpVendor[3] =
{
{ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpVendor), "Vendor Specific", NULL},
{ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Vendor.ByteLength), "Length", NULL},
{ACPI_RSD_LONGLIST, ACPI_RSD_OFFSET (Vendor.ByteData[0]), "Vendor Data", NULL}
};
 
ACPI_RSDUMP_INFO AcpiRsDumpEndTag[1] =
{
{ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpEndTag), "EndTag", NULL}
};
 
ACPI_RSDUMP_INFO AcpiRsDumpMemory24[6] =
{
{ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpMemory24), "24-Bit Memory Range", NULL},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Memory24.WriteProtect), "Write Protect", AcpiGbl_RwDecode},
{ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Memory24.Minimum), "Address Minimum", NULL},
{ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Memory24.Maximum), "Address Maximum", NULL},
{ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Memory24.Alignment), "Alignment", NULL},
{ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Memory24.AddressLength), "Address Length", NULL}
};
 
ACPI_RSDUMP_INFO AcpiRsDumpMemory32[6] =
{
{ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpMemory32), "32-Bit Memory Range", NULL},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Memory32.WriteProtect), "Write Protect", AcpiGbl_RwDecode},
{ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Memory32.Minimum), "Address Minimum", NULL},
{ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Memory32.Maximum), "Address Maximum", NULL},
{ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Memory32.Alignment), "Alignment", NULL},
{ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Memory32.AddressLength), "Address Length", NULL}
};
 
ACPI_RSDUMP_INFO AcpiRsDumpFixedMemory32[4] =
{
{ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpFixedMemory32), "32-Bit Fixed Memory Range",NULL},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (FixedMemory32.WriteProtect), "Write Protect", AcpiGbl_RwDecode},
{ACPI_RSD_UINT32, ACPI_RSD_OFFSET (FixedMemory32.Address), "Address", NULL},
{ACPI_RSD_UINT32, ACPI_RSD_OFFSET (FixedMemory32.AddressLength), "Address Length", NULL}
};
 
ACPI_RSDUMP_INFO AcpiRsDumpAddress16[8] =
{
{ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpAddress16), "16-Bit WORD Address Space",NULL},
{ACPI_RSD_ADDRESS, 0, NULL, NULL},
{ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Address16.Granularity), "Granularity", NULL},
{ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Address16.Minimum), "Address Minimum", NULL},
{ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Address16.Maximum), "Address Maximum", NULL},
{ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Address16.TranslationOffset), "Translation Offset", NULL},
{ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Address16.AddressLength), "Address Length", NULL},
{ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (Address16.ResourceSource), NULL, NULL}
};
 
ACPI_RSDUMP_INFO AcpiRsDumpAddress32[8] =
{
{ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpAddress32), "32-Bit DWORD Address Space", NULL},
{ACPI_RSD_ADDRESS, 0, NULL, NULL},
{ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Address32.Granularity), "Granularity", NULL},
{ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Address32.Minimum), "Address Minimum", NULL},
{ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Address32.Maximum), "Address Maximum", NULL},
{ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Address32.TranslationOffset), "Translation Offset", NULL},
{ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Address32.AddressLength), "Address Length", NULL},
{ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (Address32.ResourceSource), NULL, NULL}
};
 
ACPI_RSDUMP_INFO AcpiRsDumpAddress64[8] =
{
{ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpAddress64), "64-Bit QWORD Address Space", NULL},
{ACPI_RSD_ADDRESS, 0, NULL, NULL},
{ACPI_RSD_UINT64, ACPI_RSD_OFFSET (Address64.Granularity), "Granularity", NULL},
{ACPI_RSD_UINT64, ACPI_RSD_OFFSET (Address64.Minimum), "Address Minimum", NULL},
{ACPI_RSD_UINT64, ACPI_RSD_OFFSET (Address64.Maximum), "Address Maximum", NULL},
{ACPI_RSD_UINT64, ACPI_RSD_OFFSET (Address64.TranslationOffset), "Translation Offset", NULL},
{ACPI_RSD_UINT64, ACPI_RSD_OFFSET (Address64.AddressLength), "Address Length", NULL},
{ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (Address64.ResourceSource), NULL, NULL}
};
 
ACPI_RSDUMP_INFO AcpiRsDumpExtAddress64[8] =
{
{ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpExtAddress64), "64-Bit Extended Address Space", NULL},
{ACPI_RSD_ADDRESS, 0, NULL, NULL},
{ACPI_RSD_UINT64, ACPI_RSD_OFFSET (ExtAddress64.Granularity), "Granularity", NULL},
{ACPI_RSD_UINT64, ACPI_RSD_OFFSET (ExtAddress64.Minimum), "Address Minimum", NULL},
{ACPI_RSD_UINT64, ACPI_RSD_OFFSET (ExtAddress64.Maximum), "Address Maximum", NULL},
{ACPI_RSD_UINT64, ACPI_RSD_OFFSET (ExtAddress64.TranslationOffset), "Translation Offset", NULL},
{ACPI_RSD_UINT64, ACPI_RSD_OFFSET (ExtAddress64.AddressLength), "Address Length", NULL},
{ACPI_RSD_UINT64, ACPI_RSD_OFFSET (ExtAddress64.TypeSpecific), "Type-Specific Attribute", NULL}
};
 
ACPI_RSDUMP_INFO AcpiRsDumpExtIrq[8] =
{
{ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpExtIrq), "Extended IRQ", NULL},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.ProducerConsumer), "Type", AcpiGbl_ConsumeDecode},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.Triggering), "Triggering", AcpiGbl_HeDecode},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.Polarity), "Polarity", AcpiGbl_LlDecode},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.Sharable), "Sharing", AcpiGbl_ShrDecode},
{ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (ExtendedIrq.ResourceSource), NULL, NULL},
{ACPI_RSD_UINT8, ACPI_RSD_OFFSET (ExtendedIrq.InterruptCount), "Interrupt Count", NULL},
{ACPI_RSD_DWORDLIST,ACPI_RSD_OFFSET (ExtendedIrq.Interrupts[0]), "Interrupt List", NULL}
};
 
ACPI_RSDUMP_INFO AcpiRsDumpGenericReg[6] =
{
{ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpGenericReg), "Generic Register", NULL},
{ACPI_RSD_UINT8, ACPI_RSD_OFFSET (GenericReg.SpaceId), "Space ID", NULL},
{ACPI_RSD_UINT8, ACPI_RSD_OFFSET (GenericReg.BitWidth), "Bit Width", NULL},
{ACPI_RSD_UINT8, ACPI_RSD_OFFSET (GenericReg.BitOffset), "Bit Offset", NULL},
{ACPI_RSD_UINT8, ACPI_RSD_OFFSET (GenericReg.AccessSize), "Access Size", NULL},
{ACPI_RSD_UINT64, ACPI_RSD_OFFSET (GenericReg.Address), "Address", NULL}
};
 
 
/*
* Tables used for common address descriptor flag fields
*/
static ACPI_RSDUMP_INFO AcpiRsDumpGeneralFlags[5] =
{
{ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpGeneralFlags), NULL, NULL},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.ProducerConsumer), "Consumer/Producer", AcpiGbl_ConsumeDecode},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Decode), "Address Decode", AcpiGbl_DecDecode},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.MinAddressFixed), "Min Relocatability", AcpiGbl_MinDecode},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.MaxAddressFixed), "Max Relocatability", AcpiGbl_MaxDecode}
};
 
static ACPI_RSDUMP_INFO AcpiRsDumpMemoryFlags[5] =
{
{ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE (AcpiRsDumpMemoryFlags), "Resource Type", (void *) "Memory Range"},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.WriteProtect), "Write Protect", AcpiGbl_RwDecode},
{ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.Caching), "Caching", AcpiGbl_MemDecode},
{ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.RangeType), "Range Type", AcpiGbl_MtpDecode},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.Translation), "Translation", AcpiGbl_TtpDecode}
};
 
static ACPI_RSDUMP_INFO AcpiRsDumpIoFlags[4] =
{
{ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE (AcpiRsDumpIoFlags), "Resource Type", (void *) "I/O Range"},
{ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Address.Info.Io.RangeType), "Range Type", AcpiGbl_RngDecode},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Io.Translation), "Translation", AcpiGbl_TtpDecode},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Io.TranslationType), "Translation Type", AcpiGbl_TrsDecode}
};
 
 
/*
* Table used to dump _PRT contents
*/
static ACPI_RSDUMP_INFO AcpiRsDumpPrt[5] =
{
{ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpPrt), NULL, NULL},
{ACPI_RSD_UINT64, ACPI_PRT_OFFSET (Address), "Address", NULL},
{ACPI_RSD_UINT32, ACPI_PRT_OFFSET (Pin), "Pin", NULL},
{ACPI_RSD_STRING, ACPI_PRT_OFFSET (Source[0]), "Source", NULL},
{ACPI_RSD_UINT32, ACPI_PRT_OFFSET (SourceIndex), "Source Index", NULL}
};
 
 
/*******************************************************************************
*
* FUNCTION: AcpiRsDumpDescriptor
*
* PARAMETERS: Resource
*
* RETURN: None
*
* DESCRIPTION:
*
******************************************************************************/
 
static void
AcpiRsDumpDescriptor (
void *Resource,
ACPI_RSDUMP_INFO *Table)
{
UINT8 *Target = NULL;
UINT8 *PreviousTarget;
char *Name;
UINT8 Count;
 
 
/* First table entry must contain the table length (# of table entries) */
 
Count = Table->Offset;
 
while (Count)
{
PreviousTarget = Target;
Target = ACPI_ADD_PTR (UINT8, Resource, Table->Offset);
Name = Table->Name;
 
switch (Table->Opcode)
{
case ACPI_RSD_TITLE:
/*
* Optional resource title
*/
if (Table->Name)
{
AcpiOsPrintf ("%s Resource\n", Name);
}
break;
 
/* Strings */
 
case ACPI_RSD_LITERAL:
AcpiRsOutString (Name, ACPI_CAST_PTR (char, Table->Pointer));
break;
 
case ACPI_RSD_STRING:
AcpiRsOutString (Name, ACPI_CAST_PTR (char, Target));
break;
 
/* Data items, 8/16/32/64 bit */
 
case ACPI_RSD_UINT8:
AcpiRsOutInteger8 (Name, ACPI_GET8 (Target));
break;
 
case ACPI_RSD_UINT16:
AcpiRsOutInteger16 (Name, ACPI_GET16 (Target));
break;
 
case ACPI_RSD_UINT32:
AcpiRsOutInteger32 (Name, ACPI_GET32 (Target));
break;
 
case ACPI_RSD_UINT64:
AcpiRsOutInteger64 (Name, ACPI_GET64 (Target));
break;
 
/* Flags: 1-bit and 2-bit flags supported */
 
case ACPI_RSD_1BITFLAG:
AcpiRsOutString (Name, ACPI_CAST_PTR (char,
Table->Pointer [*Target & 0x01]));
break;
 
case ACPI_RSD_2BITFLAG:
AcpiRsOutString (Name, ACPI_CAST_PTR (char,
Table->Pointer [*Target & 0x03]));
break;
 
case ACPI_RSD_SHORTLIST:
/*
* Short byte list (single line output) for DMA and IRQ resources
* Note: The list length is obtained from the previous table entry
*/
if (PreviousTarget)
{
AcpiRsOutTitle (Name);
AcpiRsDumpShortByteList (*PreviousTarget, Target);
}
break;
 
case ACPI_RSD_LONGLIST:
/*
* Long byte list for Vendor resource data
* Note: The list length is obtained from the previous table entry
*/
if (PreviousTarget)
{
AcpiRsDumpByteList (ACPI_GET16 (PreviousTarget), Target);
}
break;
 
case ACPI_RSD_DWORDLIST:
/*
* Dword list for Extended Interrupt resources
* Note: The list length is obtained from the previous table entry
*/
if (PreviousTarget)
{
AcpiRsDumpDwordList (*PreviousTarget,
ACPI_CAST_PTR (UINT32, Target));
}
break;
 
case ACPI_RSD_ADDRESS:
/*
* Common flags for all Address resources
*/
AcpiRsDumpAddressCommon (ACPI_CAST_PTR (ACPI_RESOURCE_DATA, Target));
break;
 
case ACPI_RSD_SOURCE:
/*
* Optional ResourceSource for Address resources
*/
AcpiRsDumpResourceSource (ACPI_CAST_PTR (ACPI_RESOURCE_SOURCE, Target));
break;
 
default:
AcpiOsPrintf ("**** Invalid table opcode [%X] ****\n",
Table->Opcode);
return;
}
 
Table++;
Count--;
}
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiRsDumpResourceSource
*
* PARAMETERS: ResourceSource - Pointer to a Resource Source struct
*
* RETURN: None
*
* DESCRIPTION: Common routine for dumping the optional ResourceSource and the
* corresponding ResourceSourceIndex.
*
******************************************************************************/
 
static void
AcpiRsDumpResourceSource (
ACPI_RESOURCE_SOURCE *ResourceSource)
{
ACPI_FUNCTION_ENTRY ();
 
 
if (ResourceSource->Index == 0xFF)
{
return;
}
 
AcpiRsOutInteger8 ("Resource Source Index",
ResourceSource->Index);
 
AcpiRsOutString ("Resource Source",
ResourceSource->StringPtr ?
ResourceSource->StringPtr : "[Not Specified]");
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiRsDumpAddressCommon
*
* PARAMETERS: Resource - Pointer to an internal resource descriptor
*
* RETURN: None
*
* DESCRIPTION: Dump the fields that are common to all Address resource
* descriptors
*
******************************************************************************/
 
static void
AcpiRsDumpAddressCommon (
ACPI_RESOURCE_DATA *Resource)
{
ACPI_FUNCTION_ENTRY ();
 
 
/* Decode the type-specific flags */
 
switch (Resource->Address.ResourceType)
{
case ACPI_MEMORY_RANGE:
 
AcpiRsDumpDescriptor (Resource, AcpiRsDumpMemoryFlags);
break;
 
case ACPI_IO_RANGE:
 
AcpiRsDumpDescriptor (Resource, AcpiRsDumpIoFlags);
break;
 
case ACPI_BUS_NUMBER_RANGE:
 
AcpiRsOutString ("Resource Type", "Bus Number Range");
break;
 
default:
 
AcpiRsOutInteger8 ("Resource Type",
(UINT8) Resource->Address.ResourceType);
break;
}
 
/* Decode the general flags */
 
AcpiRsDumpDescriptor (Resource, AcpiRsDumpGeneralFlags);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiRsDumpResourceList
*
* PARAMETERS: ResourceList - Pointer to a resource descriptor list
*
* RETURN: None
*
* DESCRIPTION: Dispatches the structure to the correct dump routine.
*
******************************************************************************/
 
void
AcpiRsDumpResourceList (
ACPI_RESOURCE *ResourceList)
{
UINT32 Count = 0;
UINT32 Type;
 
 
ACPI_FUNCTION_ENTRY ();
 
 
if (!(AcpiDbgLevel & ACPI_LV_RESOURCES) || !( _COMPONENT & AcpiDbgLayer))
{
return;
}
 
/* Walk list and dump all resource descriptors (END_TAG terminates) */
 
do
{
AcpiOsPrintf ("\n[%02X] ", Count);
Count++;
 
/* Validate Type before dispatch */
 
Type = ResourceList->Type;
if (Type > ACPI_RESOURCE_TYPE_MAX)
{
AcpiOsPrintf (
"Invalid descriptor type (%X) in resource list\n",
ResourceList->Type);
return;
}
 
/* Dump the resource descriptor */
 
AcpiRsDumpDescriptor (&ResourceList->Data,
AcpiGbl_DumpResourceDispatch[Type]);
 
/* Point to the next resource structure */
 
ResourceList = ACPI_ADD_PTR (ACPI_RESOURCE, ResourceList,
ResourceList->Length);
 
/* Exit when END_TAG descriptor is reached */
 
} while (Type != ACPI_RESOURCE_TYPE_END_TAG);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiRsDumpIrqList
*
* PARAMETERS: RouteTable - Pointer to the routing table to dump.
*
* RETURN: None
*
* DESCRIPTION: Print IRQ routing table
*
******************************************************************************/
 
void
AcpiRsDumpIrqList (
UINT8 *RouteTable)
{
ACPI_PCI_ROUTING_TABLE *PrtElement;
UINT8 Count;
 
 
ACPI_FUNCTION_ENTRY ();
 
 
if (!(AcpiDbgLevel & ACPI_LV_RESOURCES) || !( _COMPONENT & AcpiDbgLayer))
{
return;
}
 
PrtElement = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, RouteTable);
 
/* Dump all table elements, Exit on zero length element */
 
for (Count = 0; PrtElement->Length; Count++)
{
AcpiOsPrintf ("\n[%02X] PCI IRQ Routing Table Package\n", Count);
AcpiRsDumpDescriptor (PrtElement, AcpiRsDumpPrt);
 
PrtElement = ACPI_ADD_PTR (ACPI_PCI_ROUTING_TABLE,
PrtElement, PrtElement->Length);
}
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiRsOut*
*
* PARAMETERS: Title - Name of the resource field
* Value - Value of the resource field
*
* RETURN: None
*
* DESCRIPTION: Miscellaneous helper functions to consistently format the
* output of the resource dump routines
*
******************************************************************************/
 
static void
AcpiRsOutString (
char *Title,
char *Value)
{
AcpiOsPrintf ("%27s : %s", Title, Value);
if (!*Value)
{
AcpiOsPrintf ("[NULL NAMESTRING]");
}
AcpiOsPrintf ("\n");
}
 
static void
AcpiRsOutInteger8 (
char *Title,
UINT8 Value)
{
AcpiOsPrintf ("%27s : %2.2X\n", Title, Value);
}
 
static void
AcpiRsOutInteger16 (
char *Title,
UINT16 Value)
{
AcpiOsPrintf ("%27s : %4.4X\n", Title, Value);
}
 
static void
AcpiRsOutInteger32 (
char *Title,
UINT32 Value)
{
AcpiOsPrintf ("%27s : %8.8X\n", Title, Value);
}
 
static void
AcpiRsOutInteger64 (
char *Title,
UINT64 Value)
{
AcpiOsPrintf ("%27s : %8.8X%8.8X\n", Title,
ACPI_FORMAT_UINT64 (Value));
}
 
static void
AcpiRsOutTitle (
char *Title)
{
AcpiOsPrintf ("%27s : ", Title);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiRsDump*List
*
* PARAMETERS: Length - Number of elements in the list
* Data - Start of the list
*
* RETURN: None
*
* DESCRIPTION: Miscellaneous functions to dump lists of raw data
*
******************************************************************************/
 
static void
AcpiRsDumpByteList (
UINT16 Length,
UINT8 *Data)
{
UINT8 i;
 
 
for (i = 0; i < Length; i++)
{
AcpiOsPrintf ("%25s%2.2X : %2.2X\n",
"Byte", i, Data[i]);
}
}
 
static void
AcpiRsDumpShortByteList (
UINT8 Length,
UINT8 *Data)
{
UINT8 i;
 
 
for (i = 0; i < Length; i++)
{
AcpiOsPrintf ("%X ", Data[i]);
}
AcpiOsPrintf ("\n");
}
 
static void
AcpiRsDumpDwordList (
UINT8 Length,
UINT32 *Data)
{
UINT8 i;
 
 
for (i = 0; i < Length; i++)
{
AcpiOsPrintf ("%25s%2.2X : %8.8X\n",
"Dword", i, Data[i]);
}
}
 
#endif
 
/drivers/devman/acpica/resources/rsinfo.c
0,0 → 1,290
/*******************************************************************************
*
* Module Name: rsinfo - Dispatch and Info tables
*
******************************************************************************/
 
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* Code in any form, with the right to sublicense such rights; and
*
* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
* license (with the right to sublicense), under only those claims of Intel
* patents that are infringed by the Original Intel Code, to make, use, sell,
* offer to sell, and import the Covered Code and derivative works thereof
* solely to the minimum extent necessary to exercise the above copyright
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************/
 
#define __RSINFO_C__
 
#include "acpi.h"
#include "accommon.h"
#include "acresrc.h"
 
#define _COMPONENT ACPI_RESOURCES
ACPI_MODULE_NAME ("rsinfo")
 
/*
* Resource dispatch and information tables. Any new resource types (either
* Large or Small) must be reflected in each of these tables, so they are here
* in one place.
*
* The tables for Large descriptors are indexed by bits 6:0 of the AML
* descriptor type byte. The tables for Small descriptors are indexed by
* bits 6:3 of the descriptor byte. The tables for internal resource
* descriptors are indexed by the ACPI_RESOURCE_TYPE field.
*/
 
 
/* Dispatch table for resource-to-AML (Set Resource) conversion functions */
 
ACPI_RSCONVERT_INFO *AcpiGbl_SetResourceDispatch[] =
{
AcpiRsSetIrq, /* 0x00, ACPI_RESOURCE_TYPE_IRQ */
AcpiRsConvertDma, /* 0x01, ACPI_RESOURCE_TYPE_DMA */
AcpiRsSetStartDpf, /* 0x02, ACPI_RESOURCE_TYPE_START_DEPENDENT */
AcpiRsConvertEndDpf, /* 0x03, ACPI_RESOURCE_TYPE_END_DEPENDENT */
AcpiRsConvertIo, /* 0x04, ACPI_RESOURCE_TYPE_IO */
AcpiRsConvertFixedIo, /* 0x05, ACPI_RESOURCE_TYPE_FIXED_IO */
AcpiRsSetVendor, /* 0x06, ACPI_RESOURCE_TYPE_VENDOR */
AcpiRsConvertEndTag, /* 0x07, ACPI_RESOURCE_TYPE_END_TAG */
AcpiRsConvertMemory24, /* 0x08, ACPI_RESOURCE_TYPE_MEMORY24 */
AcpiRsConvertMemory32, /* 0x09, ACPI_RESOURCE_TYPE_MEMORY32 */
AcpiRsConvertFixedMemory32, /* 0x0A, ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */
AcpiRsConvertAddress16, /* 0x0B, ACPI_RESOURCE_TYPE_ADDRESS16 */
AcpiRsConvertAddress32, /* 0x0C, ACPI_RESOURCE_TYPE_ADDRESS32 */
AcpiRsConvertAddress64, /* 0x0D, ACPI_RESOURCE_TYPE_ADDRESS64 */
AcpiRsConvertExtAddress64, /* 0x0E, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */
AcpiRsConvertExtIrq, /* 0x0F, ACPI_RESOURCE_TYPE_EXTENDED_IRQ */
AcpiRsConvertGenericReg /* 0x10, ACPI_RESOURCE_TYPE_GENERIC_REGISTER */
};
 
/* Dispatch tables for AML-to-resource (Get Resource) conversion functions */
 
ACPI_RSCONVERT_INFO *AcpiGbl_GetResourceDispatch[] =
{
/* Small descriptors */
 
NULL, /* 0x00, Reserved */
NULL, /* 0x01, Reserved */
NULL, /* 0x02, Reserved */
NULL, /* 0x03, Reserved */
AcpiRsGetIrq, /* 0x04, ACPI_RESOURCE_NAME_IRQ */
AcpiRsConvertDma, /* 0x05, ACPI_RESOURCE_NAME_DMA */
AcpiRsGetStartDpf, /* 0x06, ACPI_RESOURCE_NAME_START_DEPENDENT */
AcpiRsConvertEndDpf, /* 0x07, ACPI_RESOURCE_NAME_END_DEPENDENT */
AcpiRsConvertIo, /* 0x08, ACPI_RESOURCE_NAME_IO */
AcpiRsConvertFixedIo, /* 0x09, ACPI_RESOURCE_NAME_FIXED_IO */
NULL, /* 0x0A, Reserved */
NULL, /* 0x0B, Reserved */
NULL, /* 0x0C, Reserved */
NULL, /* 0x0D, Reserved */
AcpiRsGetVendorSmall, /* 0x0E, ACPI_RESOURCE_NAME_VENDOR_SMALL */
AcpiRsConvertEndTag, /* 0x0F, ACPI_RESOURCE_NAME_END_TAG */
 
/* Large descriptors */
 
NULL, /* 0x00, Reserved */
AcpiRsConvertMemory24, /* 0x01, ACPI_RESOURCE_NAME_MEMORY24 */
AcpiRsConvertGenericReg, /* 0x02, ACPI_RESOURCE_NAME_GENERIC_REGISTER */
NULL, /* 0x03, Reserved */
AcpiRsGetVendorLarge, /* 0x04, ACPI_RESOURCE_NAME_VENDOR_LARGE */
AcpiRsConvertMemory32, /* 0x05, ACPI_RESOURCE_NAME_MEMORY32 */
AcpiRsConvertFixedMemory32, /* 0x06, ACPI_RESOURCE_NAME_FIXED_MEMORY32 */
AcpiRsConvertAddress32, /* 0x07, ACPI_RESOURCE_NAME_ADDRESS32 */
AcpiRsConvertAddress16, /* 0x08, ACPI_RESOURCE_NAME_ADDRESS16 */
AcpiRsConvertExtIrq, /* 0x09, ACPI_RESOURCE_NAME_EXTENDED_IRQ */
AcpiRsConvertAddress64, /* 0x0A, ACPI_RESOURCE_NAME_ADDRESS64 */
AcpiRsConvertExtAddress64 /* 0x0B, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64 */
};
 
 
#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
 
/* Dispatch table for resource dump functions */
 
ACPI_RSDUMP_INFO *AcpiGbl_DumpResourceDispatch[] =
{
AcpiRsDumpIrq, /* ACPI_RESOURCE_TYPE_IRQ */
AcpiRsDumpDma, /* ACPI_RESOURCE_TYPE_DMA */
AcpiRsDumpStartDpf, /* ACPI_RESOURCE_TYPE_START_DEPENDENT */
AcpiRsDumpEndDpf, /* ACPI_RESOURCE_TYPE_END_DEPENDENT */
AcpiRsDumpIo, /* ACPI_RESOURCE_TYPE_IO */
AcpiRsDumpFixedIo, /* ACPI_RESOURCE_TYPE_FIXED_IO */
AcpiRsDumpVendor, /* ACPI_RESOURCE_TYPE_VENDOR */
AcpiRsDumpEndTag, /* ACPI_RESOURCE_TYPE_END_TAG */
AcpiRsDumpMemory24, /* ACPI_RESOURCE_TYPE_MEMORY24 */
AcpiRsDumpMemory32, /* ACPI_RESOURCE_TYPE_MEMORY32 */
AcpiRsDumpFixedMemory32, /* ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */
AcpiRsDumpAddress16, /* ACPI_RESOURCE_TYPE_ADDRESS16 */
AcpiRsDumpAddress32, /* ACPI_RESOURCE_TYPE_ADDRESS32 */
AcpiRsDumpAddress64, /* ACPI_RESOURCE_TYPE_ADDRESS64 */
AcpiRsDumpExtAddress64, /* ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */
AcpiRsDumpExtIrq, /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */
AcpiRsDumpGenericReg, /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */
};
#endif
 
 
/*
* Base sizes for external AML resource descriptors, indexed by internal type.
* Includes size of the descriptor header (1 byte for small descriptors,
* 3 bytes for large descriptors)
*/
const UINT8 AcpiGbl_AmlResourceSizes[] =
{
sizeof (AML_RESOURCE_IRQ), /* ACPI_RESOURCE_TYPE_IRQ (optional Byte 3 always created) */
sizeof (AML_RESOURCE_DMA), /* ACPI_RESOURCE_TYPE_DMA */
sizeof (AML_RESOURCE_START_DEPENDENT), /* ACPI_RESOURCE_TYPE_START_DEPENDENT (optional Byte 1 always created) */
sizeof (AML_RESOURCE_END_DEPENDENT), /* ACPI_RESOURCE_TYPE_END_DEPENDENT */
sizeof (AML_RESOURCE_IO), /* ACPI_RESOURCE_TYPE_IO */
sizeof (AML_RESOURCE_FIXED_IO), /* ACPI_RESOURCE_TYPE_FIXED_IO */
sizeof (AML_RESOURCE_VENDOR_SMALL), /* ACPI_RESOURCE_TYPE_VENDOR */
sizeof (AML_RESOURCE_END_TAG), /* ACPI_RESOURCE_TYPE_END_TAG */
sizeof (AML_RESOURCE_MEMORY24), /* ACPI_RESOURCE_TYPE_MEMORY24 */
sizeof (AML_RESOURCE_MEMORY32), /* ACPI_RESOURCE_TYPE_MEMORY32 */
sizeof (AML_RESOURCE_FIXED_MEMORY32), /* ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */
sizeof (AML_RESOURCE_ADDRESS16), /* ACPI_RESOURCE_TYPE_ADDRESS16 */
sizeof (AML_RESOURCE_ADDRESS32), /* ACPI_RESOURCE_TYPE_ADDRESS32 */
sizeof (AML_RESOURCE_ADDRESS64), /* ACPI_RESOURCE_TYPE_ADDRESS64 */
sizeof (AML_RESOURCE_EXTENDED_ADDRESS64),/*ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */
sizeof (AML_RESOURCE_EXTENDED_IRQ), /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */
sizeof (AML_RESOURCE_GENERIC_REGISTER) /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */
};
 
 
const UINT8 AcpiGbl_ResourceStructSizes[] =
{
/* Small descriptors */
 
0,
0,
0,
0,
ACPI_RS_SIZE (ACPI_RESOURCE_IRQ),
ACPI_RS_SIZE (ACPI_RESOURCE_DMA),
ACPI_RS_SIZE (ACPI_RESOURCE_START_DEPENDENT),
ACPI_RS_SIZE_MIN,
ACPI_RS_SIZE (ACPI_RESOURCE_IO),
ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_IO),
0,
0,
0,
0,
ACPI_RS_SIZE (ACPI_RESOURCE_VENDOR),
ACPI_RS_SIZE_MIN,
 
/* Large descriptors */
 
0,
ACPI_RS_SIZE (ACPI_RESOURCE_MEMORY24),
ACPI_RS_SIZE (ACPI_RESOURCE_GENERIC_REGISTER),
0,
ACPI_RS_SIZE (ACPI_RESOURCE_VENDOR),
ACPI_RS_SIZE (ACPI_RESOURCE_MEMORY32),
ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_MEMORY32),
ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS32),
ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS16),
ACPI_RS_SIZE (ACPI_RESOURCE_EXTENDED_IRQ),
ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS64),
ACPI_RS_SIZE (ACPI_RESOURCE_EXTENDED_ADDRESS64)
};
 
/drivers/devman/acpica/resources/rsio.c
0,0 → 1,376
/*******************************************************************************
*
* Module Name: rsio - IO and DMA resource descriptors
*
******************************************************************************/
 
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* Code in any form, with the right to sublicense such rights; and
*
* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
* license (with the right to sublicense), under only those claims of Intel
* patents that are infringed by the Original Intel Code, to make, use, sell,
* offer to sell, and import the Covered Code and derivative works thereof
* solely to the minimum extent necessary to exercise the above copyright
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************/
 
#define __RSIO_C__
 
#include "acpi.h"
#include "accommon.h"
#include "acresrc.h"
 
#define _COMPONENT ACPI_RESOURCES
ACPI_MODULE_NAME ("rsio")
 
 
/*******************************************************************************
*
* AcpiRsConvertIo
*
******************************************************************************/
 
ACPI_RSCONVERT_INFO AcpiRsConvertIo[5] =
{
{ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_IO,
ACPI_RS_SIZE (ACPI_RESOURCE_IO),
ACPI_RSC_TABLE_SIZE (AcpiRsConvertIo)},
 
{ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_IO,
sizeof (AML_RESOURCE_IO),
0},
 
/* Decode flag */
 
{ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Io.IoDecode),
AML_OFFSET (Io.Flags),
0},
/*
* These fields are contiguous in both the source and destination:
* Address Alignment
* Length
* Minimum Base Address
* Maximum Base Address
*/
{ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Io.Alignment),
AML_OFFSET (Io.Alignment),
2},
 
{ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.Io.Minimum),
AML_OFFSET (Io.Minimum),
2}
};
 
 
/*******************************************************************************
*
* AcpiRsConvertFixedIo
*
******************************************************************************/
 
ACPI_RSCONVERT_INFO AcpiRsConvertFixedIo[4] =
{
{ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_FIXED_IO,
ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_IO),
ACPI_RSC_TABLE_SIZE (AcpiRsConvertFixedIo)},
 
{ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_FIXED_IO,
sizeof (AML_RESOURCE_FIXED_IO),
0},
/*
* These fields are contiguous in both the source and destination:
* Base Address
* Length
*/
{ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.FixedIo.AddressLength),
AML_OFFSET (FixedIo.AddressLength),
1},
 
{ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.FixedIo.Address),
AML_OFFSET (FixedIo.Address),
1}
};
 
 
/*******************************************************************************
*
* AcpiRsConvertGenericReg
*
******************************************************************************/
 
ACPI_RSCONVERT_INFO AcpiRsConvertGenericReg[4] =
{
{ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_GENERIC_REGISTER,
ACPI_RS_SIZE (ACPI_RESOURCE_GENERIC_REGISTER),
ACPI_RSC_TABLE_SIZE (AcpiRsConvertGenericReg)},
 
{ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_GENERIC_REGISTER,
sizeof (AML_RESOURCE_GENERIC_REGISTER),
0},
/*
* These fields are contiguous in both the source and destination:
* Address Space ID
* Register Bit Width
* Register Bit Offset
* Access Size
*/
{ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.GenericReg.SpaceId),
AML_OFFSET (GenericReg.AddressSpaceId),
4},
 
/* Get the Register Address */
 
{ACPI_RSC_MOVE64, ACPI_RS_OFFSET (Data.GenericReg.Address),
AML_OFFSET (GenericReg.Address),
1}
};
 
 
/*******************************************************************************
*
* AcpiRsConvertEndDpf
*
******************************************************************************/
 
ACPI_RSCONVERT_INFO AcpiRsConvertEndDpf[2] =
{
{ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_DEPENDENT,
ACPI_RS_SIZE_MIN,
ACPI_RSC_TABLE_SIZE (AcpiRsConvertEndDpf)},
 
{ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_DEPENDENT,
sizeof (AML_RESOURCE_END_DEPENDENT),
0}
};
 
 
/*******************************************************************************
*
* AcpiRsConvertEndTag
*
******************************************************************************/
 
ACPI_RSCONVERT_INFO AcpiRsConvertEndTag[2] =
{
{ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_TAG,
ACPI_RS_SIZE_MIN,
ACPI_RSC_TABLE_SIZE (AcpiRsConvertEndTag)},
 
/*
* Note: The checksum field is set to zero, meaning that the resource
* data is treated as if the checksum operation succeeded.
* (ACPI Spec 1.0b Section 6.4.2.8)
*/
{ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_TAG,
sizeof (AML_RESOURCE_END_TAG),
0}
};
 
 
/*******************************************************************************
*
* AcpiRsGetStartDpf
*
******************************************************************************/
 
ACPI_RSCONVERT_INFO AcpiRsGetStartDpf[6] =
{
{ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_START_DEPENDENT,
ACPI_RS_SIZE (ACPI_RESOURCE_START_DEPENDENT),
ACPI_RSC_TABLE_SIZE (AcpiRsGetStartDpf)},
 
/* Defaults for Compatibility and Performance priorities */
 
{ACPI_RSC_SET8, ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority),
ACPI_ACCEPTABLE_CONFIGURATION,
2},
 
/* Get the descriptor length (0 or 1 for Start Dpf descriptor) */
 
{ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.DescriptorLength),
AML_OFFSET (StartDpf.DescriptorType),
0},
 
/* All done if there is no flag byte present in the descriptor */
 
{ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 1},
 
/* Flag byte is present, get the flags */
 
{ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority),
AML_OFFSET (StartDpf.Flags),
0},
 
{ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.PerformanceRobustness),
AML_OFFSET (StartDpf.Flags),
2}
};
 
 
/*******************************************************************************
*
* AcpiRsSetStartDpf
*
******************************************************************************/
 
ACPI_RSCONVERT_INFO AcpiRsSetStartDpf[10] =
{
/* Start with a default descriptor of length 1 */
 
{ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_START_DEPENDENT,
sizeof (AML_RESOURCE_START_DEPENDENT),
ACPI_RSC_TABLE_SIZE (AcpiRsSetStartDpf)},
 
/* Set the default flag values */
 
{ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority),
AML_OFFSET (StartDpf.Flags),
0},
 
{ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.PerformanceRobustness),
AML_OFFSET (StartDpf.Flags),
2},
/*
* All done if the output descriptor length is required to be 1
* (i.e., optimization to 0 bytes cannot be attempted)
*/
{ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE,
ACPI_RS_OFFSET(Data.StartDpf.DescriptorLength),
1},
 
/* Set length to 0 bytes (no flags byte) */
 
{ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_START_DEPENDENT_NOPRIO)},
 
/*
* All done if the output descriptor length is required to be 0.
*
* TBD: Perhaps we should check for error if input flags are not
* compatible with a 0-byte descriptor.
*/
{ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE,
ACPI_RS_OFFSET(Data.StartDpf.DescriptorLength),
0},
 
/* Reset length to 1 byte (descriptor with flags byte) */
 
{ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_START_DEPENDENT)},
 
 
/*
* All done if flags byte is necessary -- if either priority value
* is not ACPI_ACCEPTABLE_CONFIGURATION
*/
{ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority),
ACPI_ACCEPTABLE_CONFIGURATION},
 
{ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
ACPI_RS_OFFSET (Data.StartDpf.PerformanceRobustness),
ACPI_ACCEPTABLE_CONFIGURATION},
 
/* Flag byte is not necessary */
 
{ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_START_DEPENDENT_NOPRIO)}
};
 
 
/drivers/devman/acpica/resources/rsirq.c
0,0 → 1,348
/*******************************************************************************
*
* Module Name: rsirq - IRQ resource descriptors
*
******************************************************************************/
 
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* Code in any form, with the right to sublicense such rights; and
*
* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
* license (with the right to sublicense), under only those claims of Intel
* patents that are infringed by the Original Intel Code, to make, use, sell,
* offer to sell, and import the Covered Code and derivative works thereof
* solely to the minimum extent necessary to exercise the above copyright
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************/
 
#define __RSIRQ_C__
 
#include "acpi.h"
#include "accommon.h"
#include "acresrc.h"
 
#define _COMPONENT ACPI_RESOURCES
ACPI_MODULE_NAME ("rsirq")
 
 
/*******************************************************************************
*
* AcpiRsGetIrq
*
******************************************************************************/
 
ACPI_RSCONVERT_INFO AcpiRsGetIrq[8] =
{
{ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_IRQ,
ACPI_RS_SIZE (ACPI_RESOURCE_IRQ),
ACPI_RSC_TABLE_SIZE (AcpiRsGetIrq)},
 
/* Get the IRQ mask (bytes 1:2) */
 
{ACPI_RSC_BITMASK16,ACPI_RS_OFFSET (Data.Irq.Interrupts[0]),
AML_OFFSET (Irq.IrqMask),
ACPI_RS_OFFSET (Data.Irq.InterruptCount)},
 
/* Set default flags (others are zero) */
 
{ACPI_RSC_SET8, ACPI_RS_OFFSET (Data.Irq.Triggering),
ACPI_EDGE_SENSITIVE,
1},
 
/* Get the descriptor length (2 or 3 for IRQ descriptor) */
 
{ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Irq.DescriptorLength),
AML_OFFSET (Irq.DescriptorType),
0},
 
/* All done if no flag byte present in descriptor */
 
{ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 3},
 
/* Get flags: Triggering[0], Polarity[3], Sharing[4] */
 
{ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Triggering),
AML_OFFSET (Irq.Flags),
0},
 
{ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Polarity),
AML_OFFSET (Irq.Flags),
3},
 
{ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Sharable),
AML_OFFSET (Irq.Flags),
4}
};
 
 
/*******************************************************************************
*
* AcpiRsSetIrq
*
******************************************************************************/
 
ACPI_RSCONVERT_INFO AcpiRsSetIrq[13] =
{
/* Start with a default descriptor of length 3 */
 
{ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_IRQ,
sizeof (AML_RESOURCE_IRQ),
ACPI_RSC_TABLE_SIZE (AcpiRsSetIrq)},
 
/* Convert interrupt list to 16-bit IRQ bitmask */
 
{ACPI_RSC_BITMASK16,ACPI_RS_OFFSET (Data.Irq.Interrupts[0]),
AML_OFFSET (Irq.IrqMask),
ACPI_RS_OFFSET (Data.Irq.InterruptCount)},
 
/* Set the flags byte */
 
{ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Triggering),
AML_OFFSET (Irq.Flags),
0},
 
{ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Polarity),
AML_OFFSET (Irq.Flags),
3},
 
{ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Sharable),
AML_OFFSET (Irq.Flags),
4},
 
/*
* All done if the output descriptor length is required to be 3
* (i.e., optimization to 2 bytes cannot be attempted)
*/
{ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE,
ACPI_RS_OFFSET(Data.Irq.DescriptorLength),
3},
 
/* Set length to 2 bytes (no flags byte) */
 
{ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_IRQ_NOFLAGS)},
 
/*
* All done if the output descriptor length is required to be 2.
*
* TBD: Perhaps we should check for error if input flags are not
* compatible with a 2-byte descriptor.
*/
{ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE,
ACPI_RS_OFFSET(Data.Irq.DescriptorLength),
2},
 
/* Reset length to 3 bytes (descriptor with flags byte) */
 
{ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_IRQ)},
 
/*
* Check if the flags byte is necessary. Not needed if the flags are:
* ACPI_EDGE_SENSITIVE, ACPI_ACTIVE_HIGH, ACPI_EXCLUSIVE
*/
{ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
ACPI_RS_OFFSET (Data.Irq.Triggering),
ACPI_EDGE_SENSITIVE},
 
{ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
ACPI_RS_OFFSET (Data.Irq.Polarity),
ACPI_ACTIVE_HIGH},
 
{ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
ACPI_RS_OFFSET (Data.Irq.Sharable),
ACPI_EXCLUSIVE},
 
/* We can optimize to a 2-byte IrqNoFlags() descriptor */
 
{ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_IRQ_NOFLAGS)}
};
 
 
/*******************************************************************************
*
* AcpiRsConvertExtIrq
*
******************************************************************************/
 
ACPI_RSCONVERT_INFO AcpiRsConvertExtIrq[9] =
{
{ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_EXTENDED_IRQ,
ACPI_RS_SIZE (ACPI_RESOURCE_EXTENDED_IRQ),
ACPI_RSC_TABLE_SIZE (AcpiRsConvertExtIrq)},
 
{ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_EXTENDED_IRQ,
sizeof (AML_RESOURCE_EXTENDED_IRQ),
0},
 
/* Flag bits */
 
{ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.ExtendedIrq.ProducerConsumer),
AML_OFFSET (ExtendedIrq.Flags),
0},
 
{ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.ExtendedIrq.Triggering),
AML_OFFSET (ExtendedIrq.Flags),
1},
 
{ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.ExtendedIrq.Polarity),
AML_OFFSET (ExtendedIrq.Flags),
2},
 
{ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.ExtendedIrq.Sharable),
AML_OFFSET (ExtendedIrq.Flags),
3},
 
/* IRQ Table length (Byte4) */
 
{ACPI_RSC_COUNT, ACPI_RS_OFFSET (Data.ExtendedIrq.InterruptCount),
AML_OFFSET (ExtendedIrq.InterruptCount),
sizeof (UINT32)},
 
/* Copy every IRQ in the table, each is 32 bits */
 
{ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.ExtendedIrq.Interrupts[0]),
AML_OFFSET (ExtendedIrq.Interrupts[0]),
0},
 
/* Optional ResourceSource (Index and String) */
 
{ACPI_RSC_SOURCEX, ACPI_RS_OFFSET (Data.ExtendedIrq.ResourceSource),
ACPI_RS_OFFSET (Data.ExtendedIrq.Interrupts[0]),
sizeof (AML_RESOURCE_EXTENDED_IRQ)}
};
 
 
/*******************************************************************************
*
* AcpiRsConvertDma
*
******************************************************************************/
 
ACPI_RSCONVERT_INFO AcpiRsConvertDma[6] =
{
{ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_DMA,
ACPI_RS_SIZE (ACPI_RESOURCE_DMA),
ACPI_RSC_TABLE_SIZE (AcpiRsConvertDma)},
 
{ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_DMA,
sizeof (AML_RESOURCE_DMA),
0},
 
/* Flags: transfer preference, bus mastering, channel speed */
 
{ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Dma.Transfer),
AML_OFFSET (Dma.Flags),
0},
 
{ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Dma.BusMaster),
AML_OFFSET (Dma.Flags),
2},
 
{ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Dma.Type),
AML_OFFSET (Dma.Flags),
5},
 
/* DMA channel mask bits */
 
{ACPI_RSC_BITMASK, ACPI_RS_OFFSET (Data.Dma.Channels[0]),
AML_OFFSET (Dma.DmaChannelMask),
ACPI_RS_OFFSET (Data.Dma.ChannelCount)}
};
 
/drivers/devman/acpica/resources/rslist.c
0,0 → 1,286
/*******************************************************************************
*
* Module Name: rslist - Linked list utilities
*
******************************************************************************/
 
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* Code in any form, with the right to sublicense such rights; and
*
* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
* license (with the right to sublicense), under only those claims of Intel
* patents that are infringed by the Original Intel Code, to make, use, sell,
* offer to sell, and import the Covered Code and derivative works thereof
* solely to the minimum extent necessary to exercise the above copyright
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************/
 
#define __RSLIST_C__
 
#include "acpi.h"
#include "accommon.h"
#include "acresrc.h"
 
#define _COMPONENT ACPI_RESOURCES
ACPI_MODULE_NAME ("rslist")
 
 
/*******************************************************************************
*
* FUNCTION: AcpiRsConvertAmlToResources
*
* PARAMETERS: ACPI_WALK_AML_CALLBACK
* ResourcePtr - Pointer to the buffer that will
* contain the output structures
*
* RETURN: Status
*
* DESCRIPTION: Convert an AML resource to an internal representation of the
* resource that is aligned and easier to access.
*
******************************************************************************/
 
ACPI_STATUS
AcpiRsConvertAmlToResources (
UINT8 *Aml,
UINT32 Length,
UINT32 Offset,
UINT8 ResourceIndex,
void *Context)
{
ACPI_RESOURCE **ResourcePtr = ACPI_CAST_INDIRECT_PTR (
ACPI_RESOURCE, Context);
ACPI_RESOURCE *Resource;
ACPI_STATUS Status;
 
 
ACPI_FUNCTION_TRACE (RsConvertAmlToResources);
 
 
/*
* Check that the input buffer and all subsequent pointers into it
* are aligned on a native word boundary. Most important on IA64
*/
Resource = *ResourcePtr;
if (ACPI_IS_MISALIGNED (Resource))
{
ACPI_WARNING ((AE_INFO,
"Misaligned resource pointer %p", Resource));
}
 
/* Convert the AML byte stream resource to a local resource struct */
 
Status = AcpiRsConvertAmlToResource (
Resource, ACPI_CAST_PTR (AML_RESOURCE, Aml),
AcpiGbl_GetResourceDispatch[ResourceIndex]);
if (ACPI_FAILURE (Status))
{
ACPI_EXCEPTION ((AE_INFO, Status,
"Could not convert AML resource (Type 0x%X)", *Aml));
return_ACPI_STATUS (Status);
}
 
ACPI_DEBUG_PRINT ((ACPI_DB_RESOURCES,
"Type %.2X, AmlLength %.2X InternalLength %.2X\n",
AcpiUtGetResourceType (Aml), Length,
Resource->Length));
 
/* Point to the next structure in the output buffer */
 
*ResourcePtr = ACPI_ADD_PTR (void, Resource, Resource->Length);
return_ACPI_STATUS (AE_OK);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiRsConvertResourcesToAml
*
* PARAMETERS: Resource - Pointer to the resource linked list
* AmlSizeNeeded - Calculated size of the byte stream
* needed from calling AcpiRsGetAmlLength()
* The size of the OutputBuffer is
* guaranteed to be >= AmlSizeNeeded
* OutputBuffer - Pointer to the buffer that will
* contain the byte stream
*
* RETURN: Status
*
* DESCRIPTION: Takes the resource linked list and parses it, creating a
* byte stream of resources in the caller's output buffer
*
******************************************************************************/
 
ACPI_STATUS
AcpiRsConvertResourcesToAml (
ACPI_RESOURCE *Resource,
ACPI_SIZE AmlSizeNeeded,
UINT8 *OutputBuffer)
{
UINT8 *Aml = OutputBuffer;
UINT8 *EndAml = OutputBuffer + AmlSizeNeeded;
ACPI_STATUS Status;
 
 
ACPI_FUNCTION_TRACE (RsConvertResourcesToAml);
 
 
/* Walk the resource descriptor list, convert each descriptor */
 
while (Aml < EndAml)
{
/* Validate the (internal) Resource Type */
 
if (Resource->Type > ACPI_RESOURCE_TYPE_MAX)
{
ACPI_ERROR ((AE_INFO,
"Invalid descriptor type (0x%X) in resource list",
Resource->Type));
return_ACPI_STATUS (AE_BAD_DATA);
}
 
/* Perform the conversion */
 
Status = AcpiRsConvertResourceToAml (Resource,
ACPI_CAST_PTR (AML_RESOURCE, Aml),
AcpiGbl_SetResourceDispatch[Resource->Type]);
if (ACPI_FAILURE (Status))
{
ACPI_EXCEPTION ((AE_INFO, Status,
"Could not convert resource (type 0x%X) to AML",
Resource->Type));
return_ACPI_STATUS (Status);
}
 
/* Perform final sanity check on the new AML resource descriptor */
 
Status = AcpiUtValidateResource (
ACPI_CAST_PTR (AML_RESOURCE, Aml), NULL);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
 
/* Check for end-of-list, normal exit */
 
if (Resource->Type == ACPI_RESOURCE_TYPE_END_TAG)
{
/* An End Tag indicates the end of the input Resource Template */
 
return_ACPI_STATUS (AE_OK);
}
 
/*
* Extract the total length of the new descriptor and set the
* Aml to point to the next (output) resource descriptor
*/
Aml += AcpiUtGetDescriptorLength (Aml);
 
/* Point to the next input resource descriptor */
 
Resource = ACPI_ADD_PTR (ACPI_RESOURCE, Resource, Resource->Length);
}
 
/* Completed buffer, but did not find an EndTag resource descriptor */
 
return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
}
 
/drivers/devman/acpica/resources/rsmemory.c
0,0 → 1,323
/*******************************************************************************
*
* Module Name: rsmem24 - Memory resource descriptors
*
******************************************************************************/
 
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* Code in any form, with the right to sublicense such rights; and
*
* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
* license (with the right to sublicense), under only those claims of Intel
* patents that are infringed by the Original Intel Code, to make, use, sell,
* offer to sell, and import the Covered Code and derivative works thereof
* solely to the minimum extent necessary to exercise the above copyright
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************/
 
#define __RSMEMORY_C__
 
#include "acpi.h"
#include "accommon.h"
#include "acresrc.h"
 
#define _COMPONENT ACPI_RESOURCES
ACPI_MODULE_NAME ("rsmemory")
 
 
/*******************************************************************************
*
* AcpiRsConvertMemory24
*
******************************************************************************/
 
ACPI_RSCONVERT_INFO AcpiRsConvertMemory24[4] =
{
{ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_MEMORY24,
ACPI_RS_SIZE (ACPI_RESOURCE_MEMORY24),
ACPI_RSC_TABLE_SIZE (AcpiRsConvertMemory24)},
 
{ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_MEMORY24,
sizeof (AML_RESOURCE_MEMORY24),
0},
 
/* Read/Write bit */
 
{ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Memory24.WriteProtect),
AML_OFFSET (Memory24.Flags),
0},
/*
* These fields are contiguous in both the source and destination:
* Minimum Base Address
* Maximum Base Address
* Address Base Alignment
* Range Length
*/
{ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.Memory24.Minimum),
AML_OFFSET (Memory24.Minimum),
4}
};
 
 
/*******************************************************************************
*
* AcpiRsConvertMemory32
*
******************************************************************************/
 
ACPI_RSCONVERT_INFO AcpiRsConvertMemory32[4] =
{
{ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_MEMORY32,
ACPI_RS_SIZE (ACPI_RESOURCE_MEMORY32),
ACPI_RSC_TABLE_SIZE (AcpiRsConvertMemory32)},
 
{ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_MEMORY32,
sizeof (AML_RESOURCE_MEMORY32),
0},
 
/* Read/Write bit */
 
{ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Memory32.WriteProtect),
AML_OFFSET (Memory32.Flags),
0},
/*
* These fields are contiguous in both the source and destination:
* Minimum Base Address
* Maximum Base Address
* Address Base Alignment
* Range Length
*/
{ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.Memory32.Minimum),
AML_OFFSET (Memory32.Minimum),
4}
};
 
 
/*******************************************************************************
*
* AcpiRsConvertFixedMemory32
*
******************************************************************************/
 
ACPI_RSCONVERT_INFO AcpiRsConvertFixedMemory32[4] =
{
{ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_FIXED_MEMORY32,
ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_MEMORY32),
ACPI_RSC_TABLE_SIZE (AcpiRsConvertFixedMemory32)},
 
{ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_FIXED_MEMORY32,
sizeof (AML_RESOURCE_FIXED_MEMORY32),
0},
 
/* Read/Write bit */
 
{ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.FixedMemory32.WriteProtect),
AML_OFFSET (FixedMemory32.Flags),
0},
/*
* These fields are contiguous in both the source and destination:
* Base Address
* Range Length
*/
{ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.FixedMemory32.Address),
AML_OFFSET (FixedMemory32.Address),
2}
};
 
 
/*******************************************************************************
*
* AcpiRsGetVendorSmall
*
******************************************************************************/
 
ACPI_RSCONVERT_INFO AcpiRsGetVendorSmall[3] =
{
{ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_VENDOR,
ACPI_RS_SIZE (ACPI_RESOURCE_VENDOR),
ACPI_RSC_TABLE_SIZE (AcpiRsGetVendorSmall)},
 
/* Length of the vendor data (byte count) */
 
{ACPI_RSC_COUNT16, ACPI_RS_OFFSET (Data.Vendor.ByteLength),
0,
sizeof (UINT8)},
 
/* Vendor data */
 
{ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Vendor.ByteData[0]),
sizeof (AML_RESOURCE_SMALL_HEADER),
0}
};
 
 
/*******************************************************************************
*
* AcpiRsGetVendorLarge
*
******************************************************************************/
 
ACPI_RSCONVERT_INFO AcpiRsGetVendorLarge[3] =
{
{ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_VENDOR,
ACPI_RS_SIZE (ACPI_RESOURCE_VENDOR),
ACPI_RSC_TABLE_SIZE (AcpiRsGetVendorLarge)},
 
/* Length of the vendor data (byte count) */
 
{ACPI_RSC_COUNT16, ACPI_RS_OFFSET (Data.Vendor.ByteLength),
0,
sizeof (UINT8)},
 
/* Vendor data */
 
{ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Vendor.ByteData[0]),
sizeof (AML_RESOURCE_LARGE_HEADER),
0}
};
 
 
/*******************************************************************************
*
* AcpiRsSetVendor
*
******************************************************************************/
 
ACPI_RSCONVERT_INFO AcpiRsSetVendor[7] =
{
/* Default is a small vendor descriptor */
 
{ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_VENDOR_SMALL,
sizeof (AML_RESOURCE_SMALL_HEADER),
ACPI_RSC_TABLE_SIZE (AcpiRsSetVendor)},
 
/* Get the length and copy the data */
 
{ACPI_RSC_COUNT16, ACPI_RS_OFFSET (Data.Vendor.ByteLength),
0,
0},
 
{ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Vendor.ByteData[0]),
sizeof (AML_RESOURCE_SMALL_HEADER),
0},
 
/*
* All done if the Vendor byte length is 7 or less, meaning that it will
* fit within a small descriptor
*/
{ACPI_RSC_EXIT_LE, 0, 0, 7},
 
/* Must create a large vendor descriptor */
 
{ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_VENDOR_LARGE,
sizeof (AML_RESOURCE_LARGE_HEADER),
0},
 
{ACPI_RSC_COUNT16, ACPI_RS_OFFSET (Data.Vendor.ByteLength),
0,
0},
 
{ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Vendor.ByteData[0]),
sizeof (AML_RESOURCE_LARGE_HEADER),
0}
};
 
 
/drivers/devman/acpica/resources/rsmisc.c
0,0 → 1,683
/*******************************************************************************
*
* Module Name: rsmisc - Miscellaneous resource descriptors
*
******************************************************************************/
 
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* Code in any form, with the right to sublicense such rights; and
*
* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
* license (with the right to sublicense), under only those claims of Intel
* patents that are infringed by the Original Intel Code, to make, use, sell,
* offer to sell, and import the Covered Code and derivative works thereof
* solely to the minimum extent necessary to exercise the above copyright
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************/
 
#define __RSMISC_C__
 
#include "acpi.h"
#include "accommon.h"
#include "acresrc.h"
 
#define _COMPONENT ACPI_RESOURCES
ACPI_MODULE_NAME ("rsmisc")
 
 
#define INIT_RESOURCE_TYPE(i) i->ResourceOffset
#define INIT_RESOURCE_LENGTH(i) i->AmlOffset
#define INIT_TABLE_LENGTH(i) i->Value
 
#define COMPARE_OPCODE(i) i->ResourceOffset
#define COMPARE_TARGET(i) i->AmlOffset
#define COMPARE_VALUE(i) i->Value
 
 
/*******************************************************************************
*
* FUNCTION: AcpiRsConvertAmlToResource
*
* PARAMETERS: Resource - Pointer to the resource descriptor
* Aml - Where the AML descriptor is returned
* Info - Pointer to appropriate conversion table
*
* RETURN: Status
*
* DESCRIPTION: Convert an external AML resource descriptor to the corresponding
* internal resource descriptor
*
******************************************************************************/
 
ACPI_STATUS
AcpiRsConvertAmlToResource (
ACPI_RESOURCE *Resource,
AML_RESOURCE *Aml,
ACPI_RSCONVERT_INFO *Info)
{
ACPI_RS_LENGTH AmlResourceLength;
void *Source;
void *Destination;
char *Target;
UINT8 Count;
UINT8 FlagsMode = FALSE;
UINT16 ItemCount = 0;
UINT16 Temp16 = 0;
 
 
ACPI_FUNCTION_TRACE (RsConvertAmlToResource);
 
 
if (((ACPI_SIZE) Resource) & 0x3)
{
/* Each internal resource struct is expected to be 32-bit aligned */
 
ACPI_WARNING ((AE_INFO,
"Misaligned resource pointer (get): %p Type 0x%2.2X Length %u",
Resource, Resource->Type, Resource->Length));
}
 
/* Extract the resource Length field (does not include header length) */
 
AmlResourceLength = AcpiUtGetResourceLength (Aml);
 
/*
* First table entry must be ACPI_RSC_INITxxx and must contain the
* table length (# of table entries)
*/
Count = INIT_TABLE_LENGTH (Info);
 
while (Count)
{
/*
* Source is the external AML byte stream buffer,
* destination is the internal resource descriptor
*/
Source = ACPI_ADD_PTR (void, Aml, Info->AmlOffset);
Destination = ACPI_ADD_PTR (void, Resource, Info->ResourceOffset);
 
switch (Info->Opcode)
{
case ACPI_RSC_INITGET:
/*
* Get the resource type and the initial (minimum) length
*/
ACPI_MEMSET (Resource, 0, INIT_RESOURCE_LENGTH (Info));
Resource->Type = INIT_RESOURCE_TYPE (Info);
Resource->Length = INIT_RESOURCE_LENGTH (Info);
break;
 
 
case ACPI_RSC_INITSET:
break;
 
 
case ACPI_RSC_FLAGINIT:
 
FlagsMode = TRUE;
break;
 
 
case ACPI_RSC_1BITFLAG:
/*
* Mask and shift the flag bit
*/
ACPI_SET8 (Destination) = (UINT8)
((ACPI_GET8 (Source) >> Info->Value) & 0x01);
break;
 
 
case ACPI_RSC_2BITFLAG:
/*
* Mask and shift the flag bits
*/
ACPI_SET8 (Destination) = (UINT8)
((ACPI_GET8 (Source) >> Info->Value) & 0x03);
break;
 
 
case ACPI_RSC_COUNT:
 
ItemCount = ACPI_GET8 (Source);
ACPI_SET8 (Destination) = (UINT8) ItemCount;
 
Resource->Length = Resource->Length +
(Info->Value * (ItemCount - 1));
break;
 
 
case ACPI_RSC_COUNT16:
 
ItemCount = AmlResourceLength;
ACPI_SET16 (Destination) = ItemCount;
 
Resource->Length = Resource->Length +
(Info->Value * (ItemCount - 1));
break;
 
 
case ACPI_RSC_LENGTH:
 
Resource->Length = Resource->Length + Info->Value;
break;
 
 
case ACPI_RSC_MOVE8:
case ACPI_RSC_MOVE16:
case ACPI_RSC_MOVE32:
case ACPI_RSC_MOVE64:
/*
* Raw data move. Use the Info value field unless ItemCount has
* been previously initialized via a COUNT opcode
*/
if (Info->Value)
{
ItemCount = Info->Value;
}
AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
break;
 
 
case ACPI_RSC_SET8:
 
ACPI_MEMSET (Destination, Info->AmlOffset, Info->Value);
break;
 
 
case ACPI_RSC_DATA8:
 
Target = ACPI_ADD_PTR (char, Resource, Info->Value);
ACPI_MEMCPY (Destination, Source, ACPI_GET16 (Target));
break;
 
 
case ACPI_RSC_ADDRESS:
/*
* Common handler for address descriptor flags
*/
if (!AcpiRsGetAddressCommon (Resource, Aml))
{
return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
}
break;
 
 
case ACPI_RSC_SOURCE:
/*
* Optional ResourceSource (Index and String)
*/
Resource->Length +=
AcpiRsGetResourceSource (AmlResourceLength, Info->Value,
Destination, Aml, NULL);
break;
 
 
case ACPI_RSC_SOURCEX:
/*
* Optional ResourceSource (Index and String). This is the more
* complicated case used by the Interrupt() macro
*/
Target = ACPI_ADD_PTR (char, Resource, Info->AmlOffset + (ItemCount * 4));
 
Resource->Length +=
AcpiRsGetResourceSource (AmlResourceLength,
(ACPI_RS_LENGTH) (((ItemCount - 1) * sizeof (UINT32)) + Info->Value),
Destination, Aml, Target);
break;
 
 
case ACPI_RSC_BITMASK:
/*
* 8-bit encoded bitmask (DMA macro)
*/
ItemCount = AcpiRsDecodeBitmask (ACPI_GET8 (Source), Destination);
if (ItemCount)
{
Resource->Length += (ItemCount - 1);
}
 
Target = ACPI_ADD_PTR (char, Resource, Info->Value);
ACPI_SET8 (Target) = (UINT8) ItemCount;
break;
 
 
case ACPI_RSC_BITMASK16:
/*
* 16-bit encoded bitmask (IRQ macro)
*/
ACPI_MOVE_16_TO_16 (&Temp16, Source);
 
ItemCount = AcpiRsDecodeBitmask (Temp16, Destination);
if (ItemCount)
{
Resource->Length += (ItemCount - 1);
}
 
Target = ACPI_ADD_PTR (char, Resource, Info->Value);
ACPI_SET8 (Target) = (UINT8) ItemCount;
break;
 
 
case ACPI_RSC_EXIT_NE:
/*
* Control - Exit conversion if not equal
*/
switch (Info->ResourceOffset)
{
case ACPI_RSC_COMPARE_AML_LENGTH:
if (AmlResourceLength != Info->Value)
{
goto Exit;
}
break;
 
case ACPI_RSC_COMPARE_VALUE:
if (ACPI_GET8 (Source) != Info->Value)
{
goto Exit;
}
break;
 
default:
 
ACPI_ERROR ((AE_INFO, "Invalid conversion sub-opcode"));
return_ACPI_STATUS (AE_BAD_PARAMETER);
}
break;
 
 
default:
 
ACPI_ERROR ((AE_INFO, "Invalid conversion opcode"));
return_ACPI_STATUS (AE_BAD_PARAMETER);
}
 
Count--;
Info++;
}
 
Exit:
if (!FlagsMode)
{
/* Round the resource struct length up to the next boundary (32 or 64) */
 
Resource->Length = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (Resource->Length);
}
return_ACPI_STATUS (AE_OK);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiRsConvertResourceToAml
*
* PARAMETERS: Resource - Pointer to the resource descriptor
* Aml - Where the AML descriptor is returned
* Info - Pointer to appropriate conversion table
*
* RETURN: Status
*
* DESCRIPTION: Convert an internal resource descriptor to the corresponding
* external AML resource descriptor.
*
******************************************************************************/
 
ACPI_STATUS
AcpiRsConvertResourceToAml (
ACPI_RESOURCE *Resource,
AML_RESOURCE *Aml,
ACPI_RSCONVERT_INFO *Info)
{
void *Source = NULL;
void *Destination;
ACPI_RSDESC_SIZE AmlLength = 0;
UINT8 Count;
UINT16 Temp16 = 0;
UINT16 ItemCount = 0;
 
 
ACPI_FUNCTION_TRACE (RsConvertResourceToAml);
 
 
/*
* First table entry must be ACPI_RSC_INITxxx and must contain the
* table length (# of table entries)
*/
Count = INIT_TABLE_LENGTH (Info);
 
while (Count)
{
/*
* Source is the internal resource descriptor,
* destination is the external AML byte stream buffer
*/
Source = ACPI_ADD_PTR (void, Resource, Info->ResourceOffset);
Destination = ACPI_ADD_PTR (void, Aml, Info->AmlOffset);
 
switch (Info->Opcode)
{
case ACPI_RSC_INITSET:
 
ACPI_MEMSET (Aml, 0, INIT_RESOURCE_LENGTH (Info));
AmlLength = INIT_RESOURCE_LENGTH (Info);
AcpiRsSetResourceHeader (INIT_RESOURCE_TYPE (Info), AmlLength, Aml);
break;
 
 
case ACPI_RSC_INITGET:
break;
 
 
case ACPI_RSC_FLAGINIT:
/*
* Clear the flag byte
*/
ACPI_SET8 (Destination) = 0;
break;
 
 
case ACPI_RSC_1BITFLAG:
/*
* Mask and shift the flag bit
*/
ACPI_SET8 (Destination) |= (UINT8)
((ACPI_GET8 (Source) & 0x01) << Info->Value);
break;
 
 
case ACPI_RSC_2BITFLAG:
/*
* Mask and shift the flag bits
*/
ACPI_SET8 (Destination) |= (UINT8)
((ACPI_GET8 (Source) & 0x03) << Info->Value);
break;
 
 
case ACPI_RSC_COUNT:
 
ItemCount = ACPI_GET8 (Source);
ACPI_SET8 (Destination) = (UINT8) ItemCount;
 
AmlLength = (UINT16) (AmlLength + (Info->Value * (ItemCount - 1)));
break;
 
 
case ACPI_RSC_COUNT16:
 
ItemCount = ACPI_GET16 (Source);
AmlLength = (UINT16) (AmlLength + ItemCount);
AcpiRsSetResourceLength (AmlLength, Aml);
break;
 
 
case ACPI_RSC_LENGTH:
 
AcpiRsSetResourceLength (Info->Value, Aml);
break;
 
 
case ACPI_RSC_MOVE8:
case ACPI_RSC_MOVE16:
case ACPI_RSC_MOVE32:
case ACPI_RSC_MOVE64:
 
if (Info->Value)
{
ItemCount = Info->Value;
}
AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
break;
 
 
case ACPI_RSC_ADDRESS:
 
/* Set the Resource Type, General Flags, and Type-Specific Flags */
 
AcpiRsSetAddressCommon (Aml, Resource);
break;
 
 
case ACPI_RSC_SOURCEX:
/*
* Optional ResourceSource (Index and String)
*/
AmlLength = AcpiRsSetResourceSource (
Aml, (ACPI_RS_LENGTH) AmlLength, Source);
AcpiRsSetResourceLength (AmlLength, Aml);
break;
 
 
case ACPI_RSC_SOURCE:
/*
* Optional ResourceSource (Index and String). This is the more
* complicated case used by the Interrupt() macro
*/
AmlLength = AcpiRsSetResourceSource (Aml, Info->Value, Source);
AcpiRsSetResourceLength (AmlLength, Aml);
break;
 
 
case ACPI_RSC_BITMASK:
/*
* 8-bit encoded bitmask (DMA macro)
*/
ACPI_SET8 (Destination) = (UINT8)
AcpiRsEncodeBitmask (Source,
*ACPI_ADD_PTR (UINT8, Resource, Info->Value));
break;
 
 
case ACPI_RSC_BITMASK16:
/*
* 16-bit encoded bitmask (IRQ macro)
*/
Temp16 = AcpiRsEncodeBitmask (Source,
*ACPI_ADD_PTR (UINT8, Resource, Info->Value));
ACPI_MOVE_16_TO_16 (Destination, &Temp16);
break;
 
 
case ACPI_RSC_EXIT_LE:
/*
* Control - Exit conversion if less than or equal
*/
if (ItemCount <= Info->Value)
{
goto Exit;
}
break;
 
 
case ACPI_RSC_EXIT_NE:
/*
* Control - Exit conversion if not equal
*/
switch (COMPARE_OPCODE (Info))
{
case ACPI_RSC_COMPARE_VALUE:
 
if (*ACPI_ADD_PTR (UINT8, Resource,
COMPARE_TARGET (Info)) != COMPARE_VALUE (Info))
{
goto Exit;
}
break;
 
default:
 
ACPI_ERROR ((AE_INFO, "Invalid conversion sub-opcode"));
return_ACPI_STATUS (AE_BAD_PARAMETER);
}
break;
 
 
case ACPI_RSC_EXIT_EQ:
/*
* Control - Exit conversion if equal
*/
if (*ACPI_ADD_PTR (UINT8, Resource,
COMPARE_TARGET (Info)) == COMPARE_VALUE (Info))
{
goto Exit;
}
break;
 
 
default:
 
ACPI_ERROR ((AE_INFO, "Invalid conversion opcode"));
return_ACPI_STATUS (AE_BAD_PARAMETER);
}
 
Count--;
Info++;
}
 
Exit:
return_ACPI_STATUS (AE_OK);
}
 
 
#if 0
/* Previous resource validations */
 
if (Aml->ExtAddress64.RevisionID != AML_RESOURCE_EXTENDED_ADDRESS_REVISION)
{
return_ACPI_STATUS (AE_SUPPORT);
}
 
if (Resource->Data.StartDpf.PerformanceRobustness >= 3)
{
return_ACPI_STATUS (AE_AML_BAD_RESOURCE_VALUE);
}
 
if (((Aml->Irq.Flags & 0x09) == 0x00) ||
((Aml->Irq.Flags & 0x09) == 0x09))
{
/*
* Only [ActiveHigh, EdgeSensitive] or [ActiveLow, LevelSensitive]
* polarity/trigger interrupts are allowed (ACPI spec, section
* "IRQ Format"), so 0x00 and 0x09 are illegal.
*/
ACPI_ERROR ((AE_INFO,
"Invalid interrupt polarity/trigger in resource list, 0x%X",
Aml->Irq.Flags));
return_ACPI_STATUS (AE_BAD_DATA);
}
 
Resource->Data.ExtendedIrq.InterruptCount = Temp8;
if (Temp8 < 1)
{
/* Must have at least one IRQ */
 
return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH);
}
 
if (Resource->Data.Dma.Transfer == 0x03)
{
ACPI_ERROR ((AE_INFO,
"Invalid DMA.Transfer preference (3)"));
return_ACPI_STATUS (AE_BAD_DATA);
}
#endif
 
 
/drivers/devman/acpica/resources/rsutils.c
0,0 → 1,874
/*******************************************************************************
*
* Module Name: rsutils - Utilities for the resource manager
*
******************************************************************************/
 
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* Code in any form, with the right to sublicense such rights; and
*
* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
* license (with the right to sublicense), under only those claims of Intel
* patents that are infringed by the Original Intel Code, to make, use, sell,
* offer to sell, and import the Covered Code and derivative works thereof
* solely to the minimum extent necessary to exercise the above copyright
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************/
 
 
#define __RSUTILS_C__
 
#include "acpi.h"
#include "accommon.h"
#include "acnamesp.h"
#include "acresrc.h"
 
 
#define _COMPONENT ACPI_RESOURCES
ACPI_MODULE_NAME ("rsutils")
 
 
/*******************************************************************************
*
* FUNCTION: AcpiRsDecodeBitmask
*
* PARAMETERS: Mask - Bitmask to decode
* List - Where the converted list is returned
*
* RETURN: Count of bits set (length of list)
*
* DESCRIPTION: Convert a bit mask into a list of values
*
******************************************************************************/
 
UINT8
AcpiRsDecodeBitmask (
UINT16 Mask,
UINT8 *List)
{
UINT8 i;
UINT8 BitCount;
 
 
ACPI_FUNCTION_ENTRY ();
 
 
/* Decode the mask bits */
 
for (i = 0, BitCount = 0; Mask; i++)
{
if (Mask & 0x0001)
{
List[BitCount] = i;
BitCount++;
}
 
Mask >>= 1;
}
 
return (BitCount);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiRsEncodeBitmask
*
* PARAMETERS: List - List of values to encode
* Count - Length of list
*
* RETURN: Encoded bitmask
*
* DESCRIPTION: Convert a list of values to an encoded bitmask
*
******************************************************************************/
 
UINT16
AcpiRsEncodeBitmask (
UINT8 *List,
UINT8 Count)
{
UINT32 i;
UINT16 Mask;
 
 
ACPI_FUNCTION_ENTRY ();
 
 
/* Encode the list into a single bitmask */
 
for (i = 0, Mask = 0; i < Count; i++)
{
Mask |= (0x1 << List[i]);
}
 
return (Mask);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiRsMoveData
*
* PARAMETERS: Destination - Pointer to the destination descriptor
* Source - Pointer to the source descriptor
* ItemCount - How many items to move
* MoveType - Byte width
*
* RETURN: None
*
* DESCRIPTION: Move multiple data items from one descriptor to another. Handles
* alignment issues and endian issues if necessary, as configured
* via the ACPI_MOVE_* macros. (This is why a memcpy is not used)
*
******************************************************************************/
 
void
AcpiRsMoveData (
void *Destination,
void *Source,
UINT16 ItemCount,
UINT8 MoveType)
{
UINT32 i;
 
 
ACPI_FUNCTION_ENTRY ();
 
 
/* One move per item */
 
for (i = 0; i < ItemCount; i++)
{
switch (MoveType)
{
/*
* For the 8-bit case, we can perform the move all at once
* since there are no alignment or endian issues
*/
case ACPI_RSC_MOVE8:
ACPI_MEMCPY (Destination, Source, ItemCount);
return;
 
/*
* 16-, 32-, and 64-bit cases must use the move macros that perform
* endian conversion and/or accomodate hardware that cannot perform
* misaligned memory transfers
*/
case ACPI_RSC_MOVE16:
ACPI_MOVE_16_TO_16 (&ACPI_CAST_PTR (UINT16, Destination)[i],
&ACPI_CAST_PTR (UINT16, Source)[i]);
break;
 
case ACPI_RSC_MOVE32:
ACPI_MOVE_32_TO_32 (&ACPI_CAST_PTR (UINT32, Destination)[i],
&ACPI_CAST_PTR (UINT32, Source)[i]);
break;
 
case ACPI_RSC_MOVE64:
ACPI_MOVE_64_TO_64 (&ACPI_CAST_PTR (UINT64, Destination)[i],
&ACPI_CAST_PTR (UINT64, Source)[i]);
break;
 
default:
return;
}
}
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiRsSetResourceLength
*
* PARAMETERS: TotalLength - Length of the AML descriptor, including
* the header and length fields.
* Aml - Pointer to the raw AML descriptor
*
* RETURN: None
*
* DESCRIPTION: Set the ResourceLength field of an AML
* resource descriptor, both Large and Small descriptors are
* supported automatically. Note: Descriptor Type field must
* be valid.
*
******************************************************************************/
 
void
AcpiRsSetResourceLength (
ACPI_RSDESC_SIZE TotalLength,
AML_RESOURCE *Aml)
{
ACPI_RS_LENGTH ResourceLength;
 
 
ACPI_FUNCTION_ENTRY ();
 
 
/* Length is the total descriptor length minus the header length */
 
ResourceLength = (ACPI_RS_LENGTH)
(TotalLength - AcpiUtGetResourceHeaderLength (Aml));
 
/* Length is stored differently for large and small descriptors */
 
if (Aml->SmallHeader.DescriptorType & ACPI_RESOURCE_NAME_LARGE)
{
/* Large descriptor -- bytes 1-2 contain the 16-bit length */
 
ACPI_MOVE_16_TO_16 (&Aml->LargeHeader.ResourceLength, &ResourceLength);
}
else
{
/* Small descriptor -- bits 2:0 of byte 0 contain the length */
 
Aml->SmallHeader.DescriptorType = (UINT8)
 
/* Clear any existing length, preserving descriptor type bits */
 
((Aml->SmallHeader.DescriptorType & ~ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK)
 
| ResourceLength);
}
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiRsSetResourceHeader
*
* PARAMETERS: DescriptorType - Byte to be inserted as the type
* TotalLength - Length of the AML descriptor, including
* the header and length fields.
* Aml - Pointer to the raw AML descriptor
*
* RETURN: None
*
* DESCRIPTION: Set the DescriptorType and ResourceLength fields of an AML
* resource descriptor, both Large and Small descriptors are
* supported automatically
*
******************************************************************************/
 
void
AcpiRsSetResourceHeader (
UINT8 DescriptorType,
ACPI_RSDESC_SIZE TotalLength,
AML_RESOURCE *Aml)
{
ACPI_FUNCTION_ENTRY ();
 
 
/* Set the Resource Type */
 
Aml->SmallHeader.DescriptorType = DescriptorType;
 
/* Set the Resource Length */
 
AcpiRsSetResourceLength (TotalLength, Aml);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiRsStrcpy
*
* PARAMETERS: Destination - Pointer to the destination string
* Source - Pointer to the source string
*
* RETURN: String length, including NULL terminator
*
* DESCRIPTION: Local string copy that returns the string length, saving a
* strcpy followed by a strlen.
*
******************************************************************************/
 
static UINT16
AcpiRsStrcpy (
char *Destination,
char *Source)
{
UINT16 i;
 
 
ACPI_FUNCTION_ENTRY ();
 
 
for (i = 0; Source[i]; i++)
{
Destination[i] = Source[i];
}
 
Destination[i] = 0;
 
/* Return string length including the NULL terminator */
 
return ((UINT16) (i + 1));
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiRsGetResourceSource
*
* PARAMETERS: ResourceLength - Length field of the descriptor
* MinimumLength - Minimum length of the descriptor (minus
* any optional fields)
* ResourceSource - Where the ResourceSource is returned
* Aml - Pointer to the raw AML descriptor
* StringPtr - (optional) where to store the actual
* ResourceSource string
*
* RETURN: Length of the string plus NULL terminator, rounded up to native
* word boundary
*
* DESCRIPTION: Copy the optional ResourceSource data from a raw AML descriptor
* to an internal resource descriptor
*
******************************************************************************/
 
ACPI_RS_LENGTH
AcpiRsGetResourceSource (
ACPI_RS_LENGTH ResourceLength,
ACPI_RS_LENGTH MinimumLength,
ACPI_RESOURCE_SOURCE *ResourceSource,
AML_RESOURCE *Aml,
char *StringPtr)
{
ACPI_RSDESC_SIZE TotalLength;
UINT8 *AmlResourceSource;
 
 
ACPI_FUNCTION_ENTRY ();
 
 
TotalLength = ResourceLength + sizeof (AML_RESOURCE_LARGE_HEADER);
AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength);
 
/*
* ResourceSource is present if the length of the descriptor is longer than
* the minimum length.
*
* Note: Some resource descriptors will have an additional null, so
* we add 1 to the minimum length.
*/
if (TotalLength > (ACPI_RSDESC_SIZE) (MinimumLength + 1))
{
/* Get the ResourceSourceIndex */
 
ResourceSource->Index = AmlResourceSource[0];
 
ResourceSource->StringPtr = StringPtr;
if (!StringPtr)
{
/*
* String destination pointer is not specified; Set the String
* pointer to the end of the current ResourceSource structure.
*/
ResourceSource->StringPtr = ACPI_ADD_PTR (char, ResourceSource,
sizeof (ACPI_RESOURCE_SOURCE));
}
 
/*
* In order for the Resource length to be a multiple of the native
* word, calculate the length of the string (+1 for NULL terminator)
* and expand to the next word multiple.
*
* Zero the entire area of the buffer.
*/
TotalLength = (UINT32) ACPI_STRLEN (
ACPI_CAST_PTR (char, &AmlResourceSource[1])) + 1;
TotalLength = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (TotalLength);
 
ACPI_MEMSET (ResourceSource->StringPtr, 0, TotalLength);
 
/* Copy the ResourceSource string to the destination */
 
ResourceSource->StringLength = AcpiRsStrcpy (ResourceSource->StringPtr,
ACPI_CAST_PTR (char, &AmlResourceSource[1]));
 
return ((ACPI_RS_LENGTH) TotalLength);
}
 
/* ResourceSource is not present */
 
ResourceSource->Index = 0;
ResourceSource->StringLength = 0;
ResourceSource->StringPtr = NULL;
return (0);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiRsSetResourceSource
*
* PARAMETERS: Aml - Pointer to the raw AML descriptor
* MinimumLength - Minimum length of the descriptor (minus
* any optional fields)
* ResourceSource - Internal ResourceSource
 
*
* RETURN: Total length of the AML descriptor
*
* DESCRIPTION: Convert an optional ResourceSource from internal format to a
* raw AML resource descriptor
*
******************************************************************************/
 
ACPI_RSDESC_SIZE
AcpiRsSetResourceSource (
AML_RESOURCE *Aml,
ACPI_RS_LENGTH MinimumLength,
ACPI_RESOURCE_SOURCE *ResourceSource)
{
UINT8 *AmlResourceSource;
ACPI_RSDESC_SIZE DescriptorLength;
 
 
ACPI_FUNCTION_ENTRY ();
 
 
DescriptorLength = MinimumLength;
 
/* Non-zero string length indicates presence of a ResourceSource */
 
if (ResourceSource->StringLength)
{
/* Point to the end of the AML descriptor */
 
AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength);
 
/* Copy the ResourceSourceIndex */
 
AmlResourceSource[0] = (UINT8) ResourceSource->Index;
 
/* Copy the ResourceSource string */
 
ACPI_STRCPY (ACPI_CAST_PTR (char, &AmlResourceSource[1]),
ResourceSource->StringPtr);
 
/*
* Add the length of the string (+ 1 for null terminator) to the
* final descriptor length
*/
DescriptorLength += ((ACPI_RSDESC_SIZE) ResourceSource->StringLength + 1);
}
 
/* Return the new total length of the AML descriptor */
 
return (DescriptorLength);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiRsGetPrtMethodData
*
* PARAMETERS: Node - Device node
* RetBuffer - Pointer to a buffer structure for the
* results
*
* RETURN: Status
*
* DESCRIPTION: This function is called to get the _PRT value of an object
* contained in an object specified by the handle passed in
*
* If the function fails an appropriate status will be returned
* and the contents of the callers buffer is undefined.
*
******************************************************************************/
 
ACPI_STATUS
AcpiRsGetPrtMethodData (
ACPI_NAMESPACE_NODE *Node,
ACPI_BUFFER *RetBuffer)
{
ACPI_OPERAND_OBJECT *ObjDesc;
ACPI_STATUS Status;
 
 
ACPI_FUNCTION_TRACE (RsGetPrtMethodData);
 
 
/* Parameters guaranteed valid by caller */
 
/* Execute the method, no parameters */
 
Status = AcpiUtEvaluateObject (Node, METHOD_NAME__PRT,
ACPI_BTYPE_PACKAGE, &ObjDesc);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
 
/*
* Create a resource linked list from the byte stream buffer that comes
* back from the _CRS method execution.
*/
Status = AcpiRsCreatePciRoutingTable (ObjDesc, RetBuffer);
 
/* On exit, we must delete the object returned by EvaluateObject */
 
AcpiUtRemoveReference (ObjDesc);
return_ACPI_STATUS (Status);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiRsGetCrsMethodData
*
* PARAMETERS: Node - Device node
* RetBuffer - Pointer to a buffer structure for the
* results
*
* RETURN: Status
*
* DESCRIPTION: This function is called to get the _CRS value of an object
* contained in an object specified by the handle passed in
*
* If the function fails an appropriate status will be returned
* and the contents of the callers buffer is undefined.
*
******************************************************************************/
 
ACPI_STATUS
AcpiRsGetCrsMethodData (
ACPI_NAMESPACE_NODE *Node,
ACPI_BUFFER *RetBuffer)
{
ACPI_OPERAND_OBJECT *ObjDesc;
ACPI_STATUS Status;
 
 
ACPI_FUNCTION_TRACE (RsGetCrsMethodData);
 
 
/* Parameters guaranteed valid by caller */
 
/* Execute the method, no parameters */
 
Status = AcpiUtEvaluateObject (Node, METHOD_NAME__CRS,
ACPI_BTYPE_BUFFER, &ObjDesc);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
 
/*
* Make the call to create a resource linked list from the
* byte stream buffer that comes back from the _CRS method
* execution.
*/
Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
 
/* On exit, we must delete the object returned by evaluateObject */
 
AcpiUtRemoveReference (ObjDesc);
return_ACPI_STATUS (Status);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiRsGetPrsMethodData
*
* PARAMETERS: Node - Device node
* RetBuffer - Pointer to a buffer structure for the
* results
*
* RETURN: Status
*
* DESCRIPTION: This function is called to get the _PRS value of an object
* contained in an object specified by the handle passed in
*
* If the function fails an appropriate status will be returned
* and the contents of the callers buffer is undefined.
*
******************************************************************************/
 
ACPI_STATUS
AcpiRsGetPrsMethodData (
ACPI_NAMESPACE_NODE *Node,
ACPI_BUFFER *RetBuffer)
{
ACPI_OPERAND_OBJECT *ObjDesc;
ACPI_STATUS Status;
 
 
ACPI_FUNCTION_TRACE (RsGetPrsMethodData);
 
 
/* Parameters guaranteed valid by caller */
 
/* Execute the method, no parameters */
 
Status = AcpiUtEvaluateObject (Node, METHOD_NAME__PRS,
ACPI_BTYPE_BUFFER, &ObjDesc);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
 
/*
* Make the call to create a resource linked list from the
* byte stream buffer that comes back from the _CRS method
* execution.
*/
Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
 
/* On exit, we must delete the object returned by evaluateObject */
 
AcpiUtRemoveReference (ObjDesc);
return_ACPI_STATUS (Status);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiRsGetMethodData
*
* PARAMETERS: Handle - Handle to the containing object
* Path - Path to method, relative to Handle
* RetBuffer - Pointer to a buffer structure for the
* results
*
* RETURN: Status
*
* DESCRIPTION: This function is called to get the _CRS or _PRS value of an
* object contained in an object specified by the handle passed in
*
* If the function fails an appropriate status will be returned
* and the contents of the callers buffer is undefined.
*
******************************************************************************/
 
ACPI_STATUS
AcpiRsGetMethodData (
ACPI_HANDLE Handle,
char *Path,
ACPI_BUFFER *RetBuffer)
{
ACPI_OPERAND_OBJECT *ObjDesc;
ACPI_STATUS Status;
 
 
ACPI_FUNCTION_TRACE (RsGetMethodData);
 
 
/* Parameters guaranteed valid by caller */
 
/* Execute the method, no parameters */
 
Status = AcpiUtEvaluateObject (Handle, Path, ACPI_BTYPE_BUFFER, &ObjDesc);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
 
/*
* Make the call to create a resource linked list from the
* byte stream buffer that comes back from the method
* execution.
*/
Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
 
/* On exit, we must delete the object returned by EvaluateObject */
 
AcpiUtRemoveReference (ObjDesc);
return_ACPI_STATUS (Status);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiRsSetSrsMethodData
*
* PARAMETERS: Node - Device node
* InBuffer - Pointer to a buffer structure of the
* parameter
*
* RETURN: Status
*
* DESCRIPTION: This function is called to set the _SRS of an object contained
* in an object specified by the handle passed in
*
* If the function fails an appropriate status will be returned
* and the contents of the callers buffer is undefined.
*
* Note: Parameters guaranteed valid by caller
*
******************************************************************************/
 
ACPI_STATUS
AcpiRsSetSrsMethodData (
ACPI_NAMESPACE_NODE *Node,
ACPI_BUFFER *InBuffer)
{
ACPI_EVALUATE_INFO *Info;
ACPI_OPERAND_OBJECT *Args[2];
ACPI_STATUS Status;
ACPI_BUFFER Buffer;
 
 
ACPI_FUNCTION_TRACE (RsSetSrsMethodData);
 
 
/* Allocate and initialize the evaluation information block */
 
Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
if (!Info)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
 
Info->PrefixNode = Node;
Info->Pathname = METHOD_NAME__SRS;
Info->Parameters = Args;
Info->Flags = ACPI_IGNORE_RETURN_VALUE;
 
/*
* The InBuffer parameter will point to a linked list of
* resource parameters. It needs to be formatted into a
* byte stream to be sent in as an input parameter to _SRS
*
* Convert the linked list into a byte stream
*/
Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
Status = AcpiRsCreateAmlResources (InBuffer->Pointer, &Buffer);
if (ACPI_FAILURE (Status))
{
goto Cleanup;
}
 
/* Create and initialize the method parameter object */
 
Args[0] = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER);
if (!Args[0])
{
/*
* Must free the buffer allocated above (otherwise it is freed
* later)
*/
ACPI_FREE (Buffer.Pointer);
Status = AE_NO_MEMORY;
goto Cleanup;
}
 
Args[0]->Buffer.Length = (UINT32) Buffer.Length;
Args[0]->Buffer.Pointer = Buffer.Pointer;
Args[0]->Common.Flags = AOPOBJ_DATA_VALID;
Args[1] = NULL;
 
/* Execute the method, no return value is expected */
 
Status = AcpiNsEvaluate (Info);
 
/* Clean up and return the status from AcpiNsEvaluate */
 
AcpiUtRemoveReference (Args[0]);
 
Cleanup:
ACPI_FREE (Info);
return_ACPI_STATUS (Status);
}
 
/drivers/devman/acpica/resources/rsxface.c
0,0 → 1,713
/*******************************************************************************
*
* Module Name: rsxface - Public interfaces to the resource manager
*
******************************************************************************/
 
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* Code in any form, with the right to sublicense such rights; and
*
* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
* license (with the right to sublicense), under only those claims of Intel
* patents that are infringed by the Original Intel Code, to make, use, sell,
* offer to sell, and import the Covered Code and derivative works thereof
* solely to the minimum extent necessary to exercise the above copyright
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************/
 
 
#define __RSXFACE_C__
 
#include "acpi.h"
#include "accommon.h"
#include "acresrc.h"
#include "acnamesp.h"
 
#define _COMPONENT ACPI_RESOURCES
ACPI_MODULE_NAME ("rsxface")
 
/* Local macros for 16,32-bit to 64-bit conversion */
 
#define ACPI_COPY_FIELD(Out, In, Field) ((Out)->Field = (In)->Field)
#define ACPI_COPY_ADDRESS(Out, In) \
ACPI_COPY_FIELD(Out, In, ResourceType); \
ACPI_COPY_FIELD(Out, In, ProducerConsumer); \
ACPI_COPY_FIELD(Out, In, Decode); \
ACPI_COPY_FIELD(Out, In, MinAddressFixed); \
ACPI_COPY_FIELD(Out, In, MaxAddressFixed); \
ACPI_COPY_FIELD(Out, In, Info); \
ACPI_COPY_FIELD(Out, In, Granularity); \
ACPI_COPY_FIELD(Out, In, Minimum); \
ACPI_COPY_FIELD(Out, In, Maximum); \
ACPI_COPY_FIELD(Out, In, TranslationOffset); \
ACPI_COPY_FIELD(Out, In, AddressLength); \
ACPI_COPY_FIELD(Out, In, ResourceSource);
 
 
/* Local prototypes */
 
static ACPI_STATUS
AcpiRsMatchVendorResource (
ACPI_RESOURCE *Resource,
void *Context);
 
static ACPI_STATUS
AcpiRsValidateParameters (
ACPI_HANDLE DeviceHandle,
ACPI_BUFFER *Buffer,
ACPI_NAMESPACE_NODE **ReturnNode);
 
 
/*******************************************************************************
*
* FUNCTION: AcpiRsValidateParameters
*
* PARAMETERS: DeviceHandle - Handle to a device
* Buffer - Pointer to a data buffer
* ReturnNode - Pointer to where the device node is returned
*
* RETURN: Status
*
* DESCRIPTION: Common parameter validation for resource interfaces
*
******************************************************************************/
 
static ACPI_STATUS
AcpiRsValidateParameters (
ACPI_HANDLE DeviceHandle,
ACPI_BUFFER *Buffer,
ACPI_NAMESPACE_NODE **ReturnNode)
{
ACPI_STATUS Status;
ACPI_NAMESPACE_NODE *Node;
 
 
ACPI_FUNCTION_TRACE (RsValidateParameters);
 
 
/*
* Must have a valid handle to an ACPI device
*/
if (!DeviceHandle)
{
return_ACPI_STATUS (AE_BAD_PARAMETER);
}
 
Node = AcpiNsValidateHandle (DeviceHandle);
if (!Node)
{
return_ACPI_STATUS (AE_BAD_PARAMETER);
}
 
if (Node->Type != ACPI_TYPE_DEVICE)
{
return_ACPI_STATUS (AE_TYPE);
}
 
/*
* Validate the user buffer object
*
* if there is a non-zero buffer length we also need a valid pointer in
* the buffer. If it's a zero buffer length, we'll be returning the
* needed buffer size (later), so keep going.
*/
Status = AcpiUtValidateBuffer (Buffer);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
 
*ReturnNode = Node;
return_ACPI_STATUS (AE_OK);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiGetIrqRoutingTable
*
* PARAMETERS: DeviceHandle - Handle to the Bus device we are querying
* RetBuffer - Pointer to a buffer to receive the
* current resources for the device
*
* RETURN: Status
*
* DESCRIPTION: This function is called to get the IRQ routing table for a
* specific bus. The caller must first acquire a handle for the
* desired bus. The routine table is placed in the buffer pointed
* to by the RetBuffer variable parameter.
*
* If the function fails an appropriate status will be returned
* and the value of RetBuffer is undefined.
*
* This function attempts to execute the _PRT method contained in
* the object indicated by the passed DeviceHandle.
*
******************************************************************************/
 
ACPI_STATUS
AcpiGetIrqRoutingTable (
ACPI_HANDLE DeviceHandle,
ACPI_BUFFER *RetBuffer)
{
ACPI_STATUS Status;
ACPI_NAMESPACE_NODE *Node;
 
 
ACPI_FUNCTION_TRACE (AcpiGetIrqRoutingTable);
 
 
/* Validate parameters then dispatch to internal routine */
 
Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
 
Status = AcpiRsGetPrtMethodData (Node, RetBuffer);
return_ACPI_STATUS (Status);
}
 
ACPI_EXPORT_SYMBOL (AcpiGetIrqRoutingTable)
 
 
/*******************************************************************************
*
* FUNCTION: AcpiGetCurrentResources
*
* PARAMETERS: DeviceHandle - Handle to the device object for the
* device we are querying
* RetBuffer - Pointer to a buffer to receive the
* current resources for the device
*
* RETURN: Status
*
* DESCRIPTION: This function is called to get the current resources for a
* specific device. The caller must first acquire a handle for
* the desired device. The resource data is placed in the buffer
* pointed to by the RetBuffer variable parameter.
*
* If the function fails an appropriate status will be returned
* and the value of RetBuffer is undefined.
*
* This function attempts to execute the _CRS method contained in
* the object indicated by the passed DeviceHandle.
*
******************************************************************************/
 
ACPI_STATUS
AcpiGetCurrentResources (
ACPI_HANDLE DeviceHandle,
ACPI_BUFFER *RetBuffer)
{
ACPI_STATUS Status;
ACPI_NAMESPACE_NODE *Node;
 
 
ACPI_FUNCTION_TRACE (AcpiGetCurrentResources);
 
 
/* Validate parameters then dispatch to internal routine */
 
Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
 
Status = AcpiRsGetCrsMethodData (Node, RetBuffer);
return_ACPI_STATUS (Status);
}
 
ACPI_EXPORT_SYMBOL (AcpiGetCurrentResources)
 
 
/*******************************************************************************
*
* FUNCTION: AcpiGetPossibleResources
*
* PARAMETERS: DeviceHandle - Handle to the device object for the
* device we are querying
* RetBuffer - Pointer to a buffer to receive the
* resources for the device
*
* RETURN: Status
*
* DESCRIPTION: This function is called to get a list of the possible resources
* for a specific device. The caller must first acquire a handle
* for the desired device. The resource data is placed in the
* buffer pointed to by the RetBuffer variable.
*
* If the function fails an appropriate status will be returned
* and the value of RetBuffer is undefined.
*
******************************************************************************/
 
ACPI_STATUS
AcpiGetPossibleResources (
ACPI_HANDLE DeviceHandle,
ACPI_BUFFER *RetBuffer)
{
ACPI_STATUS Status;
ACPI_NAMESPACE_NODE *Node;
 
 
ACPI_FUNCTION_TRACE (AcpiGetPossibleResources);
 
 
/* Validate parameters then dispatch to internal routine */
 
Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
 
Status = AcpiRsGetPrsMethodData (Node, RetBuffer);
return_ACPI_STATUS (Status);
}
 
ACPI_EXPORT_SYMBOL (AcpiGetPossibleResources)
 
 
/*******************************************************************************
*
* FUNCTION: AcpiSetCurrentResources
*
* PARAMETERS: DeviceHandle - Handle to the device object for the
* device we are setting resources
* InBuffer - Pointer to a buffer containing the
* resources to be set for the device
*
* RETURN: Status
*
* DESCRIPTION: This function is called to set the current resources for a
* specific device. The caller must first acquire a handle for
* the desired device. The resource data is passed to the routine
* the buffer pointed to by the InBuffer variable.
*
******************************************************************************/
 
ACPI_STATUS
AcpiSetCurrentResources (
ACPI_HANDLE DeviceHandle,
ACPI_BUFFER *InBuffer)
{
ACPI_STATUS Status;
ACPI_NAMESPACE_NODE *Node;
 
 
ACPI_FUNCTION_TRACE (AcpiSetCurrentResources);
 
 
/* Validate the buffer, don't allow zero length */
 
if ((!InBuffer) ||
(!InBuffer->Pointer) ||
(!InBuffer->Length))
{
return_ACPI_STATUS (AE_BAD_PARAMETER);
}
 
/* Validate parameters then dispatch to internal routine */
 
Status = AcpiRsValidateParameters (DeviceHandle, InBuffer, &Node);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
 
Status = AcpiRsSetSrsMethodData (Node, InBuffer);
return_ACPI_STATUS (Status);
}
 
ACPI_EXPORT_SYMBOL (AcpiSetCurrentResources)
 
 
/******************************************************************************
*
* FUNCTION: AcpiResourceToAddress64
*
* PARAMETERS: Resource - Pointer to a resource
* Out - Pointer to the users's return buffer
* (a struct acpi_resource_address64)
*
* RETURN: Status
*
* DESCRIPTION: If the resource is an address16, address32, or address64,
* copy it to the address64 return buffer. This saves the
* caller from having to duplicate code for different-sized
* addresses.
*
******************************************************************************/
 
ACPI_STATUS
AcpiResourceToAddress64 (
ACPI_RESOURCE *Resource,
ACPI_RESOURCE_ADDRESS64 *Out)
{
ACPI_RESOURCE_ADDRESS16 *Address16;
ACPI_RESOURCE_ADDRESS32 *Address32;
 
 
if (!Resource || !Out)
{
return (AE_BAD_PARAMETER);
}
 
/* Convert 16 or 32 address descriptor to 64 */
 
switch (Resource->Type)
{
case ACPI_RESOURCE_TYPE_ADDRESS16:
 
Address16 = ACPI_CAST_PTR (ACPI_RESOURCE_ADDRESS16, &Resource->Data);
ACPI_COPY_ADDRESS (Out, Address16);
break;
 
case ACPI_RESOURCE_TYPE_ADDRESS32:
 
Address32 = ACPI_CAST_PTR (ACPI_RESOURCE_ADDRESS32, &Resource->Data);
ACPI_COPY_ADDRESS (Out, Address32);
break;
 
case ACPI_RESOURCE_TYPE_ADDRESS64:
 
/* Simple copy for 64 bit source */
 
ACPI_MEMCPY (Out, &Resource->Data, sizeof (ACPI_RESOURCE_ADDRESS64));
break;
 
default:
return (AE_BAD_PARAMETER);
}
 
return (AE_OK);
}
 
ACPI_EXPORT_SYMBOL (AcpiResourceToAddress64)
 
 
/*******************************************************************************
*
* FUNCTION: AcpiGetVendorResource
*
* PARAMETERS: DeviceHandle - Handle for the parent device object
* Name - Method name for the parent resource
* (METHOD_NAME__CRS or METHOD_NAME__PRS)
* Uuid - Pointer to the UUID to be matched.
* includes both subtype and 16-byte UUID
* RetBuffer - Where the vendor resource is returned
*
* RETURN: Status
*
* DESCRIPTION: Walk a resource template for the specified evice to find a
* vendor-defined resource that matches the supplied UUID and
* UUID subtype. Returns a ACPI_RESOURCE of type Vendor.
*
******************************************************************************/
 
ACPI_STATUS
AcpiGetVendorResource (
ACPI_HANDLE DeviceHandle,
char *Name,
ACPI_VENDOR_UUID *Uuid,
ACPI_BUFFER *RetBuffer)
{
ACPI_VENDOR_WALK_INFO Info;
ACPI_STATUS Status;
 
 
/* Other parameters are validated by AcpiWalkResources */
 
if (!Uuid || !RetBuffer)
{
return (AE_BAD_PARAMETER);
}
 
Info.Uuid = Uuid;
Info.Buffer = RetBuffer;
Info.Status = AE_NOT_EXIST;
 
/* Walk the _CRS or _PRS resource list for this device */
 
Status = AcpiWalkResources (DeviceHandle, Name, AcpiRsMatchVendorResource,
&Info);
if (ACPI_FAILURE (Status))
{
return (Status);
}
 
return (Info.Status);
}
 
ACPI_EXPORT_SYMBOL (AcpiGetVendorResource)
 
 
/*******************************************************************************
*
* FUNCTION: AcpiRsMatchVendorResource
*
* PARAMETERS: ACPI_WALK_RESOURCE_CALLBACK
*
* RETURN: Status
*
* DESCRIPTION: Match a vendor resource via the ACPI 3.0 UUID
*
******************************************************************************/
 
static ACPI_STATUS
AcpiRsMatchVendorResource (
ACPI_RESOURCE *Resource,
void *Context)
{
ACPI_VENDOR_WALK_INFO *Info = Context;
ACPI_RESOURCE_VENDOR_TYPED *Vendor;
ACPI_BUFFER *Buffer;
ACPI_STATUS Status;
 
 
/* Ignore all descriptors except Vendor */
 
if (Resource->Type != ACPI_RESOURCE_TYPE_VENDOR)
{
return (AE_OK);
}
 
Vendor = &Resource->Data.VendorTyped;
 
/*
* For a valid match, these conditions must hold:
*
* 1) Length of descriptor data must be at least as long as a UUID struct
* 2) The UUID subtypes must match
* 3) The UUID data must match
*/
if ((Vendor->ByteLength < (ACPI_UUID_LENGTH + 1)) ||
(Vendor->UuidSubtype != Info->Uuid->Subtype) ||
(ACPI_MEMCMP (Vendor->Uuid, Info->Uuid->Data, ACPI_UUID_LENGTH)))
{
return (AE_OK);
}
 
/* Validate/Allocate/Clear caller buffer */
 
Buffer = Info->Buffer;
Status = AcpiUtInitializeBuffer (Buffer, Resource->Length);
if (ACPI_FAILURE (Status))
{
return (Status);
}
 
/* Found the correct resource, copy and return it */
 
ACPI_MEMCPY (Buffer->Pointer, Resource, Resource->Length);
Buffer->Length = Resource->Length;
 
/* Found the desired descriptor, terminate resource walk */
 
Info->Status = AE_OK;
return (AE_CTRL_TERMINATE);
}
 
 
/*******************************************************************************
*
* FUNCTION: AcpiWalkResources
*
* PARAMETERS: DeviceHandle - Handle to the device object for the
* device we are querying
* Name - Method name of the resources we want
* (METHOD_NAME__CRS or METHOD_NAME__PRS)
* UserFunction - Called for each resource
* Context - Passed to UserFunction
*
* RETURN: Status
*
* DESCRIPTION: Retrieves the current or possible resource list for the
* specified device. The UserFunction is called once for
* each resource in the list.
*
******************************************************************************/
 
ACPI_STATUS
AcpiWalkResources (
ACPI_HANDLE DeviceHandle,
char *Name,
ACPI_WALK_RESOURCE_CALLBACK UserFunction,
void *Context)
{
ACPI_STATUS Status;
ACPI_BUFFER Buffer;
ACPI_RESOURCE *Resource;
ACPI_RESOURCE *ResourceEnd;
 
 
ACPI_FUNCTION_TRACE (AcpiWalkResources);
 
 
/* Parameter validation */
 
if (!DeviceHandle || !UserFunction || !Name ||
(!ACPI_COMPARE_NAME (Name, METHOD_NAME__CRS) &&
!ACPI_COMPARE_NAME (Name, METHOD_NAME__PRS)))
{
return_ACPI_STATUS (AE_BAD_PARAMETER);
}
 
/* Get the _CRS or _PRS resource list */
 
Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
Status = AcpiRsGetMethodData (DeviceHandle, Name, &Buffer);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
 
/* Buffer now contains the resource list */
 
Resource = ACPI_CAST_PTR (ACPI_RESOURCE, Buffer.Pointer);
ResourceEnd = ACPI_ADD_PTR (ACPI_RESOURCE, Buffer.Pointer, Buffer.Length);
 
/* Walk the resource list until the EndTag is found (or buffer end) */
 
while (Resource < ResourceEnd)
{
/* Sanity check the resource */
 
if (Resource->Type > ACPI_RESOURCE_TYPE_MAX)
{
Status = AE_AML_INVALID_RESOURCE_TYPE;
break;
}
 
/* Invoke the user function, abort on any error returned */
 
Status = UserFunction (Resource, Context);
if (ACPI_FAILURE (Status))
{
if (Status == AE_CTRL_TERMINATE)
{
/* This is an OK termination by the user function */
 
Status = AE_OK;
}
break;
}
 
/* EndTag indicates end-of-list */
 
if (Resource->Type == ACPI_RESOURCE_TYPE_END_TAG)
{
break;
}
 
/* Get the next resource descriptor */
 
Resource = ACPI_ADD_PTR (ACPI_RESOURCE, Resource, Resource->Length);
}
 
ACPI_FREE (Buffer.Pointer);
return_ACPI_STATUS (Status);
}
 
ACPI_EXPORT_SYMBOL (AcpiWalkResources)