예제 #1
0
/**
  This function validates the System Vector Base in the GICD.

  @param [in] Ptr     Pointer to the start of the field data.
  @param [in] Context Pointer to context specific information e.g. this
                      could be a pointer to the ACPI table header.
**/
STATIC
VOID
EFIAPI
ValidateGICDSystemVectorBase (
  IN UINT8* Ptr,
  IN VOID*  Context
)
{
  if (*(UINT32*)Ptr != 0) {
    IncrementErrorCount ();
    Print (
      L"\nERROR: System Vector Base must be zero."
    );
  }
}
예제 #2
0
파일: Tree.c 프로젝트: MARFMS/chiquitico
void ReportTreeErrorAt(TreeNode Node)
{
   String Location;

   fprintf(stdout, " at node ");
   Write_String(stdout, NodeName(Node));
   fprintf(stdout, "[%1d]", Node);
   Location = SourceLocation(Node);
 
   if(Location != UndefinedString)
   {
      fprintf(stdout, " @ ");
      Write_String(stdout, Location);
   }
  
   fprintf(stdout, " ***\n");
   IncrementErrorCount(1);
	
}
예제 #3
0
파일: SpcrParser.c 프로젝트: b-man/edk2
/**
  This function validates the Irq.

  @param [in] Ptr     Pointer to the start of the field data.
  @param [in] Context Pointer to context specific information e.g. this
                      could be a pointer to the ACPI table header.
**/
STATIC
VOID
EFIAPI
ValidateIrq (
  IN UINT8* Ptr,
  IN VOID*  Context
  )
{
#if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
  UINT8 Irq;

  Irq = *Ptr;

  if (Irq != 0) {
    IncrementErrorCount ();
    Print (
      L"\nERROR: Irq = %d. This must be zero on ARM Platforms\n",
      Irq
      );
  }
#endif
}
예제 #4
0
파일: SpcrParser.c 프로젝트: b-man/edk2
/**
  This function validates the Interrupt Type.

  @param [in] Ptr     Pointer to the start of the field data.
  @param [in] Context Pointer to context specific information e.g. this
                      could be a pointer to the ACPI table header.
**/
STATIC
VOID
EFIAPI
ValidateInterruptType (
  IN UINT8* Ptr,
  IN VOID*  Context
  )
{
#if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
  UINT8 InterruptType;

  InterruptType = *Ptr;

  if (InterruptType !=
        EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_INTERRUPT_TYPE_GIC) {
    IncrementErrorCount ();
    Print (
      L"\nERROR: InterruptType = %d. This must be 8 on ARM Platforms",
      InterruptType
      );
  }
#endif
}
예제 #5
0
파일: XsdtParser.c 프로젝트: b-man/edk2
/**
  This function parses the ACPI XSDT table and optionally traces the ACPI table fields.

  This function also performs validation of the XSDT table.

  @param [in] Trace              If TRUE, trace the ACPI fields.
  @param [in] Ptr                Pointer to the start of the buffer.
  @param [in] AcpiTableLength    Length of the ACPI table.
  @param [in] AcpiTableRevision  Revision of the ACPI table.
**/
VOID
EFIAPI
ParseAcpiXsdt (
  IN BOOLEAN Trace,
  IN UINT8*  Ptr,
  IN UINT32  AcpiTableLength,
  IN UINT8   AcpiTableRevision
  )
{
  UINT32        Offset;
  UINT32        TableOffset;
  UINT64*       TablePointer;
  UINTN         EntryIndex;
  CHAR16        Buffer[32];

  // Parse the ACPI header to get the length
  ParseAcpi (
    FALSE,
    0,
    "XSDT",
    Ptr,
    ACPI_DESCRIPTION_HEADER_LENGTH,
    PARSER_PARAMS (XsdtParser)
    );

  Offset = ParseAcpi (
             Trace,
             0,
             "XSDT",
             Ptr,
             *AcpiHdrInfo.Length,
             PARSER_PARAMS (XsdtParser)
             );

  TableOffset = Offset;

  if (Trace) {
    EntryIndex = 0;
    TablePointer = (UINT64*)(Ptr + TableOffset);
    while (Offset < (*AcpiHdrInfo.Length)) {
      CONST UINT32* Signature;
      CONST UINT32* Length;
      CONST UINT8*  Revision;

      if ((UINT64*)(UINTN)(*TablePointer) != NULL) {
        UINT8*      Ptr;

        ParseAcpiHeader (
          (UINT8*)(UINTN)(*TablePointer),
          &Signature,
          &Length,
          &Revision
          );

        Ptr = (UINT8*)Signature;

        UnicodeSPrint (
          Buffer,
          sizeof (Buffer),
          L"Entry[%d] - %c%c%c%c",
          EntryIndex++,
          Ptr[0],
          Ptr[1],
          Ptr[2],
          Ptr[3]
          );
      } else {
        UnicodeSPrint (
          Buffer,
          sizeof (Buffer),
          L"Entry[%d]",
          EntryIndex++
          );
      }

      PrintFieldName (2, Buffer);
      Print (L"0x%lx\n", *TablePointer);

      // Validate the table pointers are not NULL
      if ((UINT64*)(UINTN)(*TablePointer) == NULL) {
        IncrementErrorCount ();
        Print (
          L"ERROR: Invalid table entry at 0x%lx, table address is 0x%lx\n",
          TablePointer,
          *TablePointer
          );
      }
      Offset += sizeof (UINT64);
      TablePointer++;
    } // while
  }

  // Process the tables
  Offset = TableOffset;
  TablePointer = (UINT64*)(Ptr + TableOffset);
  while (Offset < (*AcpiHdrInfo.Length)) {
    if ((UINT64*)(UINTN)(*TablePointer) != NULL) {
      ProcessAcpiTable ((UINT8*)(UINTN)(*TablePointer));
    }
    Offset += sizeof (UINT64);
    TablePointer++;
  } // while
}
예제 #6
0
파일: SlitParser.c 프로젝트: b-man/edk2
/**
  This function parses the ACPI SLIT table.
  When trace is enabled this function parses the SLIT table and
  traces the ACPI table fields.

  This function also validates System Localities for the following:
    - Diagonal elements have a normalized value of 10
    - Relative distance from System Locality at i*N+j is same as
      j*N+i

  @param [in] Trace              If TRUE, trace the ACPI fields.
  @param [in] Ptr                Pointer to the start of the buffer.
  @param [in] AcpiTableLength    Length of the ACPI table.
  @param [in] AcpiTableRevision  Revision of the ACPI table.
**/
VOID
EFIAPI
ParseAcpiSlit (
  IN BOOLEAN Trace,
  IN UINT8*  Ptr,
  IN UINT32  AcpiTableLength,
  IN UINT8   AcpiTableRevision
  )
{
  UINT32 Offset;
  UINT64 Count;
  UINT64 Index;
  UINT64 LocalityCount;
  UINT8* LocalityPtr;
  CHAR16 Buffer[80];  // Used for AsciiName param of ParseAcpi

  if (!Trace) {
    return;
  }

  Offset = ParseAcpi (
             TRUE,
             0,
             "SLIT",
             Ptr,
             AcpiTableLength,
             PARSER_PARAMS (SlitParser)
             );
  LocalityPtr = Ptr + Offset;

  LocalityCount = *SlitSystemLocalityCount;
  // We only print the Localities if the count is less than 16
  // If the locality count is more than 16 then refer to the
  // raw data dump.
  if (LocalityCount < 16) {
    UnicodeSPrint (
      Buffer,
      sizeof (Buffer),
      L"Entry[0x%lx][0x%lx]",
      LocalityCount,
      LocalityCount
      );
    PrintFieldName (0, Buffer);
    Print (L"\n");
    Print (L"       ");
    for (Index = 0; Index < LocalityCount; Index++) {
      Print (L" (%3d) ", Index);
    }
    Print (L"\n");
    for (Count = 0; Count< LocalityCount; Count++) {
      Print (L" (%3d) ", Count);
      for (Index = 0; Index < LocalityCount; Index++) {
        Print (L"  %3d  ", SLIT_ELEMENT (LocalityPtr, Count, Index));
      }
      Print (L"\n");
    }
  }

  // Validate
  for (Count = 0; Count < LocalityCount; Count++) {
    for (Index = 0; Index < LocalityCount; Index++) {
      // Element[x][x] must be equal to 10
      if ((Count == Index) && (SLIT_ELEMENT (LocalityPtr, Count,Index) != 10)) {
        IncrementErrorCount ();
        Print (
          L"ERROR: Diagonal Element[0x%lx][0x%lx] (%3d)."
            " Normalized Value is not 10\n",
          Count,
          Index,
          SLIT_ELEMENT (LocalityPtr, Count, Index)
          );
      }
      // Element[i][j] must be equal to Element[j][i]
      if (SLIT_ELEMENT (LocalityPtr, Count, Index) !=
          SLIT_ELEMENT (LocalityPtr, Index, Count)) {
        IncrementErrorCount ();
        Print (
          L"ERROR: Relative distances for Element[0x%lx][0x%lx] (%3d) and \n"
           "Element[0x%lx][0x%lx] (%3d) do not match.\n",
          Count,
          Index,
          SLIT_ELEMENT (LocalityPtr, Count, Index),
          Index,
          Count,
          SLIT_ELEMENT (LocalityPtr, Index, Count)
          );
      }
    }
  }
}
예제 #7
0
/**
  This function parses the ACPI MADT table.
  When trace is enabled this function parses the MADT table and
  traces the ACPI table fields.

  This function currently parses the following Interrupt Controller
  Structures:
    - GICC
    - GICD
    - GIC MSI Frame
    - GICR
    - GIC ITS

  This function also performs validation of the ACPI table fields.

  @param [in] Trace              If TRUE, trace the ACPI fields.
  @param [in] Ptr                Pointer to the start of the buffer.
  @param [in] AcpiTableLength    Length of the ACPI table.
  @param [in] AcpiTableRevision  Revision of the ACPI table.
**/
VOID
EFIAPI
ParseAcpiMadt (
  IN BOOLEAN Trace,
  IN UINT8*  Ptr,
  IN UINT32  AcpiTableLength,
  IN UINT8   AcpiTableRevision
  )
{
  UINT32 Offset;
  UINT8* InterruptContollerPtr;
  UINT32 GICDCount;

  GICDCount = 0;

  if (!Trace) {
    return;
  }

  Offset = ParseAcpi (
             TRUE,
             0,
             "MADT",
             Ptr,
             AcpiTableLength,
             PARSER_PARAMS (MadtParser)
             );
  InterruptContollerPtr = Ptr + Offset;

  while (Offset < AcpiTableLength) {
    // Parse Interrupt Controller Structure to obtain Length.
    ParseAcpi (
      FALSE,
      0,
      NULL,
      InterruptContollerPtr,
      2,  //  Length is 1 byte at offset 1
      PARSER_PARAMS (MadtInterruptControllerHeaderParser)
      );

    if (((Offset + (*MadtInterruptControllerLength)) > AcpiTableLength) ||
        (*MadtInterruptControllerLength < 4)) {
      IncrementErrorCount ();
      Print (
         L"ERROR: Invalid Interrupt Controller Length,"
          L" Type = %d, Length = %d\n",
         *MadtInterruptControllerType,
         *MadtInterruptControllerLength
         );
      break;
    }

    switch (*MadtInterruptControllerType) {
      case EFI_ACPI_6_2_GIC: {
        ParseAcpi (
          TRUE,
          2,
          "GICC",
          InterruptContollerPtr,
          *MadtInterruptControllerLength,
          PARSER_PARAMS (GicCParser)
          );
        break;
      }

      case EFI_ACPI_6_2_GICD: {
        if (++GICDCount > 1) {
          IncrementErrorCount ();
          Print (
            L"ERROR: Only one GICD must be present,"
              L" GICDCount = %d\n",
            GICDCount
            );
        }
        ParseAcpi (
          TRUE,
          2,
          "GICD",
          InterruptContollerPtr,
          *MadtInterruptControllerLength,
          PARSER_PARAMS (GicDParser)
          );
        break;
      }

      case EFI_ACPI_6_2_GIC_MSI_FRAME: {
        ParseAcpi (
          TRUE,
          2,
          "GIC MSI Frame",
          InterruptContollerPtr,
          *MadtInterruptControllerLength,
          PARSER_PARAMS (GicMSIFrameParser)
          );
        break;
      }

      case EFI_ACPI_6_2_GICR: {
        ParseAcpi (
          TRUE,
          2,
          "GICR",
          InterruptContollerPtr,
          *MadtInterruptControllerLength,
          PARSER_PARAMS (GicRParser)
          );
        break;
      }

      case EFI_ACPI_6_2_GIC_ITS: {
        ParseAcpi (
          TRUE,
          2,
          "GIC ITS",
          InterruptContollerPtr,
          *MadtInterruptControllerLength,
          PARSER_PARAMS (GicITSParser)
          );
        break;
      }

      default: {
        IncrementErrorCount ();
        Print (
          L"ERROR: Unknown Interrupt Controller Structure,"
            L" Type = %d, Length = %d\n",
          *MadtInterruptControllerType,
          *MadtInterruptControllerLength
          );
      }
    } // switch

    InterruptContollerPtr += *MadtInterruptControllerLength;
    Offset += *MadtInterruptControllerLength;
  } // while
}