summaryrefslogtreecommitdiffstats
path: root/sys/contrib/dev/acpica/rsaddr.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/contrib/dev/acpica/rsaddr.c')
-rw-r--r--sys/contrib/dev/acpica/rsaddr.c649
1 files changed, 529 insertions, 120 deletions
diff --git a/sys/contrib/dev/acpica/rsaddr.c b/sys/contrib/dev/acpica/rsaddr.c
index 546ff9b..61bc590 100644
--- a/sys/contrib/dev/acpica/rsaddr.c
+++ b/sys/contrib/dev/acpica/rsaddr.c
@@ -1,10 +1,7 @@
/*******************************************************************************
*
- * Module Name: rsaddr - AcpiRsAddress16Resource
- * AcpiRsAddress16Stream
- * AcpiRsAddress32Resource
- * AcpiRsAddress32Stream
- * $Revision: 14 $
+ * Module Name: rsaddr - Address resource descriptors (16/32/64)
+ * $Revision: 18 $
*
******************************************************************************/
@@ -122,7 +119,7 @@
#include "acpi.h"
#include "acresrc.h"
-#define _COMPONENT RESOURCE_MANAGER
+#define _COMPONENT ACPI_RESOURCES
MODULE_NAME ("rsaddr")
@@ -131,20 +128,20 @@
* FUNCTION: AcpiRsAddress16Resource
*
* PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
- * stream
+ * stream
* BytesConsumed - UINT32 pointer that is filled with
- * the number of bytes consumed from
- * the ByteStreamBuffer
+ * the number of bytes consumed from
+ * the ByteStreamBuffer
* OutputBuffer - Pointer to the user's return buffer
* StructureSize - UINT32 pointer that is filled with
- * the number of bytes in the filled
- * in structure
+ * the number of bytes in the filled
+ * in structure
*
- * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
+ * RETURN: Status
*
* DESCRIPTION: Take the resource byte stream and fill out the appropriate
- * structure pointed to by the OutputBuffer. Return the
- * number of bytes consumed from the byte stream.
+ * structure pointed to by the OutputBuffer. Return the
+ * number of bytes consumed from the byte stream.
*
******************************************************************************/
@@ -156,12 +153,12 @@ AcpiRsAddress16Resource (
UINT32 *StructureSize)
{
UINT8 *Buffer = ByteStreamBuffer;
- RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer;
+ ACPI_RESOURCE *OutputStruct = (ACPI_RESOURCE *) *OutputBuffer;
+ NATIVE_CHAR *TempPtr;
+ UINT32 StructSize = SIZEOF_RESOURCE (ACPI_RESOURCE_ADDRESS16);
+ UINT32 Index;
UINT16 Temp16;
UINT8 Temp8;
- UINT32 Index;
- UINT32 StructSize = sizeof(ADDRESS16_RESOURCE) +
- RESOURCE_LENGTH_NO_DATA;
FUNCTION_TRACE ("RsAddress16Resource");
@@ -170,14 +167,10 @@ AcpiRsAddress16Resource (
* Point past the Descriptor to get the number of bytes consumed
*/
Buffer += 1;
-
MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
*BytesConsumed = Temp16 + 3;
-
- OutputStruct->Id = Address16;
-
- OutputStruct->Length = StructSize;
+ OutputStruct->Id = ACPI_RSTYPE_ADDRESS16;
/*
* Get the Resource Type (Byte3)
@@ -188,7 +181,7 @@ AcpiRsAddress16Resource (
/* Values 0-2 are valid */
if (Temp8 > 2)
{
- return_ACPI_STATUS (AE_AML_ERROR);
+ return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
}
OutputStruct->Data.Address16.ResourceType = Temp8 & 0x03;
@@ -243,7 +236,7 @@ AcpiRsAddress16Resource (
else
{
- /* BUS_NUMBER_RANGE == Address32Data->ResourceType */
+ /* BUS_NUMBER_RANGE == Address16.Data->ResourceType */
/* Nothing needs to be filled in */
}
}
@@ -266,25 +259,22 @@ AcpiRsAddress16Resource (
* Get MaxAddressRange (Bytes 10-11)
*/
Buffer += 2;
- MOVE_UNALIGNED16_TO_16
- (&OutputStruct->Data.Address16.MaxAddressRange,
- Buffer);
+ MOVE_UNALIGNED16_TO_16 (&OutputStruct->Data.Address16.MaxAddressRange,
+ Buffer);
/*
* Get AddressTranslationOffset (Bytes 12-13)
*/
Buffer += 2;
- MOVE_UNALIGNED16_TO_16
- (&OutputStruct->Data.Address16.AddressTranslationOffset,
- Buffer);
+ MOVE_UNALIGNED16_TO_16 (&OutputStruct->Data.Address16.AddressTranslationOffset,
+ Buffer);
/*
* Get AddressLength (Bytes 14-15)
*/
Buffer += 2;
- MOVE_UNALIGNED16_TO_16
- (&OutputStruct->Data.Address16.AddressLength,
- Buffer);
+ MOVE_UNALIGNED16_TO_16 (&OutputStruct->Data.Address16.AddressLength,
+ Buffer);
/*
* Resource Source Index (if present)
@@ -293,32 +283,38 @@ AcpiRsAddress16Resource (
/*
* This will leave us pointing to the Resource Source Index
- * If it is present, then save it off and calculate the
- * pointer to where the null terminated string goes:
- * Each Interrupt takes 32-bits + the 5 bytes of the
- * stream that are default.
+ * If it is present, then save it off and calculate the
+ * pointer to where the null terminated string goes:
+ * Each Interrupt takes 32-bits + the 5 bytes of the
+ * stream that are default.
*/
if (*BytesConsumed > 16)
{
/* Dereference the Index */
Temp8 = *Buffer;
- OutputStruct->Data.Address16.ResourceSourceIndex =
- (UINT32) Temp8;
+ OutputStruct->Data.Address16.ResourceSource.Index = (UINT32) Temp8;
/* Point to the String */
Buffer += 1;
+ /* Point the String pointer to the end of this structure */
+
+ OutputStruct->Data.Address16.ResourceSource.StringPtr =
+ (NATIVE_CHAR *)((UINT8 * )OutputStruct + StructSize);
+
+ TempPtr = OutputStruct->Data.Address16.ResourceSource.StringPtr;
+
/* Copy the string into the buffer */
Index = 0;
while (0x00 != *Buffer)
{
- OutputStruct->Data.Address16.ResourceSource[Index] =
- *Buffer;
+ *TempPtr = *Buffer;
+ TempPtr += 1;
Buffer += 1;
Index += 1;
}
@@ -326,32 +322,35 @@ AcpiRsAddress16Resource (
/*
* Add the terminating null
*/
- OutputStruct->Data.Address16.ResourceSource[Index] = 0x00;
+ *TempPtr = 0x00;
- OutputStruct->Data.Address16.ResourceSourceStringLength =
- Index + 1;
+ OutputStruct->Data.Address16.ResourceSource.StringLength = Index + 1;
/*
- * In order for the StructSize to fall on a 32-bit boundry,
- * calculate the length of the string and expand the
- * StructSize to the next 32-bit boundry.
+ * In order for the StructSize to fall on a 32-bit boundary,
+ * calculate the length of the string and expand the
+ * StructSize to the next 32-bit boundary.
*/
Temp8 = (UINT8) (Index + 1);
StructSize += ROUND_UP_TO_32BITS (Temp8);
- OutputStruct->Length = StructSize;
}
+
else
{
- OutputStruct->Data.Address16.ResourceSourceIndex = 0x00;
- OutputStruct->Data.Address16.ResourceSourceStringLength = 0;
- OutputStruct->Data.Address16.ResourceSource[0] = 0x00;
+ OutputStruct->Data.Address16.ResourceSource.Index = 0x00;
+ OutputStruct->Data.Address16.ResourceSource.StringLength = 0;
+ OutputStruct->Data.Address16.ResourceSource.StringPtr = NULL;
}
/*
+ * Set the Length parameter
+ */
+ OutputStruct->Length = StructSize;
+
+ /*
* Return the final size of the structure
*/
*StructureSize = StructSize;
-
return_ACPI_STATUS (AE_OK);
}
@@ -363,19 +362,19 @@ AcpiRsAddress16Resource (
* PARAMETERS: LinkedList - Pointer to the resource linked list
* OutputBuffer - Pointer to the user's return buffer
* BytesConsumed - UINT32 pointer that is filled with
- * the number of bytes of the
- * OutputBuffer used
+ * the number of bytes of the
+ * OutputBuffer used
*
- * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
+ * RETURN: Status
*
* DESCRIPTION: Take the linked list resource structure and fills in the
- * the appropriate bytes in a byte stream
+ * the appropriate bytes in a byte stream
*
******************************************************************************/
ACPI_STATUS
AcpiRsAddress16Stream (
- RESOURCE *LinkedList,
+ ACPI_RESOURCE *LinkedList,
UINT8 **OutputBuffer,
UINT32 *BytesConsumed)
{
@@ -388,6 +387,7 @@ AcpiRsAddress16Stream (
FUNCTION_TRACE ("RsAddress16Stream");
+
/*
* The descriptor field is static
*/
@@ -449,43 +449,43 @@ AcpiRsAddress16Stream (
* Set the address space granularity
*/
MOVE_UNALIGNED16_TO_16 (Buffer,
- &LinkedList->Data.Address16.Granularity);
+ &LinkedList->Data.Address16.Granularity);
Buffer += 2;
/*
* Set the address range minimum
*/
MOVE_UNALIGNED16_TO_16 (Buffer,
- &LinkedList->Data.Address16.MinAddressRange);
+ &LinkedList->Data.Address16.MinAddressRange);
Buffer += 2;
/*
* Set the address range maximum
*/
MOVE_UNALIGNED16_TO_16 (Buffer,
- &LinkedList->Data.Address16.MaxAddressRange);
+ &LinkedList->Data.Address16.MaxAddressRange);
Buffer += 2;
/*
* Set the address translation offset
*/
MOVE_UNALIGNED16_TO_16 (Buffer,
- &LinkedList->Data.Address16.AddressTranslationOffset);
+ &LinkedList->Data.Address16.AddressTranslationOffset);
Buffer += 2;
/*
* Set the address length
*/
MOVE_UNALIGNED16_TO_16 (Buffer,
- &LinkedList->Data.Address16.AddressLength);
+ &LinkedList->Data.Address16.AddressLength);
Buffer += 2;
/*
* Resource Source Index and Resource Source are optional
*/
- if (0 != LinkedList->Data.Address16.ResourceSourceStringLength)
+ if (0 != LinkedList->Data.Address16.ResourceSource.StringLength)
{
- Temp8 = (UINT8) LinkedList->Data.Address16.ResourceSourceIndex;
+ Temp8 = (UINT8) LinkedList->Data.Address16.ResourceSource.Index;
*Buffer = Temp8;
Buffer += 1;
@@ -495,21 +495,21 @@ AcpiRsAddress16Stream (
/*
* Copy the string
*/
- STRCPY (TempPointer, LinkedList->Data.Address16.ResourceSource);
+ STRCPY (TempPointer,
+ LinkedList->Data.Address16.ResourceSource.StringPtr);
/*
* Buffer needs to be set to the length of the sting + one for the
* terminating null
*/
- Buffer += (STRLEN (LinkedList->Data.Address16.ResourceSource) + 1);
+ Buffer += (STRLEN (LinkedList->Data.Address16.ResourceSource.StringPtr)
+ + 1);
}
/*
* Return the number of bytes consumed in this operation
*/
- ActualBytes = (UINT32) ((NATIVE_UINT) Buffer -
- (NATIVE_UINT) *OutputBuffer);
-
+ ActualBytes = POINTER_DIFF (Buffer, *OutputBuffer);
*BytesConsumed = ActualBytes;
/*
@@ -518,7 +518,6 @@ AcpiRsAddress16Stream (
*/
ActualBytes -= 3;
MOVE_UNALIGNED16_TO_16 (LengthField, &ActualBytes);
-
return_ACPI_STATUS (AE_OK);
}
@@ -528,20 +527,20 @@ AcpiRsAddress16Stream (
* FUNCTION: AcpiRsAddress32Resource
*
* PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
- * stream
+ * stream
* BytesConsumed - UINT32 pointer that is filled with
- * the number of bytes consumed from
- * the ByteStreamBuffer
+ * the number of bytes consumed from
+ * the ByteStreamBuffer
* OutputBuffer - Pointer to the user's return buffer
* StructureSize - UINT32 pointer that is filled with
- * the number of bytes in the filled
- * in structure
+ * the number of bytes in the filled
+ * in structure
*
- * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
+ * RETURN: Status
*
* DESCRIPTION: Take the resource byte stream and fill out the appropriate
- * structure pointed to by the OutputBuffer. Return the
- * number of bytes consumed from the byte stream.
+ * structure pointed to by the OutputBuffer. Return the
+ * number of bytes consumed from the byte stream.
*
******************************************************************************/
@@ -553,21 +552,21 @@ AcpiRsAddress32Resource (
UINT32 *StructureSize)
{
UINT8 *Buffer;
- RESOURCE *OutputStruct;
+ ACPI_RESOURCE *OutputStruct;
UINT16 Temp16;
UINT8 Temp8;
+ NATIVE_CHAR *TempPtr;
UINT32 StructSize;
UINT32 Index;
FUNCTION_TRACE ("RsAddress32Resource");
- Buffer = ByteStreamBuffer;
- OutputStruct = (RESOURCE *) *OutputBuffer;
+ Buffer = ByteStreamBuffer;
+ OutputStruct = (ACPI_RESOURCE *) *OutputBuffer;
- StructSize = sizeof (ADDRESS32_RESOURCE) +
- RESOURCE_LENGTH_NO_DATA;
+ StructSize = SIZEOF_RESOURCE (ACPI_RESOURCE_ADDRESS32);
/*
* Point past the Descriptor to get the number of bytes consumed
@@ -577,7 +576,7 @@ AcpiRsAddress32Resource (
*BytesConsumed = Temp16 + 3;
- OutputStruct->Id = Address32;
+ OutputStruct->Id = ACPI_RSTYPE_ADDRESS32;
/*
* Get the Resource Type (Byte3)
@@ -588,7 +587,7 @@ AcpiRsAddress32Resource (
/* Values 0-2 are valid */
if(Temp8 > 2)
{
- return_ACPI_STATUS (AE_AML_ERROR);
+ return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
}
OutputStruct->Data.Address32.ResourceType = Temp8 & 0x03;
@@ -674,9 +673,8 @@ AcpiRsAddress32Resource (
* Get AddressTranslationOffset (Bytes 18-21)
*/
Buffer += 4;
- MOVE_UNALIGNED32_TO_32
- (&OutputStruct->Data.Address32.AddressTranslationOffset,
- Buffer);
+ MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Address32.AddressTranslationOffset,
+ Buffer);
/*
* Get AddressLength (Bytes 22-25)
@@ -692,29 +690,37 @@ AcpiRsAddress32Resource (
/*
* This will leave us pointing to the Resource Source Index
- * If it is present, then save it off and calculate the
- * pointer to where the null terminated string goes:
- * Each Interrupt takes 32-bits + the 5 bytes of the
- * stream that are default.
+ * If it is present, then save it off and calculate the
+ * pointer to where the null terminated string goes:
*/
if (*BytesConsumed > 26)
{
/* Dereference the Index */
Temp8 = *Buffer;
- OutputStruct->Data.Address32.ResourceSourceIndex = (UINT32)Temp8;
+ OutputStruct->Data.Address32.ResourceSource.Index =
+ (UINT32) Temp8;
/* Point to the String */
Buffer += 1;
+ /* Point the String pointer to the end of this structure */
+
+ OutputStruct->Data.Address32.ResourceSource.StringPtr =
+ (NATIVE_CHAR *)((UINT8 *)OutputStruct + StructSize);
+
+ TempPtr = OutputStruct->Data.Address32.ResourceSource.StringPtr;
+
/* Copy the string into the buffer */
Index = 0;
while (0x00 != *Buffer)
{
- OutputStruct->Data.Address32.ResourceSource[Index] = *Buffer;
+ *TempPtr = *Buffer;
+
+ TempPtr += 1;
Buffer += 1;
Index += 1;
}
@@ -722,14 +728,13 @@ AcpiRsAddress32Resource (
/*
* Add the terminating null
*/
- OutputStruct->Data.Address32.ResourceSource[Index] = 0x00;
-
- OutputStruct->Data.Address32.ResourceSourceStringLength = Index + 1;
+ *TempPtr = 0x00;
+ OutputStruct->Data.Address32.ResourceSource.StringLength = Index + 1;
/*
- * In order for the StructSize to fall on a 32-bit boundry,
+ * In order for the StructSize to fall on a 32-bit boundary,
* calculate the length of the string and expand the
- * StructSize to the next 32-bit boundry.
+ * StructSize to the next 32-bit boundary.
*/
Temp8 = (UINT8) (Index + 1);
StructSize += ROUND_UP_TO_32BITS (Temp8);
@@ -737,9 +742,9 @@ AcpiRsAddress32Resource (
else
{
- OutputStruct->Data.Address32.ResourceSourceIndex = 0x00;
- OutputStruct->Data.Address32.ResourceSourceStringLength = 0;
- OutputStruct->Data.Address32.ResourceSource[0] = 0x00;
+ OutputStruct->Data.Address32.ResourceSource.Index = 0x00;
+ OutputStruct->Data.Address32.ResourceSource.StringLength = 0;
+ OutputStruct->Data.Address32.ResourceSource.StringPtr = NULL;
}
/*
@@ -751,7 +756,6 @@ AcpiRsAddress32Resource (
* Return the final size of the structure
*/
*StructureSize = StructSize;
-
return_ACPI_STATUS (AE_OK);
}
@@ -763,19 +767,19 @@ AcpiRsAddress32Resource (
* PARAMETERS: LinkedList - Pointer to the resource linked list
* OutputBuffer - Pointer to the user's return buffer
* BytesConsumed - UINT32 pointer that is filled with
- * the number of bytes of the
- * OutputBuffer used
+ * the number of bytes of the
+ * OutputBuffer used
*
- * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
+ * RETURN: Status
*
* DESCRIPTION: Take the linked list resource structure and fills in the
- * the appropriate bytes in a byte stream
+ * the appropriate bytes in a byte stream
*
******************************************************************************/
ACPI_STATUS
AcpiRsAddress32Stream (
- RESOURCE *LinkedList,
+ ACPI_RESOURCE *LinkedList,
UINT8 **OutputBuffer,
UINT32 *BytesConsumed)
{
@@ -787,6 +791,7 @@ AcpiRsAddress32Stream (
FUNCTION_TRACE ("RsAddress32Stream");
+
Buffer = *OutputBuffer;
/*
@@ -799,7 +804,7 @@ AcpiRsAddress32Stream (
* Set a pointer to the Length field - to be filled in later
*/
- LengthField = (UINT16 *)Buffer;
+ LengthField = (UINT16 *) Buffer;
Buffer += 2;
/*
@@ -851,21 +856,21 @@ AcpiRsAddress32Stream (
* Set the address space granularity
*/
MOVE_UNALIGNED32_TO_32 (Buffer,
- &LinkedList->Data.Address32.Granularity);
+ &LinkedList->Data.Address32.Granularity);
Buffer += 4;
/*
* Set the address range minimum
*/
MOVE_UNALIGNED32_TO_32 (Buffer,
- &LinkedList->Data.Address32.MinAddressRange);
+ &LinkedList->Data.Address32.MinAddressRange);
Buffer += 4;
/*
* Set the address range maximum
*/
MOVE_UNALIGNED32_TO_32 (Buffer,
- &LinkedList->Data.Address32.MaxAddressRange);
+ &LinkedList->Data.Address32.MaxAddressRange);
Buffer += 4;
/*
@@ -879,15 +884,15 @@ AcpiRsAddress32Stream (
* Set the address length
*/
MOVE_UNALIGNED32_TO_32 (Buffer,
- &LinkedList->Data.Address32.AddressLength);
+ &LinkedList->Data.Address32.AddressLength);
Buffer += 4;
/*
* Resource Source Index and Resource Source are optional
*/
- if (0 != LinkedList->Data.Address32.ResourceSourceStringLength)
+ if (0 != LinkedList->Data.Address32.ResourceSource.StringLength)
{
- Temp8 = (UINT8) LinkedList->Data.Address32.ResourceSourceIndex;
+ Temp8 = (UINT8) LinkedList->Data.Address32.ResourceSource.Index;
*Buffer = Temp8;
Buffer += 1;
@@ -897,27 +902,431 @@ AcpiRsAddress32Stream (
/*
* Copy the string
*/
- STRCPY (TempPointer, LinkedList->Data.Address32.ResourceSource);
+ STRCPY (TempPointer,
+ LinkedList->Data.Address32.ResourceSource.StringPtr);
/*
* Buffer needs to be set to the length of the sting + one for the
* terminating null
*/
- Buffer += (STRLEN (LinkedList->Data.Address32.ResourceSource) + 1);
+ Buffer += (STRLEN (LinkedList->Data.Address32.ResourceSource.StringPtr) + 1);
}
/*
* Return the number of bytes consumed in this operation
*/
- *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer -
- (NATIVE_UINT) *OutputBuffer);
+ *BytesConsumed = POINTER_DIFF (Buffer, *OutputBuffer);
/*
* Set the length field to the number of bytes consumed
* minus the header size (3 bytes)
*/
*LengthField = (UINT16) (*BytesConsumed - 3);
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsAddress64Resource
+ *
+ * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
+ * stream
+ * BytesConsumed - UINT32 pointer that is filled with
+ * the number of bytes consumed from
+ * the ByteStreamBuffer
+ * OutputBuffer - Pointer to the user's return buffer
+ * StructureSize - UINT32 pointer that is filled with
+ * the number of bytes in the filled
+ * in structure
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Take the resource byte stream and fill out the appropriate
+ * structure pointed to by the OutputBuffer. Return the
+ * number of bytes consumed from the byte stream.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsAddress64Resource (
+ UINT8 *ByteStreamBuffer,
+ UINT32 *BytesConsumed,
+ UINT8 **OutputBuffer,
+ UINT32 *StructureSize)
+{
+ UINT8 *Buffer;
+ ACPI_RESOURCE *OutputStruct;
+ UINT16 Temp16;
+ UINT8 Temp8;
+ NATIVE_CHAR *TempPtr;
+ UINT32 StructSize;
+ UINT32 Index;
+
+
+ FUNCTION_TRACE ("RsAddress64Resource");
+
+
+ Buffer = ByteStreamBuffer;
+ OutputStruct = (ACPI_RESOURCE *) *OutputBuffer;
+
+ StructSize = SIZEOF_RESOURCE (ACPI_RESOURCE_ADDRESS64);
+
+ /*
+ * Point past the Descriptor to get the number of bytes consumed
+ */
+ Buffer += 1;
+ MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
+
+ *BytesConsumed = Temp16 + 3;
+ OutputStruct->Id = ACPI_RSTYPE_ADDRESS64;
+
+ /*
+ * Get the Resource Type (Byte3)
+ */
+ Buffer += 2;
+ Temp8 = *Buffer;
+
+ /* Values 0-2 are valid */
+ if(Temp8 > 2)
+ {
+ return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
+ }
+
+ OutputStruct->Data.Address64.ResourceType = Temp8 & 0x03;
+
+ /*
+ * Get the General Flags (Byte4)
+ */
+ Buffer += 1;
+ Temp8 = *Buffer;
+
+ /*
+ * Producer / Consumer
+ */
+ OutputStruct->Data.Address64.ProducerConsumer = Temp8 & 0x01;
+
+ /*
+ * Decode
+ */
+ OutputStruct->Data.Address64.Decode = (Temp8 >> 1) & 0x01;
+
+ /*
+ * Min Address Fixed
+ */
+ OutputStruct->Data.Address64.MinAddressFixed = (Temp8 >> 2) & 0x01;
+
+ /*
+ * Max Address Fixed
+ */
+ OutputStruct->Data.Address64.MaxAddressFixed = (Temp8 >> 3) & 0x01;
+
+ /*
+ * Get the Type Specific Flags (Byte5)
+ */
+ Buffer += 1;
+ Temp8 = *Buffer;
+
+ if (MEMORY_RANGE == OutputStruct->Data.Address64.ResourceType)
+ {
+ OutputStruct->Data.Address64.Attribute.Memory.ReadWriteAttribute =
+ (UINT16) (Temp8 & 0x01);
+
+ OutputStruct->Data.Address64.Attribute.Memory.CacheAttribute =
+ (UINT16) ((Temp8 >> 1) & 0x0F);
+ }
+
+ else
+ {
+ if (IO_RANGE == OutputStruct->Data.Address64.ResourceType)
+ {
+ OutputStruct->Data.Address64.Attribute.Io.RangeAttribute =
+ (UINT16) (Temp8 & 0x03);
+ }
+
+ else
+ {
+ /* BUS_NUMBER_RANGE == OutputStruct->Data.Address64.ResourceType */
+ /* Nothing needs to be filled in */
+ }
+ }
+
+ /*
+ * Get Granularity (Bytes 6-13)
+ */
+ Buffer += 1;
+ MOVE_UNALIGNED64_TO_64 (&OutputStruct->Data.Address64.Granularity,
+ Buffer);
+
+ /*
+ * Get MinAddressRange (Bytes 14-21)
+ */
+ Buffer += 8;
+ MOVE_UNALIGNED64_TO_64 (&OutputStruct->Data.Address64.MinAddressRange,
+ Buffer);
+
+ /*
+ * Get MaxAddressRange (Bytes 22-29)
+ */
+ Buffer += 8;
+ MOVE_UNALIGNED64_TO_64 (&OutputStruct->Data.Address64.MaxAddressRange,
+ Buffer);
+
+ /*
+ * Get AddressTranslationOffset (Bytes 30-37)
+ */
+ Buffer += 8;
+ MOVE_UNALIGNED64_TO_64 (&OutputStruct->Data.Address64.AddressTranslationOffset,
+ Buffer);
+
+ /*
+ * Get AddressLength (Bytes 38-45)
+ */
+ Buffer += 8;
+ MOVE_UNALIGNED64_TO_64 (&OutputStruct->Data.Address64.AddressLength,
+ Buffer);
+
+ /*
+ * Resource Source Index (if present)
+ */
+ Buffer += 8;
+
+ /*
+ * This will leave us pointing to the Resource Source Index
+ * If it is present, then save it off and calculate the
+ * pointer to where the null terminated string goes:
+ * Each Interrupt takes 32-bits + the 5 bytes of the
+ * stream that are default.
+ */
+ if (*BytesConsumed > 46)
+ {
+ /* Dereference the Index */
+
+ Temp8 = *Buffer;
+ OutputStruct->Data.Address64.ResourceSource.Index =
+ (UINT32) Temp8;
+
+ /* Point to the String */
+
+ Buffer += 1;
+
+ /* Point the String pointer to the end of this structure */
+
+ OutputStruct->Data.Address64.ResourceSource.StringPtr =
+ (NATIVE_CHAR *)((UINT8 *)OutputStruct + StructSize);
+
+ TempPtr = OutputStruct->Data.Address64.ResourceSource.StringPtr;
+
+ /* Copy the string into the buffer */
+
+ Index = 0;
+
+ while (0x00 != *Buffer)
+ {
+ *TempPtr = *Buffer;
+
+ TempPtr += 1;
+ Buffer += 1;
+ Index += 1;
+ }
+
+ /*
+ * Add the terminating null
+ */
+ *TempPtr = 0x00;
+
+ OutputStruct->Data.Address64.ResourceSource.StringLength = Index + 1;
+
+ /*
+ * In order for the StructSize to fall on a 32-bit boundary,
+ * calculate the length of the string and expand the
+ * StructSize to the next 32-bit boundary.
+ */
+ Temp8 = (UINT8) (Index + 1);
+ StructSize += ROUND_UP_TO_32BITS (Temp8);
+ }
+
+ else
+ {
+ OutputStruct->Data.Address64.ResourceSource.Index = 0x00;
+ OutputStruct->Data.Address64.ResourceSource.StringLength = 0;
+ OutputStruct->Data.Address64.ResourceSource.StringPtr = NULL;
+ }
+
+ /*
+ * Set the Length parameter
+ */
+ OutputStruct->Length = StructSize;
+
+ /*
+ * Return the final size of the structure
+ */
+ *StructureSize = StructSize;
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsAddress64Stream
+ *
+ * PARAMETERS: LinkedList - Pointer to the resource linked list
+ * OutputBuffer - Pointer to the user's return buffer
+ * BytesConsumed - UINT32 pointer that is filled with
+ * the number of bytes of the
+ * OutputBuffer used
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Take the linked list resource structure and fills in the
+ * the appropriate bytes in a byte stream
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsAddress64Stream (
+ ACPI_RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ UINT32 *BytesConsumed)
+{
+ UINT8 *Buffer;
+ UINT16 *LengthField;
+ UINT8 Temp8;
+ NATIVE_CHAR *TempPointer;
+
+
+ FUNCTION_TRACE ("RsAddress64Stream");
+
+
+ Buffer = *OutputBuffer;
+
+ /*
+ * The descriptor field is static
+ */
+ *Buffer = 0x8A;
+ Buffer += 1;
+
+ /*
+ * Set a pointer to the Length field - to be filled in later
+ */
+
+ LengthField = (UINT16 *)Buffer;
+ Buffer += 2;
+ /*
+ * Set the Resource Type (Memory, Io, BusNumber)
+ */
+ Temp8 = (UINT8) (LinkedList->Data.Address64.ResourceType & 0x03);
+
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ /*
+ * Set the general flags
+ */
+ Temp8 = (UINT8) (LinkedList->Data.Address64.ProducerConsumer & 0x01);
+ Temp8 |= (LinkedList->Data.Address64.Decode & 0x01) << 1;
+ Temp8 |= (LinkedList->Data.Address64.MinAddressFixed & 0x01) << 2;
+ Temp8 |= (LinkedList->Data.Address64.MaxAddressFixed & 0x01) << 3;
+
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ /*
+ * Set the type specific flags
+ */
+ Temp8 = 0;
+
+ if(MEMORY_RANGE == LinkedList->Data.Address64.ResourceType)
+ {
+ Temp8 = (UINT8)
+ (LinkedList->Data.Address64.Attribute.Memory.ReadWriteAttribute &
+ 0x01);
+
+ Temp8 |=
+ (LinkedList->Data.Address64.Attribute.Memory.CacheAttribute &
+ 0x0F) << 1;
+ }
+
+ else if (IO_RANGE == LinkedList->Data.Address64.ResourceType)
+ {
+ Temp8 = (UINT8)
+ (LinkedList->Data.Address64.Attribute.Io.RangeAttribute &
+ 0x03);
+ }
+
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ /*
+ * Set the address space granularity
+ */
+ MOVE_UNALIGNED64_TO_64 (Buffer,
+ &LinkedList->Data.Address64.Granularity);
+ Buffer += 8;
+
+ /*
+ * Set the address range minimum
+ */
+ MOVE_UNALIGNED64_TO_64 (Buffer,
+ &LinkedList->Data.Address64.MinAddressRange);
+ Buffer += 8;
+
+ /*
+ * Set the address range maximum
+ */
+ MOVE_UNALIGNED64_TO_64 (Buffer,
+ &LinkedList->Data.Address64.MaxAddressRange);
+ Buffer += 8;
+
+ /*
+ * Set the address translation offset
+ */
+ MOVE_UNALIGNED64_TO_64 (Buffer,
+ &LinkedList->Data.Address64.AddressTranslationOffset);
+ Buffer += 8;
+
+ /*
+ * Set the address length
+ */
+ MOVE_UNALIGNED64_TO_64 (Buffer,
+ &LinkedList->Data.Address64.AddressLength);
+ Buffer += 8;
+
+ /*
+ * Resource Source Index and Resource Source are optional
+ */
+ if (0 != LinkedList->Data.Address64.ResourceSource.StringLength)
+ {
+ Temp8 = (UINT8) LinkedList->Data.Address64.ResourceSource.Index;
+
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ TempPointer = (NATIVE_CHAR *) Buffer;
+
+ /*
+ * Copy the string
+ */
+ STRCPY (TempPointer, LinkedList->Data.Address64.ResourceSource.StringPtr);
+
+ /*
+ * Buffer needs to be set to the length of the sting + one for the
+ * terminating null
+ */
+ Buffer += (STRLEN (LinkedList->Data.Address64.ResourceSource.StringPtr) + 1);
+ }
+
+ /*
+ * Return the number of bytes consumed in this operation
+ */
+ *BytesConsumed = POINTER_DIFF (Buffer, *OutputBuffer);
+
+ /*
+ * Set the length field to the number of bytes consumed
+ * minus the header size (3 bytes)
+ */
+ *LengthField = (UINT16) (*BytesConsumed - 3);
return_ACPI_STATUS (AE_OK);
}
OpenPOWER on IntegriCloud