Beispiel #1
0
/**
  Init the SMBIOS VIEW API's environment.

  @retval EFI_SUCCESS  Successful to init the SMBIOS VIEW Lib.
**/
EFI_STATUS
LibSmbios64BitInit (
  VOID
  )
{
  EFI_STATUS  Status;

  //
  // Init only once
  //
  if (m64Init == 1) {
    return EFI_SUCCESS;
  }
  //
  // Get SMBIOS table from System Configure table
  //
  Status = GetSystemConfigurationTable (&gEfiSmbios3TableGuid, (VOID**)&mSmbios64BitTable);

  if (mSmbios64BitTable == NULL) {
    return EFI_NOT_FOUND;
  }

  if (EFI_ERROR (Status)) {
    ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_LIBSMBIOSVIEW_GET_TABLE_ERROR), gShellDebug1HiiHandle, Status);
    return Status;
  }
  //
  // Init SMBIOS structure table address
  //
  mSmbios64BitStruct->Raw  = (UINT8 *) (UINTN) (mSmbios64BitTable->TableAddress);

  m64Init               = 1;
  return EFI_SUCCESS;
}
Beispiel #2
0
EFI_STATUS
	Main(
	VOID
	)
{
	EFI_ACPI_SUPPORT_PROTOCOL *AcpiSupportProtocol;
	EFI_LEGACY_BIOS_PROTOCOL *LegacyBiosProtocol;
	UINT64 Handel = 0;
	UINTN DataSize = 0;
	EFI_TPL OldTpl;
	EFI_STATUS Status = EFI_UNSUPPORTED;
	Rsdp20Tbl_t *RsdpTable = 0;
	Rsdp20Tbl_t *LegacyRsdpTable = 0;
	RsdtTbl_t *RsdtTable = 0;
	XsdtTbl_t *XsdtTable = 0;
	SlicTbl_t *SlicTable = 0;
	AcpiTbl_t *AcpiTable = 0;
	VOID *LegacyAddress = 0;
	UINT8 SlpString[0x20] = { 0 };
	UINTN i = 0;

	//=========================================================================//
	// code starts                                                             //
	//=========================================================================//

	SlicTable = (SlicTbl_t *)SLIC;

	//=========================================================================//
	// add Marker and Public Key to empty SLIC                                 //
	//=========================================================================//

	DataSize = sizeof(Marker_t);
	if (RS->GetVariable(OaMarkerName, &OaMarkerGuid, 0, &DataSize, &SlicTable->Marker) != EFI_SUCCESS ||
		DataSize != sizeof(Marker_t)) {
			return EFI_NOT_FOUND;
	}
	DataSize = sizeof(PublicKey_t);
	if (RS->GetVariable(OaPublicKeyName, &OaPublicKeyGuid, 0, &DataSize, &SlicTable->PublicKey) != EFI_SUCCESS ||
		DataSize != sizeof(PublicKey_t)) {
			return EFI_NOT_FOUND;
	}

	//=========================================================================//
	// copy OemId, OemTableId from Marker to SLIC ACPI header                  //
	//=========================================================================//

	BS->CopyMem(SlicTable->Header.OemId, SlicTable->Marker.OemId, 6);
	BS->CopyMem(SlicTable->Header.OemTableId, SlicTable->Marker.OemTableId, 8);

	//=========================================================================//
	// add SLIC to ACPI tables                                                 //
	//=========================================================================//

	if(BS->LocateProtocol(&AcpiProtocolGuid, NULL, (VOID **) &AcpiSupportProtocol) == EFI_SUCCESS) {
		Status = AcpiSupportProtocol->SetAcpiTable(AcpiSupportProtocol, (VOID *)SLIC, TRUE,
			EFI_ACPI_TABLE_VERSION_1_0B|EFI_ACPI_TABLE_VERSION_2_0|EFI_ACPI_TABLE_VERSION_3_0, &Handel);
	}

	if (Status != EFI_SUCCESS) {
		return Status;
	}

#if SLP_INJECT == 1

	//=========================================================================//
	// add SLP 1.0 string to legacy region                                     //
	//=========================================================================//

	DataSize = sizeof(SlpString);
	if (RS->GetVariable(OaSlpName, &OaSlpGuid, 0, &DataSize, SlpString) == EFI_SUCCESS) {
		if (BS->LocateProtocol(&LegacyBiosGuid, NULL, (VOID **)&LegacyBiosProtocol) == EFI_SUCCESS) {
			if (LegacyBiosProtocol->GetLegacyRegion(LegacyBiosProtocol, sizeof(SlpString), 1, 2, &LegacyAddress) == EFI_SUCCESS) {
				Status = LegacyBiosProtocol->CopyLegacyRegion(LegacyBiosProtocol, DataSize, LegacyAddress, SlpString);
			}
		}
	}
#endif

	//=========================================================================//
	// find ACPI tables                                                        //
	//=========================================================================//

	OldTpl = BS->RaiseTPL(TPL_HIGH_LEVEL);
	Status = GetSystemConfigurationTable (&EfiAcpi20TableGuid, (VOID **)&RsdpTable);
	if (EFI_ERROR (Status)) {
		Status = GetSystemConfigurationTable (&EfiAcpiTableGuid, (VOID **)&RsdpTable);
	}
	if (Status == EFI_SUCCESS) {
		if (RsdpTable->Revision == 0) {
			RsdtTable = (RsdtTbl_t *) RsdpTable->RSDTAddress;
		}
		else if (RsdpTable->Revision == 2) {
			RsdtTable = (RsdtTbl_t *) RsdpTable->RSDTAddress;
			XsdtTable = (XsdtTbl_t *) RsdpTable->XSDTAddress;
		}
		else {
			return EFI_UNSUPPORTED;
		}
	}
	else {
		return EFI_NOT_FOUND;
	}

	//=========================================================================//
	// copy SLIC OemId, OemTableId to RSDP, RSDT, XSDT                         //
	//=========================================================================//

#if PATCH_TABLES == 1
	DataSize = (RsdtTable->Header.Length - sizeof(AcpiHeader_t)) << 2;
	for(i = 0 ; i < DataSize; i++) {
		AcpiTable = (AcpiTbl_t *) RsdtTable->Entry[i];
		if (AcpiTable != NULL) {
			if (CompareMem(AcpiTable->Header.OemId, RsdtTable->Header.OemId, 6) == 0 &&
				CompareMem(AcpiTable->Header.OemTableId, RsdtTable->Header.OemTableId, 8) == 0) {
					BS->CopyMem(AcpiTable->Header.OemId, SlicTable->Header.OemId, 6);
					BS->CopyMem(AcpiTable->Header.OemTableId, SlicTable->Header.OemTableId, 8);
					AcpiTable->Header.Checksum = 0;
					AcpiTable->Header.Checksum = ComputeChecksum((UINT8 *) AcpiTable, AcpiTable->Header.Length);
			}
		}
	}
#endif

	BS->CopyMem(RsdtTable->Header.OemId, SlicTable->Header.OemId, 6);
	BS->CopyMem(RsdtTable->Header.OemTableId, SlicTable->Header.OemTableId, 8);
	RsdtTable->Header.Checksum = 0;
	RsdtTable->Header.Checksum = ComputeChecksum((UINT8 *) RsdtTable, RsdtTable->Header.Length);
	BS->CopyMem(RsdpTable->OemId, SlicTable->Header.OemId, 6);
	RsdpTable->Checksum = 0;
	RsdpTable->Checksum = ComputeChecksum((UINT8 *) RsdpTable, 0x14);
	if(RsdpTable->Revision == 2) {

#if PATCH_TABLES == 1
		DataSize = (XsdtTable->Header.Length - sizeof(AcpiHeader_t)) << 3;
		for(i = 0 ; i < DataSize; i++) {
			AcpiTable = (AcpiTbl_t *) (XsdtTable->Entry[i] & 0xFFFFFFFF);
			if (AcpiTable != NULL) {
				if (CompareMem(AcpiTable->Header.OemId, XsdtTable->Header.OemId, 6) == 0 &&
					CompareMem(AcpiTable->Header.OemTableId, XsdtTable->Header.OemTableId, 8) == 0) {
						BS->CopyMem(AcpiTable->Header.OemId, SlicTable->Header.OemId, 6);
						BS->CopyMem(AcpiTable->Header.OemTableId, SlicTable->Header.OemTableId, 8);
						AcpiTable->Header.Checksum = 0;
						AcpiTable->Header.Checksum = ComputeChecksum((UINT8 *) AcpiTable, AcpiTable->Header.Length);
				}
			}
		}
#endif

		RsdpTable->ExtendedChecksum = 0;
		RsdpTable->ExtendedChecksum = ComputeChecksum((UINT8 *) RsdpTable, RsdpTable->Length);
		BS->CopyMem(XsdtTable->Header.OemId, SlicTable->Header.OemId, 6);
		BS->CopyMem(XsdtTable->Header.OemTableId, SlicTable->Header.OemTableId, 8);
		XsdtTable->Header.Checksum = 0;
		XsdtTable->Header.Checksum = ComputeChecksum((UINT8 *) XsdtTable, XsdtTable->Header.Length);
	}

	//=========================================================================//
	// copy OemId to RSDP in legacy region                                     //
	//=========================================================================//

	LegacyRsdpTable = (Rsdp20Tbl_t *) FindAcpiRsdPtr();
	if (LegacyRsdpTable != NULL && LegacyUnlock() == EFI_SUCCESS)
	{
		BS->CopyMem(LegacyRsdpTable->OemId, SlicTable->Header.OemId, 6);
		LegacyRsdpTable->RSDTAddress = RsdpTable->RSDTAddress;
		LegacyRsdpTable->Checksum = 0;
		LegacyRsdpTable->Checksum = ComputeChecksum((UINT8 *) LegacyRsdpTable, 0x14);
		if(LegacyRsdpTable->Revision == 2) {
			LegacyRsdpTable->XSDTAddress = RsdpTable->XSDTAddress;
			LegacyRsdpTable->ExtendedChecksum = 0;
			LegacyRsdpTable->ExtendedChecksum = ComputeChecksum((UINT8 *) LegacyRsdpTable, LegacyRsdpTable->Length);
		}
		LegacyLock();
	}
	BS->RestoreTPL(OldTpl);
	return Status;
}