diff options
Diffstat (limited to 'sys/contrib/dev/acpica/rsirq.c')
-rw-r--r-- | sys/contrib/dev/acpica/rsirq.c | 169 |
1 files changed, 82 insertions, 87 deletions
diff --git a/sys/contrib/dev/acpica/rsirq.c b/sys/contrib/dev/acpica/rsirq.c index 586195e854c0..ae7af71a2733 100644 --- a/sys/contrib/dev/acpica/rsirq.c +++ b/sys/contrib/dev/acpica/rsirq.c @@ -1,10 +1,7 @@ /******************************************************************************* * - * Module Name: rsirq - AcpiRsIrqResource, - * AcpiRsIrqStream - * AcpiRsExtendedIrqResource - * AcpiRsExtendedIrqStream - * $Revision: 13 $ + * Module Name: rsirq - IRQ resource descriptors + * $Revision: 17 $ * ******************************************************************************/ @@ -122,7 +119,7 @@ #include "acpi.h" #include "acresrc.h" -#define _COMPONENT RESOURCE_MANAGER +#define _COMPONENT ACPI_RESOURCES MODULE_NAME ("rsirq") @@ -131,20 +128,20 @@ * FUNCTION: AcpiRsIrqResource * * 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,24 +153,24 @@ AcpiRsIrqResource ( UINT32 *StructureSize) { UINT8 *Buffer = ByteStreamBuffer; - RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer; + ACPI_RESOURCE *OutputStruct = (ACPI_RESOURCE *) *OutputBuffer; UINT16 Temp16 = 0; UINT8 Temp8 = 0; UINT8 Index; UINT8 i; - UINT32 StructSize = sizeof (IRQ_RESOURCE) + - RESOURCE_LENGTH_NO_DATA; + UINT32 StructSize = SIZEOF_RESOURCE (ACPI_RESOURCE_IRQ); FUNCTION_TRACE ("RsIrqResource"); + /* * The number of bytes consumed are contained in the descriptor * (Bits:0-1) */ Temp8 = *Buffer; *BytesConsumed = (Temp8 & 0x03) + 1; - OutputStruct->Id = Irq; + OutputStruct->Id = ACPI_RSTYPE_IRQ; /* * Point to the 16-bits of Bytes 1 and 2 @@ -229,8 +226,8 @@ AcpiRsIrqResource ( { /* * Only _LL and _HE polarity/trigger interrupts - * are allowed (ACPI spec v1.0b ection 6.4.2.1), - * so an error will occur if we reach this point + * are allowed (ACPI spec v1.0b ection 6.4.2.1), + * so an error will occur if we reach this point */ return_ACPI_STATUS (AE_BAD_DATA); } @@ -246,7 +243,7 @@ AcpiRsIrqResource ( { /* * Assume Edge Sensitive, Active High, Non-Sharable - * per ACPI Specification + * per ACPI Specification */ OutputStruct->Data.Irq.EdgeLevel = EDGE_SENSITIVE; OutputStruct->Data.Irq.ActiveHighLow = ACTIVE_HIGH; @@ -262,7 +259,6 @@ AcpiRsIrqResource ( * Return the final size of the structure */ *StructureSize = StructSize; - return_ACPI_STATUS (AE_OK); } @@ -274,19 +270,19 @@ AcpiRsIrqResource ( * 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 AcpiRsIrqStream ( - RESOURCE *LinkedList, + ACPI_RESOURCE *LinkedList, UINT8 **OutputBuffer, UINT32 *BytesConsumed) { @@ -302,7 +298,7 @@ AcpiRsIrqStream ( /* * The descriptor field is set based upon whether a third byte is - * needed to contain the IRQ Information. + * needed to contain the IRQ Information. */ if (EDGE_SENSITIVE == LinkedList->Data.Irq.EdgeLevel && ACTIVE_HIGH == LinkedList->Data.Irq.ActiveHighLow && @@ -311,6 +307,7 @@ AcpiRsIrqStream ( *Buffer = 0x22; IRQInfoByteNeeded = FALSE; } + else { *Buffer = 0x23; @@ -361,9 +358,7 @@ AcpiRsIrqStream ( /* * Return the number of bytes consumed in this operation */ - *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer - - (NATIVE_UINT) *OutputBuffer); - + *BytesConsumed = POINTER_DIFF (Buffer, *OutputBuffer); return_ACPI_STATUS (AE_OK); } @@ -373,20 +368,20 @@ AcpiRsIrqStream ( * FUNCTION: AcpiRsExtendedIrqResource * * 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. * ******************************************************************************/ @@ -398,16 +393,17 @@ AcpiRsExtendedIrqResource ( UINT32 *StructureSize) { UINT8 *Buffer = ByteStreamBuffer; - RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer; + ACPI_RESOURCE *OutputStruct = (ACPI_RESOURCE *) *OutputBuffer; UINT16 Temp16 = 0; UINT8 Temp8 = 0; + NATIVE_CHAR *TempPtr; UINT8 Index; - UINT32 StructSize = sizeof (EXTENDED_IRQ_RESOURCE) + - RESOURCE_LENGTH_NO_DATA; + UINT32 StructSize = SIZEOF_RESOURCE (ACPI_RESOURCE_EXT_IRQ); FUNCTION_TRACE ("RsExtendedIrqResource"); + /* * Point past the Descriptor to get the number of bytes consumed */ @@ -415,7 +411,7 @@ AcpiRsExtendedIrqResource ( MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); *BytesConsumed = Temp16 + 3; - OutputStruct->Id = ExtendedIrq; + OutputStruct->Id = ACPI_RSTYPE_EXT_IRQ; /* * Point to the Byte3 @@ -446,8 +442,8 @@ AcpiRsExtendedIrqResource ( { /* * Only _LL and _HE polarity/trigger interrupts - * are allowed (ACPI spec v1.0b ection 6.4.2.1), - * so an error will occur if we reach this point + * are allowed (ACPI spec v1.0b ection 6.4.2.1), + * so an error will occur if we reach this point */ return_ACPI_STATUS (AE_BAD_DATA); } @@ -456,8 +452,7 @@ AcpiRsExtendedIrqResource ( /* * Check for sharable */ - OutputStruct->Data.ExtendedIrq.SharedExclusive = - (Temp8 >> 3) & 0x01; + OutputStruct->Data.ExtendedIrq.SharedExclusive = (Temp8 >> 3) & 0x01; /* * Point to Byte4 (IRQ Table length) @@ -469,9 +464,9 @@ AcpiRsExtendedIrqResource ( /* * Add any additional structure size to properly calculate - * the next pointer at the end of this function + * the next pointer at the end of this function */ - StructSize += (Temp8 - 1) * 4; + StructSize += (Temp8 - 1) * 4; /* * Point to Byte5 (First IRQ Number) @@ -493,34 +488,40 @@ AcpiRsExtendedIrqResource ( /* * 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 > - (UINT32)(OutputStruct->Data.ExtendedIrq.NumberOfInterrupts * - 4) + 5) + (UINT32)(OutputStruct->Data.ExtendedIrq.NumberOfInterrupts * 4) + 5) { /* Dereference the Index */ Temp8 = *Buffer; - OutputStruct->Data.ExtendedIrq.ResourceSourceIndex = - (UINT32)Temp8; + OutputStruct->Data.ExtendedIrq.ResourceSource.Index = (UINT32) Temp8; /* Point to the String */ Buffer += 1; + /* + * Point the String pointer to the end of this structure. + */ + OutputStruct->Data.ExtendedIrq.ResourceSource.StringPtr = + (NATIVE_CHAR *)(OutputStruct + StructSize); + + TempPtr = OutputStruct->Data.ExtendedIrq.ResourceSource.StringPtr; + /* Copy the string into the buffer */ Index = 0; while (0x00 != *Buffer) { - OutputStruct->Data.ExtendedIrq.ResourceSource[Index] = - *Buffer; + *TempPtr = *Buffer; + TempPtr += 1; Buffer += 1; Index += 1; } @@ -528,24 +529,23 @@ AcpiRsExtendedIrqResource ( /* * Add the terminating null */ - OutputStruct->Data.ExtendedIrq.ResourceSource[Index] = 0x00; - OutputStruct->Data.ExtendedIrq.ResourceSourceStringLength = - Index + 1; + *TempPtr = 0x00; + OutputStruct->Data.ExtendedIrq.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); - Temp8 = (UINT8) ROUND_UP_TO_32BITS (Temp8); + StructSize += ROUND_UP_TO_32BITS (Temp8); } else { - OutputStruct->Data.ExtendedIrq.ResourceSourceIndex = 0x00; - OutputStruct->Data.ExtendedIrq.ResourceSourceStringLength = 0; - OutputStruct->Data.ExtendedIrq.ResourceSource[0] = 0x00; + OutputStruct->Data.ExtendedIrq.ResourceSource.Index = 0x00; + OutputStruct->Data.ExtendedIrq.ResourceSource.StringLength = 0; + OutputStruct->Data.ExtendedIrq.ResourceSource.StringPtr = NULL; } /* @@ -557,7 +557,6 @@ AcpiRsExtendedIrqResource ( * Return the final size of the structure */ *StructureSize = StructSize; - return_ACPI_STATUS (AE_OK); } @@ -569,10 +568,10 @@ AcpiRsExtendedIrqResource ( * 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 @@ -581,7 +580,7 @@ AcpiRsExtendedIrqResource ( ACPI_STATUS AcpiRsExtendedIrqStream ( - RESOURCE *LinkedList, + ACPI_RESOURCE *LinkedList, UINT8 **OutputBuffer, UINT32 *BytesConsumed) { @@ -604,7 +603,6 @@ AcpiRsExtendedIrqStream ( /* * Set a pointer to the Length field - to be filled in later */ - LengthField = (UINT16 *)Buffer; Buffer += 2; @@ -612,7 +610,6 @@ AcpiRsExtendedIrqStream ( * Set the Interrupt vector flags */ Temp8 = (UINT8)(LinkedList->Data.ExtendedIrq.ProducerConsumer & 0x01); - Temp8 |= ((LinkedList->Data.ExtendedIrq.SharedExclusive & 0x01) << 3); if (LEVEL_SENSITIVE == LinkedList->Data.ExtendedIrq.EdgeLevel && @@ -636,8 +633,7 @@ AcpiRsExtendedIrqStream ( *Buffer = Temp8; Buffer += 1; - for (Index = 0; - Index < LinkedList->Data.ExtendedIrq.NumberOfInterrupts; + for (Index = 0; Index < LinkedList->Data.ExtendedIrq.NumberOfInterrupts; Index++) { MOVE_UNALIGNED32_TO_32 (Buffer, @@ -648,9 +644,9 @@ AcpiRsExtendedIrqStream ( /* * Resource Source Index and Resource Source are optional */ - if (0 != LinkedList->Data.ExtendedIrq.ResourceSourceStringLength) + if (0 != LinkedList->Data.ExtendedIrq.ResourceSource.StringLength) { - *Buffer = (UINT8) LinkedList->Data.ExtendedIrq.ResourceSourceIndex; + *Buffer = (UINT8) LinkedList->Data.ExtendedIrq.ResourceSource.Index; Buffer += 1; TempPointer = (NATIVE_CHAR *) Buffer; @@ -658,27 +654,26 @@ AcpiRsExtendedIrqStream ( /* * Copy the string */ - STRCPY (TempPointer, LinkedList->Data.ExtendedIrq.ResourceSource); + STRCPY (TempPointer, + LinkedList->Data.ExtendedIrq.ResourceSource.StringPtr); /* * Buffer needs to be set to the length of the sting + one for the - * terminating null + * terminating null */ - Buffer += (STRLEN (LinkedList->Data.ExtendedIrq.ResourceSource) + 1); + Buffer += (STRLEN (LinkedList->Data.ExtendedIrq.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) + * minus the header size (3 bytes) */ *LengthField = (UINT16) (*BytesConsumed - 3); - return_ACPI_STATUS (AE_OK); } |