diff options
author | jkim <jkim@FreeBSD.org> | 2005-11-01 22:11:18 +0000 |
---|---|---|
committer | jkim <jkim@FreeBSD.org> | 2005-11-01 22:11:18 +0000 |
commit | 5f6a2493ddea1cf36a4dcd58b865c4148427e0a2 (patch) | |
tree | 4450b2c84d749dd8a8425a8feb88b084809f6ef0 /sys/contrib/dev/acpica/rsaddr.c | |
parent | 50133a977cb75b3f52603d4b351a8cf45bb556c8 (diff) | |
download | FreeBSD-src-5f6a2493ddea1cf36a4dcd58b865c4148427e0a2.zip FreeBSD-src-5f6a2493ddea1cf36a4dcd58b865c4148427e0a2.tar.gz |
Vendor import of Intel ACPI-CA 20051021
Diffstat (limited to 'sys/contrib/dev/acpica/rsaddr.c')
-rw-r--r-- | sys/contrib/dev/acpica/rsaddr.c | 1268 |
1 files changed, 215 insertions, 1053 deletions
diff --git a/sys/contrib/dev/acpica/rsaddr.c b/sys/contrib/dev/acpica/rsaddr.c index 8640e7a..c252978 100644 --- a/sys/contrib/dev/acpica/rsaddr.c +++ b/sys/contrib/dev/acpica/rsaddr.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: rsaddr - Address resource descriptors (16/32/64) - * $Revision: 35 $ + * $Revision: 1.48 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -125,1193 +125,355 @@ /******************************************************************************* * - * FUNCTION: AcpiRsAddress16Resource - * - * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte - * stream - * BytesConsumed - Pointer to where the number of bytes - * consumed the ByteStreamBuffer is - * returned - * OutputBuffer - Pointer to the return data buffer - * StructureSize - Pointer to where the number of bytes - * in the return data struct is returned - * - * 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. + * AcpiRsConvertAddress16 - All WORD (16-bit) address resources * ******************************************************************************/ -ACPI_STATUS -AcpiRsAddress16Resource ( - UINT8 *ByteStreamBuffer, - ACPI_SIZE *BytesConsumed, - UINT8 **OutputBuffer, - ACPI_SIZE *StructureSize) +ACPI_RSCONVERT_INFO AcpiRsConvertAddress16[5] = { - UINT8 *Buffer = ByteStreamBuffer; - ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer; - UINT8 *TempPtr; - ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_ADDRESS16); - UINT32 Index; - UINT16 Temp16; - UINT8 Temp8; - - - ACPI_FUNCTION_TRACE ("RsAddress16Resource"); - - - /* - * Point past the Descriptor to get the number of bytes consumed - */ - Buffer += 1; - ACPI_MOVE_16_TO_16 (&Temp16, Buffer); - - /* Validate minimum descriptor length */ - - if (Temp16 < 13) - { - return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH); - } - - *BytesConsumed = Temp16 + 3; - OutputStruct->Id = ACPI_RSTYPE_ADDRESS16; - - /* - * 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.Address16.ResourceType = Temp8 & 0x03; - - /* - * Get the General Flags (Byte4) - */ - Buffer += 1; - Temp8 = *Buffer; - - /* Producer / Consumer */ - - OutputStruct->Data.Address16.ProducerConsumer = Temp8 & 0x01; - - /* Decode */ - - OutputStruct->Data.Address16.Decode = (Temp8 >> 1) & 0x01; - - /* Min Address Fixed */ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS16, + ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS16), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertAddress16)}, - OutputStruct->Data.Address16.MinAddressFixed = (Temp8 >> 2) & 0x01; + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS16, + sizeof (AML_RESOURCE_ADDRESS16), + 0}, - /* Max Address Fixed */ - - OutputStruct->Data.Address16.MaxAddressFixed = (Temp8 >> 3) & 0x01; - - /* - * Get the Type Specific Flags (Byte5) - */ - Buffer += 1; - Temp8 = *Buffer; - - if (ACPI_MEMORY_RANGE == OutputStruct->Data.Address16.ResourceType) - { - OutputStruct->Data.Address16.Attribute.Memory.ReadWriteAttribute = - (UINT16) (Temp8 & 0x01); - OutputStruct->Data.Address16.Attribute.Memory.CacheAttribute = - (UINT16) ((Temp8 >> 1) & 0x03); - } - else - { - if (ACPI_IO_RANGE == OutputStruct->Data.Address16.ResourceType) - { - OutputStruct->Data.Address16.Attribute.Io.RangeAttribute = - (UINT16) (Temp8 & 0x03); - OutputStruct->Data.Address16.Attribute.Io.TranslationAttribute = - (UINT16) ((Temp8 >> 4) & 0x03); - } - else - { - /* BUS_NUMBER_RANGE == Address16.Data->ResourceType */ - /* Nothing needs to be filled in */ - } - } + /* Resource Type, General Flags, and Type-Specific Flags */ - /* - * Get Granularity (Bytes 6-7) - */ - Buffer += 1; - ACPI_MOVE_16_TO_32 (&OutputStruct->Data.Address16.Granularity, Buffer); + {ACPI_RSC_ADDRESS, 0, 0, 0}, /* - * Get MinAddressRange (Bytes 8-9) + * These fields are contiguous in both the source and destination: + * Address Granularity + * Address Range Minimum + * Address Range Maximum + * Address Translation Offset + * Address Length */ - Buffer += 2; - ACPI_MOVE_16_TO_32 (&OutputStruct->Data.Address16.MinAddressRange, Buffer); + {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.Address16.Granularity), + AML_OFFSET (Address16.Granularity), + 5}, - /* - * Get MaxAddressRange (Bytes 10-11) - */ - Buffer += 2; - ACPI_MOVE_16_TO_32 (&OutputStruct->Data.Address16.MaxAddressRange, Buffer); + /* Optional ResourceSource (Index and String) */ - /* - * Get AddressTranslationOffset (Bytes 12-13) - */ - Buffer += 2; - ACPI_MOVE_16_TO_32 (&OutputStruct->Data.Address16.AddressTranslationOffset, Buffer); - - /* - * Get AddressLength (Bytes 14-15) - */ - Buffer += 2; - ACPI_MOVE_16_TO_32 (&OutputStruct->Data.Address16.AddressLength, Buffer); - - /* - * Resource Source Index (if present) - */ - Buffer += 2; - - /* - * 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. - * - * Note: Some resource descriptors will have an additional null, so - * we add 1 to the length. - */ - if (*BytesConsumed > (16 + 1)) - { - /* Dereference the Index */ - - Temp8 = *Buffer; - 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 = - (char *)((UINT8 * )OutputStruct + StructSize); - - TempPtr = (UINT8 *) OutputStruct->Data.Address16.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.Address16.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 += ACPI_ROUND_UP_TO_32BITS (Temp8); - } - else - { - OutputStruct->Data.Address16.ResourceSource.Index = 0x00; - OutputStruct->Data.Address16.ResourceSource.StringLength = 0; - OutputStruct->Data.Address16.ResourceSource.StringPtr = NULL; - } - - /* - * Set the Length parameter - */ - OutputStruct->Length = (UINT32) StructSize; - - /* - * Return the final size of the structure - */ - *StructureSize = StructSize; - return_ACPI_STATUS (AE_OK); -} + {ACPI_RSC_SOURCE, ACPI_RS_OFFSET (Data.Address16.ResourceSource), + 0, + sizeof (AML_RESOURCE_ADDRESS16)} +}; /******************************************************************************* * - * FUNCTION: AcpiRsAddress16Stream - * - * PARAMETERS: LinkedList - Pointer to the resource linked list - * OutputBuffer - Pointer to the user's return buffer - * BytesConsumed - Pointer to where the number of bytes - * used in the OutputBuffer is returned - * - * RETURN: Status - * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream + * AcpiRsConvertAddress32 - All DWORD (32-bit) address resources * ******************************************************************************/ -ACPI_STATUS -AcpiRsAddress16Stream ( - ACPI_RESOURCE *LinkedList, - UINT8 **OutputBuffer, - ACPI_SIZE *BytesConsumed) +ACPI_RSCONVERT_INFO AcpiRsConvertAddress32[5] = { - UINT8 *Buffer = *OutputBuffer; - UINT8 *LengthField; - UINT8 Temp8; - char *TempPointer = NULL; - ACPI_SIZE ActualBytes; - - - ACPI_FUNCTION_TRACE ("RsAddress16Stream"); - - - /* - * The descriptor field is static - */ - *Buffer = 0x88; - Buffer += 1; - - /* - * Save a pointer to the Length field - to be filled in later - */ - LengthField = Buffer; - Buffer += 2; - - /* - * Set the Resource Type (Memory, Io, BusNumber) - */ - Temp8 = (UINT8) (LinkedList->Data.Address16.ResourceType & 0x03); - *Buffer = Temp8; - Buffer += 1; + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS32, + ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS32), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertAddress32)}, - /* - * Set the general flags - */ - Temp8 = (UINT8) (LinkedList->Data.Address16.ProducerConsumer & 0x01); - - Temp8 |= (LinkedList->Data.Address16.Decode & 0x01) << 1; - Temp8 |= (LinkedList->Data.Address16.MinAddressFixed & 0x01) << 2; - Temp8 |= (LinkedList->Data.Address16.MaxAddressFixed & 0x01) << 3; - - *Buffer = Temp8; - Buffer += 1; - - /* - * Set the type specific flags - */ - Temp8 = 0; - - if (ACPI_MEMORY_RANGE == LinkedList->Data.Address16.ResourceType) - { - Temp8 = (UINT8) - (LinkedList->Data.Address16.Attribute.Memory.ReadWriteAttribute & - 0x01); - - Temp8 |= - (LinkedList->Data.Address16.Attribute.Memory.CacheAttribute & - 0x03) << 1; - } - else if (ACPI_IO_RANGE == LinkedList->Data.Address16.ResourceType) - { - Temp8 = (UINT8) - (LinkedList->Data.Address16.Attribute.Io.RangeAttribute & - 0x03); - Temp8 |= - (LinkedList->Data.Address16.Attribute.Io.TranslationAttribute & - 0x03) << 4; - } - - *Buffer = Temp8; - Buffer += 1; - - /* - * Set the address space granularity - */ - ACPI_MOVE_32_TO_16 (Buffer, &LinkedList->Data.Address16.Granularity); - Buffer += 2; - - /* - * Set the address range minimum - */ - ACPI_MOVE_32_TO_16 (Buffer, &LinkedList->Data.Address16.MinAddressRange); - Buffer += 2; - - /* - * Set the address range maximum - */ - ACPI_MOVE_32_TO_16 (Buffer, &LinkedList->Data.Address16.MaxAddressRange); - Buffer += 2; + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS32, + sizeof (AML_RESOURCE_ADDRESS32), + 0}, - /* - * Set the address translation offset - */ - ACPI_MOVE_32_TO_16 (Buffer, &LinkedList->Data.Address16.AddressTranslationOffset); - Buffer += 2; + /* Resource Type, General Flags, and Type-Specific Flags */ - /* - * Set the address length - */ - ACPI_MOVE_32_TO_16 (Buffer, &LinkedList->Data.Address16.AddressLength); - Buffer += 2; + {ACPI_RSC_ADDRESS, 0, 0, 0}, /* - * Resource Source Index and Resource Source are optional + * These fields are contiguous in both the source and destination: + * Address Granularity + * Address Range Minimum + * Address Range Maximum + * Address Translation Offset + * Address Length */ - if (0 != LinkedList->Data.Address16.ResourceSource.StringLength) - { - Temp8 = (UINT8) LinkedList->Data.Address16.ResourceSource.Index; - - *Buffer = Temp8; - Buffer += 1; - - TempPointer = (char *) Buffer; + {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.Address32.Granularity), + AML_OFFSET (Address32.Granularity), + 5}, - /* - * Copy the string - */ - ACPI_STRCPY (TempPointer, - LinkedList->Data.Address16.ResourceSource.StringPtr); + /* Optional ResourceSource (Index and String) */ - /* - * Buffer needs to be set to the length of the sting + one for the - * terminating null - */ - Buffer += (ACPI_SIZE)(ACPI_STRLEN (LinkedList->Data.Address16.ResourceSource.StringPtr) + 1); - } - - /* - * Return the number of bytes consumed in this operation - */ - ActualBytes = ACPI_PTR_DIFF (Buffer, *OutputBuffer); - *BytesConsumed = ActualBytes; - - /* - * Set the length field to the number of bytes consumed - * minus the header size (3 bytes) - */ - ActualBytes -= 3; - ACPI_MOVE_SIZE_TO_16 (LengthField, &ActualBytes); - return_ACPI_STATUS (AE_OK); -} + {ACPI_RSC_SOURCE, ACPI_RS_OFFSET (Data.Address32.ResourceSource), + 0, + sizeof (AML_RESOURCE_ADDRESS32)} +}; /******************************************************************************* * - * FUNCTION: AcpiRsAddress32Resource - * - * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte - * stream - * BytesConsumed - Pointer to where the number of bytes - * consumed the ByteStreamBuffer is - * returned - * OutputBuffer - Pointer to the return data buffer - * StructureSize - Pointer to where the number of bytes - * in the return data struct is returned - * - * 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. + * AcpiRsConvertAddress64 - All QWORD (64-bit) address resources * ******************************************************************************/ -ACPI_STATUS -AcpiRsAddress32Resource ( - UINT8 *ByteStreamBuffer, - ACPI_SIZE *BytesConsumed, - UINT8 **OutputBuffer, - ACPI_SIZE *StructureSize) +ACPI_RSCONVERT_INFO AcpiRsConvertAddress64[5] = { - UINT8 *Buffer; - ACPI_RESOURCE *OutputStruct= (void *) *OutputBuffer; - UINT16 Temp16; - UINT8 Temp8; - UINT8 *TempPtr; - ACPI_SIZE StructSize; - UINT32 Index; - + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS64, + ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS64), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertAddress64)}, - ACPI_FUNCTION_TRACE ("RsAddress32Resource"); + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS64, + sizeof (AML_RESOURCE_ADDRESS64), + 0}, + /* Resource Type, General Flags, and Type-Specific Flags */ - Buffer = ByteStreamBuffer; - StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_ADDRESS32); + {ACPI_RSC_ADDRESS, 0, 0, 0}, /* - * Point past the Descriptor to get the number of bytes consumed + * These fields are contiguous in both the source and destination: + * Address Granularity + * Address Range Minimum + * Address Range Maximum + * Address Translation Offset + * Address Length */ - Buffer += 1; - ACPI_MOVE_16_TO_16 (&Temp16, Buffer); + {ACPI_RSC_MOVE64, ACPI_RS_OFFSET (Data.Address64.Granularity), + AML_OFFSET (Address64.Granularity), + 5}, - /* Validate minimum descriptor length */ + /* Optional ResourceSource (Index and String) */ - if (Temp16 < 23) - { - return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH); - } - - *BytesConsumed = Temp16 + 3; - OutputStruct->Id = ACPI_RSTYPE_ADDRESS32; + {ACPI_RSC_SOURCE, ACPI_RS_OFFSET (Data.Address64.ResourceSource), + 0, + sizeof (AML_RESOURCE_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.Address32.ResourceType = Temp8 & 0x03; - - /* - * Get the General Flags (Byte4) - */ - Buffer += 1; - Temp8 = *Buffer; - - /* - * Producer / Consumer - */ - OutputStruct->Data.Address32.ProducerConsumer = Temp8 & 0x01; - - /* - * Decode - */ - OutputStruct->Data.Address32.Decode = (Temp8 >> 1) & 0x01; - - /* - * Min Address Fixed - */ - OutputStruct->Data.Address32.MinAddressFixed = (Temp8 >> 2) & 0x01; - - /* - * Max Address Fixed - */ - OutputStruct->Data.Address32.MaxAddressFixed = (Temp8 >> 3) & 0x01; - - /* - * Get the Type Specific Flags (Byte5) - */ - Buffer += 1; - Temp8 = *Buffer; - - if (ACPI_MEMORY_RANGE == OutputStruct->Data.Address32.ResourceType) - { - OutputStruct->Data.Address32.Attribute.Memory.ReadWriteAttribute = - (UINT16) (Temp8 & 0x01); - - OutputStruct->Data.Address32.Attribute.Memory.CacheAttribute = - (UINT16) ((Temp8 >> 1) & 0x03); - } - else - { - if (ACPI_IO_RANGE == OutputStruct->Data.Address32.ResourceType) - { - OutputStruct->Data.Address32.Attribute.Io.RangeAttribute = - (UINT16) (Temp8 & 0x03); - OutputStruct->Data.Address32.Attribute.Io.TranslationAttribute = - (UINT16) ((Temp8 >> 4) & 0x03); - } - else - { - /* BUS_NUMBER_RANGE == OutputStruct->Data.Address32.ResourceType */ - /* Nothing needs to be filled in */ - } - } - - /* - * Get Granularity (Bytes 6-9) - */ - Buffer += 1; - ACPI_MOVE_32_TO_32 (&OutputStruct->Data.Address32.Granularity, Buffer); - - /* - * Get MinAddressRange (Bytes 10-13) - */ - Buffer += 4; - ACPI_MOVE_32_TO_32 (&OutputStruct->Data.Address32.MinAddressRange, Buffer); - - /* - * Get MaxAddressRange (Bytes 14-17) - */ - Buffer += 4; - ACPI_MOVE_32_TO_32 (&OutputStruct->Data.Address32.MaxAddressRange, Buffer); - - /* - * Get AddressTranslationOffset (Bytes 18-21) - */ - Buffer += 4; - ACPI_MOVE_32_TO_32 (&OutputStruct->Data.Address32.AddressTranslationOffset, Buffer); - - /* - * Get AddressLength (Bytes 22-25) - */ - Buffer += 4; - ACPI_MOVE_32_TO_32 (&OutputStruct->Data.Address32.AddressLength, Buffer); - - /* - * Resource Source Index (if present) - */ - Buffer += 4; - - /* - * 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: - * - * Note: Some resource descriptors will have an additional null, so - * we add 1 to the length. - */ - if (*BytesConsumed > (26 + 1)) - { - /* Dereference the Index */ - - Temp8 = *Buffer; - 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 = - (char *)((UINT8 *)OutputStruct + StructSize); - - TempPtr = (UINT8 *) OutputStruct->Data.Address32.ResourceSource.StringPtr; - - /* Copy the string into the buffer */ +/******************************************************************************* + * + * AcpiRsConvertExtAddress64 - All Extended (64-bit) address resources + * + ******************************************************************************/ - Index = 0; - while (0x00 != *Buffer) - { - *TempPtr = *Buffer; +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)}, - TempPtr += 1; - Buffer += 1; - Index += 1; - } + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64, + sizeof (AML_RESOURCE_EXTENDED_ADDRESS64), + 0}, - /* - * Add the terminating null - */ - *TempPtr = 0x00; - OutputStruct->Data.Address32.ResourceSource.StringLength = Index + 1; + /* Resource Type, General Flags, and Type-Specific Flags */ - /* - * 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 += ACPI_ROUND_UP_TO_32BITS (Temp8); - } - else - { - OutputStruct->Data.Address32.ResourceSource.Index = 0x00; - OutputStruct->Data.Address32.ResourceSource.StringLength = 0; - OutputStruct->Data.Address32.ResourceSource.StringPtr = NULL; - } + {ACPI_RSC_ADDRESS, 0, 0, 0}, - /* - * Set the Length parameter - */ - OutputStruct->Length = (UINT32) StructSize; + /* Revision ID */ + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.ExtAddress64.RevisionID), + AML_OFFSET (ExtAddress64.RevisionID), + 1}, /* - * Return the final size of the structure + * 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 */ - *StructureSize = StructSize; - return_ACPI_STATUS (AE_OK); -} + {ACPI_RSC_MOVE64, ACPI_RS_OFFSET (Data.ExtAddress64.Granularity), + AML_OFFSET (ExtAddress64.Granularity), + 6} +}; /******************************************************************************* * - * FUNCTION: AcpiRsAddress32Stream - * - * PARAMETERS: LinkedList - Pointer to the resource linked list - * OutputBuffer - Pointer to the user's return buffer - * BytesConsumed - Pointer to where the number of bytes - * used in the OutputBuffer is returned - * - * RETURN: Status - * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream + * AcpiRsConvertGeneralFlags - Flags common to all address descriptors * ******************************************************************************/ -ACPI_STATUS -AcpiRsAddress32Stream ( - ACPI_RESOURCE *LinkedList, - UINT8 **OutputBuffer, - ACPI_SIZE *BytesConsumed) +static ACPI_RSCONVERT_INFO AcpiRsConvertGeneralFlags[6] = { - UINT8 *Buffer; - UINT16 *LengthField; - UINT8 Temp8; - char *TempPointer; + {ACPI_RSC_FLAGINIT, 0, AML_OFFSET (Address.Flags), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertGeneralFlags)}, + /* Resource Type (Memory, Io, BusNumber, etc.) */ - ACPI_FUNCTION_TRACE ("RsAddress32Stream"); + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Address.ResourceType), + AML_OFFSET (Address.ResourceType), + 1}, + /* General Flags - Consume, Decode, MinFixed, MaxFixed */ - Buffer = *OutputBuffer; + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.ProducerConsumer), + AML_OFFSET (Address.Flags), + 0}, - /* - * The descriptor field is static - */ - *Buffer = 0x87; - Buffer += 1; + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Decode), + AML_OFFSET (Address.Flags), + 1}, - /* - * Set a pointer to the Length field - to be filled in later - */ - LengthField = ACPI_CAST_PTR (UINT16, Buffer); - Buffer += 2; + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.MinAddressFixed), + AML_OFFSET (Address.Flags), + 2}, - /* - * Set the Resource Type (Memory, Io, BusNumber) - */ - Temp8 = (UINT8) (LinkedList->Data.Address32.ResourceType & 0x03); + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.MaxAddressFixed), + AML_OFFSET (Address.Flags), + 3} +}; - *Buffer = Temp8; - Buffer += 1; - /* - * Set the general flags - */ - Temp8 = (UINT8) (LinkedList->Data.Address32.ProducerConsumer & 0x01); - Temp8 |= (LinkedList->Data.Address32.Decode & 0x01) << 1; - Temp8 |= (LinkedList->Data.Address32.MinAddressFixed & 0x01) << 2; - Temp8 |= (LinkedList->Data.Address32.MaxAddressFixed & 0x01) << 3; +/******************************************************************************* + * + * AcpiRsConvertMemFlags - Flags common to Memory address descriptors + * + ******************************************************************************/ - *Buffer = Temp8; - Buffer += 1; +static ACPI_RSCONVERT_INFO AcpiRsConvertMemFlags[5] = +{ + {ACPI_RSC_FLAGINIT, 0, AML_OFFSET (Address.SpecificFlags), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertMemFlags)}, - /* - * Set the type specific flags - */ - Temp8 = 0; + /* Memory-specific flags */ - if (ACPI_MEMORY_RANGE == LinkedList->Data.Address32.ResourceType) - { - Temp8 = (UINT8) - (LinkedList->Data.Address32.Attribute.Memory.ReadWriteAttribute & - 0x01); + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.WriteProtect), + AML_OFFSET (Address.SpecificFlags), + 0}, - Temp8 |= - (LinkedList->Data.Address32.Attribute.Memory.CacheAttribute & - 0x03) << 1; - } - else if (ACPI_IO_RANGE == LinkedList->Data.Address32.ResourceType) - { - Temp8 = (UINT8) - (LinkedList->Data.Address32.Attribute.Io.RangeAttribute & - 0x03); - Temp8 |= - (LinkedList->Data.Address32.Attribute.Io.TranslationAttribute & - 0x03) << 4; - } + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.Caching), + AML_OFFSET (Address.SpecificFlags), + 1}, - *Buffer = Temp8; - Buffer += 1; + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.RangeType), + AML_OFFSET (Address.SpecificFlags), + 3}, - /* - * Set the address space granularity - */ - ACPI_MOVE_32_TO_32 (Buffer, &LinkedList->Data.Address32.Granularity); - Buffer += 4; + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.Translation), + AML_OFFSET (Address.SpecificFlags), + 5} +}; - /* - * Set the address range minimum - */ - ACPI_MOVE_32_TO_32 (Buffer, &LinkedList->Data.Address32.MinAddressRange); - Buffer += 4; - /* - * Set the address range maximum - */ - ACPI_MOVE_32_TO_32 (Buffer, &LinkedList->Data.Address32.MaxAddressRange); - Buffer += 4; - - /* - * Set the address translation offset - */ - ACPI_MOVE_32_TO_32 (Buffer, &LinkedList->Data.Address32.AddressTranslationOffset); - Buffer += 4; - - /* - * Set the address length - */ - ACPI_MOVE_32_TO_32 (Buffer, &LinkedList->Data.Address32.AddressLength); - Buffer += 4; - - /* - * Resource Source Index and Resource Source are optional - */ - if (0 != LinkedList->Data.Address32.ResourceSource.StringLength) - { - Temp8 = (UINT8) LinkedList->Data.Address32.ResourceSource.Index; - - *Buffer = Temp8; - Buffer += 1; +/******************************************************************************* + * + * AcpiRsConvertIoFlags - Flags common to I/O address descriptors + * + ******************************************************************************/ - TempPointer = (char *) Buffer; +static ACPI_RSCONVERT_INFO AcpiRsConvertIoFlags[4] = +{ + {ACPI_RSC_FLAGINIT, 0, AML_OFFSET (Address.SpecificFlags), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertIoFlags)}, - /* - * Copy the string - */ - ACPI_STRCPY (TempPointer, - LinkedList->Data.Address32.ResourceSource.StringPtr); + /* I/O-specific flags */ - /* - * Buffer needs to be set to the length of the sting + one for the - * terminating null - */ - Buffer += (ACPI_SIZE)(ACPI_STRLEN (LinkedList->Data.Address32.ResourceSource.StringPtr) + 1); - } + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Io.RangeType), + AML_OFFSET (Address.SpecificFlags), + 0}, - /* - * Return the number of bytes consumed in this operation - */ - *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer); + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Io.Translation), + AML_OFFSET (Address.SpecificFlags), + 4}, - /* - * 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); -} + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Io.TranslationType), + AML_OFFSET (Address.SpecificFlags), + 5} +}; /******************************************************************************* * - * FUNCTION: AcpiRsAddress64Resource + * FUNCTION: AcpiRsGetAddressCommon * - * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte - * stream - * BytesConsumed - Pointer to where the number of bytes - * consumed the ByteStreamBuffer is - * returned - * OutputBuffer - Pointer to the return data buffer - * StructureSize - Pointer to where the number of bytes - * in the return data struct is returned + * PARAMETERS: Resource - Pointer to the internal resource struct + * Aml - Pointer to the AML resource descriptor * - * RETURN: Status + * RETURN: TRUE if the ResourceType field is OK, FALSE otherwise * - * 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. + * DESCRIPTION: Convert common flag fields from a raw AML resource descriptor + * to an internal resource descriptor * ******************************************************************************/ -ACPI_STATUS -AcpiRsAddress64Resource ( - UINT8 *ByteStreamBuffer, - ACPI_SIZE *BytesConsumed, - UINT8 **OutputBuffer, - ACPI_SIZE *StructureSize) +BOOLEAN +AcpiRsGetAddressCommon ( + ACPI_RESOURCE *Resource, + AML_RESOURCE *Aml) { - UINT8 *Buffer; - ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer; - UINT16 Temp16; - UINT8 Temp8; - UINT8 *TempPtr; - ACPI_SIZE StructSize; - UINT32 Index; - + ACPI_FUNCTION_ENTRY (); - ACPI_FUNCTION_TRACE ("RsAddress64Resource"); + /* Validate the Resource Type */ - Buffer = ByteStreamBuffer; - StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_ADDRESS64); - - /* - * Point past the Descriptor to get the number of bytes consumed - */ - Buffer += 1; - ACPI_MOVE_16_TO_16 (&Temp16, Buffer); - - /* Validate minimum descriptor length */ - - if (Temp16 < 43) + if ((Aml->Address.ResourceType > 2) && (Aml->Address.ResourceType < 0xC0)) { - return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH); + return (FALSE); } - *BytesConsumed = Temp16 + 3; - OutputStruct->Id = ACPI_RSTYPE_ADDRESS64; + /* Get the Resource Type and General Flags */ - /* - * Get the Resource Type (Byte3) - */ - Buffer += 2; - Temp8 = *Buffer; + (void) AcpiRsConvertAmlToResource (Resource, Aml, AcpiRsConvertGeneralFlags); - /* Values 0-2 are valid */ + /* Get the Type-Specific Flags (Memory and I/O descriptors only) */ - if(Temp8 > 2) + if (Resource->Data.Address.ResourceType == ACPI_MEMORY_RANGE) { - return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); + (void) AcpiRsConvertAmlToResource (Resource, Aml, AcpiRsConvertMemFlags); } - - 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 (ACPI_MEMORY_RANGE == OutputStruct->Data.Address64.ResourceType) + else if (Resource->Data.Address.ResourceType == ACPI_IO_RANGE) { - OutputStruct->Data.Address64.Attribute.Memory.ReadWriteAttribute = - (UINT16) (Temp8 & 0x01); - - OutputStruct->Data.Address64.Attribute.Memory.CacheAttribute = - (UINT16) ((Temp8 >> 1) & 0x03); + (void) AcpiRsConvertAmlToResource (Resource, Aml, AcpiRsConvertIoFlags); } else { - if (ACPI_IO_RANGE == OutputStruct->Data.Address64.ResourceType) - { - OutputStruct->Data.Address64.Attribute.Io.RangeAttribute = - (UINT16) (Temp8 & 0x03); - OutputStruct->Data.Address64.Attribute.Io.TranslationAttribute = - (UINT16) ((Temp8 >> 4) & 0x03); - } - else - { - /* BUS_NUMBER_RANGE == OutputStruct->Data.Address64.ResourceType */ - /* Nothing needs to be filled in */ - } - } - - /* - * Get Granularity (Bytes 6-13) - */ - Buffer += 1; - ACPI_MOVE_64_TO_64 (&OutputStruct->Data.Address64.Granularity, Buffer); - - /* - * Get MinAddressRange (Bytes 14-21) - */ - Buffer += 8; - ACPI_MOVE_64_TO_64 (&OutputStruct->Data.Address64.MinAddressRange, Buffer); - - /* - * Get MaxAddressRange (Bytes 22-29) - */ - Buffer += 8; - ACPI_MOVE_64_TO_64 (&OutputStruct->Data.Address64.MaxAddressRange, Buffer); - - /* - * Get AddressTranslationOffset (Bytes 30-37) - */ - Buffer += 8; - ACPI_MOVE_64_TO_64 (&OutputStruct->Data.Address64.AddressTranslationOffset, Buffer); - - /* - * Get AddressLength (Bytes 38-45) - */ - Buffer += 8; - ACPI_MOVE_64_TO_64 (&OutputStruct->Data.Address64.AddressLength, Buffer); - - /* - * Resource Source Index (if present) - */ - Buffer += 8; + /* Generic resource type, just grab the TypeSpecific byte */ - /* - * 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. - * - * Note: Some resource descriptors will have an additional null, so - * we add 1 to the length. - */ - if (*BytesConsumed > (46 + 1)) - { - /* 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 = - (char *)((UINT8 *)OutputStruct + StructSize); - - TempPtr = (UINT8 *) 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 += ACPI_ROUND_UP_TO_32BITS (Temp8); - } - else - { - OutputStruct->Data.Address64.ResourceSource.Index = 0x00; - OutputStruct->Data.Address64.ResourceSource.StringLength = 0; - OutputStruct->Data.Address64.ResourceSource.StringPtr = NULL; + Resource->Data.Address.Info.TypeSpecific = Aml->Address.SpecificFlags; } - /* - * Set the Length parameter - */ - OutputStruct->Length = (UINT32) StructSize; - - /* - * Return the final size of the structure - */ - *StructureSize = StructSize; - return_ACPI_STATUS (AE_OK); + return (TRUE); } /******************************************************************************* * - * FUNCTION: AcpiRsAddress64Stream + * FUNCTION: AcpiRsSetAddressCommon * - * PARAMETERS: LinkedList - Pointer to the resource linked list - * OutputBuffer - Pointer to the user's return buffer - * BytesConsumed - Pointer to where the number of bytes - * used in the OutputBuffer is returned + * PARAMETERS: Aml - Pointer to the AML resource descriptor + * Resource - Pointer to the internal resource struct * - * RETURN: Status + * RETURN: None * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream + * DESCRIPTION: Convert common flag fields from a resource descriptor to an + * AML descriptor * ******************************************************************************/ -ACPI_STATUS -AcpiRsAddress64Stream ( - ACPI_RESOURCE *LinkedList, - UINT8 **OutputBuffer, - ACPI_SIZE *BytesConsumed) +void +AcpiRsSetAddressCommon ( + AML_RESOURCE *Aml, + ACPI_RESOURCE *Resource) { - UINT8 *Buffer; - UINT16 *LengthField; - UINT8 Temp8; - char *TempPointer; - + ACPI_FUNCTION_ENTRY (); - ACPI_FUNCTION_TRACE ("RsAddress64Stream"); + /* Set the Resource Type and General Flags */ - Buffer = *OutputBuffer; + (void) AcpiRsConvertResourceToAml (Resource, Aml, AcpiRsConvertGeneralFlags); - /* - * The descriptor field is static - */ - *Buffer = 0x8A; - Buffer += 1; - - /* - * Set a pointer to the Length field - to be filled in later - */ - LengthField = ACPI_CAST_PTR (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; + /* Set the Type-Specific Flags (Memory and I/O descriptors only) */ - *Buffer = Temp8; - Buffer += 1; - - /* - * Set the type specific flags - */ - Temp8 = 0; - - if (ACPI_MEMORY_RANGE == LinkedList->Data.Address64.ResourceType) + if (Resource->Data.Address.ResourceType == ACPI_MEMORY_RANGE) { - Temp8 = (UINT8) - (LinkedList->Data.Address64.Attribute.Memory.ReadWriteAttribute & - 0x01); - - Temp8 |= - (LinkedList->Data.Address64.Attribute.Memory.CacheAttribute & - 0x03) << 1; + (void) AcpiRsConvertResourceToAml (Resource, Aml, AcpiRsConvertMemFlags); } - else if (ACPI_IO_RANGE == LinkedList->Data.Address64.ResourceType) + else if (Resource->Data.Address.ResourceType == ACPI_IO_RANGE) { - Temp8 = (UINT8) - (LinkedList->Data.Address64.Attribute.Io.RangeAttribute & - 0x03); - Temp8 |= - (LinkedList->Data.Address64.Attribute.Io.RangeAttribute & - 0x03) << 4; + (void) AcpiRsConvertResourceToAml (Resource, Aml, AcpiRsConvertIoFlags); } - - *Buffer = Temp8; - Buffer += 1; - - /* - * Set the address space granularity - */ - ACPI_MOVE_64_TO_64 (Buffer, &LinkedList->Data.Address64.Granularity); - Buffer += 8; - - /* - * Set the address range minimum - */ - ACPI_MOVE_64_TO_64 (Buffer, &LinkedList->Data.Address64.MinAddressRange); - Buffer += 8; - - /* - * Set the address range maximum - */ - ACPI_MOVE_64_TO_64 (Buffer, &LinkedList->Data.Address64.MaxAddressRange); - Buffer += 8; - - /* - * Set the address translation offset - */ - ACPI_MOVE_64_TO_64 (Buffer, &LinkedList->Data.Address64.AddressTranslationOffset); - Buffer += 8; - - /* - * Set the address length - */ - ACPI_MOVE_64_TO_64 (Buffer, &LinkedList->Data.Address64.AddressLength); - Buffer += 8; - - /* - * Resource Source Index and Resource Source are optional - */ - if (0 != LinkedList->Data.Address64.ResourceSource.StringLength) + else { - Temp8 = (UINT8) LinkedList->Data.Address64.ResourceSource.Index; - - *Buffer = Temp8; - Buffer += 1; - - TempPointer = (char *) Buffer; + /* Generic resource type, just copy the TypeSpecific byte */ - /* - * Copy the string - */ - ACPI_STRCPY (TempPointer, LinkedList->Data.Address64.ResourceSource.StringPtr); - - /* - * Buffer needs to be set to the length of the sting + one for the - * terminating null - */ - Buffer += (ACPI_SIZE)(ACPI_STRLEN (LinkedList->Data.Address64.ResourceSource.StringPtr) + 1); + Aml->Address.SpecificFlags = Resource->Data.Address.Info.TypeSpecific; } - - /* - * Return the number of bytes consumed in this operation - */ - *BytesConsumed = ACPI_PTR_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); } + |