diff options
Diffstat (limited to 'compiler/dtfield.c')
-rw-r--r-- | compiler/dtfield.c | 153 |
1 files changed, 74 insertions, 79 deletions
diff --git a/compiler/dtfield.c b/compiler/dtfield.c index d3f32a4..34696c1 100644 --- a/compiler/dtfield.c +++ b/compiler/dtfield.c @@ -131,15 +131,9 @@ DtCompileString ( UINT32 ByteLength); static char * -DtPciPathToBuffer ( - char *PciPath); - -static void -DtCompilePciPath ( - UINT8 *Buffer, - char *StringValue, - DT_FIELD *Field, - UINT32 ByteLength); +DtNormalizeBuffer ( + char *Buffer, + UINT32 *Count); /****************************************************************************** @@ -180,10 +174,6 @@ DtCompileOneField ( DtCompileBuffer (Buffer, Field->Value, Field, ByteLength); break; - case DT_FIELD_TYPE_PCI_PATH: - DtCompilePciPath (Buffer, Field->Value, Field, ByteLength); - break; - default: DtFatal (ASL_MSG_COMPILER_INTERNAL, Field, "Invalid field type"); break; @@ -225,9 +215,6 @@ DtCompileString ( Length = ByteLength; } - /* If input string is shorter than ByteLength, pad with blanks */ - - ACPI_MEMSET (Buffer, 0x20, ByteLength); ACPI_MEMCPY (Buffer, Field->Value, Length); } @@ -347,33 +334,68 @@ Exit: /****************************************************************************** * - * FUNCTION: DtPciPathToBuffer + * FUNCTION: DtNormalizeBuffer * - * PARAMETERS: PciPath - DMAR "PCI Path" field + * PARAMETERS: Buffer - Input buffer + * Count - Output the count of hex number in + * the Buffer * - * RETURN: Strings of PCI path + * RETURN: The normalized buffer, freed by caller * - * DESCRIPTION: Remove brackets and comma from DMAR "PCI Path" string, for - * example: [1D, 01] ==> 1D 01 + * DESCRIPTION: [1A,2B,3C,4D] or 1A, 2B, 3C, 4D will be normalized + * to 1A 2B 3C 4D * *****************************************************************************/ static char * -DtPciPathToBuffer ( - char *PciPath) +DtNormalizeBuffer ( + char *Buffer, + UINT32 *Count) { - char *Buffer; + char *NewBuffer; + char *TmpBuffer; + UINT32 BufferCount = 0; + BOOLEAN Separator = TRUE; + char c; - Buffer = UtLocalCalloc (6); + NewBuffer = UtLocalCalloc (ACPI_STRLEN (Buffer) + 1); + TmpBuffer = NewBuffer; - Buffer[0] = PciPath[1]; - Buffer[1] = PciPath[2]; - Buffer[2] = ' '; - Buffer[3] = PciPath[5]; - Buffer[4] = PciPath[6]; + while ((c = *Buffer++)) + { + switch (c) + { + /* Valid separators */ + + case '[': + case ']': + case ' ': + case ',': + Separator = TRUE; + break; + + default: + if (Separator) + { + /* Insert blank as the standard separator */ + + if (NewBuffer[0]) + { + *TmpBuffer++ = ' '; + BufferCount++; + } + + Separator = FALSE; + } + + *TmpBuffer++ = c; + break; + } + } - return (Buffer); + *Count = BufferCount + 1; + return (NewBuffer); } @@ -407,13 +429,17 @@ DtCompileBuffer ( UINT32 Count; - Count = ACPI_STRLEN (StringValue) / 3 + 1; + /* Allow several different types of value separators */ + + StringValue = DtNormalizeBuffer (StringValue, &Count); Hex[2] = 0; for (i = 0; i < Count; i++) { - Hex[0] = StringValue[0]; - Hex[1] = StringValue[1]; + /* Each element of StringValue is three chars */ + + Hex[0] = StringValue[(3 * i)]; + Hex[1] = StringValue[(3 * i) + 1]; /* Convert one hex byte */ @@ -426,70 +452,36 @@ DtCompileBuffer ( } Buffer[i] = (UINT8) Value; - StringValue += 3; } + ACPI_FREE (StringValue); return (ByteLength - Count); } /****************************************************************************** * - * FUNCTION: DtCompilePciPath - * - * PARAMETERS: Buffer - Output buffer - * StringValue - DMAR pci path string - * ByteLength - Byte length of DMAR pci path string, 2 - * - * RETURN: None - * - * DESCRIPTION: Compile DMAR PCI path string to binary - * - *****************************************************************************/ - -static void -DtCompilePciPath ( - UINT8 *Buffer, - char *StringValue, - DT_FIELD *Field, - UINT32 ByteLength) -{ - char *PciPathBuffer; - - - /* Parse path to simple hex digits, then convert to binary */ - - PciPathBuffer = DtPciPathToBuffer (StringValue); - - DtCompileBuffer (Buffer, PciPathBuffer, Field, ByteLength); - ACPI_FREE (PciPathBuffer); -} - - -/****************************************************************************** - * * FUNCTION: DtCompileFlag * * PARAMETERS: Buffer - Output buffer * Field - Field to be compiled * Info - Flag info - * BitPosition - Flag bit position * - * RETURN: Next flag bit position + * RETURN: * * DESCRIPTION: Compile a flag * *****************************************************************************/ -UINT32 +void DtCompileFlag ( UINT8 *Buffer, DT_FIELD *Field, - ACPI_DMTABLE_INFO *Info, - UINT32 BitPosition) + ACPI_DMTABLE_INFO *Info) { UINT64 Value = 0; UINT32 BitLength = 1; + UINT8 BitPosition = 0; ACPI_STATUS Status; @@ -510,12 +502,20 @@ DtCompileFlag ( case ACPI_DMT_FLAG6: case ACPI_DMT_FLAG7: + BitPosition = Info->Opcode; BitLength = 1; break; case ACPI_DMT_FLAGS0: + + BitPosition = 0; + BitLength = 2; + break; + + case ACPI_DMT_FLAGS2: + BitPosition = 2; BitLength = 2; break; @@ -534,10 +534,5 @@ DtCompileFlag ( Value = 0; } - /* Insert the flag, return next flag bit position */ - - Buffer += ACPI_DIV_8 (BitPosition); - *Buffer |= (UINT8) (Value << ACPI_MOD_8 (BitPosition)); - - return (BitPosition + BitLength); + *Buffer |= (UINT8) (Value << BitPosition); } |