mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-28 08:04:07 +02:00
ArmVirtPkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the ArmVirtPkg package Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
This commit is contained in:
parent
40b0b23ed3
commit
2b16a4fb91
@ -26,13 +26,13 @@ FindAcpiTableProtocol (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_ACPI_TABLE_PROTOCOL *AcpiTable;
|
EFI_ACPI_TABLE_PROTOCOL *AcpiTable;
|
||||||
|
|
||||||
Status = gBS->LocateProtocol (
|
Status = gBS->LocateProtocol (
|
||||||
&gEfiAcpiTableProtocolGuid,
|
&gEfiAcpiTableProtocolGuid,
|
||||||
NULL,
|
NULL,
|
||||||
(VOID**)&AcpiTable
|
(VOID **)&AcpiTable
|
||||||
);
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
return AcpiTable;
|
return AcpiTable;
|
||||||
@ -52,32 +52,32 @@ FindAcpiTableProtocol (
|
|||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
InstallCloudHvAcpiTables (
|
InstallCloudHvAcpiTables (
|
||||||
IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol
|
IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINTN InstalledKey;
|
UINTN InstalledKey;
|
||||||
UINTN TableSize;
|
UINTN TableSize;
|
||||||
UINTN AcpiTableLength;
|
UINTN AcpiTableLength;
|
||||||
UINT64 RsdpPtr;
|
UINT64 RsdpPtr;
|
||||||
UINT64 XsdtPtr;
|
UINT64 XsdtPtr;
|
||||||
UINT64 TableOffset;
|
UINT64 TableOffset;
|
||||||
UINT64 AcpiTablePtr;
|
UINT64 AcpiTablePtr;
|
||||||
UINT64 *DsdtPtr;
|
UINT64 *DsdtPtr;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
|
||||||
if (AcpiProtocol == NULL) {
|
if (AcpiProtocol == NULL) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
RsdpPtr = PcdGet64 (PcdCloudHvAcpiRsdpBaseAddress);
|
RsdpPtr = PcdGet64 (PcdCloudHvAcpiRsdpBaseAddress);
|
||||||
XsdtPtr = ((EFI_ACPI_6_3_ROOT_SYSTEM_DESCRIPTION_POINTER *)RsdpPtr)->XsdtAddress;
|
XsdtPtr = ((EFI_ACPI_6_3_ROOT_SYSTEM_DESCRIPTION_POINTER *)RsdpPtr)->XsdtAddress;
|
||||||
AcpiTableLength = ((EFI_ACPI_COMMON_HEADER *)XsdtPtr)->Length;
|
AcpiTableLength = ((EFI_ACPI_COMMON_HEADER *)XsdtPtr)->Length;
|
||||||
TableOffset = sizeof (EFI_ACPI_DESCRIPTION_HEADER);
|
TableOffset = sizeof (EFI_ACPI_DESCRIPTION_HEADER);
|
||||||
DsdtPtr = NULL;
|
DsdtPtr = NULL;
|
||||||
|
|
||||||
while (TableOffset < AcpiTableLength) {
|
while (TableOffset < AcpiTableLength) {
|
||||||
AcpiTablePtr = *(UINT64 *)(XsdtPtr + TableOffset);
|
AcpiTablePtr = *(UINT64 *)(XsdtPtr + TableOffset);
|
||||||
TableSize = ((EFI_ACPI_COMMON_HEADER *)AcpiTablePtr)->Length;
|
TableSize = ((EFI_ACPI_COMMON_HEADER *)AcpiTablePtr)->Length;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Install ACPI tables from XSDT
|
// Install ACPI tables from XSDT
|
||||||
@ -89,7 +89,7 @@ InstallCloudHvAcpiTables (
|
|||||||
&InstalledKey
|
&InstalledKey
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -97,7 +97,8 @@ InstallCloudHvAcpiTables (
|
|||||||
//
|
//
|
||||||
if ((DsdtPtr == NULL) &&
|
if ((DsdtPtr == NULL) &&
|
||||||
(EFI_ACPI_6_3_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE ==
|
(EFI_ACPI_6_3_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE ==
|
||||||
((EFI_ACPI_COMMON_HEADER *)AcpiTablePtr)->Signature)) {
|
((EFI_ACPI_COMMON_HEADER *)AcpiTablePtr)->Signature))
|
||||||
|
{
|
||||||
DsdtPtr = (UINT64 *)((EFI_ACPI_6_3_FIXED_ACPI_DESCRIPTION_TABLE *)AcpiTablePtr)->XDsdt;
|
DsdtPtr = (UINT64 *)((EFI_ACPI_6_3_FIXED_ACPI_DESCRIPTION_TABLE *)AcpiTablePtr)->XDsdt;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,12 +114,12 @@ InstallCloudHvAcpiTables (
|
|||||||
// Install DSDT table
|
// Install DSDT table
|
||||||
//
|
//
|
||||||
TableSize = ((EFI_ACPI_COMMON_HEADER *)DsdtPtr)->Length;
|
TableSize = ((EFI_ACPI_COMMON_HEADER *)DsdtPtr)->Length;
|
||||||
Status = AcpiProtocol->InstallAcpiTable (
|
Status = AcpiProtocol->InstallAcpiTable (
|
||||||
AcpiProtocol,
|
AcpiProtocol,
|
||||||
DsdtPtr,
|
DsdtPtr,
|
||||||
TableSize,
|
TableSize,
|
||||||
&InstalledKey
|
&InstalledKey
|
||||||
);
|
);
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
@ -138,22 +139,22 @@ InstallCloudHvAcpiTables (
|
|||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
CloudHvAcpiPlatformEntryPoint (
|
CloudHvAcpiPlatformEntryPoint (
|
||||||
IN EFI_HANDLE ImageHandle,
|
IN EFI_HANDLE ImageHandle,
|
||||||
IN EFI_SYSTEM_TABLE *SystemTable
|
IN EFI_SYSTEM_TABLE *SystemTable
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
|
||||||
Status = InstallCloudHvAcpiTables (FindAcpiTableProtocol ());
|
Status = InstallCloudHvAcpiTables (FindAcpiTableProtocol ());
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((
|
DEBUG ((
|
||||||
DEBUG_ERROR,
|
DEBUG_ERROR,
|
||||||
"%a: Fail to install Acpi table: %r\n",
|
"%a: Fail to install Acpi table: %r\n",
|
||||||
__FUNCTION__,
|
__FUNCTION__,
|
||||||
Status
|
Status
|
||||||
));
|
));
|
||||||
CpuDeadLoop ();
|
CpuDeadLoop ();
|
||||||
}
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
|
@ -28,19 +28,20 @@
|
|||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PlatformHasAcpiDt (
|
PlatformHasAcpiDt (
|
||||||
IN EFI_HANDLE ImageHandle,
|
IN EFI_HANDLE ImageHandle,
|
||||||
IN EFI_SYSTEM_TABLE *SystemTable
|
IN EFI_SYSTEM_TABLE *SystemTable
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
|
||||||
//
|
//
|
||||||
// If we fail to install any of the necessary protocols below, the OS will be
|
// If we fail to install any of the necessary protocols below, the OS will be
|
||||||
// unbootable anyway (due to lacking hardware description), so tolerate no
|
// unbootable anyway (due to lacking hardware description), so tolerate no
|
||||||
// errors here.
|
// errors here.
|
||||||
//
|
//
|
||||||
if (MAX_UINTN == MAX_UINT64 &&
|
if ((MAX_UINTN == MAX_UINT64) &&
|
||||||
!PcdGetBool (PcdForceNoAcpi)) {
|
!PcdGetBool (PcdForceNoAcpi))
|
||||||
|
{
|
||||||
Status = gBS->InstallProtocolInterface (
|
Status = gBS->InstallProtocolInterface (
|
||||||
&ImageHandle,
|
&ImageHandle,
|
||||||
&gEdkiiPlatformHasAcpiGuid,
|
&gEdkiiPlatformHasAcpiGuid,
|
||||||
|
@ -11,12 +11,12 @@
|
|||||||
#ifndef EARLY_16550_UART_BASE_ADDRESS_H__
|
#ifndef EARLY_16550_UART_BASE_ADDRESS_H__
|
||||||
#define EARLY_16550_UART_BASE_ADDRESS_H__
|
#define EARLY_16550_UART_BASE_ADDRESS_H__
|
||||||
|
|
||||||
#define EARLY_16550_UART_BASE_ADDRESS_GUID { \
|
#define EARLY_16550_UART_BASE_ADDRESS_GUID { \
|
||||||
0xea67ca3e, 0x1f54, 0x436b, { \
|
0xea67ca3e, 0x1f54, 0x436b, { \
|
||||||
0x97, 0x88, 0xd4, 0xeb, 0x29, 0xc3, 0x42, 0x67 \
|
0x97, 0x88, 0xd4, 0xeb, 0x29, 0xc3, 0x42, 0x67 \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
extern EFI_GUID gEarly16550UartBaseAddressGuid;
|
extern EFI_GUID gEarly16550UartBaseAddressGuid;
|
||||||
|
|
||||||
#endif // EARLY_16550_UART_BASE_ADDRESS_H__
|
#endif // EARLY_16550_UART_BASE_ADDRESS_H__
|
||||||
|
@ -11,11 +11,11 @@
|
|||||||
#ifndef __EARLY_PL011_BASE_ADDRESS_H__
|
#ifndef __EARLY_PL011_BASE_ADDRESS_H__
|
||||||
#define __EARLY_PL011_BASE_ADDRESS_H__
|
#define __EARLY_PL011_BASE_ADDRESS_H__
|
||||||
|
|
||||||
#define EARLY_PL011_BASE_ADDRESS_GUID { \
|
#define EARLY_PL011_BASE_ADDRESS_GUID {\
|
||||||
0xB199DEA9, 0xFD5C, 0x4A84, \
|
0xB199DEA9, 0xFD5C, 0x4A84, \
|
||||||
{ 0x80, 0x82, 0x2F, 0x41, 0x70, 0x78, 0x03, 0x05 } \
|
{ 0x80, 0x82, 0x2F, 0x41, 0x70, 0x78, 0x03, 0x05 } \
|
||||||
}
|
}
|
||||||
|
|
||||||
extern EFI_GUID gEarlyPL011BaseAddressGuid;
|
extern EFI_GUID gEarlyPL011BaseAddressGuid;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
ArmVirtGetMemoryMap (
|
ArmVirtGetMemoryMap (
|
||||||
OUT ARM_MEMORY_REGION_DESCRIPTOR **VirtualMemoryMap
|
OUT ARM_MEMORY_REGION_DESCRIPTOR **VirtualMemoryMap
|
||||||
);
|
);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
STATIC
|
STATIC
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
PlatformHasAcpiDt (
|
PlatformHasAcpiDt (
|
||||||
IN EFI_HANDLE ImageHandle
|
IN EFI_HANDLE ImageHandle
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (!PcdGetBool (PcdForceNoAcpi)) {
|
if (!PcdGetBool (PcdForceNoAcpi)) {
|
||||||
@ -69,11 +69,11 @@ PlatformHasAcpiDt (
|
|||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
KvmtoolPlatformDxeEntryPoint (
|
KvmtoolPlatformDxeEntryPoint (
|
||||||
IN EFI_HANDLE ImageHandle,
|
IN EFI_HANDLE ImageHandle,
|
||||||
IN EFI_SYSTEM_TABLE *SystemTable
|
IN EFI_SYSTEM_TABLE *SystemTable
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
|
||||||
Status = PlatformHasAcpiDt (ImageHandle);
|
Status = PlatformHasAcpiDt (ImageHandle);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
@ -43,7 +43,7 @@ HobLibConstructor (
|
|||||||
IN EFI_SYSTEM_TABLE *SystemTable
|
IN EFI_SYSTEM_TABLE *SystemTable
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINTN Index;
|
UINTN Index;
|
||||||
|
|
||||||
for (Index = 0; Index < SystemTable->NumberOfTableEntries; Index++) {
|
for (Index = 0; Index < SystemTable->NumberOfTableEntries; Index++) {
|
||||||
if (CompareGuid (&gEfiHobListGuid, &(SystemTable->ConfigurationTable[Index].VendorGuid))) {
|
if (CompareGuid (&gEfiHobListGuid, &(SystemTable->ConfigurationTable[Index].VendorGuid))) {
|
||||||
@ -101,15 +101,15 @@ GetHobList (
|
|||||||
VOID *
|
VOID *
|
||||||
EFIAPI
|
EFIAPI
|
||||||
GetNextHob (
|
GetNextHob (
|
||||||
IN UINT16 Type,
|
IN UINT16 Type,
|
||||||
IN CONST VOID *HobStart
|
IN CONST VOID *HobStart
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_PEI_HOB_POINTERS Hob;
|
EFI_PEI_HOB_POINTERS Hob;
|
||||||
|
|
||||||
ASSERT (HobStart != NULL);
|
ASSERT (HobStart != NULL);
|
||||||
|
|
||||||
Hob.Raw = (UINT8 *) HobStart;
|
Hob.Raw = (UINT8 *)HobStart;
|
||||||
//
|
//
|
||||||
// Parse the HOB list until end of list or matching type is found.
|
// Parse the HOB list until end of list or matching type is found.
|
||||||
//
|
//
|
||||||
@ -117,8 +117,10 @@ GetNextHob (
|
|||||||
if (Hob.Header->HobType == Type) {
|
if (Hob.Header->HobType == Type) {
|
||||||
return Hob.Raw;
|
return Hob.Raw;
|
||||||
}
|
}
|
||||||
|
|
||||||
Hob.Raw = GET_NEXT_HOB (Hob);
|
Hob.Raw = GET_NEXT_HOB (Hob);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,10 +140,10 @@ GetNextHob (
|
|||||||
VOID *
|
VOID *
|
||||||
EFIAPI
|
EFIAPI
|
||||||
GetFirstHob (
|
GetFirstHob (
|
||||||
IN UINT16 Type
|
IN UINT16 Type
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
VOID *HobList;
|
VOID *HobList;
|
||||||
|
|
||||||
HobList = GetHobList ();
|
HobList = GetHobList ();
|
||||||
return GetNextHob (Type, HobList);
|
return GetNextHob (Type, HobList);
|
||||||
@ -172,19 +174,21 @@ GetFirstHob (
|
|||||||
VOID *
|
VOID *
|
||||||
EFIAPI
|
EFIAPI
|
||||||
GetNextGuidHob (
|
GetNextGuidHob (
|
||||||
IN CONST EFI_GUID *Guid,
|
IN CONST EFI_GUID *Guid,
|
||||||
IN CONST VOID *HobStart
|
IN CONST VOID *HobStart
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_PEI_HOB_POINTERS GuidHob;
|
EFI_PEI_HOB_POINTERS GuidHob;
|
||||||
|
|
||||||
GuidHob.Raw = (UINT8 *) HobStart;
|
GuidHob.Raw = (UINT8 *)HobStart;
|
||||||
while ((GuidHob.Raw = GetNextHob (EFI_HOB_TYPE_GUID_EXTENSION, GuidHob.Raw)) != NULL) {
|
while ((GuidHob.Raw = GetNextHob (EFI_HOB_TYPE_GUID_EXTENSION, GuidHob.Raw)) != NULL) {
|
||||||
if (CompareGuid (Guid, &GuidHob.Guid->Name)) {
|
if (CompareGuid (Guid, &GuidHob.Guid->Name)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
GuidHob.Raw = GET_NEXT_HOB (GuidHob);
|
GuidHob.Raw = GET_NEXT_HOB (GuidHob);
|
||||||
}
|
}
|
||||||
|
|
||||||
return GuidHob.Raw;
|
return GuidHob.Raw;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,10 +213,10 @@ GetNextGuidHob (
|
|||||||
VOID *
|
VOID *
|
||||||
EFIAPI
|
EFIAPI
|
||||||
GetFirstGuidHob (
|
GetFirstGuidHob (
|
||||||
IN CONST EFI_GUID *Guid
|
IN CONST EFI_GUID *Guid
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
VOID *HobList;
|
VOID *HobList;
|
||||||
|
|
||||||
HobList = GetHobList ();
|
HobList = GetHobList ();
|
||||||
return GetNextGuidHob (Guid, HobList);
|
return GetNextGuidHob (Guid, HobList);
|
||||||
@ -237,11 +241,11 @@ GetBootModeHob (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob;
|
EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob;
|
||||||
|
|
||||||
HandOffHob = (EFI_HOB_HANDOFF_INFO_TABLE *) GetHobList ();
|
HandOffHob = (EFI_HOB_HANDOFF_INFO_TABLE *)GetHobList ();
|
||||||
|
|
||||||
return HandOffHob->BootMode;
|
return HandOffHob->BootMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -263,10 +267,10 @@ GetBootModeHob (
|
|||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
BuildModuleHob (
|
BuildModuleHob (
|
||||||
IN CONST EFI_GUID *ModuleName,
|
IN CONST EFI_GUID *ModuleName,
|
||||||
IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule,
|
IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule,
|
||||||
IN UINT64 ModuleLength,
|
IN UINT64 ModuleLength,
|
||||||
IN EFI_PHYSICAL_ADDRESS EntryPoint
|
IN EFI_PHYSICAL_ADDRESS EntryPoint
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@ -330,8 +334,8 @@ BuildResourceDescriptorHob (
|
|||||||
VOID *
|
VOID *
|
||||||
EFIAPI
|
EFIAPI
|
||||||
BuildGuidHob (
|
BuildGuidHob (
|
||||||
IN CONST EFI_GUID *Guid,
|
IN CONST EFI_GUID *Guid,
|
||||||
IN UINTN DataLength
|
IN UINTN DataLength
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@ -369,9 +373,9 @@ BuildGuidHob (
|
|||||||
VOID *
|
VOID *
|
||||||
EFIAPI
|
EFIAPI
|
||||||
BuildGuidDataHob (
|
BuildGuidDataHob (
|
||||||
IN CONST EFI_GUID *Guid,
|
IN CONST EFI_GUID *Guid,
|
||||||
IN VOID *Data,
|
IN VOID *Data,
|
||||||
IN UINTN DataLength
|
IN UINTN DataLength
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@ -398,8 +402,8 @@ BuildGuidDataHob (
|
|||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
BuildFvHob (
|
BuildFvHob (
|
||||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||||
IN UINT64 Length
|
IN UINT64 Length
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@ -427,10 +431,10 @@ BuildFvHob (
|
|||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
BuildFv2Hob (
|
BuildFv2Hob (
|
||||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||||
IN UINT64 Length,
|
IN UINT64 Length,
|
||||||
IN CONST EFI_GUID *FvName,
|
IN CONST EFI_GUID *FvName,
|
||||||
IN CONST EFI_GUID *FileName
|
IN CONST EFI_GUID *FileName
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT (FALSE);
|
ASSERT (FALSE);
|
||||||
@ -460,12 +464,12 @@ BuildFv2Hob (
|
|||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
BuildFv3Hob (
|
BuildFv3Hob (
|
||||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||||
IN UINT64 Length,
|
IN UINT64 Length,
|
||||||
IN UINT32 AuthenticationStatus,
|
IN UINT32 AuthenticationStatus,
|
||||||
IN BOOLEAN ExtractedFv,
|
IN BOOLEAN ExtractedFv,
|
||||||
IN CONST EFI_GUID *FvName OPTIONAL,
|
IN CONST EFI_GUID *FvName OPTIONAL,
|
||||||
IN CONST EFI_GUID *FileName OPTIONAL
|
IN CONST EFI_GUID *FileName OPTIONAL
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT (FALSE);
|
ASSERT (FALSE);
|
||||||
@ -488,8 +492,8 @@ BuildFv3Hob (
|
|||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
BuildCvHob (
|
BuildCvHob (
|
||||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||||
IN UINT64 Length
|
IN UINT64 Length
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@ -514,8 +518,8 @@ BuildCvHob (
|
|||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
BuildCpuHob (
|
BuildCpuHob (
|
||||||
IN UINT8 SizeOfMemorySpace,
|
IN UINT8 SizeOfMemorySpace,
|
||||||
IN UINT8 SizeOfIoSpace
|
IN UINT8 SizeOfIoSpace
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@ -540,8 +544,8 @@ BuildCpuHob (
|
|||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
BuildStackHob (
|
BuildStackHob (
|
||||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||||
IN UINT64 Length
|
IN UINT64 Length
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@ -567,9 +571,9 @@ BuildStackHob (
|
|||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
BuildBspStoreHob (
|
BuildBspStoreHob (
|
||||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||||
IN UINT64 Length,
|
IN UINT64 Length,
|
||||||
IN EFI_MEMORY_TYPE MemoryType
|
IN EFI_MEMORY_TYPE MemoryType
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@ -595,9 +599,9 @@ BuildBspStoreHob (
|
|||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
BuildMemoryAllocationHob (
|
BuildMemoryAllocationHob (
|
||||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||||
IN UINT64 Length,
|
IN UINT64 Length,
|
||||||
IN EFI_MEMORY_TYPE MemoryType
|
IN EFI_MEMORY_TYPE MemoryType
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#include <Protocol/FdtClient.h>
|
#include <Protocol/FdtClient.h>
|
||||||
|
|
||||||
STATIC ARM_GIC_ARCH_REVISION mGicArchRevision;
|
STATIC ARM_GIC_ARCH_REVISION mGicArchRevision;
|
||||||
|
|
||||||
RETURN_STATUS
|
RETURN_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
@ -27,115 +27,133 @@ ArmVirtGicArchLibConstructor (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINT32 IccSre;
|
UINT32 IccSre;
|
||||||
FDT_CLIENT_PROTOCOL *FdtClient;
|
FDT_CLIENT_PROTOCOL *FdtClient;
|
||||||
CONST UINT64 *Reg;
|
CONST UINT64 *Reg;
|
||||||
UINT32 RegSize;
|
UINT32 RegSize;
|
||||||
UINTN AddressCells, SizeCells;
|
UINTN AddressCells, SizeCells;
|
||||||
UINTN GicRevision;
|
UINTN GicRevision;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
UINT64 DistBase, CpuBase, RedistBase;
|
UINT64 DistBase, CpuBase, RedistBase;
|
||||||
RETURN_STATUS PcdStatus;
|
RETURN_STATUS PcdStatus;
|
||||||
|
|
||||||
Status = gBS->LocateProtocol (&gFdtClientProtocolGuid, NULL,
|
Status = gBS->LocateProtocol (
|
||||||
(VOID **)&FdtClient);
|
&gFdtClientProtocolGuid,
|
||||||
|
NULL,
|
||||||
|
(VOID **)&FdtClient
|
||||||
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
GicRevision = 2;
|
GicRevision = 2;
|
||||||
Status = FdtClient->FindCompatibleNodeReg (FdtClient, "arm,cortex-a15-gic",
|
Status = FdtClient->FindCompatibleNodeReg (
|
||||||
(CONST VOID **)&Reg, &AddressCells, &SizeCells,
|
FdtClient,
|
||||||
&RegSize);
|
"arm,cortex-a15-gic",
|
||||||
|
(CONST VOID **)&Reg,
|
||||||
|
&AddressCells,
|
||||||
|
&SizeCells,
|
||||||
|
&RegSize
|
||||||
|
);
|
||||||
if (Status == EFI_NOT_FOUND) {
|
if (Status == EFI_NOT_FOUND) {
|
||||||
GicRevision = 3;
|
GicRevision = 3;
|
||||||
Status = FdtClient->FindCompatibleNodeReg (FdtClient, "arm,gic-v3",
|
Status = FdtClient->FindCompatibleNodeReg (
|
||||||
(CONST VOID **)&Reg, &AddressCells, &SizeCells,
|
FdtClient,
|
||||||
&RegSize);
|
"arm,gic-v3",
|
||||||
|
(CONST VOID **)&Reg,
|
||||||
|
&AddressCells,
|
||||||
|
&SizeCells,
|
||||||
|
&RegSize
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (GicRevision) {
|
switch (GicRevision) {
|
||||||
|
case 3:
|
||||||
|
//
|
||||||
|
// The GIC v3 DT binding describes a series of at least 3 physical (base
|
||||||
|
// addresses, size) pairs: the distributor interface (GICD), at least one
|
||||||
|
// redistributor region (GICR) containing dedicated redistributor
|
||||||
|
// interfaces for all individual CPUs, and the CPU interface (GICC).
|
||||||
|
// Under virtualization, we assume that the first redistributor region
|
||||||
|
// listed covers the boot CPU. Also, our GICv3 driver only supports the
|
||||||
|
// system register CPU interface, so we can safely ignore the MMIO version
|
||||||
|
// which is listed after the sequence of redistributor interfaces.
|
||||||
|
// This means we are only interested in the first two memory regions
|
||||||
|
// supplied, and ignore everything else.
|
||||||
|
//
|
||||||
|
ASSERT (RegSize >= 32);
|
||||||
|
|
||||||
case 3:
|
// RegProp[0..1] == { GICD base, GICD size }
|
||||||
//
|
DistBase = SwapBytes64 (Reg[0]);
|
||||||
// The GIC v3 DT binding describes a series of at least 3 physical (base
|
ASSERT (DistBase < MAX_UINTN);
|
||||||
// addresses, size) pairs: the distributor interface (GICD), at least one
|
|
||||||
// redistributor region (GICR) containing dedicated redistributor
|
|
||||||
// interfaces for all individual CPUs, and the CPU interface (GICC).
|
|
||||||
// Under virtualization, we assume that the first redistributor region
|
|
||||||
// listed covers the boot CPU. Also, our GICv3 driver only supports the
|
|
||||||
// system register CPU interface, so we can safely ignore the MMIO version
|
|
||||||
// which is listed after the sequence of redistributor interfaces.
|
|
||||||
// This means we are only interested in the first two memory regions
|
|
||||||
// supplied, and ignore everything else.
|
|
||||||
//
|
|
||||||
ASSERT (RegSize >= 32);
|
|
||||||
|
|
||||||
// RegProp[0..1] == { GICD base, GICD size }
|
// RegProp[2..3] == { GICR base, GICR size }
|
||||||
DistBase = SwapBytes64 (Reg[0]);
|
RedistBase = SwapBytes64 (Reg[2]);
|
||||||
ASSERT (DistBase < MAX_UINTN);
|
ASSERT (RedistBase < MAX_UINTN);
|
||||||
|
|
||||||
// RegProp[2..3] == { GICR base, GICR size }
|
PcdStatus = PcdSet64S (PcdGicDistributorBase, DistBase);
|
||||||
RedistBase = SwapBytes64 (Reg[2]);
|
ASSERT_RETURN_ERROR (PcdStatus);
|
||||||
ASSERT (RedistBase < MAX_UINTN);
|
PcdStatus = PcdSet64S (PcdGicRedistributorsBase, RedistBase);
|
||||||
|
ASSERT_RETURN_ERROR (PcdStatus);
|
||||||
|
|
||||||
PcdStatus = PcdSet64S (PcdGicDistributorBase, DistBase);
|
DEBUG ((
|
||||||
ASSERT_RETURN_ERROR (PcdStatus);
|
DEBUG_INFO,
|
||||||
PcdStatus = PcdSet64S (PcdGicRedistributorsBase, RedistBase);
|
"Found GIC v3 (re)distributor @ 0x%Lx (0x%Lx)\n",
|
||||||
ASSERT_RETURN_ERROR (PcdStatus);
|
DistBase,
|
||||||
|
RedistBase
|
||||||
|
));
|
||||||
|
|
||||||
DEBUG ((DEBUG_INFO, "Found GIC v3 (re)distributor @ 0x%Lx (0x%Lx)\n",
|
//
|
||||||
DistBase, RedistBase));
|
// The default implementation of ArmGicArchLib is responsible for enabling
|
||||||
|
// the system register interface on the GICv3 if one is found. So let's do
|
||||||
//
|
// the same here.
|
||||||
// The default implementation of ArmGicArchLib is responsible for enabling
|
//
|
||||||
// the system register interface on the GICv3 if one is found. So let's do
|
|
||||||
// the same here.
|
|
||||||
//
|
|
||||||
IccSre = ArmGicV3GetControlSystemRegisterEnable ();
|
|
||||||
if (!(IccSre & ICC_SRE_EL2_SRE)) {
|
|
||||||
ArmGicV3SetControlSystemRegisterEnable (IccSre | ICC_SRE_EL2_SRE);
|
|
||||||
IccSre = ArmGicV3GetControlSystemRegisterEnable ();
|
IccSre = ArmGicV3GetControlSystemRegisterEnable ();
|
||||||
}
|
if (!(IccSre & ICC_SRE_EL2_SRE)) {
|
||||||
|
ArmGicV3SetControlSystemRegisterEnable (IccSre | ICC_SRE_EL2_SRE);
|
||||||
|
IccSre = ArmGicV3GetControlSystemRegisterEnable ();
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Unlike the default implementation, there is no fall through to GICv2
|
// Unlike the default implementation, there is no fall through to GICv2
|
||||||
// mode if this GICv3 cannot be driven in native mode due to the fact
|
// mode if this GICv3 cannot be driven in native mode due to the fact
|
||||||
// that the System Register interface is unavailable.
|
// that the System Register interface is unavailable.
|
||||||
//
|
//
|
||||||
ASSERT (IccSre & ICC_SRE_EL2_SRE);
|
ASSERT (IccSre & ICC_SRE_EL2_SRE);
|
||||||
|
|
||||||
mGicArchRevision = ARM_GIC_ARCH_REVISION_3;
|
mGicArchRevision = ARM_GIC_ARCH_REVISION_3;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
//
|
//
|
||||||
// When the GICv2 is emulated with virtualization=on, it adds a virtual
|
// When the GICv2 is emulated with virtualization=on, it adds a virtual
|
||||||
// set of control registers. This means the register property can be
|
// set of control registers. This means the register property can be
|
||||||
// either 32 or 64 bytes in size.
|
// either 32 or 64 bytes in size.
|
||||||
//
|
//
|
||||||
ASSERT ((RegSize == 32) || (RegSize == 64));
|
ASSERT ((RegSize == 32) || (RegSize == 64));
|
||||||
|
|
||||||
DistBase = SwapBytes64 (Reg[0]);
|
DistBase = SwapBytes64 (Reg[0]);
|
||||||
CpuBase = SwapBytes64 (Reg[2]);
|
CpuBase = SwapBytes64 (Reg[2]);
|
||||||
ASSERT (DistBase < MAX_UINTN);
|
ASSERT (DistBase < MAX_UINTN);
|
||||||
ASSERT (CpuBase < MAX_UINTN);
|
ASSERT (CpuBase < MAX_UINTN);
|
||||||
|
|
||||||
PcdStatus = PcdSet64S (PcdGicDistributorBase, DistBase);
|
PcdStatus = PcdSet64S (PcdGicDistributorBase, DistBase);
|
||||||
ASSERT_RETURN_ERROR (PcdStatus);
|
ASSERT_RETURN_ERROR (PcdStatus);
|
||||||
PcdStatus = PcdSet64S (PcdGicInterruptInterfaceBase, CpuBase);
|
PcdStatus = PcdSet64S (PcdGicInterruptInterfaceBase, CpuBase);
|
||||||
ASSERT_RETURN_ERROR (PcdStatus);
|
ASSERT_RETURN_ERROR (PcdStatus);
|
||||||
|
|
||||||
DEBUG ((DEBUG_INFO, "Found GIC @ 0x%Lx/0x%Lx\n", DistBase, CpuBase));
|
DEBUG ((DEBUG_INFO, "Found GIC @ 0x%Lx/0x%Lx\n", DistBase, CpuBase));
|
||||||
|
|
||||||
mGicArchRevision = ARM_GIC_ARCH_REVISION_2;
|
mGicArchRevision = ARM_GIC_ARCH_REVISION_2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
DEBUG ((DEBUG_ERROR, "%a: No GIC revision specified!\n", __FUNCTION__));
|
DEBUG ((DEBUG_ERROR, "%a: No GIC revision specified!\n", __FUNCTION__));
|
||||||
return RETURN_NOT_FOUND;
|
return RETURN_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
return RETURN_SUCCESS;
|
return RETURN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ InitMmu (
|
|||||||
// Get Virtual Memory Map from the Platform Library
|
// Get Virtual Memory Map from the Platform Library
|
||||||
ArmVirtGetMemoryMap (&MemoryTable);
|
ArmVirtGetMemoryMap (&MemoryTable);
|
||||||
|
|
||||||
//Note: Because we called PeiServicesInstallPeiMemory() before to call InitMmu() the MMU Page Table resides in
|
// Note: Because we called PeiServicesInstallPeiMemory() before to call InitMmu() the MMU Page Table resides in
|
||||||
// DRAM (even at the top of DRAM as it is the first permanent memory allocation)
|
// DRAM (even at the top of DRAM as it is the first permanent memory allocation)
|
||||||
Status = ArmConfigureMmu (MemoryTable, &TranslationTableBase, &TranslationTableSize);
|
Status = ArmConfigureMmu (MemoryTable, &TranslationTableBase, &TranslationTableSize);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
@ -46,12 +46,12 @@ InitMmu (
|
|||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
MemoryPeim (
|
MemoryPeim (
|
||||||
IN EFI_PHYSICAL_ADDRESS UefiMemoryBase,
|
IN EFI_PHYSICAL_ADDRESS UefiMemoryBase,
|
||||||
IN UINT64 UefiMemorySize
|
IN UINT64 UefiMemorySize
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttributes;
|
EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttributes;
|
||||||
UINT64 SystemMemoryTop;
|
UINT64 SystemMemoryTop;
|
||||||
|
|
||||||
// Ensure PcdSystemMemorySize has been set
|
// Ensure PcdSystemMemorySize has been set
|
||||||
ASSERT (PcdGet64 (PcdSystemMemorySize) != 0);
|
ASSERT (PcdGet64 (PcdSystemMemorySize) != 0);
|
||||||
@ -60,35 +60,35 @@ MemoryPeim (
|
|||||||
// Now, the permanent memory has been installed, we can call AllocatePages()
|
// Now, the permanent memory has been installed, we can call AllocatePages()
|
||||||
//
|
//
|
||||||
ResourceAttributes = (
|
ResourceAttributes = (
|
||||||
EFI_RESOURCE_ATTRIBUTE_PRESENT |
|
EFI_RESOURCE_ATTRIBUTE_PRESENT |
|
||||||
EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
|
EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
|
||||||
EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE |
|
EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE |
|
||||||
EFI_RESOURCE_ATTRIBUTE_TESTED
|
EFI_RESOURCE_ATTRIBUTE_TESTED
|
||||||
);
|
);
|
||||||
|
|
||||||
SystemMemoryTop = PcdGet64 (PcdSystemMemoryBase) +
|
SystemMemoryTop = PcdGet64 (PcdSystemMemoryBase) +
|
||||||
PcdGet64 (PcdSystemMemorySize);
|
PcdGet64 (PcdSystemMemorySize);
|
||||||
|
|
||||||
if (SystemMemoryTop - 1 > MAX_ALLOC_ADDRESS) {
|
if (SystemMemoryTop - 1 > MAX_ALLOC_ADDRESS) {
|
||||||
BuildResourceDescriptorHob (
|
BuildResourceDescriptorHob (
|
||||||
EFI_RESOURCE_SYSTEM_MEMORY,
|
EFI_RESOURCE_SYSTEM_MEMORY,
|
||||||
ResourceAttributes,
|
ResourceAttributes,
|
||||||
PcdGet64 (PcdSystemMemoryBase),
|
PcdGet64 (PcdSystemMemoryBase),
|
||||||
(UINT64)MAX_ALLOC_ADDRESS - PcdGet64 (PcdSystemMemoryBase) + 1
|
(UINT64)MAX_ALLOC_ADDRESS - PcdGet64 (PcdSystemMemoryBase) + 1
|
||||||
);
|
);
|
||||||
BuildResourceDescriptorHob (
|
BuildResourceDescriptorHob (
|
||||||
EFI_RESOURCE_SYSTEM_MEMORY,
|
EFI_RESOURCE_SYSTEM_MEMORY,
|
||||||
ResourceAttributes,
|
ResourceAttributes,
|
||||||
(UINT64)MAX_ALLOC_ADDRESS + 1,
|
(UINT64)MAX_ALLOC_ADDRESS + 1,
|
||||||
SystemMemoryTop - MAX_ALLOC_ADDRESS - 1
|
SystemMemoryTop - MAX_ALLOC_ADDRESS - 1
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
BuildResourceDescriptorHob (
|
BuildResourceDescriptorHob (
|
||||||
EFI_RESOURCE_SYSTEM_MEMORY,
|
EFI_RESOURCE_SYSTEM_MEMORY,
|
||||||
ResourceAttributes,
|
ResourceAttributes,
|
||||||
PcdGet64 (PcdSystemMemoryBase),
|
PcdGet64 (PcdSystemMemoryBase),
|
||||||
PcdGet64 (PcdSystemMemorySize)
|
PcdGet64 (PcdSystemMemorySize)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -98,7 +98,7 @@ MemoryPeim (
|
|||||||
// that the contents we put there with the caches and MMU off will still
|
// that the contents we put there with the caches and MMU off will still
|
||||||
// be visible after turning them on.
|
// be visible after turning them on.
|
||||||
//
|
//
|
||||||
InvalidateDataCacheRange ((VOID*)(UINTN)UefiMemoryBase, UefiMemorySize);
|
InvalidateDataCacheRange ((VOID *)(UINTN)UefiMemoryBase, UefiMemorySize);
|
||||||
|
|
||||||
// Build Memory Allocation Hob
|
// Build Memory Allocation Hob
|
||||||
InitMmu ();
|
InitMmu ();
|
||||||
|
@ -22,31 +22,44 @@ ArmVirtPL031FdtClientLibConstructor (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
FDT_CLIENT_PROTOCOL *FdtClient;
|
FDT_CLIENT_PROTOCOL *FdtClient;
|
||||||
INT32 Node;
|
INT32 Node;
|
||||||
CONST UINT64 *Reg;
|
CONST UINT64 *Reg;
|
||||||
UINT32 RegSize;
|
UINT32 RegSize;
|
||||||
UINT64 RegBase;
|
UINT64 RegBase;
|
||||||
RETURN_STATUS PcdStatus;
|
RETURN_STATUS PcdStatus;
|
||||||
|
|
||||||
Status = gBS->LocateProtocol (&gFdtClientProtocolGuid, NULL,
|
Status = gBS->LocateProtocol (
|
||||||
(VOID **)&FdtClient);
|
&gFdtClientProtocolGuid,
|
||||||
|
NULL,
|
||||||
|
(VOID **)&FdtClient
|
||||||
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
Status = FdtClient->FindCompatibleNode (FdtClient, "arm,pl031", &Node);
|
Status = FdtClient->FindCompatibleNode (FdtClient, "arm,pl031", &Node);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_WARN, "%a: No 'arm,pl031' compatible DT node found\n",
|
DEBUG ((
|
||||||
__FUNCTION__));
|
DEBUG_WARN,
|
||||||
|
"%a: No 'arm,pl031' compatible DT node found\n",
|
||||||
|
__FUNCTION__
|
||||||
|
));
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = FdtClient->GetNodeProperty (FdtClient, Node, "reg",
|
Status = FdtClient->GetNodeProperty (
|
||||||
(CONST VOID **)&Reg, &RegSize);
|
FdtClient,
|
||||||
|
Node,
|
||||||
|
"reg",
|
||||||
|
(CONST VOID **)&Reg,
|
||||||
|
&RegSize
|
||||||
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_WARN,
|
DEBUG ((
|
||||||
|
DEBUG_WARN,
|
||||||
"%a: No 'reg' property found in 'arm,pl031' compatible DT node\n",
|
"%a: No 'reg' property found in 'arm,pl031' compatible DT node\n",
|
||||||
__FUNCTION__));
|
__FUNCTION__
|
||||||
|
));
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,10 +79,15 @@ ArmVirtPL031FdtClientLibConstructor (
|
|||||||
// need to disable it in the device tree to prevent the OS from attaching
|
// need to disable it in the device tree to prevent the OS from attaching
|
||||||
// its device driver as well.
|
// its device driver as well.
|
||||||
//
|
//
|
||||||
Status = FdtClient->SetNodeProperty (FdtClient, Node, "status",
|
Status = FdtClient->SetNodeProperty (
|
||||||
"disabled", sizeof ("disabled"));
|
FdtClient,
|
||||||
|
Node,
|
||||||
|
"status",
|
||||||
|
"disabled",
|
||||||
|
sizeof ("disabled")
|
||||||
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_WARN, "Failed to set PL031 status to 'disabled'\n"));
|
DEBUG ((DEBUG_WARN, "Failed to set PL031 status to 'disabled'\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
|
@ -19,30 +19,30 @@
|
|||||||
|
|
||||||
#pragma pack(1)
|
#pragma pack(1)
|
||||||
typedef struct {
|
typedef struct {
|
||||||
ACPI_HID_DEVICE_PATH AcpiDevicePath;
|
ACPI_HID_DEVICE_PATH AcpiDevicePath;
|
||||||
EFI_DEVICE_PATH_PROTOCOL EndDevicePath;
|
EFI_DEVICE_PATH_PROTOCOL EndDevicePath;
|
||||||
} EFI_PCI_ROOT_BRIDGE_DEVICE_PATH;
|
} EFI_PCI_ROOT_BRIDGE_DEVICE_PATH;
|
||||||
#pragma pack ()
|
#pragma pack ()
|
||||||
|
|
||||||
GLOBAL_REMOVE_IF_UNREFERENCED
|
GLOBAL_REMOVE_IF_UNREFERENCED
|
||||||
CHAR16 *mPciHostBridgeAcpiAddressSpaceTypeStr[] = {
|
CHAR16 *mPciHostBridgeAcpiAddressSpaceTypeStr[] = {
|
||||||
L"Mem",
|
L"Mem",
|
||||||
L"I/O",
|
L"I/O",
|
||||||
L"Bus"
|
L"Bus"
|
||||||
};
|
};
|
||||||
|
|
||||||
STATIC CONST EFI_PCI_ROOT_BRIDGE_DEVICE_PATH mEfiPciRootBridgeDevicePath = {
|
STATIC CONST EFI_PCI_ROOT_BRIDGE_DEVICE_PATH mEfiPciRootBridgeDevicePath = {
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
ACPI_DEVICE_PATH,
|
ACPI_DEVICE_PATH,
|
||||||
ACPI_DP,
|
ACPI_DP,
|
||||||
{
|
{
|
||||||
(UINT8) (sizeof (ACPI_HID_DEVICE_PATH)),
|
(UINT8)(sizeof (ACPI_HID_DEVICE_PATH)),
|
||||||
(UINT8) ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8)
|
(UINT8)((sizeof (ACPI_HID_DEVICE_PATH)) >> 8)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
EISA_PNP_ID (0x0A03), // HID
|
EISA_PNP_ID (0x0A03), // HID
|
||||||
0 // UID
|
0 // UID
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -55,13 +55,12 @@ STATIC CONST EFI_PCI_ROOT_BRIDGE_DEVICE_PATH mEfiPciRootBridgeDevicePath = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
GLOBAL_REMOVE_IF_UNREFERENCED
|
GLOBAL_REMOVE_IF_UNREFERENCED
|
||||||
CHAR16 *mPciHostBridgeLibAcpiAddressSpaceTypeStr[] = {
|
CHAR16 *mPciHostBridgeLibAcpiAddressSpaceTypeStr[] = {
|
||||||
L"Mem", L"I/O", L"Bus"
|
L"Mem", L"I/O", L"Bus"
|
||||||
};
|
};
|
||||||
|
|
||||||
STATIC PCI_ROOT_BRIDGE mRootBridge;
|
STATIC PCI_ROOT_BRIDGE mRootBridge;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Utility function to return all the root bridge instances in an array.
|
Utility function to return all the root bridge instances in an array.
|
||||||
@ -84,18 +83,18 @@ STATIC PCI_ROOT_BRIDGE mRootBridge;
|
|||||||
PCI_ROOT_BRIDGE *
|
PCI_ROOT_BRIDGE *
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PciHostBridgeUtilityGetRootBridges (
|
PciHostBridgeUtilityGetRootBridges (
|
||||||
OUT UINTN *Count,
|
OUT UINTN *Count,
|
||||||
IN UINT64 Attributes,
|
IN UINT64 Attributes,
|
||||||
IN UINT64 AllocationAttributes,
|
IN UINT64 AllocationAttributes,
|
||||||
IN BOOLEAN DmaAbove4G,
|
IN BOOLEAN DmaAbove4G,
|
||||||
IN BOOLEAN NoExtendedConfigSpace,
|
IN BOOLEAN NoExtendedConfigSpace,
|
||||||
IN UINTN BusMin,
|
IN UINTN BusMin,
|
||||||
IN UINTN BusMax,
|
IN UINTN BusMax,
|
||||||
IN PCI_ROOT_BRIDGE_APERTURE *Io,
|
IN PCI_ROOT_BRIDGE_APERTURE *Io,
|
||||||
IN PCI_ROOT_BRIDGE_APERTURE *Mem,
|
IN PCI_ROOT_BRIDGE_APERTURE *Mem,
|
||||||
IN PCI_ROOT_BRIDGE_APERTURE *MemAbove4G,
|
IN PCI_ROOT_BRIDGE_APERTURE *MemAbove4G,
|
||||||
IN PCI_ROOT_BRIDGE_APERTURE *PMem,
|
IN PCI_ROOT_BRIDGE_APERTURE *PMem,
|
||||||
IN PCI_ROOT_BRIDGE_APERTURE *PMemAbove4G
|
IN PCI_ROOT_BRIDGE_APERTURE *PMemAbove4G
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if ((Count == NULL) ||
|
if ((Count == NULL) ||
|
||||||
@ -103,38 +102,38 @@ PciHostBridgeUtilityGetRootBridges (
|
|||||||
(Mem == NULL) ||
|
(Mem == NULL) ||
|
||||||
(MemAbove4G == NULL) ||
|
(MemAbove4G == NULL) ||
|
||||||
(PMem == NULL) ||
|
(PMem == NULL) ||
|
||||||
(PMemAbove4G == NULL)) {
|
(PMemAbove4G == NULL))
|
||||||
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
*Count = 1;
|
*Count = 1;
|
||||||
|
|
||||||
mRootBridge.Segment = 0;
|
mRootBridge.Segment = 0;
|
||||||
mRootBridge.Supports = Attributes;
|
mRootBridge.Supports = Attributes;
|
||||||
mRootBridge.Attributes = Attributes;
|
mRootBridge.Attributes = Attributes;
|
||||||
|
|
||||||
mRootBridge.DmaAbove4G = DmaAbove4G;
|
mRootBridge.DmaAbove4G = DmaAbove4G;
|
||||||
mRootBridge.NoExtendedConfigSpace = NoExtendedConfigSpace;
|
mRootBridge.NoExtendedConfigSpace = NoExtendedConfigSpace;
|
||||||
mRootBridge.ResourceAssigned = FALSE;
|
mRootBridge.ResourceAssigned = FALSE;
|
||||||
|
|
||||||
mRootBridge.AllocationAttributes = AllocationAttributes;
|
mRootBridge.AllocationAttributes = AllocationAttributes;
|
||||||
|
|
||||||
mRootBridge.Bus.Base = BusMin;
|
mRootBridge.Bus.Base = BusMin;
|
||||||
mRootBridge.Bus.Limit = BusMax;
|
mRootBridge.Bus.Limit = BusMax;
|
||||||
mRootBridge.Io.Base = Io->Base;
|
mRootBridge.Io.Base = Io->Base;
|
||||||
mRootBridge.Io.Limit = Io->Limit;
|
mRootBridge.Io.Limit = Io->Limit;
|
||||||
mRootBridge.Mem.Base = Mem->Base;
|
mRootBridge.Mem.Base = Mem->Base;
|
||||||
mRootBridge.Mem.Limit = Mem->Limit;
|
mRootBridge.Mem.Limit = Mem->Limit;
|
||||||
mRootBridge.MemAbove4G.Base = MemAbove4G->Base;
|
mRootBridge.MemAbove4G.Base = MemAbove4G->Base;
|
||||||
mRootBridge.MemAbove4G.Limit = MemAbove4G->Limit;
|
mRootBridge.MemAbove4G.Limit = MemAbove4G->Limit;
|
||||||
mRootBridge.PMem.Base = PMem->Base;
|
mRootBridge.PMem.Base = PMem->Base;
|
||||||
mRootBridge.PMem.Limit = PMem->Limit;
|
mRootBridge.PMem.Limit = PMem->Limit;
|
||||||
mRootBridge.PMemAbove4G.Base = PMemAbove4G->Base;
|
mRootBridge.PMemAbove4G.Base = PMemAbove4G->Base;
|
||||||
mRootBridge.PMemAbove4G.Limit = PMemAbove4G->Limit;
|
mRootBridge.PMemAbove4G.Limit = PMemAbove4G->Limit;
|
||||||
|
|
||||||
mRootBridge.DevicePath =
|
mRootBridge.DevicePath =
|
||||||
(EFI_DEVICE_PATH_PROTOCOL*)&mEfiPciRootBridgeDevicePath;
|
(EFI_DEVICE_PATH_PROTOCOL *)&mEfiPciRootBridgeDevicePath;
|
||||||
|
|
||||||
return &mRootBridge;
|
return &mRootBridge;
|
||||||
}
|
}
|
||||||
@ -149,8 +148,8 @@ PciHostBridgeUtilityGetRootBridges (
|
|||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PciHostBridgeUtilityFreeRootBridges (
|
PciHostBridgeUtilityFreeRootBridges (
|
||||||
IN PCI_ROOT_BRIDGE *Bridges,
|
IN PCI_ROOT_BRIDGE *Bridges,
|
||||||
IN UINTN Count
|
IN UINTN Count
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Nothing to do here.
|
// Nothing to do here.
|
||||||
@ -176,18 +175,20 @@ PciHostBridgeUtilityResourceConflict (
|
|||||||
IN VOID *Configuration
|
IN VOID *Configuration
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptor;
|
EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptor;
|
||||||
UINTN RootBridgeIndex;
|
UINTN RootBridgeIndex;
|
||||||
|
|
||||||
DEBUG ((DEBUG_ERROR, "PciHostBridge: Resource conflict happens!\n"));
|
DEBUG ((DEBUG_ERROR, "PciHostBridge: Resource conflict happens!\n"));
|
||||||
|
|
||||||
RootBridgeIndex = 0;
|
RootBridgeIndex = 0;
|
||||||
Descriptor = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR*)Configuration;
|
Descriptor = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)Configuration;
|
||||||
while (Descriptor->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR) {
|
while (Descriptor->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR) {
|
||||||
DEBUG ((DEBUG_ERROR, "RootBridge[%d]:\n", RootBridgeIndex++));
|
DEBUG ((DEBUG_ERROR, "RootBridge[%d]:\n", RootBridgeIndex++));
|
||||||
for (; Descriptor->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR; Descriptor++) {
|
for ( ; Descriptor->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR; Descriptor++) {
|
||||||
ASSERT (Descriptor->ResType <
|
ASSERT (
|
||||||
ARRAY_SIZE (mPciHostBridgeAcpiAddressSpaceTypeStr)
|
Descriptor->ResType <
|
||||||
);
|
ARRAY_SIZE (mPciHostBridgeAcpiAddressSpaceTypeStr)
|
||||||
|
);
|
||||||
DEBUG ((
|
DEBUG ((
|
||||||
DEBUG_ERROR,
|
DEBUG_ERROR,
|
||||||
" %s: Length/Alignment = 0x%lx / 0x%lx\n",
|
" %s: Length/Alignment = 0x%lx / 0x%lx\n",
|
||||||
@ -207,12 +208,13 @@ PciHostBridgeUtilityResourceConflict (
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Skip the END descriptor for root bridge
|
// Skip the END descriptor for root bridge
|
||||||
//
|
//
|
||||||
ASSERT (Descriptor->Desc == ACPI_END_TAG_DESCRIPTOR);
|
ASSERT (Descriptor->Desc == ACPI_END_TAG_DESCRIPTOR);
|
||||||
Descriptor = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR*)(
|
Descriptor = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)(
|
||||||
(EFI_ACPI_END_TAG_DESCRIPTOR*)Descriptor + 1
|
(EFI_ACPI_END_TAG_DESCRIPTOR *)Descriptor + 1
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
#include <Protocol/FdtClient.h>
|
#include <Protocol/FdtClient.h>
|
||||||
|
|
||||||
STATIC UINT32 mArmPsciMethod;
|
STATIC UINT32 mArmPsciMethod;
|
||||||
|
|
||||||
RETURN_STATUS
|
RETURN_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
@ -35,16 +35,24 @@ ArmPsciResetSystemLibConstructor (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
FDT_CLIENT_PROTOCOL *FdtClient;
|
FDT_CLIENT_PROTOCOL *FdtClient;
|
||||||
CONST VOID *Prop;
|
CONST VOID *Prop;
|
||||||
|
|
||||||
Status = gBS->LocateProtocol (&gFdtClientProtocolGuid, NULL,
|
Status = gBS->LocateProtocol (
|
||||||
(VOID **)&FdtClient);
|
&gFdtClientProtocolGuid,
|
||||||
|
NULL,
|
||||||
|
(VOID **)&FdtClient
|
||||||
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
Status = FdtClient->FindCompatibleNodeProperty (FdtClient, "arm,psci-0.2",
|
Status = FdtClient->FindCompatibleNodeProperty (
|
||||||
"method", &Prop, NULL);
|
FdtClient,
|
||||||
|
"arm,psci-0.2",
|
||||||
|
"method",
|
||||||
|
&Prop,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
@ -54,10 +62,15 @@ ArmPsciResetSystemLibConstructor (
|
|||||||
} else if (AsciiStrnCmp (Prop, "smc", 3) == 0) {
|
} else if (AsciiStrnCmp (Prop, "smc", 3) == 0) {
|
||||||
mArmPsciMethod = 2;
|
mArmPsciMethod = 2;
|
||||||
} else {
|
} else {
|
||||||
DEBUG ((DEBUG_ERROR, "%a: Unknown PSCI method \"%a\"\n", __FUNCTION__,
|
DEBUG ((
|
||||||
Prop));
|
DEBUG_ERROR,
|
||||||
|
"%a: Unknown PSCI method \"%a\"\n",
|
||||||
|
__FUNCTION__,
|
||||||
|
Prop
|
||||||
|
));
|
||||||
return EFI_NOT_FOUND;
|
return EFI_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,24 +88,24 @@ ResetCold (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ARM_SMC_ARGS ArmSmcArgs;
|
ARM_SMC_ARGS ArmSmcArgs;
|
||||||
ARM_HVC_ARGS ArmHvcArgs;
|
ARM_HVC_ARGS ArmHvcArgs;
|
||||||
|
|
||||||
// Send a PSCI 0.2 SYSTEM_RESET command
|
// Send a PSCI 0.2 SYSTEM_RESET command
|
||||||
ArmSmcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_RESET;
|
ArmSmcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_RESET;
|
||||||
ArmHvcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_RESET;
|
ArmHvcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_RESET;
|
||||||
|
|
||||||
switch (mArmPsciMethod) {
|
switch (mArmPsciMethod) {
|
||||||
case 1:
|
case 1:
|
||||||
ArmCallHvc (&ArmHvcArgs);
|
ArmCallHvc (&ArmHvcArgs);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
ArmCallSmc (&ArmSmcArgs);
|
ArmCallSmc (&ArmSmcArgs);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
DEBUG ((DEBUG_ERROR, "%a: no PSCI method defined\n", __FUNCTION__));
|
DEBUG ((DEBUG_ERROR, "%a: no PSCI method defined\n", __FUNCTION__));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,24 +137,24 @@ ResetShutdown (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ARM_SMC_ARGS ArmSmcArgs;
|
ARM_SMC_ARGS ArmSmcArgs;
|
||||||
ARM_HVC_ARGS ArmHvcArgs;
|
ARM_HVC_ARGS ArmHvcArgs;
|
||||||
|
|
||||||
// Send a PSCI 0.2 SYSTEM_OFF command
|
// Send a PSCI 0.2 SYSTEM_OFF command
|
||||||
ArmSmcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_OFF;
|
ArmSmcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_OFF;
|
||||||
ArmHvcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_OFF;
|
ArmHvcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_OFF;
|
||||||
|
|
||||||
switch (mArmPsciMethod) {
|
switch (mArmPsciMethod) {
|
||||||
case 1:
|
case 1:
|
||||||
ArmCallHvc (&ArmHvcArgs);
|
ArmCallHvc (&ArmHvcArgs);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
ArmCallSmc (&ArmSmcArgs);
|
ArmCallSmc (&ArmSmcArgs);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
DEBUG ((DEBUG_ERROR, "%a: no PSCI method defined\n", __FUNCTION__));
|
DEBUG ((DEBUG_ERROR, "%a: no PSCI method defined\n", __FUNCTION__));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,8 +172,8 @@ ResetShutdown (
|
|||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
ResetPlatformSpecific (
|
ResetPlatformSpecific (
|
||||||
IN UINTN DataSize,
|
IN UINTN DataSize,
|
||||||
IN VOID *ResetData
|
IN VOID *ResetData
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Map the platform specific reset as reboot
|
// Map the platform specific reset as reboot
|
||||||
@ -182,30 +195,30 @@ ResetPlatformSpecific (
|
|||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
ResetSystem (
|
ResetSystem (
|
||||||
IN EFI_RESET_TYPE ResetType,
|
IN EFI_RESET_TYPE ResetType,
|
||||||
IN EFI_STATUS ResetStatus,
|
IN EFI_STATUS ResetStatus,
|
||||||
IN UINTN DataSize,
|
IN UINTN DataSize,
|
||||||
IN VOID *ResetData OPTIONAL
|
IN VOID *ResetData OPTIONAL
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
switch (ResetType) {
|
switch (ResetType) {
|
||||||
case EfiResetWarm:
|
case EfiResetWarm:
|
||||||
ResetWarm ();
|
ResetWarm ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EfiResetCold:
|
case EfiResetCold:
|
||||||
ResetCold ();
|
ResetCold ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EfiResetShutdown:
|
case EfiResetShutdown:
|
||||||
ResetShutdown ();
|
ResetShutdown ();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case EfiResetPlatformSpecific:
|
case EfiResetPlatformSpecific:
|
||||||
ResetPlatformSpecific (DataSize, ResetData);
|
ResetPlatformSpecific (DataSize, ResetData);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,20 +34,20 @@ DiscoverPsciMethod (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
VOID *DeviceTreeBase;
|
VOID *DeviceTreeBase;
|
||||||
INT32 Node, Prev;
|
INT32 Node, Prev;
|
||||||
INT32 Len;
|
INT32 Len;
|
||||||
CONST CHAR8 *Compatible;
|
CONST CHAR8 *Compatible;
|
||||||
CONST CHAR8 *CompatibleItem;
|
CONST CHAR8 *CompatibleItem;
|
||||||
CONST VOID *Prop;
|
CONST VOID *Prop;
|
||||||
|
|
||||||
DeviceTreeBase = (VOID*)(UINTN)PcdGet64 (PcdDeviceTreeInitialBaseAddress);
|
DeviceTreeBase = (VOID *)(UINTN)PcdGet64 (PcdDeviceTreeInitialBaseAddress);
|
||||||
ASSERT (fdt_check_header (DeviceTreeBase) == 0);
|
ASSERT (fdt_check_header (DeviceTreeBase) == 0);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Enumerate all FDT nodes looking for the PSCI node and capture the method
|
// Enumerate all FDT nodes looking for the PSCI node and capture the method
|
||||||
//
|
//
|
||||||
for (Prev = 0;; Prev = Node) {
|
for (Prev = 0; ; Prev = Node) {
|
||||||
Node = fdt_next_node (DeviceTreeBase, Prev, NULL);
|
Node = fdt_next_node (DeviceTreeBase, Prev, NULL);
|
||||||
if (Node < 0) {
|
if (Node < 0) {
|
||||||
break;
|
break;
|
||||||
@ -62,16 +62,19 @@ DiscoverPsciMethod (
|
|||||||
// Iterate over the NULL-separated items in the compatible string
|
// Iterate over the NULL-separated items in the compatible string
|
||||||
//
|
//
|
||||||
for (CompatibleItem = Compatible; CompatibleItem < Compatible + Len;
|
for (CompatibleItem = Compatible; CompatibleItem < Compatible + Len;
|
||||||
CompatibleItem += 1 + AsciiStrLen (CompatibleItem)) {
|
CompatibleItem += 1 + AsciiStrLen (CompatibleItem))
|
||||||
|
{
|
||||||
if (AsciiStrCmp (CompatibleItem, "arm,psci-0.2") != 0) {
|
if (AsciiStrCmp (CompatibleItem, "arm,psci-0.2") != 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Prop = fdt_getprop (DeviceTreeBase, Node, "method", NULL);
|
Prop = fdt_getprop (DeviceTreeBase, Node, "method", NULL);
|
||||||
if (!Prop) {
|
if (!Prop) {
|
||||||
DEBUG ((DEBUG_ERROR, "%a: Missing PSCI method property\n",
|
DEBUG ((
|
||||||
__FUNCTION__));
|
DEBUG_ERROR,
|
||||||
|
"%a: Missing PSCI method property\n",
|
||||||
|
__FUNCTION__
|
||||||
|
));
|
||||||
return PsciMethodUnknown;
|
return PsciMethodUnknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,39 +83,44 @@ DiscoverPsciMethod (
|
|||||||
} else if (AsciiStrnCmp (Prop, "smc", 3) == 0) {
|
} else if (AsciiStrnCmp (Prop, "smc", 3) == 0) {
|
||||||
return PsciMethodSmc;
|
return PsciMethodSmc;
|
||||||
} else {
|
} else {
|
||||||
DEBUG ((DEBUG_ERROR, "%a: Unknown PSCI method \"%a\"\n", __FUNCTION__,
|
DEBUG ((
|
||||||
Prop));
|
DEBUG_ERROR,
|
||||||
|
"%a: Unknown PSCI method \"%a\"\n",
|
||||||
|
__FUNCTION__,
|
||||||
|
Prop
|
||||||
|
));
|
||||||
return PsciMethodUnknown;
|
return PsciMethodUnknown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return PsciMethodUnknown;
|
return PsciMethodUnknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC
|
STATIC
|
||||||
VOID
|
VOID
|
||||||
PerformPsciAction (
|
PerformPsciAction (
|
||||||
IN UINTN Arg0
|
IN UINTN Arg0
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ARM_SMC_ARGS ArmSmcArgs;
|
ARM_SMC_ARGS ArmSmcArgs;
|
||||||
ARM_HVC_ARGS ArmHvcArgs;
|
ARM_HVC_ARGS ArmHvcArgs;
|
||||||
|
|
||||||
ArmSmcArgs.Arg0 = Arg0;
|
ArmSmcArgs.Arg0 = Arg0;
|
||||||
ArmHvcArgs.Arg0 = Arg0;
|
ArmHvcArgs.Arg0 = Arg0;
|
||||||
|
|
||||||
switch (DiscoverPsciMethod ()) {
|
switch (DiscoverPsciMethod ()) {
|
||||||
case PsciMethodHvc:
|
case PsciMethodHvc:
|
||||||
ArmCallHvc (&ArmHvcArgs);
|
ArmCallHvc (&ArmHvcArgs);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PsciMethodSmc:
|
case PsciMethodSmc:
|
||||||
ArmCallSmc (&ArmSmcArgs);
|
ArmCallSmc (&ArmSmcArgs);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
DEBUG ((DEBUG_ERROR, "%a: no PSCI method defined\n", __FUNCTION__));
|
DEBUG ((DEBUG_ERROR, "%a: no PSCI method defined\n", __FUNCTION__));
|
||||||
ASSERT (FALSE);
|
ASSERT (FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,8 +188,8 @@ ResetShutdown (
|
|||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
ResetPlatformSpecific (
|
ResetPlatformSpecific (
|
||||||
IN UINTN DataSize,
|
IN UINTN DataSize,
|
||||||
IN VOID *ResetData
|
IN VOID *ResetData
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Map the platform specific reset as reboot
|
// Map the platform specific reset as reboot
|
||||||
@ -203,30 +211,30 @@ ResetPlatformSpecific (
|
|||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
ResetSystem (
|
ResetSystem (
|
||||||
IN EFI_RESET_TYPE ResetType,
|
IN EFI_RESET_TYPE ResetType,
|
||||||
IN EFI_STATUS ResetStatus,
|
IN EFI_STATUS ResetStatus,
|
||||||
IN UINTN DataSize,
|
IN UINTN DataSize,
|
||||||
IN VOID *ResetData OPTIONAL
|
IN VOID *ResetData OPTIONAL
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
switch (ResetType) {
|
switch (ResetType) {
|
||||||
case EfiResetWarm:
|
case EfiResetWarm:
|
||||||
ResetWarm ();
|
ResetWarm ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EfiResetCold:
|
case EfiResetCold:
|
||||||
ResetCold ();
|
ResetCold ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EfiResetShutdown:
|
case EfiResetShutdown:
|
||||||
ResetShutdown ();
|
ResetShutdown ();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case EfiResetPlatformSpecific:
|
case EfiResetPlatformSpecific:
|
||||||
ResetPlatformSpecific (DataSize, ResetData);
|
ResetPlatformSpecific (DataSize, ResetData);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,9 +18,9 @@
|
|||||||
|
|
||||||
#pragma pack (1)
|
#pragma pack (1)
|
||||||
typedef struct {
|
typedef struct {
|
||||||
UINT32 Type;
|
UINT32 Type;
|
||||||
UINT32 Number;
|
UINT32 Number;
|
||||||
UINT32 Flags;
|
UINT32 Flags;
|
||||||
} INTERRUPT_PROPERTY;
|
} INTERRUPT_PROPERTY;
|
||||||
#pragma pack ()
|
#pragma pack ()
|
||||||
|
|
||||||
@ -30,25 +30,35 @@ ArmVirtTimerFdtClientLibConstructor (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
FDT_CLIENT_PROTOCOL *FdtClient;
|
FDT_CLIENT_PROTOCOL *FdtClient;
|
||||||
CONST INTERRUPT_PROPERTY *InterruptProp;
|
CONST INTERRUPT_PROPERTY *InterruptProp;
|
||||||
UINT32 PropSize;
|
UINT32 PropSize;
|
||||||
INT32 SecIntrNum, IntrNum, VirtIntrNum, HypIntrNum;
|
INT32 SecIntrNum, IntrNum, VirtIntrNum, HypIntrNum;
|
||||||
RETURN_STATUS PcdStatus;
|
RETURN_STATUS PcdStatus;
|
||||||
|
|
||||||
Status = gBS->LocateProtocol (&gFdtClientProtocolGuid, NULL,
|
Status = gBS->LocateProtocol (
|
||||||
(VOID **)&FdtClient);
|
&gFdtClientProtocolGuid,
|
||||||
|
NULL,
|
||||||
|
(VOID **)&FdtClient
|
||||||
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
Status = FdtClient->FindCompatibleNodeProperty (FdtClient, "arm,armv7-timer",
|
Status = FdtClient->FindCompatibleNodeProperty (
|
||||||
"interrupts", (CONST VOID **)&InterruptProp,
|
FdtClient,
|
||||||
&PropSize);
|
"arm,armv7-timer",
|
||||||
|
"interrupts",
|
||||||
|
(CONST VOID **)&InterruptProp,
|
||||||
|
&PropSize
|
||||||
|
);
|
||||||
if (Status == EFI_NOT_FOUND) {
|
if (Status == EFI_NOT_FOUND) {
|
||||||
Status = FdtClient->FindCompatibleNodeProperty (FdtClient,
|
Status = FdtClient->FindCompatibleNodeProperty (
|
||||||
"arm,armv8-timer", "interrupts",
|
FdtClient,
|
||||||
|
"arm,armv8-timer",
|
||||||
|
"interrupts",
|
||||||
(CONST VOID **)&InterruptProp,
|
(CONST VOID **)&InterruptProp,
|
||||||
&PropSize);
|
&PropSize
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
@ -68,10 +78,16 @@ ArmVirtTimerFdtClientLibConstructor (
|
|||||||
VirtIntrNum = SwapBytes32 (InterruptProp[2].Number)
|
VirtIntrNum = SwapBytes32 (InterruptProp[2].Number)
|
||||||
+ (InterruptProp[2].Type ? 16 : 0);
|
+ (InterruptProp[2].Type ? 16 : 0);
|
||||||
HypIntrNum = PropSize < 48 ? 0 : SwapBytes32 (InterruptProp[3].Number)
|
HypIntrNum = PropSize < 48 ? 0 : SwapBytes32 (InterruptProp[3].Number)
|
||||||
+ (InterruptProp[3].Type ? 16 : 0);
|
+ (InterruptProp[3].Type ? 16 : 0);
|
||||||
|
|
||||||
DEBUG ((DEBUG_INFO, "Found Timer interrupts %d, %d, %d, %d\n",
|
DEBUG ((
|
||||||
SecIntrNum, IntrNum, VirtIntrNum, HypIntrNum));
|
DEBUG_INFO,
|
||||||
|
"Found Timer interrupts %d, %d, %d, %d\n",
|
||||||
|
SecIntrNum,
|
||||||
|
IntrNum,
|
||||||
|
VirtIntrNum,
|
||||||
|
HypIntrNum
|
||||||
|
));
|
||||||
|
|
||||||
PcdStatus = PcdSet32S (PcdArmArchTimerSecIntrNum, SecIntrNum);
|
PcdStatus = PcdSet32S (PcdArmArchTimerSecIntrNum, SecIntrNum);
|
||||||
ASSERT_RETURN_ERROR (PcdStatus);
|
ASSERT_RETURN_ERROR (PcdStatus);
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
|
||||||
#include <Base.h>
|
#include <Base.h>
|
||||||
|
|
||||||
#include <Library/BaseLib.h>
|
#include <Library/BaseLib.h>
|
||||||
@ -19,7 +18,6 @@
|
|||||||
#include <Library/DebugLib.h>
|
#include <Library/DebugLib.h>
|
||||||
#include <Library/PcdLib.h>
|
#include <Library/PcdLib.h>
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Assert the validity of a PCI address. A valid PCI address should contain 1's
|
Assert the validity of a PCI address. A valid PCI address should contain 1's
|
||||||
only in the low 28 bits.
|
only in the low 28 bits.
|
||||||
@ -62,7 +60,7 @@ PciExpressRegisterForRuntimeAccess (
|
|||||||
return RETURN_UNSUPPORTED;
|
return RETURN_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT64 mPciExpressBaseAddress;
|
STATIC UINT64 mPciExpressBaseAddress;
|
||||||
|
|
||||||
RETURN_STATUS
|
RETURN_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
@ -74,19 +72,18 @@ PciExpressLibInitialize (
|
|||||||
return RETURN_SUCCESS;
|
return RETURN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Gets the base address of PCI Express.
|
Gets the base address of PCI Express.
|
||||||
|
|
||||||
@return The base address of PCI Express.
|
@return The base address of PCI Express.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
VOID*
|
VOID *
|
||||||
GetPciExpressBaseAddress (
|
GetPciExpressBaseAddress (
|
||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return (VOID*)(UINTN) mPciExpressBaseAddress;
|
return (VOID *)(UINTN)mPciExpressBaseAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -107,11 +104,11 @@ GetPciExpressBaseAddress (
|
|||||||
UINT8
|
UINT8
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PciExpressRead8 (
|
PciExpressRead8 (
|
||||||
IN UINTN Address
|
IN UINTN Address
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT_INVALID_PCI_ADDRESS (Address);
|
ASSERT_INVALID_PCI_ADDRESS (Address);
|
||||||
return MmioRead8 ((UINTN) GetPciExpressBaseAddress () + Address);
|
return MmioRead8 ((UINTN)GetPciExpressBaseAddress () + Address);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -133,12 +130,12 @@ PciExpressRead8 (
|
|||||||
UINT8
|
UINT8
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PciExpressWrite8 (
|
PciExpressWrite8 (
|
||||||
IN UINTN Address,
|
IN UINTN Address,
|
||||||
IN UINT8 Value
|
IN UINT8 Value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT_INVALID_PCI_ADDRESS (Address);
|
ASSERT_INVALID_PCI_ADDRESS (Address);
|
||||||
return MmioWrite8 ((UINTN) GetPciExpressBaseAddress () + Address, Value);
|
return MmioWrite8 ((UINTN)GetPciExpressBaseAddress () + Address, Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -164,12 +161,12 @@ PciExpressWrite8 (
|
|||||||
UINT8
|
UINT8
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PciExpressOr8 (
|
PciExpressOr8 (
|
||||||
IN UINTN Address,
|
IN UINTN Address,
|
||||||
IN UINT8 OrData
|
IN UINT8 OrData
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT_INVALID_PCI_ADDRESS (Address);
|
ASSERT_INVALID_PCI_ADDRESS (Address);
|
||||||
return MmioOr8 ((UINTN) GetPciExpressBaseAddress () + Address, OrData);
|
return MmioOr8 ((UINTN)GetPciExpressBaseAddress () + Address, OrData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -195,12 +192,12 @@ PciExpressOr8 (
|
|||||||
UINT8
|
UINT8
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PciExpressAnd8 (
|
PciExpressAnd8 (
|
||||||
IN UINTN Address,
|
IN UINTN Address,
|
||||||
IN UINT8 AndData
|
IN UINT8 AndData
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT_INVALID_PCI_ADDRESS (Address);
|
ASSERT_INVALID_PCI_ADDRESS (Address);
|
||||||
return MmioAnd8 ((UINTN) GetPciExpressBaseAddress () + Address, AndData);
|
return MmioAnd8 ((UINTN)GetPciExpressBaseAddress () + Address, AndData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -228,14 +225,14 @@ PciExpressAnd8 (
|
|||||||
UINT8
|
UINT8
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PciExpressAndThenOr8 (
|
PciExpressAndThenOr8 (
|
||||||
IN UINTN Address,
|
IN UINTN Address,
|
||||||
IN UINT8 AndData,
|
IN UINT8 AndData,
|
||||||
IN UINT8 OrData
|
IN UINT8 OrData
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT_INVALID_PCI_ADDRESS (Address);
|
ASSERT_INVALID_PCI_ADDRESS (Address);
|
||||||
return MmioAndThenOr8 (
|
return MmioAndThenOr8 (
|
||||||
(UINTN) GetPciExpressBaseAddress () + Address,
|
(UINTN)GetPciExpressBaseAddress () + Address,
|
||||||
AndData,
|
AndData,
|
||||||
OrData
|
OrData
|
||||||
);
|
);
|
||||||
@ -265,14 +262,14 @@ PciExpressAndThenOr8 (
|
|||||||
UINT8
|
UINT8
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PciExpressBitFieldRead8 (
|
PciExpressBitFieldRead8 (
|
||||||
IN UINTN Address,
|
IN UINTN Address,
|
||||||
IN UINTN StartBit,
|
IN UINTN StartBit,
|
||||||
IN UINTN EndBit
|
IN UINTN EndBit
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT_INVALID_PCI_ADDRESS (Address);
|
ASSERT_INVALID_PCI_ADDRESS (Address);
|
||||||
return MmioBitFieldRead8 (
|
return MmioBitFieldRead8 (
|
||||||
(UINTN) GetPciExpressBaseAddress () + Address,
|
(UINTN)GetPciExpressBaseAddress () + Address,
|
||||||
StartBit,
|
StartBit,
|
||||||
EndBit
|
EndBit
|
||||||
);
|
);
|
||||||
@ -305,15 +302,15 @@ PciExpressBitFieldRead8 (
|
|||||||
UINT8
|
UINT8
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PciExpressBitFieldWrite8 (
|
PciExpressBitFieldWrite8 (
|
||||||
IN UINTN Address,
|
IN UINTN Address,
|
||||||
IN UINTN StartBit,
|
IN UINTN StartBit,
|
||||||
IN UINTN EndBit,
|
IN UINTN EndBit,
|
||||||
IN UINT8 Value
|
IN UINT8 Value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT_INVALID_PCI_ADDRESS (Address);
|
ASSERT_INVALID_PCI_ADDRESS (Address);
|
||||||
return MmioBitFieldWrite8 (
|
return MmioBitFieldWrite8 (
|
||||||
(UINTN) GetPciExpressBaseAddress () + Address,
|
(UINTN)GetPciExpressBaseAddress () + Address,
|
||||||
StartBit,
|
StartBit,
|
||||||
EndBit,
|
EndBit,
|
||||||
Value
|
Value
|
||||||
@ -350,15 +347,15 @@ PciExpressBitFieldWrite8 (
|
|||||||
UINT8
|
UINT8
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PciExpressBitFieldOr8 (
|
PciExpressBitFieldOr8 (
|
||||||
IN UINTN Address,
|
IN UINTN Address,
|
||||||
IN UINTN StartBit,
|
IN UINTN StartBit,
|
||||||
IN UINTN EndBit,
|
IN UINTN EndBit,
|
||||||
IN UINT8 OrData
|
IN UINT8 OrData
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT_INVALID_PCI_ADDRESS (Address);
|
ASSERT_INVALID_PCI_ADDRESS (Address);
|
||||||
return MmioBitFieldOr8 (
|
return MmioBitFieldOr8 (
|
||||||
(UINTN) GetPciExpressBaseAddress () + Address,
|
(UINTN)GetPciExpressBaseAddress () + Address,
|
||||||
StartBit,
|
StartBit,
|
||||||
EndBit,
|
EndBit,
|
||||||
OrData
|
OrData
|
||||||
@ -395,15 +392,15 @@ PciExpressBitFieldOr8 (
|
|||||||
UINT8
|
UINT8
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PciExpressBitFieldAnd8 (
|
PciExpressBitFieldAnd8 (
|
||||||
IN UINTN Address,
|
IN UINTN Address,
|
||||||
IN UINTN StartBit,
|
IN UINTN StartBit,
|
||||||
IN UINTN EndBit,
|
IN UINTN EndBit,
|
||||||
IN UINT8 AndData
|
IN UINT8 AndData
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT_INVALID_PCI_ADDRESS (Address);
|
ASSERT_INVALID_PCI_ADDRESS (Address);
|
||||||
return MmioBitFieldAnd8 (
|
return MmioBitFieldAnd8 (
|
||||||
(UINTN) GetPciExpressBaseAddress () + Address,
|
(UINTN)GetPciExpressBaseAddress () + Address,
|
||||||
StartBit,
|
StartBit,
|
||||||
EndBit,
|
EndBit,
|
||||||
AndData
|
AndData
|
||||||
@ -444,16 +441,16 @@ PciExpressBitFieldAnd8 (
|
|||||||
UINT8
|
UINT8
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PciExpressBitFieldAndThenOr8 (
|
PciExpressBitFieldAndThenOr8 (
|
||||||
IN UINTN Address,
|
IN UINTN Address,
|
||||||
IN UINTN StartBit,
|
IN UINTN StartBit,
|
||||||
IN UINTN EndBit,
|
IN UINTN EndBit,
|
||||||
IN UINT8 AndData,
|
IN UINT8 AndData,
|
||||||
IN UINT8 OrData
|
IN UINT8 OrData
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT_INVALID_PCI_ADDRESS (Address);
|
ASSERT_INVALID_PCI_ADDRESS (Address);
|
||||||
return MmioBitFieldAndThenOr8 (
|
return MmioBitFieldAndThenOr8 (
|
||||||
(UINTN) GetPciExpressBaseAddress () + Address,
|
(UINTN)GetPciExpressBaseAddress () + Address,
|
||||||
StartBit,
|
StartBit,
|
||||||
EndBit,
|
EndBit,
|
||||||
AndData,
|
AndData,
|
||||||
@ -480,11 +477,11 @@ PciExpressBitFieldAndThenOr8 (
|
|||||||
UINT16
|
UINT16
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PciExpressRead16 (
|
PciExpressRead16 (
|
||||||
IN UINTN Address
|
IN UINTN Address
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT_INVALID_PCI_ADDRESS (Address);
|
ASSERT_INVALID_PCI_ADDRESS (Address);
|
||||||
return MmioRead16 ((UINTN) GetPciExpressBaseAddress () + Address);
|
return MmioRead16 ((UINTN)GetPciExpressBaseAddress () + Address);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -507,12 +504,12 @@ PciExpressRead16 (
|
|||||||
UINT16
|
UINT16
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PciExpressWrite16 (
|
PciExpressWrite16 (
|
||||||
IN UINTN Address,
|
IN UINTN Address,
|
||||||
IN UINT16 Value
|
IN UINT16 Value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT_INVALID_PCI_ADDRESS (Address);
|
ASSERT_INVALID_PCI_ADDRESS (Address);
|
||||||
return MmioWrite16 ((UINTN) GetPciExpressBaseAddress () + Address, Value);
|
return MmioWrite16 ((UINTN)GetPciExpressBaseAddress () + Address, Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -539,12 +536,12 @@ PciExpressWrite16 (
|
|||||||
UINT16
|
UINT16
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PciExpressOr16 (
|
PciExpressOr16 (
|
||||||
IN UINTN Address,
|
IN UINTN Address,
|
||||||
IN UINT16 OrData
|
IN UINT16 OrData
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT_INVALID_PCI_ADDRESS (Address);
|
ASSERT_INVALID_PCI_ADDRESS (Address);
|
||||||
return MmioOr16 ((UINTN) GetPciExpressBaseAddress () + Address, OrData);
|
return MmioOr16 ((UINTN)GetPciExpressBaseAddress () + Address, OrData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -571,12 +568,12 @@ PciExpressOr16 (
|
|||||||
UINT16
|
UINT16
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PciExpressAnd16 (
|
PciExpressAnd16 (
|
||||||
IN UINTN Address,
|
IN UINTN Address,
|
||||||
IN UINT16 AndData
|
IN UINT16 AndData
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT_INVALID_PCI_ADDRESS (Address);
|
ASSERT_INVALID_PCI_ADDRESS (Address);
|
||||||
return MmioAnd16 ((UINTN) GetPciExpressBaseAddress () + Address, AndData);
|
return MmioAnd16 ((UINTN)GetPciExpressBaseAddress () + Address, AndData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -605,14 +602,14 @@ PciExpressAnd16 (
|
|||||||
UINT16
|
UINT16
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PciExpressAndThenOr16 (
|
PciExpressAndThenOr16 (
|
||||||
IN UINTN Address,
|
IN UINTN Address,
|
||||||
IN UINT16 AndData,
|
IN UINT16 AndData,
|
||||||
IN UINT16 OrData
|
IN UINT16 OrData
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT_INVALID_PCI_ADDRESS (Address);
|
ASSERT_INVALID_PCI_ADDRESS (Address);
|
||||||
return MmioAndThenOr16 (
|
return MmioAndThenOr16 (
|
||||||
(UINTN) GetPciExpressBaseAddress () + Address,
|
(UINTN)GetPciExpressBaseAddress () + Address,
|
||||||
AndData,
|
AndData,
|
||||||
OrData
|
OrData
|
||||||
);
|
);
|
||||||
@ -643,14 +640,14 @@ PciExpressAndThenOr16 (
|
|||||||
UINT16
|
UINT16
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PciExpressBitFieldRead16 (
|
PciExpressBitFieldRead16 (
|
||||||
IN UINTN Address,
|
IN UINTN Address,
|
||||||
IN UINTN StartBit,
|
IN UINTN StartBit,
|
||||||
IN UINTN EndBit
|
IN UINTN EndBit
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT_INVALID_PCI_ADDRESS (Address);
|
ASSERT_INVALID_PCI_ADDRESS (Address);
|
||||||
return MmioBitFieldRead16 (
|
return MmioBitFieldRead16 (
|
||||||
(UINTN) GetPciExpressBaseAddress () + Address,
|
(UINTN)GetPciExpressBaseAddress () + Address,
|
||||||
StartBit,
|
StartBit,
|
||||||
EndBit
|
EndBit
|
||||||
);
|
);
|
||||||
@ -684,15 +681,15 @@ PciExpressBitFieldRead16 (
|
|||||||
UINT16
|
UINT16
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PciExpressBitFieldWrite16 (
|
PciExpressBitFieldWrite16 (
|
||||||
IN UINTN Address,
|
IN UINTN Address,
|
||||||
IN UINTN StartBit,
|
IN UINTN StartBit,
|
||||||
IN UINTN EndBit,
|
IN UINTN EndBit,
|
||||||
IN UINT16 Value
|
IN UINT16 Value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT_INVALID_PCI_ADDRESS (Address);
|
ASSERT_INVALID_PCI_ADDRESS (Address);
|
||||||
return MmioBitFieldWrite16 (
|
return MmioBitFieldWrite16 (
|
||||||
(UINTN) GetPciExpressBaseAddress () + Address,
|
(UINTN)GetPciExpressBaseAddress () + Address,
|
||||||
StartBit,
|
StartBit,
|
||||||
EndBit,
|
EndBit,
|
||||||
Value
|
Value
|
||||||
@ -730,15 +727,15 @@ PciExpressBitFieldWrite16 (
|
|||||||
UINT16
|
UINT16
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PciExpressBitFieldOr16 (
|
PciExpressBitFieldOr16 (
|
||||||
IN UINTN Address,
|
IN UINTN Address,
|
||||||
IN UINTN StartBit,
|
IN UINTN StartBit,
|
||||||
IN UINTN EndBit,
|
IN UINTN EndBit,
|
||||||
IN UINT16 OrData
|
IN UINT16 OrData
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT_INVALID_PCI_ADDRESS (Address);
|
ASSERT_INVALID_PCI_ADDRESS (Address);
|
||||||
return MmioBitFieldOr16 (
|
return MmioBitFieldOr16 (
|
||||||
(UINTN) GetPciExpressBaseAddress () + Address,
|
(UINTN)GetPciExpressBaseAddress () + Address,
|
||||||
StartBit,
|
StartBit,
|
||||||
EndBit,
|
EndBit,
|
||||||
OrData
|
OrData
|
||||||
@ -776,15 +773,15 @@ PciExpressBitFieldOr16 (
|
|||||||
UINT16
|
UINT16
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PciExpressBitFieldAnd16 (
|
PciExpressBitFieldAnd16 (
|
||||||
IN UINTN Address,
|
IN UINTN Address,
|
||||||
IN UINTN StartBit,
|
IN UINTN StartBit,
|
||||||
IN UINTN EndBit,
|
IN UINTN EndBit,
|
||||||
IN UINT16 AndData
|
IN UINT16 AndData
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT_INVALID_PCI_ADDRESS (Address);
|
ASSERT_INVALID_PCI_ADDRESS (Address);
|
||||||
return MmioBitFieldAnd16 (
|
return MmioBitFieldAnd16 (
|
||||||
(UINTN) GetPciExpressBaseAddress () + Address,
|
(UINTN)GetPciExpressBaseAddress () + Address,
|
||||||
StartBit,
|
StartBit,
|
||||||
EndBit,
|
EndBit,
|
||||||
AndData
|
AndData
|
||||||
@ -826,16 +823,16 @@ PciExpressBitFieldAnd16 (
|
|||||||
UINT16
|
UINT16
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PciExpressBitFieldAndThenOr16 (
|
PciExpressBitFieldAndThenOr16 (
|
||||||
IN UINTN Address,
|
IN UINTN Address,
|
||||||
IN UINTN StartBit,
|
IN UINTN StartBit,
|
||||||
IN UINTN EndBit,
|
IN UINTN EndBit,
|
||||||
IN UINT16 AndData,
|
IN UINT16 AndData,
|
||||||
IN UINT16 OrData
|
IN UINT16 OrData
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT_INVALID_PCI_ADDRESS (Address);
|
ASSERT_INVALID_PCI_ADDRESS (Address);
|
||||||
return MmioBitFieldAndThenOr16 (
|
return MmioBitFieldAndThenOr16 (
|
||||||
(UINTN) GetPciExpressBaseAddress () + Address,
|
(UINTN)GetPciExpressBaseAddress () + Address,
|
||||||
StartBit,
|
StartBit,
|
||||||
EndBit,
|
EndBit,
|
||||||
AndData,
|
AndData,
|
||||||
@ -862,11 +859,11 @@ PciExpressBitFieldAndThenOr16 (
|
|||||||
UINT32
|
UINT32
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PciExpressRead32 (
|
PciExpressRead32 (
|
||||||
IN UINTN Address
|
IN UINTN Address
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT_INVALID_PCI_ADDRESS (Address);
|
ASSERT_INVALID_PCI_ADDRESS (Address);
|
||||||
return MmioRead32 ((UINTN) GetPciExpressBaseAddress () + Address);
|
return MmioRead32 ((UINTN)GetPciExpressBaseAddress () + Address);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -889,12 +886,12 @@ PciExpressRead32 (
|
|||||||
UINT32
|
UINT32
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PciExpressWrite32 (
|
PciExpressWrite32 (
|
||||||
IN UINTN Address,
|
IN UINTN Address,
|
||||||
IN UINT32 Value
|
IN UINT32 Value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT_INVALID_PCI_ADDRESS (Address);
|
ASSERT_INVALID_PCI_ADDRESS (Address);
|
||||||
return MmioWrite32 ((UINTN) GetPciExpressBaseAddress () + Address, Value);
|
return MmioWrite32 ((UINTN)GetPciExpressBaseAddress () + Address, Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -921,12 +918,12 @@ PciExpressWrite32 (
|
|||||||
UINT32
|
UINT32
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PciExpressOr32 (
|
PciExpressOr32 (
|
||||||
IN UINTN Address,
|
IN UINTN Address,
|
||||||
IN UINT32 OrData
|
IN UINT32 OrData
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT_INVALID_PCI_ADDRESS (Address);
|
ASSERT_INVALID_PCI_ADDRESS (Address);
|
||||||
return MmioOr32 ((UINTN) GetPciExpressBaseAddress () + Address, OrData);
|
return MmioOr32 ((UINTN)GetPciExpressBaseAddress () + Address, OrData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -953,12 +950,12 @@ PciExpressOr32 (
|
|||||||
UINT32
|
UINT32
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PciExpressAnd32 (
|
PciExpressAnd32 (
|
||||||
IN UINTN Address,
|
IN UINTN Address,
|
||||||
IN UINT32 AndData
|
IN UINT32 AndData
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT_INVALID_PCI_ADDRESS (Address);
|
ASSERT_INVALID_PCI_ADDRESS (Address);
|
||||||
return MmioAnd32 ((UINTN) GetPciExpressBaseAddress () + Address, AndData);
|
return MmioAnd32 ((UINTN)GetPciExpressBaseAddress () + Address, AndData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -987,14 +984,14 @@ PciExpressAnd32 (
|
|||||||
UINT32
|
UINT32
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PciExpressAndThenOr32 (
|
PciExpressAndThenOr32 (
|
||||||
IN UINTN Address,
|
IN UINTN Address,
|
||||||
IN UINT32 AndData,
|
IN UINT32 AndData,
|
||||||
IN UINT32 OrData
|
IN UINT32 OrData
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT_INVALID_PCI_ADDRESS (Address);
|
ASSERT_INVALID_PCI_ADDRESS (Address);
|
||||||
return MmioAndThenOr32 (
|
return MmioAndThenOr32 (
|
||||||
(UINTN) GetPciExpressBaseAddress () + Address,
|
(UINTN)GetPciExpressBaseAddress () + Address,
|
||||||
AndData,
|
AndData,
|
||||||
OrData
|
OrData
|
||||||
);
|
);
|
||||||
@ -1025,14 +1022,14 @@ PciExpressAndThenOr32 (
|
|||||||
UINT32
|
UINT32
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PciExpressBitFieldRead32 (
|
PciExpressBitFieldRead32 (
|
||||||
IN UINTN Address,
|
IN UINTN Address,
|
||||||
IN UINTN StartBit,
|
IN UINTN StartBit,
|
||||||
IN UINTN EndBit
|
IN UINTN EndBit
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT_INVALID_PCI_ADDRESS (Address);
|
ASSERT_INVALID_PCI_ADDRESS (Address);
|
||||||
return MmioBitFieldRead32 (
|
return MmioBitFieldRead32 (
|
||||||
(UINTN) GetPciExpressBaseAddress () + Address,
|
(UINTN)GetPciExpressBaseAddress () + Address,
|
||||||
StartBit,
|
StartBit,
|
||||||
EndBit
|
EndBit
|
||||||
);
|
);
|
||||||
@ -1066,15 +1063,15 @@ PciExpressBitFieldRead32 (
|
|||||||
UINT32
|
UINT32
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PciExpressBitFieldWrite32 (
|
PciExpressBitFieldWrite32 (
|
||||||
IN UINTN Address,
|
IN UINTN Address,
|
||||||
IN UINTN StartBit,
|
IN UINTN StartBit,
|
||||||
IN UINTN EndBit,
|
IN UINTN EndBit,
|
||||||
IN UINT32 Value
|
IN UINT32 Value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT_INVALID_PCI_ADDRESS (Address);
|
ASSERT_INVALID_PCI_ADDRESS (Address);
|
||||||
return MmioBitFieldWrite32 (
|
return MmioBitFieldWrite32 (
|
||||||
(UINTN) GetPciExpressBaseAddress () + Address,
|
(UINTN)GetPciExpressBaseAddress () + Address,
|
||||||
StartBit,
|
StartBit,
|
||||||
EndBit,
|
EndBit,
|
||||||
Value
|
Value
|
||||||
@ -1112,15 +1109,15 @@ PciExpressBitFieldWrite32 (
|
|||||||
UINT32
|
UINT32
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PciExpressBitFieldOr32 (
|
PciExpressBitFieldOr32 (
|
||||||
IN UINTN Address,
|
IN UINTN Address,
|
||||||
IN UINTN StartBit,
|
IN UINTN StartBit,
|
||||||
IN UINTN EndBit,
|
IN UINTN EndBit,
|
||||||
IN UINT32 OrData
|
IN UINT32 OrData
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT_INVALID_PCI_ADDRESS (Address);
|
ASSERT_INVALID_PCI_ADDRESS (Address);
|
||||||
return MmioBitFieldOr32 (
|
return MmioBitFieldOr32 (
|
||||||
(UINTN) GetPciExpressBaseAddress () + Address,
|
(UINTN)GetPciExpressBaseAddress () + Address,
|
||||||
StartBit,
|
StartBit,
|
||||||
EndBit,
|
EndBit,
|
||||||
OrData
|
OrData
|
||||||
@ -1158,15 +1155,15 @@ PciExpressBitFieldOr32 (
|
|||||||
UINT32
|
UINT32
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PciExpressBitFieldAnd32 (
|
PciExpressBitFieldAnd32 (
|
||||||
IN UINTN Address,
|
IN UINTN Address,
|
||||||
IN UINTN StartBit,
|
IN UINTN StartBit,
|
||||||
IN UINTN EndBit,
|
IN UINTN EndBit,
|
||||||
IN UINT32 AndData
|
IN UINT32 AndData
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT_INVALID_PCI_ADDRESS (Address);
|
ASSERT_INVALID_PCI_ADDRESS (Address);
|
||||||
return MmioBitFieldAnd32 (
|
return MmioBitFieldAnd32 (
|
||||||
(UINTN) GetPciExpressBaseAddress () + Address,
|
(UINTN)GetPciExpressBaseAddress () + Address,
|
||||||
StartBit,
|
StartBit,
|
||||||
EndBit,
|
EndBit,
|
||||||
AndData
|
AndData
|
||||||
@ -1208,16 +1205,16 @@ PciExpressBitFieldAnd32 (
|
|||||||
UINT32
|
UINT32
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PciExpressBitFieldAndThenOr32 (
|
PciExpressBitFieldAndThenOr32 (
|
||||||
IN UINTN Address,
|
IN UINTN Address,
|
||||||
IN UINTN StartBit,
|
IN UINTN StartBit,
|
||||||
IN UINTN EndBit,
|
IN UINTN EndBit,
|
||||||
IN UINT32 AndData,
|
IN UINT32 AndData,
|
||||||
IN UINT32 OrData
|
IN UINT32 OrData
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT_INVALID_PCI_ADDRESS (Address);
|
ASSERT_INVALID_PCI_ADDRESS (Address);
|
||||||
return MmioBitFieldAndThenOr32 (
|
return MmioBitFieldAndThenOr32 (
|
||||||
(UINTN) GetPciExpressBaseAddress () + Address,
|
(UINTN)GetPciExpressBaseAddress () + Address,
|
||||||
StartBit,
|
StartBit,
|
||||||
EndBit,
|
EndBit,
|
||||||
AndData,
|
AndData,
|
||||||
@ -1251,12 +1248,12 @@ PciExpressBitFieldAndThenOr32 (
|
|||||||
UINTN
|
UINTN
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PciExpressReadBuffer (
|
PciExpressReadBuffer (
|
||||||
IN UINTN StartAddress,
|
IN UINTN StartAddress,
|
||||||
IN UINTN Size,
|
IN UINTN Size,
|
||||||
OUT VOID *Buffer
|
OUT VOID *Buffer
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINTN ReturnValue;
|
UINTN ReturnValue;
|
||||||
|
|
||||||
ASSERT_INVALID_PCI_ADDRESS (StartAddress);
|
ASSERT_INVALID_PCI_ADDRESS (StartAddress);
|
||||||
ASSERT (((StartAddress & 0xFFF) + Size) <= 0x1000);
|
ASSERT (((StartAddress & 0xFFF) + Size) <= 0x1000);
|
||||||
@ -1277,41 +1274,41 @@ PciExpressReadBuffer (
|
|||||||
// Read a byte if StartAddress is byte aligned
|
// Read a byte if StartAddress is byte aligned
|
||||||
//
|
//
|
||||||
*(volatile UINT8 *)Buffer = PciExpressRead8 (StartAddress);
|
*(volatile UINT8 *)Buffer = PciExpressRead8 (StartAddress);
|
||||||
StartAddress += sizeof (UINT8);
|
StartAddress += sizeof (UINT8);
|
||||||
Size -= sizeof (UINT8);
|
Size -= sizeof (UINT8);
|
||||||
Buffer = (UINT8*)Buffer + 1;
|
Buffer = (UINT8 *)Buffer + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Size >= sizeof (UINT16) && (StartAddress & 2) != 0) {
|
if ((Size >= sizeof (UINT16)) && ((StartAddress & 2) != 0)) {
|
||||||
//
|
//
|
||||||
// Read a word if StartAddress is word aligned
|
// Read a word if StartAddress is word aligned
|
||||||
//
|
//
|
||||||
WriteUnaligned16 ((UINT16 *) Buffer, (UINT16) PciExpressRead16 (StartAddress));
|
WriteUnaligned16 ((UINT16 *)Buffer, (UINT16)PciExpressRead16 (StartAddress));
|
||||||
|
|
||||||
StartAddress += sizeof (UINT16);
|
StartAddress += sizeof (UINT16);
|
||||||
Size -= sizeof (UINT16);
|
Size -= sizeof (UINT16);
|
||||||
Buffer = (UINT16*)Buffer + 1;
|
Buffer = (UINT16 *)Buffer + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (Size >= sizeof (UINT32)) {
|
while (Size >= sizeof (UINT32)) {
|
||||||
//
|
//
|
||||||
// Read as many double words as possible
|
// Read as many double words as possible
|
||||||
//
|
//
|
||||||
WriteUnaligned32 ((UINT32 *) Buffer, (UINT32) PciExpressRead32 (StartAddress));
|
WriteUnaligned32 ((UINT32 *)Buffer, (UINT32)PciExpressRead32 (StartAddress));
|
||||||
|
|
||||||
StartAddress += sizeof (UINT32);
|
StartAddress += sizeof (UINT32);
|
||||||
Size -= sizeof (UINT32);
|
Size -= sizeof (UINT32);
|
||||||
Buffer = (UINT32*)Buffer + 1;
|
Buffer = (UINT32 *)Buffer + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Size >= sizeof (UINT16)) {
|
if (Size >= sizeof (UINT16)) {
|
||||||
//
|
//
|
||||||
// Read the last remaining word if exist
|
// Read the last remaining word if exist
|
||||||
//
|
//
|
||||||
WriteUnaligned16 ((UINT16 *) Buffer, (UINT16) PciExpressRead16 (StartAddress));
|
WriteUnaligned16 ((UINT16 *)Buffer, (UINT16)PciExpressRead16 (StartAddress));
|
||||||
StartAddress += sizeof (UINT16);
|
StartAddress += sizeof (UINT16);
|
||||||
Size -= sizeof (UINT16);
|
Size -= sizeof (UINT16);
|
||||||
Buffer = (UINT16*)Buffer + 1;
|
Buffer = (UINT16 *)Buffer + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Size >= sizeof (UINT8)) {
|
if (Size >= sizeof (UINT8)) {
|
||||||
@ -1351,12 +1348,12 @@ PciExpressReadBuffer (
|
|||||||
UINTN
|
UINTN
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PciExpressWriteBuffer (
|
PciExpressWriteBuffer (
|
||||||
IN UINTN StartAddress,
|
IN UINTN StartAddress,
|
||||||
IN UINTN Size,
|
IN UINTN Size,
|
||||||
IN VOID *Buffer
|
IN VOID *Buffer
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINTN ReturnValue;
|
UINTN ReturnValue;
|
||||||
|
|
||||||
ASSERT_INVALID_PCI_ADDRESS (StartAddress);
|
ASSERT_INVALID_PCI_ADDRESS (StartAddress);
|
||||||
ASSERT (((StartAddress & 0xFFF) + Size) <= 0x1000);
|
ASSERT (((StartAddress & 0xFFF) + Size) <= 0x1000);
|
||||||
@ -1376,47 +1373,47 @@ PciExpressWriteBuffer (
|
|||||||
//
|
//
|
||||||
// Write a byte if StartAddress is byte aligned
|
// Write a byte if StartAddress is byte aligned
|
||||||
//
|
//
|
||||||
PciExpressWrite8 (StartAddress, *(UINT8*)Buffer);
|
PciExpressWrite8 (StartAddress, *(UINT8 *)Buffer);
|
||||||
StartAddress += sizeof (UINT8);
|
StartAddress += sizeof (UINT8);
|
||||||
Size -= sizeof (UINT8);
|
Size -= sizeof (UINT8);
|
||||||
Buffer = (UINT8*)Buffer + 1;
|
Buffer = (UINT8 *)Buffer + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Size >= sizeof (UINT16) && (StartAddress & 2) != 0) {
|
if ((Size >= sizeof (UINT16)) && ((StartAddress & 2) != 0)) {
|
||||||
//
|
//
|
||||||
// Write a word if StartAddress is word aligned
|
// Write a word if StartAddress is word aligned
|
||||||
//
|
//
|
||||||
PciExpressWrite16 (StartAddress, ReadUnaligned16 ((UINT16*)Buffer));
|
PciExpressWrite16 (StartAddress, ReadUnaligned16 ((UINT16 *)Buffer));
|
||||||
StartAddress += sizeof (UINT16);
|
StartAddress += sizeof (UINT16);
|
||||||
Size -= sizeof (UINT16);
|
Size -= sizeof (UINT16);
|
||||||
Buffer = (UINT16*)Buffer + 1;
|
Buffer = (UINT16 *)Buffer + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (Size >= sizeof (UINT32)) {
|
while (Size >= sizeof (UINT32)) {
|
||||||
//
|
//
|
||||||
// Write as many double words as possible
|
// Write as many double words as possible
|
||||||
//
|
//
|
||||||
PciExpressWrite32 (StartAddress, ReadUnaligned32 ((UINT32*)Buffer));
|
PciExpressWrite32 (StartAddress, ReadUnaligned32 ((UINT32 *)Buffer));
|
||||||
StartAddress += sizeof (UINT32);
|
StartAddress += sizeof (UINT32);
|
||||||
Size -= sizeof (UINT32);
|
Size -= sizeof (UINT32);
|
||||||
Buffer = (UINT32*)Buffer + 1;
|
Buffer = (UINT32 *)Buffer + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Size >= sizeof (UINT16)) {
|
if (Size >= sizeof (UINT16)) {
|
||||||
//
|
//
|
||||||
// Write the last remaining word if exist
|
// Write the last remaining word if exist
|
||||||
//
|
//
|
||||||
PciExpressWrite16 (StartAddress, ReadUnaligned16 ((UINT16*)Buffer));
|
PciExpressWrite16 (StartAddress, ReadUnaligned16 ((UINT16 *)Buffer));
|
||||||
StartAddress += sizeof (UINT16);
|
StartAddress += sizeof (UINT16);
|
||||||
Size -= sizeof (UINT16);
|
Size -= sizeof (UINT16);
|
||||||
Buffer = (UINT16*)Buffer + 1;
|
Buffer = (UINT16 *)Buffer + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Size >= sizeof (UINT8)) {
|
if (Size >= sizeof (UINT8)) {
|
||||||
//
|
//
|
||||||
// Write the last remaining byte if exist
|
// Write the last remaining byte if exist
|
||||||
//
|
//
|
||||||
PciExpressWrite8 (StartAddress, *(UINT8*)Buffer);
|
PciExpressWrite8 (StartAddress, *(UINT8 *)Buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ReturnValue;
|
return ReturnValue;
|
||||||
|
@ -83,6 +83,7 @@ GetSerialConsolePortAddress (
|
|||||||
if (Path == NULL) {
|
if (Path == NULL) {
|
||||||
return EFI_NOT_FOUND;
|
return EFI_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
SerialConsoleNode = fdt_path_offset (Fdt, Path);
|
SerialConsoleNode = fdt_path_offset (Fdt, Path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,9 +116,9 @@ PlatformHookSerialPortInitialize (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
RETURN_STATUS Status;
|
RETURN_STATUS Status;
|
||||||
VOID *DeviceTreeBase;
|
VOID *DeviceTreeBase;
|
||||||
UINT64 SerialConsoleAddress;
|
UINT64 SerialConsoleAddress;
|
||||||
|
|
||||||
if (PcdGet64 (PcdSerialRegisterBase) != 0) {
|
if (PcdGet64 (PcdSerialRegisterBase) != 0) {
|
||||||
return RETURN_SUCCESS;
|
return RETURN_SUCCESS;
|
||||||
|
@ -35,8 +35,8 @@ PlatformHookSerialPortInitialize (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
VOID *Hob;
|
VOID *Hob;
|
||||||
UINT64 *UartBase;
|
UINT64 *UartBase;
|
||||||
|
|
||||||
if (PcdGet64 (PcdSerialRegisterBase) != 0) {
|
if (PcdGet64 (PcdSerialRegisterBase) != 0) {
|
||||||
return RETURN_SUCCESS;
|
return RETURN_SUCCESS;
|
||||||
|
@ -74,7 +74,7 @@ SerialPortGetBaseAddress (
|
|||||||
//
|
//
|
||||||
// Enumerate all FDT nodes looking for a PL011 and capture its base address
|
// Enumerate all FDT nodes looking for a PL011 and capture its base address
|
||||||
//
|
//
|
||||||
for (Prev = 0;; Prev = Node) {
|
for (Prev = 0; ; Prev = Node) {
|
||||||
Node = fdt_next_node (DeviceTreeBase, Prev, NULL);
|
Node = fdt_next_node (DeviceTreeBase, Prev, NULL);
|
||||||
if (Node < 0) {
|
if (Node < 0) {
|
||||||
break;
|
break;
|
||||||
@ -89,11 +89,11 @@ SerialPortGetBaseAddress (
|
|||||||
// Iterate over the NULL-separated items in the compatible string
|
// Iterate over the NULL-separated items in the compatible string
|
||||||
//
|
//
|
||||||
for (CompatibleItem = Compatible; CompatibleItem < Compatible + Len;
|
for (CompatibleItem = Compatible; CompatibleItem < Compatible + Len;
|
||||||
CompatibleItem += 1 + AsciiStrLen (CompatibleItem)) {
|
CompatibleItem += 1 + AsciiStrLen (CompatibleItem))
|
||||||
|
{
|
||||||
if (AsciiStrCmp (CompatibleItem, "arm,pl011") == 0) {
|
if (AsciiStrCmp (CompatibleItem, "arm,pl011") == 0) {
|
||||||
NodeStatus = fdt_getprop (DeviceTreeBase, Node, "status", &Len);
|
NodeStatus = fdt_getprop (DeviceTreeBase, Node, "status", &Len);
|
||||||
if (NodeStatus != NULL && AsciiStrCmp (NodeStatus, "okay") != 0) {
|
if ((NodeStatus != NULL) && (AsciiStrCmp (NodeStatus, "okay") != 0)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,13 +101,14 @@ SerialPortGetBaseAddress (
|
|||||||
if (Len != 16) {
|
if (Len != 16) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
UartBase = (UINTN)fdt64_to_cpu (ReadUnaligned64 (RegProperty));
|
UartBase = (UINTN)fdt64_to_cpu (ReadUnaligned64 (RegProperty));
|
||||||
|
|
||||||
BaudRate = (UINTN)FixedPcdGet64 (PcdUartDefaultBaudRate);
|
BaudRate = (UINTN)FixedPcdGet64 (PcdUartDefaultBaudRate);
|
||||||
ReceiveFifoDepth = 0; // Use the default value for Fifo depth
|
ReceiveFifoDepth = 0; // Use the default value for Fifo depth
|
||||||
Parity = (EFI_PARITY_TYPE)FixedPcdGet8 (PcdUartDefaultParity);
|
Parity = (EFI_PARITY_TYPE)FixedPcdGet8 (PcdUartDefaultParity);
|
||||||
DataBits = FixedPcdGet8 (PcdUartDefaultDataBits);
|
DataBits = FixedPcdGet8 (PcdUartDefaultDataBits);
|
||||||
StopBits = (EFI_STOP_BITS_TYPE) FixedPcdGet8 (PcdUartDefaultStopBits);
|
StopBits = (EFI_STOP_BITS_TYPE)FixedPcdGet8 (PcdUartDefaultStopBits);
|
||||||
|
|
||||||
Status = PL011UartInitializePort (
|
Status = PL011UartInitializePort (
|
||||||
UartBase,
|
UartBase,
|
||||||
@ -124,6 +125,7 @@ SerialPortGetBaseAddress (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,16 +142,17 @@ SerialPortGetBaseAddress (
|
|||||||
UINTN
|
UINTN
|
||||||
EFIAPI
|
EFIAPI
|
||||||
SerialPortWrite (
|
SerialPortWrite (
|
||||||
IN UINT8 *Buffer,
|
IN UINT8 *Buffer,
|
||||||
IN UINTN NumberOfBytes
|
IN UINTN NumberOfBytes
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINT64 SerialRegisterBase;
|
UINT64 SerialRegisterBase;
|
||||||
|
|
||||||
SerialRegisterBase = SerialPortGetBaseAddress ();
|
SerialRegisterBase = SerialPortGetBaseAddress ();
|
||||||
if (SerialRegisterBase != 0) {
|
if (SerialRegisterBase != 0) {
|
||||||
return PL011UartWrite ((UINTN)SerialRegisterBase, Buffer, NumberOfBytes);
|
return PL011UartWrite ((UINTN)SerialRegisterBase, Buffer, NumberOfBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,9 +169,9 @@ SerialPortWrite (
|
|||||||
UINTN
|
UINTN
|
||||||
EFIAPI
|
EFIAPI
|
||||||
SerialPortRead (
|
SerialPortRead (
|
||||||
OUT UINT8 *Buffer,
|
OUT UINT8 *Buffer,
|
||||||
IN UINTN NumberOfBytes
|
IN UINTN NumberOfBytes
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -202,7 +205,7 @@ SerialPortPoll (
|
|||||||
RETURN_STATUS
|
RETURN_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
SerialPortSetControl (
|
SerialPortSetControl (
|
||||||
IN UINT32 Control
|
IN UINT32 Control
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return RETURN_UNSUPPORTED;
|
return RETURN_UNSUPPORTED;
|
||||||
@ -221,7 +224,7 @@ SerialPortSetControl (
|
|||||||
RETURN_STATUS
|
RETURN_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
SerialPortGetControl (
|
SerialPortGetControl (
|
||||||
OUT UINT32 *Control
|
OUT UINT32 *Control
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return RETURN_UNSUPPORTED;
|
return RETURN_UNSUPPORTED;
|
||||||
@ -263,14 +266,13 @@ SerialPortGetControl (
|
|||||||
RETURN_STATUS
|
RETURN_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
SerialPortSetAttributes (
|
SerialPortSetAttributes (
|
||||||
IN OUT UINT64 *BaudRate,
|
IN OUT UINT64 *BaudRate,
|
||||||
IN OUT UINT32 *ReceiveFifoDepth,
|
IN OUT UINT32 *ReceiveFifoDepth,
|
||||||
IN OUT UINT32 *Timeout,
|
IN OUT UINT32 *Timeout,
|
||||||
IN OUT EFI_PARITY_TYPE *Parity,
|
IN OUT EFI_PARITY_TYPE *Parity,
|
||||||
IN OUT UINT8 *DataBits,
|
IN OUT UINT8 *DataBits,
|
||||||
IN OUT EFI_STOP_BITS_TYPE *StopBits
|
IN OUT EFI_STOP_BITS_TYPE *StopBits
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return RETURN_UNSUPPORTED;
|
return RETURN_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include <Library/HobLib.h>
|
#include <Library/HobLib.h>
|
||||||
#include <Guid/EarlyPL011BaseAddress.h>
|
#include <Guid/EarlyPL011BaseAddress.h>
|
||||||
|
|
||||||
STATIC UINTN mSerialBaseAddress;
|
STATIC UINTN mSerialBaseAddress;
|
||||||
|
|
||||||
RETURN_STATUS
|
RETURN_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
@ -57,9 +57,10 @@ FdtPL011SerialPortLibInitialize (
|
|||||||
EFI_STOP_BITS_TYPE StopBits;
|
EFI_STOP_BITS_TYPE StopBits;
|
||||||
|
|
||||||
Hob = GetFirstGuidHob (&gEarlyPL011BaseAddressGuid);
|
Hob = GetFirstGuidHob (&gEarlyPL011BaseAddressGuid);
|
||||||
if (Hob == NULL || GET_GUID_HOB_DATA_SIZE (Hob) != sizeof *UartBase) {
|
if ((Hob == NULL) || (GET_GUID_HOB_DATA_SIZE (Hob) != sizeof *UartBase)) {
|
||||||
return RETURN_NOT_FOUND;
|
return RETURN_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
UartBase = GET_GUID_HOB_DATA (Hob);
|
UartBase = GET_GUID_HOB_DATA (Hob);
|
||||||
|
|
||||||
mSerialBaseAddress = (UINTN)*UartBase;
|
mSerialBaseAddress = (UINTN)*UartBase;
|
||||||
@ -67,11 +68,11 @@ FdtPL011SerialPortLibInitialize (
|
|||||||
return RETURN_NOT_FOUND;
|
return RETURN_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
BaudRate = (UINTN)PcdGet64 (PcdUartDefaultBaudRate);
|
BaudRate = (UINTN)PcdGet64 (PcdUartDefaultBaudRate);
|
||||||
ReceiveFifoDepth = 0; // Use the default value for Fifo depth
|
ReceiveFifoDepth = 0; // Use the default value for Fifo depth
|
||||||
Parity = (EFI_PARITY_TYPE)PcdGet8 (PcdUartDefaultParity);
|
Parity = (EFI_PARITY_TYPE)PcdGet8 (PcdUartDefaultParity);
|
||||||
DataBits = PcdGet8 (PcdUartDefaultDataBits);
|
DataBits = PcdGet8 (PcdUartDefaultDataBits);
|
||||||
StopBits = (EFI_STOP_BITS_TYPE) PcdGet8 (PcdUartDefaultStopBits);
|
StopBits = (EFI_STOP_BITS_TYPE)PcdGet8 (PcdUartDefaultStopBits);
|
||||||
|
|
||||||
return PL011UartInitializePort (
|
return PL011UartInitializePort (
|
||||||
mSerialBaseAddress,
|
mSerialBaseAddress,
|
||||||
@ -97,13 +98,14 @@ FdtPL011SerialPortLibInitialize (
|
|||||||
UINTN
|
UINTN
|
||||||
EFIAPI
|
EFIAPI
|
||||||
SerialPortWrite (
|
SerialPortWrite (
|
||||||
IN UINT8 *Buffer,
|
IN UINT8 *Buffer,
|
||||||
IN UINTN NumberOfBytes
|
IN UINTN NumberOfBytes
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (mSerialBaseAddress != 0) {
|
if (mSerialBaseAddress != 0) {
|
||||||
return PL011UartWrite (mSerialBaseAddress, Buffer, NumberOfBytes);
|
return PL011UartWrite (mSerialBaseAddress, Buffer, NumberOfBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,13 +122,14 @@ SerialPortWrite (
|
|||||||
UINTN
|
UINTN
|
||||||
EFIAPI
|
EFIAPI
|
||||||
SerialPortRead (
|
SerialPortRead (
|
||||||
OUT UINT8 *Buffer,
|
OUT UINT8 *Buffer,
|
||||||
IN UINTN NumberOfBytes
|
IN UINTN NumberOfBytes
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (mSerialBaseAddress != 0) {
|
if (mSerialBaseAddress != 0) {
|
||||||
return PL011UartRead (mSerialBaseAddress, Buffer, NumberOfBytes);
|
return PL011UartRead (mSerialBaseAddress, Buffer, NumberOfBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,6 +149,7 @@ SerialPortPoll (
|
|||||||
if (mSerialBaseAddress != 0) {
|
if (mSerialBaseAddress != 0) {
|
||||||
return PL011UartPoll (mSerialBaseAddress);
|
return PL011UartPoll (mSerialBaseAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,15 +189,15 @@ SerialPortPoll (
|
|||||||
RETURN_STATUS
|
RETURN_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
SerialPortSetAttributes (
|
SerialPortSetAttributes (
|
||||||
IN OUT UINT64 *BaudRate,
|
IN OUT UINT64 *BaudRate,
|
||||||
IN OUT UINT32 *ReceiveFifoDepth,
|
IN OUT UINT32 *ReceiveFifoDepth,
|
||||||
IN OUT UINT32 *Timeout,
|
IN OUT UINT32 *Timeout,
|
||||||
IN OUT EFI_PARITY_TYPE *Parity,
|
IN OUT EFI_PARITY_TYPE *Parity,
|
||||||
IN OUT UINT8 *DataBits,
|
IN OUT UINT8 *DataBits,
|
||||||
IN OUT EFI_STOP_BITS_TYPE *StopBits
|
IN OUT EFI_STOP_BITS_TYPE *StopBits
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
RETURN_STATUS Status;
|
RETURN_STATUS Status;
|
||||||
|
|
||||||
if (mSerialBaseAddress == 0) {
|
if (mSerialBaseAddress == 0) {
|
||||||
Status = RETURN_UNSUPPORTED;
|
Status = RETURN_UNSUPPORTED;
|
||||||
@ -225,10 +229,10 @@ SerialPortSetAttributes (
|
|||||||
RETURN_STATUS
|
RETURN_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
SerialPortSetControl (
|
SerialPortSetControl (
|
||||||
IN UINT32 Control
|
IN UINT32 Control
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
RETURN_STATUS Status;
|
RETURN_STATUS Status;
|
||||||
|
|
||||||
if (mSerialBaseAddress == 0) {
|
if (mSerialBaseAddress == 0) {
|
||||||
Status = RETURN_UNSUPPORTED;
|
Status = RETURN_UNSUPPORTED;
|
||||||
@ -252,10 +256,10 @@ SerialPortSetControl (
|
|||||||
RETURN_STATUS
|
RETURN_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
SerialPortGetControl (
|
SerialPortGetControl (
|
||||||
OUT UINT32 *Control
|
OUT UINT32 *Control
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
RETURN_STATUS Status;
|
RETURN_STATUS Status;
|
||||||
|
|
||||||
if (mSerialBaseAddress == 0) {
|
if (mSerialBaseAddress == 0) {
|
||||||
Status = RETURN_UNSUPPORTED;
|
Status = RETURN_UNSUPPORTED;
|
||||||
@ -265,4 +269,3 @@ SerialPortGetControl (
|
|||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,15 +38,15 @@ PlatformPeim (
|
|||||||
UINT64 *FdtHobData;
|
UINT64 *FdtHobData;
|
||||||
UINT64 *UartHobData;
|
UINT64 *UartHobData;
|
||||||
|
|
||||||
Base = (VOID*)(UINTN)PcdGet64 (PcdDeviceTreeInitialBaseAddress);
|
Base = (VOID *)(UINTN)PcdGet64 (PcdDeviceTreeInitialBaseAddress);
|
||||||
if ((Base == NULL) || (fdt_check_header (Base) != 0)) {
|
if ((Base == NULL) || (fdt_check_header (Base) != 0)) {
|
||||||
ASSERT (0);
|
ASSERT (0);
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
FdtSize = fdt_totalsize (Base) + PcdGet32 (PcdDeviceTreeAllocationPadding);
|
FdtSize = fdt_totalsize (Base) + PcdGet32 (PcdDeviceTreeAllocationPadding);
|
||||||
FdtPages = EFI_SIZE_TO_PAGES (FdtSize);
|
FdtPages = EFI_SIZE_TO_PAGES (FdtSize);
|
||||||
NewBase = AllocatePages (FdtPages);
|
NewBase = AllocatePages (FdtPages);
|
||||||
if (NewBase == NULL) {
|
if (NewBase == NULL) {
|
||||||
ASSERT (0);
|
ASSERT (0);
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
|
@ -16,11 +16,11 @@
|
|||||||
|
|
||||||
/** RTC Index register is at offset 0x0
|
/** RTC Index register is at offset 0x0
|
||||||
*/
|
*/
|
||||||
#define RTC_INDEX_REG_OFFSET 0x0ULL
|
#define RTC_INDEX_REG_OFFSET 0x0ULL
|
||||||
|
|
||||||
/** RTC Target register is at offset 0x1
|
/** RTC Target register is at offset 0x1
|
||||||
*/
|
*/
|
||||||
#define RTC_TARGET_REG_OFFSET 0x1ULL
|
#define RTC_TARGET_REG_OFFSET 0x1ULL
|
||||||
|
|
||||||
/** Add the RTC controller address range to the memory map.
|
/** Add the RTC controller address range to the memory map.
|
||||||
|
|
||||||
@ -34,8 +34,8 @@
|
|||||||
STATIC
|
STATIC
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
KvmtoolRtcMapMemory (
|
KvmtoolRtcMapMemory (
|
||||||
IN EFI_HANDLE ImageHandle,
|
IN EFI_HANDLE ImageHandle,
|
||||||
IN EFI_PHYSICAL_ADDRESS RtcPageBase
|
IN EFI_PHYSICAL_ADDRESS RtcPageBase
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
@ -48,7 +48,8 @@ KvmtoolRtcMapMemory (
|
|||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((
|
DEBUG ((
|
||||||
DEBUG_ERROR, "Failed to add memory space. Status = %r\n",
|
DEBUG_ERROR,
|
||||||
|
"Failed to add memory space. Status = %r\n",
|
||||||
Status
|
Status
|
||||||
));
|
));
|
||||||
return Status;
|
return Status;
|
||||||
@ -117,18 +118,18 @@ KvmtoolRtcMapMemory (
|
|||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
KvmtoolRtcFdtClientLibConstructor (
|
KvmtoolRtcFdtClientLibConstructor (
|
||||||
IN EFI_HANDLE ImageHandle,
|
IN EFI_HANDLE ImageHandle,
|
||||||
IN EFI_SYSTEM_TABLE *SystemTable
|
IN EFI_SYSTEM_TABLE *SystemTable
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
FDT_CLIENT_PROTOCOL *FdtClient;
|
FDT_CLIENT_PROTOCOL *FdtClient;
|
||||||
INT32 Node;
|
INT32 Node;
|
||||||
CONST UINT32 *Reg;
|
CONST UINT32 *Reg;
|
||||||
UINT32 RegSize;
|
UINT32 RegSize;
|
||||||
UINT64 RegBase;
|
UINT64 RegBase;
|
||||||
UINT64 Range;
|
UINT64 Range;
|
||||||
RETURN_STATUS PcdStatus;
|
RETURN_STATUS PcdStatus;
|
||||||
|
|
||||||
Status = gBS->LocateProtocol (
|
Status = gBS->LocateProtocol (
|
||||||
&gFdtClientProtocolGuid,
|
&gFdtClientProtocolGuid,
|
||||||
@ -170,7 +171,7 @@ KvmtoolRtcFdtClientLibConstructor (
|
|||||||
ASSERT (RegSize == 16);
|
ASSERT (RegSize == 16);
|
||||||
|
|
||||||
RegBase = SwapBytes64 (ReadUnaligned64 ((VOID *)&Reg[0]));
|
RegBase = SwapBytes64 (ReadUnaligned64 ((VOID *)&Reg[0]));
|
||||||
Range = SwapBytes64 (ReadUnaligned64 ((VOID *)&Reg[2]));
|
Range = SwapBytes64 (ReadUnaligned64 ((VOID *)&Reg[2]));
|
||||||
DEBUG ((
|
DEBUG ((
|
||||||
DEBUG_INFO,
|
DEBUG_INFO,
|
||||||
"Found motorola,mc146818 RTC @ 0x%Lx Range = 0x%x\n",
|
"Found motorola,mc146818 RTC @ 0x%Lx Range = 0x%x\n",
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
#include <Library/MemoryAllocationLib.h>
|
#include <Library/MemoryAllocationLib.h>
|
||||||
|
|
||||||
// Number of Virtual Memory Map Descriptors
|
// Number of Virtual Memory Map Descriptors
|
||||||
#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS 5
|
#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS 5
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Return the Virtual Memory Map of your platform
|
Return the Virtual Memory Map of your platform
|
||||||
@ -32,24 +32,24 @@
|
|||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
ArmVirtGetMemoryMap (
|
ArmVirtGetMemoryMap (
|
||||||
OUT ARM_MEMORY_REGION_DESCRIPTOR **VirtualMemoryMap
|
OUT ARM_MEMORY_REGION_DESCRIPTOR **VirtualMemoryMap
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ARM_MEMORY_REGION_DESCRIPTOR *VirtualMemoryTable;
|
ARM_MEMORY_REGION_DESCRIPTOR *VirtualMemoryTable;
|
||||||
UINTN Idx;
|
UINTN Idx;
|
||||||
EFI_PHYSICAL_ADDRESS TopOfAddressSpace;
|
EFI_PHYSICAL_ADDRESS TopOfAddressSpace;
|
||||||
|
|
||||||
ASSERT (VirtualMemoryMap != NULL);
|
ASSERT (VirtualMemoryMap != NULL);
|
||||||
|
|
||||||
TopOfAddressSpace = LShiftU64 (1ULL, ArmGetPhysicalAddressBits ());
|
TopOfAddressSpace = LShiftU64 (1ULL, ArmGetPhysicalAddressBits ());
|
||||||
|
|
||||||
VirtualMemoryTable = (ARM_MEMORY_REGION_DESCRIPTOR*)
|
VirtualMemoryTable = (ARM_MEMORY_REGION_DESCRIPTOR *)
|
||||||
AllocatePages (
|
AllocatePages (
|
||||||
EFI_SIZE_TO_PAGES (
|
EFI_SIZE_TO_PAGES (
|
||||||
sizeof (ARM_MEMORY_REGION_DESCRIPTOR) *
|
sizeof (ARM_MEMORY_REGION_DESCRIPTOR) *
|
||||||
MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS
|
MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
if (VirtualMemoryTable == NULL) {
|
if (VirtualMemoryTable == NULL) {
|
||||||
DEBUG ((
|
DEBUG ((
|
||||||
DEBUG_ERROR,
|
DEBUG_ERROR,
|
||||||
@ -75,24 +75,24 @@ ArmVirtGetMemoryMap (
|
|||||||
// Peripheral space after DRAM
|
// Peripheral space after DRAM
|
||||||
VirtualMemoryTable[++Idx].PhysicalBase = PcdGet64 (PcdSystemMemoryBase) +
|
VirtualMemoryTable[++Idx].PhysicalBase = PcdGet64 (PcdSystemMemoryBase) +
|
||||||
PcdGet64 (PcdSystemMemorySize);
|
PcdGet64 (PcdSystemMemorySize);
|
||||||
VirtualMemoryTable[Idx].VirtualBase = VirtualMemoryTable[Idx].PhysicalBase;
|
VirtualMemoryTable[Idx].VirtualBase = VirtualMemoryTable[Idx].PhysicalBase;
|
||||||
VirtualMemoryTable[Idx].Length = TopOfAddressSpace -
|
VirtualMemoryTable[Idx].Length = TopOfAddressSpace -
|
||||||
VirtualMemoryTable[Idx].PhysicalBase;
|
VirtualMemoryTable[Idx].PhysicalBase;
|
||||||
VirtualMemoryTable[Idx].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
|
VirtualMemoryTable[Idx].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
|
||||||
|
|
||||||
// Map the FV region as normal executable memory
|
// Map the FV region as normal executable memory
|
||||||
VirtualMemoryTable[++Idx].PhysicalBase = PcdGet64 (PcdFvBaseAddress);
|
VirtualMemoryTable[++Idx].PhysicalBase = PcdGet64 (PcdFvBaseAddress);
|
||||||
VirtualMemoryTable[Idx].VirtualBase = VirtualMemoryTable[Idx].PhysicalBase;
|
VirtualMemoryTable[Idx].VirtualBase = VirtualMemoryTable[Idx].PhysicalBase;
|
||||||
VirtualMemoryTable[Idx].Length = FixedPcdGet32 (PcdFvSize);
|
VirtualMemoryTable[Idx].Length = FixedPcdGet32 (PcdFvSize);
|
||||||
VirtualMemoryTable[Idx].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK;
|
VirtualMemoryTable[Idx].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK;
|
||||||
|
|
||||||
// End of Table
|
// End of Table
|
||||||
VirtualMemoryTable[++Idx].PhysicalBase = 0;
|
VirtualMemoryTable[++Idx].PhysicalBase = 0;
|
||||||
VirtualMemoryTable[Idx].VirtualBase = 0;
|
VirtualMemoryTable[Idx].VirtualBase = 0;
|
||||||
VirtualMemoryTable[Idx].Length = 0;
|
VirtualMemoryTable[Idx].Length = 0;
|
||||||
VirtualMemoryTable[Idx].Attributes = (ARM_MEMORY_REGION_ATTRIBUTES)0;
|
VirtualMemoryTable[Idx].Attributes = (ARM_MEMORY_REGION_ATTRIBUTES)0;
|
||||||
|
|
||||||
ASSERT((Idx + 1) <= MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS);
|
ASSERT ((Idx + 1) <= MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS);
|
||||||
|
|
||||||
*VirtualMemoryMap = VirtualMemoryTable;
|
*VirtualMemoryMap = VirtualMemoryTable;
|
||||||
}
|
}
|
||||||
|
@ -19,15 +19,15 @@
|
|||||||
|
|
||||||
/** Macro defining the maximum number of Flash devices.
|
/** Macro defining the maximum number of Flash devices.
|
||||||
*/
|
*/
|
||||||
#define MAX_FLASH_DEVICES 4
|
#define MAX_FLASH_DEVICES 4
|
||||||
|
|
||||||
/** Macro defining the cfi-flash label describing the UEFI variable store.
|
/** Macro defining the cfi-flash label describing the UEFI variable store.
|
||||||
*/
|
*/
|
||||||
#define LABEL_UEFI_VAR_STORE "System-firmware"
|
#define LABEL_UEFI_VAR_STORE "System-firmware"
|
||||||
|
|
||||||
STATIC NOR_FLASH_DESCRIPTION mNorFlashDevices[MAX_FLASH_DEVICES];
|
STATIC NOR_FLASH_DESCRIPTION mNorFlashDevices[MAX_FLASH_DEVICES];
|
||||||
STATIC UINTN mNorFlashDeviceCount = 0;
|
STATIC UINTN mNorFlashDeviceCount = 0;
|
||||||
STATIC INT32 mUefiVarStoreNode = MAX_INT32;
|
STATIC INT32 mUefiVarStoreNode = MAX_INT32;
|
||||||
STATIC FDT_CLIENT_PROTOCOL *mFdtClient;
|
STATIC FDT_CLIENT_PROTOCOL *mFdtClient;
|
||||||
|
|
||||||
/** This function performs platform specific actions to initialise
|
/** This function performs platform specific actions to initialise
|
||||||
@ -40,7 +40,7 @@ NorFlashPlatformInitialization (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
|
||||||
DEBUG ((DEBUG_INFO, "NorFlashPlatformInitialization\n"));
|
DEBUG ((DEBUG_INFO, "NorFlashPlatformInitialization\n"));
|
||||||
|
|
||||||
@ -89,24 +89,25 @@ NorFlashPlatformInitialization (
|
|||||||
STATIC
|
STATIC
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
SetupVariableStore (
|
SetupVariableStore (
|
||||||
IN NOR_FLASH_DESCRIPTION * FlashDevice
|
IN NOR_FLASH_DESCRIPTION *FlashDevice
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINTN FlashRegion;
|
UINTN FlashRegion;
|
||||||
UINTN FlashNvStorageVariableBase;
|
UINTN FlashNvStorageVariableBase;
|
||||||
UINTN FlashNvStorageFtwWorkingBase;
|
UINTN FlashNvStorageFtwWorkingBase;
|
||||||
UINTN FlashNvStorageFtwSpareBase;
|
UINTN FlashNvStorageFtwSpareBase;
|
||||||
UINTN FlashNvStorageVariableSize;
|
UINTN FlashNvStorageVariableSize;
|
||||||
UINTN FlashNvStorageFtwWorkingSize;
|
UINTN FlashNvStorageFtwWorkingSize;
|
||||||
UINTN FlashNvStorageFtwSpareSize;
|
UINTN FlashNvStorageFtwSpareSize;
|
||||||
|
|
||||||
FlashNvStorageVariableSize = PcdGet32 (PcdFlashNvStorageVariableSize);
|
FlashNvStorageVariableSize = PcdGet32 (PcdFlashNvStorageVariableSize);
|
||||||
FlashNvStorageFtwWorkingSize = PcdGet32 (PcdFlashNvStorageFtwWorkingSize);
|
FlashNvStorageFtwWorkingSize = PcdGet32 (PcdFlashNvStorageFtwWorkingSize);
|
||||||
FlashNvStorageFtwSpareSize = PcdGet32 (PcdFlashNvStorageFtwSpareSize);
|
FlashNvStorageFtwSpareSize = PcdGet32 (PcdFlashNvStorageFtwSpareSize);
|
||||||
|
|
||||||
if ((FlashNvStorageVariableSize == 0) ||
|
if ((FlashNvStorageVariableSize == 0) ||
|
||||||
(FlashNvStorageFtwWorkingSize == 0) ||
|
(FlashNvStorageFtwWorkingSize == 0) ||
|
||||||
(FlashNvStorageFtwSpareSize == 0)) {
|
(FlashNvStorageFtwSpareSize == 0))
|
||||||
|
{
|
||||||
DEBUG ((DEBUG_ERROR, "FlashNvStorage size not defined\n"));
|
DEBUG ((DEBUG_ERROR, "FlashNvStorage size not defined\n"));
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
@ -115,13 +116,13 @@ SetupVariableStore (
|
|||||||
FlashRegion = FlashDevice->DeviceBaseAddress;
|
FlashRegion = FlashDevice->DeviceBaseAddress;
|
||||||
|
|
||||||
FlashNvStorageVariableBase = FlashRegion;
|
FlashNvStorageVariableBase = FlashRegion;
|
||||||
FlashRegion += PcdGet32 (PcdFlashNvStorageVariableSize);
|
FlashRegion += PcdGet32 (PcdFlashNvStorageVariableSize);
|
||||||
|
|
||||||
FlashNvStorageFtwWorkingBase = FlashRegion;
|
FlashNvStorageFtwWorkingBase = FlashRegion;
|
||||||
FlashRegion += PcdGet32 (PcdFlashNvStorageFtwWorkingSize);
|
FlashRegion += PcdGet32 (PcdFlashNvStorageFtwWorkingSize);
|
||||||
|
|
||||||
FlashNvStorageFtwSpareBase = FlashRegion;
|
FlashNvStorageFtwSpareBase = FlashRegion;
|
||||||
FlashRegion += PcdGet32 (PcdFlashNvStorageFtwSpareSize);
|
FlashRegion += PcdGet32 (PcdFlashNvStorageFtwSpareSize);
|
||||||
|
|
||||||
if (FlashRegion > (FlashDevice->DeviceBaseAddress + FlashDevice->Size)) {
|
if (FlashRegion > (FlashDevice->DeviceBaseAddress + FlashDevice->Size)) {
|
||||||
DEBUG ((DEBUG_ERROR, "Insufficient flash storage size\n"));
|
DEBUG ((DEBUG_ERROR, "Insufficient flash storage size\n"));
|
||||||
@ -187,15 +188,16 @@ SetupVariableStore (
|
|||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
NorFlashPlatformGetDevices (
|
NorFlashPlatformGetDevices (
|
||||||
OUT NOR_FLASH_DESCRIPTION **NorFlashDescriptions,
|
OUT NOR_FLASH_DESCRIPTION **NorFlashDescriptions,
|
||||||
OUT UINT32 *Count
|
OUT UINT32 *Count
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (mNorFlashDeviceCount > 0) {
|
if (mNorFlashDeviceCount > 0) {
|
||||||
*NorFlashDescriptions = mNorFlashDevices;
|
*NorFlashDescriptions = mNorFlashDevices;
|
||||||
*Count = mNorFlashDeviceCount;
|
*Count = mNorFlashDeviceCount;
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
return EFI_NOT_FOUND;
|
return EFI_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,20 +213,20 @@ NorFlashPlatformGetDevices (
|
|||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
NorFlashPlatformLibConstructor (
|
NorFlashPlatformLibConstructor (
|
||||||
IN EFI_HANDLE ImageHandle,
|
IN EFI_HANDLE ImageHandle,
|
||||||
IN EFI_SYSTEM_TABLE * SystemTable
|
IN EFI_SYSTEM_TABLE *SystemTable
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
INT32 Node;
|
INT32 Node;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_STATUS FindNodeStatus;
|
EFI_STATUS FindNodeStatus;
|
||||||
CONST UINT32 *Reg;
|
CONST UINT32 *Reg;
|
||||||
UINT32 PropSize;
|
UINT32 PropSize;
|
||||||
UINT64 Base;
|
UINT64 Base;
|
||||||
UINT64 Size;
|
UINT64 Size;
|
||||||
UINTN UefiVarStoreIndex;
|
UINTN UefiVarStoreIndex;
|
||||||
CONST CHAR8 *Label;
|
CONST CHAR8 *Label;
|
||||||
UINT32 LabelLen;
|
UINT32 LabelLen;
|
||||||
|
|
||||||
if (mNorFlashDeviceCount != 0) {
|
if (mNorFlashDeviceCount != 0) {
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
@ -244,13 +246,14 @@ NorFlashPlatformLibConstructor (
|
|||||||
&Node
|
&Node
|
||||||
);
|
);
|
||||||
!EFI_ERROR (FindNodeStatus) &&
|
!EFI_ERROR (FindNodeStatus) &&
|
||||||
(mNorFlashDeviceCount < MAX_FLASH_DEVICES);
|
(mNorFlashDeviceCount < MAX_FLASH_DEVICES);
|
||||||
FindNodeStatus = mFdtClient->FindNextCompatibleNode (
|
FindNodeStatus = mFdtClient->FindNextCompatibleNode (
|
||||||
mFdtClient,
|
mFdtClient,
|
||||||
"cfi-flash",
|
"cfi-flash",
|
||||||
Node,
|
Node,
|
||||||
&Node
|
&Node
|
||||||
)) {
|
))
|
||||||
|
{
|
||||||
Status = mFdtClient->GetNodeProperty (
|
Status = mFdtClient->GetNodeProperty (
|
||||||
mFdtClient,
|
mFdtClient,
|
||||||
Node,
|
Node,
|
||||||
@ -278,15 +281,20 @@ NorFlashPlatformLibConstructor (
|
|||||||
&PropSize
|
&PropSize
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_ERROR, "%a: GetNodeProperty () failed (Status == %r)\n",
|
DEBUG ((
|
||||||
__FUNCTION__, Status));
|
DEBUG_ERROR,
|
||||||
|
"%a: GetNodeProperty () failed (Status == %r)\n",
|
||||||
|
__FUNCTION__,
|
||||||
|
Status
|
||||||
|
));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT ((PropSize % (4 * sizeof (UINT32))) == 0);
|
ASSERT ((PropSize % (4 * sizeof (UINT32))) == 0);
|
||||||
|
|
||||||
while ((PropSize >= (4 * sizeof (UINT32))) &&
|
while ((PropSize >= (4 * sizeof (UINT32))) &&
|
||||||
(mNorFlashDeviceCount < MAX_FLASH_DEVICES)) {
|
(mNorFlashDeviceCount < MAX_FLASH_DEVICES))
|
||||||
|
{
|
||||||
Base = SwapBytes64 (ReadUnaligned64 ((VOID *)&Reg[0]));
|
Base = SwapBytes64 (ReadUnaligned64 ((VOID *)&Reg[0]));
|
||||||
Size = SwapBytes64 (ReadUnaligned64 ((VOID *)&Reg[2]));
|
Size = SwapBytes64 (ReadUnaligned64 ((VOID *)&Reg[2]));
|
||||||
Reg += 4;
|
Reg += 4;
|
||||||
@ -298,7 +306,8 @@ NorFlashPlatformLibConstructor (
|
|||||||
// The firmware is not updatable from inside the guest anyway.
|
// The firmware is not updatable from inside the guest anyway.
|
||||||
//
|
//
|
||||||
if ((PcdGet64 (PcdFvBaseAddress) + PcdGet32 (PcdFvSize) > Base) &&
|
if ((PcdGet64 (PcdFvBaseAddress) + PcdGet32 (PcdFvSize) > Base) &&
|
||||||
(Base + Size) > PcdGet64 (PcdFvBaseAddress)) {
|
((Base + Size) > PcdGet64 (PcdFvBaseAddress)))
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -312,8 +321,8 @@ NorFlashPlatformLibConstructor (
|
|||||||
|
|
||||||
mNorFlashDevices[mNorFlashDeviceCount].DeviceBaseAddress = (UINTN)Base;
|
mNorFlashDevices[mNorFlashDeviceCount].DeviceBaseAddress = (UINTN)Base;
|
||||||
mNorFlashDevices[mNorFlashDeviceCount].RegionBaseAddress = (UINTN)Base;
|
mNorFlashDevices[mNorFlashDeviceCount].RegionBaseAddress = (UINTN)Base;
|
||||||
mNorFlashDevices[mNorFlashDeviceCount].Size = (UINTN)Size;
|
mNorFlashDevices[mNorFlashDeviceCount].Size = (UINTN)Size;
|
||||||
mNorFlashDevices[mNorFlashDeviceCount].BlockSize = KVMTOOL_NOR_BLOCK_SIZE;
|
mNorFlashDevices[mNorFlashDeviceCount].BlockSize = KVMTOOL_NOR_BLOCK_SIZE;
|
||||||
mNorFlashDeviceCount++;
|
mNorFlashDeviceCount++;
|
||||||
}
|
}
|
||||||
} // for
|
} // for
|
||||||
@ -326,6 +335,7 @@ NorFlashPlatformLibConstructor (
|
|||||||
UefiVarStoreIndex = mNorFlashDeviceCount - 1;
|
UefiVarStoreIndex = mNorFlashDeviceCount - 1;
|
||||||
mUefiVarStoreNode = Node;
|
mUefiVarStoreNode = Node;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mNorFlashDevices[UefiVarStoreIndex].DeviceBaseAddress != 0) {
|
if (mNorFlashDevices[UefiVarStoreIndex].DeviceBaseAddress != 0) {
|
||||||
return SetupVariableStore (&mNorFlashDevices[UefiVarStoreIndex]);
|
return SetupVariableStore (&mNorFlashDevices[UefiVarStoreIndex]);
|
||||||
}
|
}
|
||||||
|
@ -13,9 +13,9 @@
|
|||||||
|
|
||||||
#include <Protocol/FdtClient.h>
|
#include <Protocol/FdtClient.h>
|
||||||
|
|
||||||
#define QEMU_NOR_BLOCK_SIZE SIZE_256KB
|
#define QEMU_NOR_BLOCK_SIZE SIZE_256KB
|
||||||
|
|
||||||
#define MAX_FLASH_BANKS 4
|
#define MAX_FLASH_BANKS 4
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
NorFlashPlatformInitialization (
|
NorFlashPlatformInitialization (
|
||||||
@ -25,40 +25,59 @@ NorFlashPlatformInitialization (
|
|||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
NOR_FLASH_DESCRIPTION mNorFlashDevices[MAX_FLASH_BANKS];
|
NOR_FLASH_DESCRIPTION mNorFlashDevices[MAX_FLASH_BANKS];
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
NorFlashPlatformGetDevices (
|
NorFlashPlatformGetDevices (
|
||||||
OUT NOR_FLASH_DESCRIPTION **NorFlashDescriptions,
|
OUT NOR_FLASH_DESCRIPTION **NorFlashDescriptions,
|
||||||
OUT UINT32 *Count
|
OUT UINT32 *Count
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
FDT_CLIENT_PROTOCOL *FdtClient;
|
FDT_CLIENT_PROTOCOL *FdtClient;
|
||||||
INT32 Node;
|
INT32 Node;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_STATUS FindNodeStatus;
|
EFI_STATUS FindNodeStatus;
|
||||||
CONST UINT32 *Reg;
|
CONST UINT32 *Reg;
|
||||||
UINT32 PropSize;
|
UINT32 PropSize;
|
||||||
UINT32 Num;
|
UINT32 Num;
|
||||||
UINT64 Base;
|
UINT64 Base;
|
||||||
UINT64 Size;
|
UINT64 Size;
|
||||||
|
|
||||||
Status = gBS->LocateProtocol (&gFdtClientProtocolGuid, NULL,
|
Status = gBS->LocateProtocol (
|
||||||
(VOID **)&FdtClient);
|
&gFdtClientProtocolGuid,
|
||||||
|
NULL,
|
||||||
|
(VOID **)&FdtClient
|
||||||
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
Num = 0;
|
Num = 0;
|
||||||
for (FindNodeStatus = FdtClient->FindCompatibleNode (FdtClient,
|
for (FindNodeStatus = FdtClient->FindCompatibleNode (
|
||||||
"cfi-flash", &Node);
|
FdtClient,
|
||||||
|
"cfi-flash",
|
||||||
|
&Node
|
||||||
|
);
|
||||||
!EFI_ERROR (FindNodeStatus) && Num < MAX_FLASH_BANKS;
|
!EFI_ERROR (FindNodeStatus) && Num < MAX_FLASH_BANKS;
|
||||||
FindNodeStatus = FdtClient->FindNextCompatibleNode (FdtClient,
|
FindNodeStatus = FdtClient->FindNextCompatibleNode (
|
||||||
"cfi-flash", Node, &Node)) {
|
FdtClient,
|
||||||
|
"cfi-flash",
|
||||||
Status = FdtClient->GetNodeProperty (FdtClient, Node, "reg",
|
Node,
|
||||||
(CONST VOID **)&Reg, &PropSize);
|
&Node
|
||||||
|
))
|
||||||
|
{
|
||||||
|
Status = FdtClient->GetNodeProperty (
|
||||||
|
FdtClient,
|
||||||
|
Node,
|
||||||
|
"reg",
|
||||||
|
(CONST VOID **)&Reg,
|
||||||
|
&PropSize
|
||||||
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_ERROR, "%a: GetNodeProperty () failed (Status == %r)\n",
|
DEBUG ((
|
||||||
__FUNCTION__, Status));
|
DEBUG_ERROR,
|
||||||
|
"%a: GetNodeProperty () failed (Status == %r)\n",
|
||||||
|
__FUNCTION__,
|
||||||
|
Status
|
||||||
|
));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +95,8 @@ NorFlashPlatformGetDevices (
|
|||||||
// The firmware is not updatable from inside the guest anyway.
|
// The firmware is not updatable from inside the guest anyway.
|
||||||
//
|
//
|
||||||
if ((PcdGet64 (PcdFvBaseAddress) + PcdGet32 (PcdFvSize) > Base) &&
|
if ((PcdGet64 (PcdFvBaseAddress) + PcdGet32 (PcdFvSize) > Base) &&
|
||||||
(Base + Size) > PcdGet64 (PcdFvBaseAddress)) {
|
((Base + Size) > PcdGet64 (PcdFvBaseAddress)))
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,15 +117,20 @@ NorFlashPlatformGetDevices (
|
|||||||
// code, which is not intended to be guest updatable, and is usually backed
|
// code, which is not intended to be guest updatable, and is usually backed
|
||||||
// in a readonly manner by QEMU anyway.
|
// in a readonly manner by QEMU anyway.
|
||||||
//
|
//
|
||||||
Status = FdtClient->SetNodeProperty (FdtClient, Node, "status",
|
Status = FdtClient->SetNodeProperty (
|
||||||
"disabled", sizeof ("disabled"));
|
FdtClient,
|
||||||
|
Node,
|
||||||
|
"status",
|
||||||
|
"disabled",
|
||||||
|
sizeof ("disabled")
|
||||||
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_WARN, "Failed to set NOR flash status to 'disabled'\n"));
|
DEBUG ((DEBUG_WARN, "Failed to set NOR flash status to 'disabled'\n"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*NorFlashDescriptions = mNorFlashDevices;
|
*NorFlashDescriptions = mNorFlashDevices;
|
||||||
*Count = Num;
|
*Count = Num;
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -32,24 +32,23 @@
|
|||||||
|
|
||||||
#include "PlatformBm.h"
|
#include "PlatformBm.h"
|
||||||
|
|
||||||
#define DP_NODE_LEN(Type) { (UINT8)sizeof (Type), (UINT8)(sizeof (Type) >> 8) }
|
#define DP_NODE_LEN(Type) { (UINT8)sizeof (Type), (UINT8)(sizeof (Type) >> 8) }
|
||||||
|
|
||||||
|
|
||||||
#pragma pack (1)
|
#pragma pack (1)
|
||||||
typedef struct {
|
typedef struct {
|
||||||
VENDOR_DEVICE_PATH SerialDxe;
|
VENDOR_DEVICE_PATH SerialDxe;
|
||||||
UART_DEVICE_PATH Uart;
|
UART_DEVICE_PATH Uart;
|
||||||
VENDOR_DEFINED_DEVICE_PATH TermType;
|
VENDOR_DEFINED_DEVICE_PATH TermType;
|
||||||
EFI_DEVICE_PATH_PROTOCOL End;
|
EFI_DEVICE_PATH_PROTOCOL End;
|
||||||
} PLATFORM_SERIAL_CONSOLE;
|
} PLATFORM_SERIAL_CONSOLE;
|
||||||
#pragma pack ()
|
#pragma pack ()
|
||||||
|
|
||||||
STATIC PLATFORM_SERIAL_CONSOLE mSerialConsole = {
|
STATIC PLATFORM_SERIAL_CONSOLE mSerialConsole = {
|
||||||
//
|
//
|
||||||
// VENDOR_DEVICE_PATH SerialDxe
|
// VENDOR_DEVICE_PATH SerialDxe
|
||||||
//
|
//
|
||||||
{
|
{
|
||||||
{ HARDWARE_DEVICE_PATH, HW_VENDOR_DP, DP_NODE_LEN (VENDOR_DEVICE_PATH) },
|
{ HARDWARE_DEVICE_PATH, HW_VENDOR_DP, DP_NODE_LEN (VENDOR_DEVICE_PATH) },
|
||||||
EDKII_SERIAL_PORT_LIB_VENDOR_GUID
|
EDKII_SERIAL_PORT_LIB_VENDOR_GUID
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -57,7 +56,7 @@ STATIC PLATFORM_SERIAL_CONSOLE mSerialConsole = {
|
|||||||
// UART_DEVICE_PATH Uart
|
// UART_DEVICE_PATH Uart
|
||||||
//
|
//
|
||||||
{
|
{
|
||||||
{ MESSAGING_DEVICE_PATH, MSG_UART_DP, DP_NODE_LEN (UART_DEVICE_PATH) },
|
{ MESSAGING_DEVICE_PATH, MSG_UART_DP, DP_NODE_LEN (UART_DEVICE_PATH) },
|
||||||
0, // Reserved
|
0, // Reserved
|
||||||
FixedPcdGet64 (PcdUartDefaultBaudRate), // BaudRate
|
FixedPcdGet64 (PcdUartDefaultBaudRate), // BaudRate
|
||||||
FixedPcdGet8 (PcdUartDefaultDataBits), // DataBits
|
FixedPcdGet8 (PcdUartDefaultDataBits), // DataBits
|
||||||
@ -87,15 +86,14 @@ STATIC PLATFORM_SERIAL_CONSOLE mSerialConsole = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#pragma pack (1)
|
#pragma pack (1)
|
||||||
typedef struct {
|
typedef struct {
|
||||||
USB_CLASS_DEVICE_PATH Keyboard;
|
USB_CLASS_DEVICE_PATH Keyboard;
|
||||||
EFI_DEVICE_PATH_PROTOCOL End;
|
EFI_DEVICE_PATH_PROTOCOL End;
|
||||||
} PLATFORM_USB_KEYBOARD;
|
} PLATFORM_USB_KEYBOARD;
|
||||||
#pragma pack ()
|
#pragma pack ()
|
||||||
|
|
||||||
STATIC PLATFORM_USB_KEYBOARD mUsbKeyboard = {
|
STATIC PLATFORM_USB_KEYBOARD mUsbKeyboard = {
|
||||||
//
|
//
|
||||||
// USB_CLASS_DEVICE_PATH Keyboard
|
// USB_CLASS_DEVICE_PATH Keyboard
|
||||||
//
|
//
|
||||||
@ -120,7 +118,6 @@ STATIC PLATFORM_USB_KEYBOARD mUsbKeyboard = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Check if the handle satisfies a particular condition.
|
Check if the handle satisfies a particular condition.
|
||||||
|
|
||||||
@ -134,12 +131,11 @@ STATIC PLATFORM_USB_KEYBOARD mUsbKeyboard = {
|
|||||||
**/
|
**/
|
||||||
typedef
|
typedef
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
(EFIAPI *FILTER_FUNCTION) (
|
(EFIAPI *FILTER_FUNCTION)(
|
||||||
IN EFI_HANDLE Handle,
|
IN EFI_HANDLE Handle,
|
||||||
IN CONST CHAR16 *ReportText
|
IN CONST CHAR16 *ReportText
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Process a handle.
|
Process a handle.
|
||||||
|
|
||||||
@ -149,7 +145,7 @@ BOOLEAN
|
|||||||
**/
|
**/
|
||||||
typedef
|
typedef
|
||||||
VOID
|
VOID
|
||||||
(EFIAPI *CALLBACK_FUNCTION) (
|
(EFIAPI *CALLBACK_FUNCTION)(
|
||||||
IN EFI_HANDLE Handle,
|
IN EFI_HANDLE Handle,
|
||||||
IN CONST CHAR16 *ReportText
|
IN CONST CHAR16 *ReportText
|
||||||
);
|
);
|
||||||
@ -170,31 +166,41 @@ VOID
|
|||||||
STATIC
|
STATIC
|
||||||
VOID
|
VOID
|
||||||
FilterAndProcess (
|
FilterAndProcess (
|
||||||
IN EFI_GUID *ProtocolGuid,
|
IN EFI_GUID *ProtocolGuid,
|
||||||
IN FILTER_FUNCTION Filter OPTIONAL,
|
IN FILTER_FUNCTION Filter OPTIONAL,
|
||||||
IN CALLBACK_FUNCTION Process
|
IN CALLBACK_FUNCTION Process
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_HANDLE *Handles;
|
EFI_HANDLE *Handles;
|
||||||
UINTN NoHandles;
|
UINTN NoHandles;
|
||||||
UINTN Idx;
|
UINTN Idx;
|
||||||
|
|
||||||
Status = gBS->LocateHandleBuffer (ByProtocol, ProtocolGuid,
|
Status = gBS->LocateHandleBuffer (
|
||||||
NULL /* SearchKey */, &NoHandles, &Handles);
|
ByProtocol,
|
||||||
|
ProtocolGuid,
|
||||||
|
NULL /* SearchKey */,
|
||||||
|
&NoHandles,
|
||||||
|
&Handles
|
||||||
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
//
|
//
|
||||||
// This is not an error, just an informative condition.
|
// This is not an error, just an informative condition.
|
||||||
//
|
//
|
||||||
DEBUG ((DEBUG_VERBOSE, "%a: %g: %r\n", __FUNCTION__, ProtocolGuid,
|
DEBUG ((
|
||||||
Status));
|
DEBUG_VERBOSE,
|
||||||
|
"%a: %g: %r\n",
|
||||||
|
__FUNCTION__,
|
||||||
|
ProtocolGuid,
|
||||||
|
Status
|
||||||
|
));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT (NoHandles > 0);
|
ASSERT (NoHandles > 0);
|
||||||
for (Idx = 0; Idx < NoHandles; ++Idx) {
|
for (Idx = 0; Idx < NoHandles; ++Idx) {
|
||||||
CHAR16 *DevicePathText;
|
CHAR16 *DevicePathText;
|
||||||
STATIC CHAR16 Fallback[] = L"<device path unavailable>";
|
STATIC CHAR16 Fallback[] = L"<device path unavailable>";
|
||||||
|
|
||||||
//
|
//
|
||||||
// The ConvertDevicePathToText() function handles NULL input transparently.
|
// The ConvertDevicePathToText() function handles NULL input transparently.
|
||||||
@ -208,7 +214,7 @@ FilterAndProcess (
|
|||||||
DevicePathText = Fallback;
|
DevicePathText = Fallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Filter == NULL || Filter (Handles[Idx], DevicePathText)) {
|
if ((Filter == NULL) || Filter (Handles[Idx], DevicePathText)) {
|
||||||
Process (Handles[Idx], DevicePathText);
|
Process (Handles[Idx], DevicePathText);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,10 +222,10 @@ FilterAndProcess (
|
|||||||
FreePool (DevicePathText);
|
FreePool (DevicePathText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gBS->FreePool (Handles);
|
gBS->FreePool (Handles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This FILTER_FUNCTION checks if a handle corresponds to a PCI display device.
|
This FILTER_FUNCTION checks if a handle corresponds to a PCI display device.
|
||||||
**/
|
**/
|
||||||
@ -227,16 +233,19 @@ STATIC
|
|||||||
BOOLEAN
|
BOOLEAN
|
||||||
EFIAPI
|
EFIAPI
|
||||||
IsPciDisplay (
|
IsPciDisplay (
|
||||||
IN EFI_HANDLE Handle,
|
IN EFI_HANDLE Handle,
|
||||||
IN CONST CHAR16 *ReportText
|
IN CONST CHAR16 *ReportText
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_PCI_IO_PROTOCOL *PciIo;
|
EFI_PCI_IO_PROTOCOL *PciIo;
|
||||||
PCI_TYPE00 Pci;
|
PCI_TYPE00 Pci;
|
||||||
|
|
||||||
Status = gBS->HandleProtocol (Handle, &gEfiPciIoProtocolGuid,
|
Status = gBS->HandleProtocol (
|
||||||
(VOID**)&PciIo);
|
Handle,
|
||||||
|
&gEfiPciIoProtocolGuid,
|
||||||
|
(VOID **)&PciIo
|
||||||
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
//
|
//
|
||||||
// This is not an error worth reporting.
|
// This is not an error worth reporting.
|
||||||
@ -244,8 +253,13 @@ IsPciDisplay (
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint32, 0 /* Offset */,
|
Status = PciIo->Pci.Read (
|
||||||
sizeof Pci / sizeof (UINT32), &Pci);
|
PciIo,
|
||||||
|
EfiPciIoWidthUint32,
|
||||||
|
0 /* Offset */,
|
||||||
|
sizeof Pci / sizeof (UINT32),
|
||||||
|
&Pci
|
||||||
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_ERROR, "%a: %s: %r\n", __FUNCTION__, ReportText, Status));
|
DEBUG ((DEBUG_ERROR, "%a: %s: %r\n", __FUNCTION__, ReportText, Status));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -254,7 +268,6 @@ IsPciDisplay (
|
|||||||
return IS_PCI_DISPLAY (&Pci);
|
return IS_PCI_DISPLAY (&Pci);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This FILTER_FUNCTION checks if a handle corresponds to a Virtio RNG device at
|
This FILTER_FUNCTION checks if a handle corresponds to a Virtio RNG device at
|
||||||
the VIRTIO_DEVICE_PROTOCOL level.
|
the VIRTIO_DEVICE_PROTOCOL level.
|
||||||
@ -263,23 +276,26 @@ STATIC
|
|||||||
BOOLEAN
|
BOOLEAN
|
||||||
EFIAPI
|
EFIAPI
|
||||||
IsVirtioRng (
|
IsVirtioRng (
|
||||||
IN EFI_HANDLE Handle,
|
IN EFI_HANDLE Handle,
|
||||||
IN CONST CHAR16 *ReportText
|
IN CONST CHAR16 *ReportText
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
VIRTIO_DEVICE_PROTOCOL *VirtIo;
|
VIRTIO_DEVICE_PROTOCOL *VirtIo;
|
||||||
|
|
||||||
Status = gBS->HandleProtocol (Handle, &gVirtioDeviceProtocolGuid,
|
Status = gBS->HandleProtocol (
|
||||||
(VOID**)&VirtIo);
|
Handle,
|
||||||
|
&gVirtioDeviceProtocolGuid,
|
||||||
|
(VOID **)&VirtIo
|
||||||
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (BOOLEAN)(VirtIo->SubSystemDeviceId ==
|
return (BOOLEAN)(VirtIo->SubSystemDeviceId ==
|
||||||
VIRTIO_SUBSYSTEM_ENTROPY_SOURCE);
|
VIRTIO_SUBSYSTEM_ENTROPY_SOURCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This FILTER_FUNCTION checks if a handle corresponds to a Virtio RNG device at
|
This FILTER_FUNCTION checks if a handle corresponds to a Virtio RNG device at
|
||||||
the EFI_PCI_IO_PROTOCOL level.
|
the EFI_PCI_IO_PROTOCOL level.
|
||||||
@ -288,20 +304,23 @@ STATIC
|
|||||||
BOOLEAN
|
BOOLEAN
|
||||||
EFIAPI
|
EFIAPI
|
||||||
IsVirtioPciRng (
|
IsVirtioPciRng (
|
||||||
IN EFI_HANDLE Handle,
|
IN EFI_HANDLE Handle,
|
||||||
IN CONST CHAR16 *ReportText
|
IN CONST CHAR16 *ReportText
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_PCI_IO_PROTOCOL *PciIo;
|
EFI_PCI_IO_PROTOCOL *PciIo;
|
||||||
UINT16 VendorId;
|
UINT16 VendorId;
|
||||||
UINT16 DeviceId;
|
UINT16 DeviceId;
|
||||||
UINT8 RevisionId;
|
UINT8 RevisionId;
|
||||||
BOOLEAN Virtio10;
|
BOOLEAN Virtio10;
|
||||||
UINT16 SubsystemId;
|
UINT16 SubsystemId;
|
||||||
|
|
||||||
Status = gBS->HandleProtocol (Handle, &gEfiPciIoProtocolGuid,
|
Status = gBS->HandleProtocol (
|
||||||
(VOID**)&PciIo);
|
Handle,
|
||||||
|
&gEfiPciIoProtocolGuid,
|
||||||
|
(VOID **)&PciIo
|
||||||
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -309,11 +328,17 @@ IsVirtioPciRng (
|
|||||||
//
|
//
|
||||||
// Read and check VendorId.
|
// Read and check VendorId.
|
||||||
//
|
//
|
||||||
Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint16, PCI_VENDOR_ID_OFFSET,
|
Status = PciIo->Pci.Read (
|
||||||
1, &VendorId);
|
PciIo,
|
||||||
|
EfiPciIoWidthUint16,
|
||||||
|
PCI_VENDOR_ID_OFFSET,
|
||||||
|
1,
|
||||||
|
&VendorId
|
||||||
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
goto PciError;
|
goto PciError;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VendorId != VIRTIO_VENDOR_ID) {
|
if (VendorId != VIRTIO_VENDOR_ID) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -321,13 +346,24 @@ IsVirtioPciRng (
|
|||||||
//
|
//
|
||||||
// Read DeviceId and RevisionId.
|
// Read DeviceId and RevisionId.
|
||||||
//
|
//
|
||||||
Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint16, PCI_DEVICE_ID_OFFSET,
|
Status = PciIo->Pci.Read (
|
||||||
1, &DeviceId);
|
PciIo,
|
||||||
|
EfiPciIoWidthUint16,
|
||||||
|
PCI_DEVICE_ID_OFFSET,
|
||||||
|
1,
|
||||||
|
&DeviceId
|
||||||
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
goto PciError;
|
goto PciError;
|
||||||
}
|
}
|
||||||
Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, PCI_REVISION_ID_OFFSET,
|
|
||||||
1, &RevisionId);
|
Status = PciIo->Pci.Read (
|
||||||
|
PciIo,
|
||||||
|
EfiPciIoWidthUint8,
|
||||||
|
PCI_REVISION_ID_OFFSET,
|
||||||
|
1,
|
||||||
|
&RevisionId
|
||||||
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
goto PciError;
|
goto PciError;
|
||||||
}
|
}
|
||||||
@ -339,10 +375,11 @@ IsVirtioPciRng (
|
|||||||
// SubsystemId will only play a sanity-check role. Otherwise, DeviceId can
|
// SubsystemId will only play a sanity-check role. Otherwise, DeviceId can
|
||||||
// only be sanity-checked, and SubsystemId will decide.
|
// only be sanity-checked, and SubsystemId will decide.
|
||||||
//
|
//
|
||||||
if (DeviceId == 0x1040 + VIRTIO_SUBSYSTEM_ENTROPY_SOURCE &&
|
if ((DeviceId == 0x1040 + VIRTIO_SUBSYSTEM_ENTROPY_SOURCE) &&
|
||||||
RevisionId >= 0x01) {
|
(RevisionId >= 0x01))
|
||||||
|
{
|
||||||
Virtio10 = TRUE;
|
Virtio10 = TRUE;
|
||||||
} else if (DeviceId >= 0x1000 && DeviceId <= 0x103F && RevisionId == 0x00) {
|
} else if ((DeviceId >= 0x1000) && (DeviceId <= 0x103F) && (RevisionId == 0x00)) {
|
||||||
Virtio10 = FALSE;
|
Virtio10 = FALSE;
|
||||||
} else {
|
} else {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -351,17 +388,25 @@ IsVirtioPciRng (
|
|||||||
//
|
//
|
||||||
// Read and check SubsystemId as dictated by Virtio10.
|
// Read and check SubsystemId as dictated by Virtio10.
|
||||||
//
|
//
|
||||||
Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint16,
|
Status = PciIo->Pci.Read (
|
||||||
PCI_SUBSYSTEM_ID_OFFSET, 1, &SubsystemId);
|
PciIo,
|
||||||
|
EfiPciIoWidthUint16,
|
||||||
|
PCI_SUBSYSTEM_ID_OFFSET,
|
||||||
|
1,
|
||||||
|
&SubsystemId
|
||||||
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
goto PciError;
|
goto PciError;
|
||||||
}
|
}
|
||||||
if (Virtio10 && SubsystemId >= 0x40) {
|
|
||||||
|
if (Virtio10 && (SubsystemId >= 0x40)) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
if (!Virtio10 && SubsystemId == VIRTIO_SUBSYSTEM_ENTROPY_SOURCE) {
|
|
||||||
|
if (!Virtio10 && (SubsystemId == VIRTIO_SUBSYSTEM_ENTROPY_SOURCE)) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
PciError:
|
PciError:
|
||||||
@ -369,7 +414,6 @@ PciError:
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This CALLBACK_FUNCTION attempts to connect a handle non-recursively, asking
|
This CALLBACK_FUNCTION attempts to connect a handle non-recursively, asking
|
||||||
the matching driver to produce all first-level child handles.
|
the matching driver to produce all first-level child handles.
|
||||||
@ -378,11 +422,11 @@ STATIC
|
|||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
Connect (
|
Connect (
|
||||||
IN EFI_HANDLE Handle,
|
IN EFI_HANDLE Handle,
|
||||||
IN CONST CHAR16 *ReportText
|
IN CONST CHAR16 *ReportText
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
|
||||||
Status = gBS->ConnectController (
|
Status = gBS->ConnectController (
|
||||||
Handle, // ControllerHandle
|
Handle, // ControllerHandle
|
||||||
@ -390,11 +434,15 @@ Connect (
|
|||||||
NULL, // RemainingDevicePath -- produce all children
|
NULL, // RemainingDevicePath -- produce all children
|
||||||
FALSE // Recursive
|
FALSE // Recursive
|
||||||
);
|
);
|
||||||
DEBUG ((EFI_ERROR (Status) ? DEBUG_ERROR : DEBUG_VERBOSE, "%a: %s: %r\n",
|
DEBUG ((
|
||||||
__FUNCTION__, ReportText, Status));
|
EFI_ERROR (Status) ? DEBUG_ERROR : DEBUG_VERBOSE,
|
||||||
|
"%a: %s: %r\n",
|
||||||
|
__FUNCTION__,
|
||||||
|
ReportText,
|
||||||
|
Status
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This CALLBACK_FUNCTION retrieves the EFI_DEVICE_PATH_PROTOCOL from the
|
This CALLBACK_FUNCTION retrieves the EFI_DEVICE_PATH_PROTOCOL from the
|
||||||
handle, and adds it to ConOut and ErrOut.
|
handle, and adds it to ConOut and ErrOut.
|
||||||
@ -403,59 +451,78 @@ STATIC
|
|||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
AddOutput (
|
AddOutput (
|
||||||
IN EFI_HANDLE Handle,
|
IN EFI_HANDLE Handle,
|
||||||
IN CONST CHAR16 *ReportText
|
IN CONST CHAR16 *ReportText
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||||
|
|
||||||
DevicePath = DevicePathFromHandle (Handle);
|
DevicePath = DevicePathFromHandle (Handle);
|
||||||
if (DevicePath == NULL) {
|
if (DevicePath == NULL) {
|
||||||
DEBUG ((DEBUG_ERROR, "%a: %s: handle %p: device path not found\n",
|
DEBUG ((
|
||||||
__FUNCTION__, ReportText, Handle));
|
DEBUG_ERROR,
|
||||||
|
"%a: %s: handle %p: device path not found\n",
|
||||||
|
__FUNCTION__,
|
||||||
|
ReportText,
|
||||||
|
Handle
|
||||||
|
));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);
|
Status = EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_ERROR, "%a: %s: adding to ConOut: %r\n", __FUNCTION__,
|
DEBUG ((
|
||||||
ReportText, Status));
|
DEBUG_ERROR,
|
||||||
|
"%a: %s: adding to ConOut: %r\n",
|
||||||
|
__FUNCTION__,
|
||||||
|
ReportText,
|
||||||
|
Status
|
||||||
|
));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL);
|
Status = EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_ERROR, "%a: %s: adding to ErrOut: %r\n", __FUNCTION__,
|
DEBUG ((
|
||||||
ReportText, Status));
|
DEBUG_ERROR,
|
||||||
|
"%a: %s: adding to ErrOut: %r\n",
|
||||||
|
__FUNCTION__,
|
||||||
|
ReportText,
|
||||||
|
Status
|
||||||
|
));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG ((DEBUG_VERBOSE, "%a: %s: added to ConOut and ErrOut\n", __FUNCTION__,
|
DEBUG ((
|
||||||
ReportText));
|
DEBUG_VERBOSE,
|
||||||
|
"%a: %s: added to ConOut and ErrOut\n",
|
||||||
|
__FUNCTION__,
|
||||||
|
ReportText
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC
|
STATIC
|
||||||
VOID
|
VOID
|
||||||
PlatformRegisterFvBootOption (
|
PlatformRegisterFvBootOption (
|
||||||
EFI_GUID *FileGuid,
|
EFI_GUID *FileGuid,
|
||||||
CHAR16 *Description,
|
CHAR16 *Description,
|
||||||
UINT32 Attributes
|
UINT32 Attributes
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
INTN OptionIndex;
|
INTN OptionIndex;
|
||||||
EFI_BOOT_MANAGER_LOAD_OPTION NewOption;
|
EFI_BOOT_MANAGER_LOAD_OPTION NewOption;
|
||||||
EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
|
EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
|
||||||
UINTN BootOptionCount;
|
UINTN BootOptionCount;
|
||||||
MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
|
MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
|
||||||
EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
|
EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
|
||||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||||
|
|
||||||
Status = gBS->HandleProtocol (
|
Status = gBS->HandleProtocol (
|
||||||
gImageHandle,
|
gImageHandle,
|
||||||
&gEfiLoadedImageProtocolGuid,
|
&gEfiLoadedImageProtocolGuid,
|
||||||
(VOID **) &LoadedImage
|
(VOID **)&LoadedImage
|
||||||
);
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
@ -464,7 +531,7 @@ PlatformRegisterFvBootOption (
|
|||||||
ASSERT (DevicePath != NULL);
|
ASSERT (DevicePath != NULL);
|
||||||
DevicePath = AppendDevicePathNode (
|
DevicePath = AppendDevicePathNode (
|
||||||
DevicePath,
|
DevicePath,
|
||||||
(EFI_DEVICE_PATH_PROTOCOL *) &FileNode
|
(EFI_DEVICE_PATH_PROTOCOL *)&FileNode
|
||||||
);
|
);
|
||||||
ASSERT (DevicePath != NULL);
|
ASSERT (DevicePath != NULL);
|
||||||
|
|
||||||
@ -482,22 +549,25 @@ PlatformRegisterFvBootOption (
|
|||||||
FreePool (DevicePath);
|
FreePool (DevicePath);
|
||||||
|
|
||||||
BootOptions = EfiBootManagerGetLoadOptions (
|
BootOptions = EfiBootManagerGetLoadOptions (
|
||||||
&BootOptionCount, LoadOptionTypeBoot
|
&BootOptionCount,
|
||||||
|
LoadOptionTypeBoot
|
||||||
);
|
);
|
||||||
|
|
||||||
OptionIndex = EfiBootManagerFindLoadOption (
|
OptionIndex = EfiBootManagerFindLoadOption (
|
||||||
&NewOption, BootOptions, BootOptionCount
|
&NewOption,
|
||||||
|
BootOptions,
|
||||||
|
BootOptionCount
|
||||||
);
|
);
|
||||||
|
|
||||||
if (OptionIndex == -1) {
|
if (OptionIndex == -1) {
|
||||||
Status = EfiBootManagerAddLoadOptionVariable (&NewOption, MAX_UINTN);
|
Status = EfiBootManagerAddLoadOptionVariable (&NewOption, MAX_UINTN);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
EfiBootManagerFreeLoadOption (&NewOption);
|
EfiBootManagerFreeLoadOption (&NewOption);
|
||||||
EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
|
EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Remove all MemoryMapped(...)/FvFile(...) and Fv(...)/FvFile(...) boot options
|
Remove all MemoryMapped(...)/FvFile(...) and Fv(...)/FvFile(...) boot options
|
||||||
whose device paths do not resolve exactly to an FvFile in the system.
|
whose device paths do not resolve exactly to an FvFile in the system.
|
||||||
@ -518,27 +588,30 @@ RemoveStaleFvFileOptions (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
|
EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
|
||||||
UINTN BootOptionCount;
|
UINTN BootOptionCount;
|
||||||
UINTN Index;
|
UINTN Index;
|
||||||
|
|
||||||
BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount,
|
BootOptions = EfiBootManagerGetLoadOptions (
|
||||||
LoadOptionTypeBoot);
|
&BootOptionCount,
|
||||||
|
LoadOptionTypeBoot
|
||||||
|
);
|
||||||
|
|
||||||
for (Index = 0; Index < BootOptionCount; ++Index) {
|
for (Index = 0; Index < BootOptionCount; ++Index) {
|
||||||
EFI_DEVICE_PATH_PROTOCOL *Node1, *Node2, *SearchNode;
|
EFI_DEVICE_PATH_PROTOCOL *Node1, *Node2, *SearchNode;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_HANDLE FvHandle;
|
EFI_HANDLE FvHandle;
|
||||||
|
|
||||||
//
|
//
|
||||||
// If the device path starts with neither MemoryMapped(...) nor Fv(...),
|
// If the device path starts with neither MemoryMapped(...) nor Fv(...),
|
||||||
// then keep the boot option.
|
// then keep the boot option.
|
||||||
//
|
//
|
||||||
Node1 = BootOptions[Index].FilePath;
|
Node1 = BootOptions[Index].FilePath;
|
||||||
if (!(DevicePathType (Node1) == HARDWARE_DEVICE_PATH &&
|
if (!((DevicePathType (Node1) == HARDWARE_DEVICE_PATH) &&
|
||||||
DevicePathSubType (Node1) == HW_MEMMAP_DP) &&
|
(DevicePathSubType (Node1) == HW_MEMMAP_DP)) &&
|
||||||
!(DevicePathType (Node1) == MEDIA_DEVICE_PATH &&
|
!((DevicePathType (Node1) == MEDIA_DEVICE_PATH) &&
|
||||||
DevicePathSubType (Node1) == MEDIA_PIWG_FW_VOL_DP)) {
|
(DevicePathSubType (Node1) == MEDIA_PIWG_FW_VOL_DP)))
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -547,8 +620,9 @@ RemoveStaleFvFileOptions (
|
|||||||
// option.
|
// option.
|
||||||
//
|
//
|
||||||
Node2 = NextDevicePathNode (Node1);
|
Node2 = NextDevicePathNode (Node1);
|
||||||
if (DevicePathType (Node2) != MEDIA_DEVICE_PATH ||
|
if ((DevicePathType (Node2) != MEDIA_DEVICE_PATH) ||
|
||||||
DevicePathSubType (Node2) != MEDIA_PIWG_FW_FILE_DP) {
|
(DevicePathSubType (Node2) != MEDIA_PIWG_FW_FILE_DP))
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -559,23 +633,29 @@ RemoveStaleFvFileOptions (
|
|||||||
// boot option.
|
// boot option.
|
||||||
//
|
//
|
||||||
SearchNode = Node1;
|
SearchNode = Node1;
|
||||||
Status = gBS->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid,
|
Status = gBS->LocateDevicePath (
|
||||||
&SearchNode, &FvHandle);
|
&gEfiFirmwareVolume2ProtocolGuid,
|
||||||
|
&SearchNode,
|
||||||
|
&FvHandle
|
||||||
|
);
|
||||||
|
|
||||||
if (!EFI_ERROR (Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
//
|
//
|
||||||
// The firmware volume was found; now let's see if it contains the FvFile
|
// The firmware volume was found; now let's see if it contains the FvFile
|
||||||
// identified by GUID.
|
// identified by GUID.
|
||||||
//
|
//
|
||||||
EFI_FIRMWARE_VOLUME2_PROTOCOL *FvProtocol;
|
EFI_FIRMWARE_VOLUME2_PROTOCOL *FvProtocol;
|
||||||
MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFileNode;
|
MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFileNode;
|
||||||
UINTN BufferSize;
|
UINTN BufferSize;
|
||||||
EFI_FV_FILETYPE FoundType;
|
EFI_FV_FILETYPE FoundType;
|
||||||
EFI_FV_FILE_ATTRIBUTES FileAttributes;
|
EFI_FV_FILE_ATTRIBUTES FileAttributes;
|
||||||
UINT32 AuthenticationStatus;
|
UINT32 AuthenticationStatus;
|
||||||
|
|
||||||
Status = gBS->HandleProtocol (FvHandle, &gEfiFirmwareVolume2ProtocolGuid,
|
Status = gBS->HandleProtocol (
|
||||||
(VOID **)&FvProtocol);
|
FvHandle,
|
||||||
|
&gEfiFirmwareVolume2ProtocolGuid,
|
||||||
|
(VOID **)&FvProtocol
|
||||||
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
FvFileNode = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)Node2;
|
FvFileNode = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)Node2;
|
||||||
@ -604,48 +684,53 @@ RemoveStaleFvFileOptions (
|
|||||||
// Delete the boot option.
|
// Delete the boot option.
|
||||||
//
|
//
|
||||||
Status = EfiBootManagerDeleteLoadOptionVariable (
|
Status = EfiBootManagerDeleteLoadOptionVariable (
|
||||||
BootOptions[Index].OptionNumber, LoadOptionTypeBoot);
|
BootOptions[Index].OptionNumber,
|
||||||
|
LoadOptionTypeBoot
|
||||||
|
);
|
||||||
DEBUG_CODE_BEGIN ();
|
DEBUG_CODE_BEGIN ();
|
||||||
CHAR16 *DevicePathString;
|
CHAR16 *DevicePathString;
|
||||||
|
|
||||||
|
DevicePathString = ConvertDevicePathToText (
|
||||||
|
BootOptions[Index].FilePath,
|
||||||
|
FALSE,
|
||||||
|
FALSE
|
||||||
|
);
|
||||||
|
DEBUG ((
|
||||||
|
EFI_ERROR (Status) ? DEBUG_WARN : DEBUG_VERBOSE,
|
||||||
|
"%a: removing stale Boot#%04x %s: %r\n",
|
||||||
|
__FUNCTION__,
|
||||||
|
(UINT32)BootOptions[Index].OptionNumber,
|
||||||
|
DevicePathString == NULL ? L"<unavailable>" : DevicePathString,
|
||||||
|
Status
|
||||||
|
));
|
||||||
|
if (DevicePathString != NULL) {
|
||||||
|
FreePool (DevicePathString);
|
||||||
|
}
|
||||||
|
|
||||||
DevicePathString = ConvertDevicePathToText(BootOptions[Index].FilePath,
|
|
||||||
FALSE, FALSE);
|
|
||||||
DEBUG ((
|
|
||||||
EFI_ERROR (Status) ? DEBUG_WARN : DEBUG_VERBOSE,
|
|
||||||
"%a: removing stale Boot#%04x %s: %r\n",
|
|
||||||
__FUNCTION__,
|
|
||||||
(UINT32)BootOptions[Index].OptionNumber,
|
|
||||||
DevicePathString == NULL ? L"<unavailable>" : DevicePathString,
|
|
||||||
Status
|
|
||||||
));
|
|
||||||
if (DevicePathString != NULL) {
|
|
||||||
FreePool (DevicePathString);
|
|
||||||
}
|
|
||||||
DEBUG_CODE_END ();
|
DEBUG_CODE_END ();
|
||||||
}
|
}
|
||||||
|
|
||||||
EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
|
EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
STATIC
|
STATIC
|
||||||
VOID
|
VOID
|
||||||
PlatformRegisterOptionsAndKeys (
|
PlatformRegisterOptionsAndKeys (
|
||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_INPUT_KEY Enter;
|
EFI_INPUT_KEY Enter;
|
||||||
EFI_INPUT_KEY F2;
|
EFI_INPUT_KEY F2;
|
||||||
EFI_INPUT_KEY Esc;
|
EFI_INPUT_KEY Esc;
|
||||||
EFI_BOOT_MANAGER_LOAD_OPTION BootOption;
|
EFI_BOOT_MANAGER_LOAD_OPTION BootOption;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Register ENTER as CONTINUE key
|
// Register ENTER as CONTINUE key
|
||||||
//
|
//
|
||||||
Enter.ScanCode = SCAN_NULL;
|
Enter.ScanCode = SCAN_NULL;
|
||||||
Enter.UnicodeChar = CHAR_CARRIAGE_RETURN;
|
Enter.UnicodeChar = CHAR_CARRIAGE_RETURN;
|
||||||
Status = EfiBootManagerRegisterContinueKeyOption (0, &Enter, NULL);
|
Status = EfiBootManagerRegisterContinueKeyOption (0, &Enter, NULL);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -655,22 +740,30 @@ PlatformRegisterOptionsAndKeys (
|
|||||||
F2.UnicodeChar = CHAR_NULL;
|
F2.UnicodeChar = CHAR_NULL;
|
||||||
Esc.ScanCode = SCAN_ESC;
|
Esc.ScanCode = SCAN_ESC;
|
||||||
Esc.UnicodeChar = CHAR_NULL;
|
Esc.UnicodeChar = CHAR_NULL;
|
||||||
Status = EfiBootManagerGetBootManagerMenu (&BootOption);
|
Status = EfiBootManagerGetBootManagerMenu (&BootOption);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
Status = EfiBootManagerAddKeyOptionVariable (
|
Status = EfiBootManagerAddKeyOptionVariable (
|
||||||
NULL, (UINT16) BootOption.OptionNumber, 0, &F2, NULL
|
NULL,
|
||||||
|
(UINT16)BootOption.OptionNumber,
|
||||||
|
0,
|
||||||
|
&F2,
|
||||||
|
NULL
|
||||||
);
|
);
|
||||||
ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
|
ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
|
||||||
Status = EfiBootManagerAddKeyOptionVariable (
|
Status = EfiBootManagerAddKeyOptionVariable (
|
||||||
NULL, (UINT16) BootOption.OptionNumber, 0, &Esc, NULL
|
NULL,
|
||||||
|
(UINT16)BootOption.OptionNumber,
|
||||||
|
0,
|
||||||
|
&Esc,
|
||||||
|
NULL
|
||||||
);
|
);
|
||||||
ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
|
ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// BDS Platform Functions
|
// BDS Platform Functions
|
||||||
//
|
//
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Do the platform init, can be customized by OEM/IBV
|
Do the platform init, can be customized by OEM/IBV
|
||||||
Possible things that can be done in PlatformBootManagerBeforeConsole:
|
Possible things that can be done in PlatformBootManagerBeforeConsole:
|
||||||
@ -688,9 +781,9 @@ PlatformBootManagerBeforeConsole (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINT16 FrontPageTimeout;
|
UINT16 FrontPageTimeout;
|
||||||
RETURN_STATUS PcdStatus;
|
RETURN_STATUS PcdStatus;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Signal EndOfDxe PI Event
|
// Signal EndOfDxe PI Event
|
||||||
@ -735,26 +828,40 @@ PlatformBootManagerBeforeConsole (
|
|||||||
//
|
//
|
||||||
// Add the hardcoded short-form USB keyboard device path to ConIn.
|
// Add the hardcoded short-form USB keyboard device path to ConIn.
|
||||||
//
|
//
|
||||||
EfiBootManagerUpdateConsoleVariable (ConIn,
|
EfiBootManagerUpdateConsoleVariable (
|
||||||
(EFI_DEVICE_PATH_PROTOCOL *)&mUsbKeyboard, NULL);
|
ConIn,
|
||||||
|
(EFI_DEVICE_PATH_PROTOCOL *)&mUsbKeyboard,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Add the hardcoded serial console device path to ConIn, ConOut, ErrOut.
|
// Add the hardcoded serial console device path to ConIn, ConOut, ErrOut.
|
||||||
//
|
//
|
||||||
CopyGuid (&mSerialConsole.TermType.Guid,
|
CopyGuid (
|
||||||
PcdGetPtr (PcdTerminalTypeGuidBuffer));
|
&mSerialConsole.TermType.Guid,
|
||||||
EfiBootManagerUpdateConsoleVariable (ConIn,
|
PcdGetPtr (PcdTerminalTypeGuidBuffer)
|
||||||
(EFI_DEVICE_PATH_PROTOCOL *)&mSerialConsole, NULL);
|
);
|
||||||
EfiBootManagerUpdateConsoleVariable (ConOut,
|
EfiBootManagerUpdateConsoleVariable (
|
||||||
(EFI_DEVICE_PATH_PROTOCOL *)&mSerialConsole, NULL);
|
ConIn,
|
||||||
EfiBootManagerUpdateConsoleVariable (ErrOut,
|
(EFI_DEVICE_PATH_PROTOCOL *)&mSerialConsole,
|
||||||
(EFI_DEVICE_PATH_PROTOCOL *)&mSerialConsole, NULL);
|
NULL
|
||||||
|
);
|
||||||
|
EfiBootManagerUpdateConsoleVariable (
|
||||||
|
ConOut,
|
||||||
|
(EFI_DEVICE_PATH_PROTOCOL *)&mSerialConsole,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
EfiBootManagerUpdateConsoleVariable (
|
||||||
|
ErrOut,
|
||||||
|
(EFI_DEVICE_PATH_PROTOCOL *)&mSerialConsole,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Set the front page timeout from the QEMU configuration.
|
// Set the front page timeout from the QEMU configuration.
|
||||||
//
|
//
|
||||||
FrontPageTimeout = GetFrontPageTimeoutFromQemu ();
|
FrontPageTimeout = GetFrontPageTimeoutFromQemu ();
|
||||||
PcdStatus = PcdSet16S (PcdPlatformBootTimeOut, FrontPageTimeout);
|
PcdStatus = PcdSet16S (PcdPlatformBootTimeOut, FrontPageTimeout);
|
||||||
ASSERT_RETURN_ERROR (PcdStatus);
|
ASSERT_RETURN_ERROR (PcdStatus);
|
||||||
//
|
//
|
||||||
// Reflect the PCD in the standard Timeout variable.
|
// Reflect the PCD in the standard Timeout variable.
|
||||||
@ -812,7 +919,7 @@ PlatformBootManagerAfterConsole (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
RETURN_STATUS Status;
|
RETURN_STATUS Status;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Show the splash screen.
|
// Show the splash screen.
|
||||||
@ -848,7 +955,9 @@ PlatformBootManagerAfterConsole (
|
|||||||
// Register UEFI Shell
|
// Register UEFI Shell
|
||||||
//
|
//
|
||||||
PlatformRegisterFvBootOption (
|
PlatformRegisterFvBootOption (
|
||||||
&gUefiShellFileGuid, L"EFI Internal Shell", LOAD_OPTION_ACTIVE
|
&gUefiShellFileGuid,
|
||||||
|
L"EFI Internal Shell",
|
||||||
|
LOAD_OPTION_ACTIVE
|
||||||
);
|
);
|
||||||
|
|
||||||
RemoveStaleFvFileOptions ();
|
RemoveStaleFvFileOptions ();
|
||||||
@ -866,12 +975,12 @@ PlatformBootManagerAfterConsole (
|
|||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PlatformBootManagerWaitCallback (
|
PlatformBootManagerWaitCallback (
|
||||||
UINT16 TimeoutRemain
|
UINT16 TimeoutRemain
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Black;
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Black;
|
||||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION White;
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION White;
|
||||||
UINT16 TimeoutInitial;
|
UINT16 TimeoutInitial;
|
||||||
|
|
||||||
TimeoutInitial = PcdGet16 (PcdPlatformBootTimeOut);
|
TimeoutInitial = PcdGet16 (PcdPlatformBootTimeOut);
|
||||||
|
|
||||||
@ -909,10 +1018,10 @@ PlatformBootManagerUnableToBoot (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_INPUT_KEY Key;
|
EFI_INPUT_KEY Key;
|
||||||
EFI_BOOT_MANAGER_LOAD_OPTION BootManagerMenu;
|
EFI_BOOT_MANAGER_LOAD_OPTION BootManagerMenu;
|
||||||
UINTN Index;
|
UINTN Index;
|
||||||
|
|
||||||
//
|
//
|
||||||
// BootManagerMenu doesn't contain the correct information when return status
|
// BootManagerMenu doesn't contain the correct information when return status
|
||||||
@ -922,6 +1031,7 @@ PlatformBootManagerUnableToBoot (
|
|||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Normally BdsDxe does not print anything to the system console, but this is
|
// Normally BdsDxe does not print anything to the system console, but this is
|
||||||
// a last resort -- the end-user will likely not see any DEBUG messages
|
// a last resort -- the end-user will likely not see any DEBUG messages
|
||||||
@ -951,7 +1061,7 @@ PlatformBootManagerUnableToBoot (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (;;) {
|
for ( ; ;) {
|
||||||
EfiBootManagerBoot (&BootManagerMenu);
|
EfiBootManagerBoot (&BootManagerMenu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,8 +40,8 @@ TryRunningQemuKernel (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_HANDLE KernelImageHandle;
|
EFI_HANDLE KernelImageHandle;
|
||||||
|
|
||||||
Status = QemuLoadKernelImage (&KernelImageHandle);
|
Status = QemuLoadKernelImage (&KernelImageHandle);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
@ -51,18 +51,24 @@ TryRunningQemuKernel (
|
|||||||
//
|
//
|
||||||
// Signal the EFI_EVENT_GROUP_READY_TO_BOOT event.
|
// Signal the EFI_EVENT_GROUP_READY_TO_BOOT event.
|
||||||
//
|
//
|
||||||
EfiSignalEventReadyToBoot();
|
EfiSignalEventReadyToBoot ();
|
||||||
|
|
||||||
REPORT_STATUS_CODE (EFI_PROGRESS_CODE,
|
REPORT_STATUS_CODE (
|
||||||
(EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_PC_READY_TO_BOOT_EVENT));
|
EFI_PROGRESS_CODE,
|
||||||
|
(EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_PC_READY_TO_BOOT_EVENT)
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Start the image.
|
// Start the image.
|
||||||
//
|
//
|
||||||
Status = QemuStartKernelImage (&KernelImageHandle);
|
Status = QemuStartKernelImage (&KernelImageHandle);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_ERROR, "%a: QemuStartKernelImage(): %r\n", __FUNCTION__,
|
DEBUG ((
|
||||||
Status));
|
DEBUG_ERROR,
|
||||||
|
"%a: QemuStartKernelImage(): %r\n",
|
||||||
|
__FUNCTION__,
|
||||||
|
Status
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
QemuUnloadKernelImage (KernelImageHandle);
|
QemuUnloadKernelImage (KernelImageHandle);
|
||||||
|
@ -19,13 +19,13 @@
|
|||||||
#include <Guid/EarlyPL011BaseAddress.h>
|
#include <Guid/EarlyPL011BaseAddress.h>
|
||||||
#include <Guid/FdtHob.h>
|
#include <Guid/FdtHob.h>
|
||||||
|
|
||||||
STATIC CONST EFI_PEI_PPI_DESCRIPTOR mTpm2DiscoveredPpi = {
|
STATIC CONST EFI_PEI_PPI_DESCRIPTOR mTpm2DiscoveredPpi = {
|
||||||
EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
|
EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
|
||||||
&gOvmfTpmDiscoveredPpiGuid,
|
&gOvmfTpmDiscoveredPpiGuid,
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
STATIC CONST EFI_PEI_PPI_DESCRIPTOR mTpm2InitializationDonePpi = {
|
STATIC CONST EFI_PEI_PPI_DESCRIPTOR mTpm2InitializationDonePpi = {
|
||||||
EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
|
EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
|
||||||
&gPeiTpmInitializationDonePpiGuid,
|
&gPeiTpmInitializationDonePpiGuid,
|
||||||
NULL
|
NULL
|
||||||
@ -37,33 +37,33 @@ PlatformPeim (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
VOID *Base;
|
VOID *Base;
|
||||||
VOID *NewBase;
|
VOID *NewBase;
|
||||||
UINTN FdtSize;
|
UINTN FdtSize;
|
||||||
UINTN FdtPages;
|
UINTN FdtPages;
|
||||||
UINT64 *FdtHobData;
|
UINT64 *FdtHobData;
|
||||||
UINT64 *UartHobData;
|
UINT64 *UartHobData;
|
||||||
INT32 Node, Prev;
|
INT32 Node, Prev;
|
||||||
INT32 Parent, Depth;
|
INT32 Parent, Depth;
|
||||||
CONST CHAR8 *Compatible;
|
CONST CHAR8 *Compatible;
|
||||||
CONST CHAR8 *CompItem;
|
CONST CHAR8 *CompItem;
|
||||||
CONST CHAR8 *NodeStatus;
|
CONST CHAR8 *NodeStatus;
|
||||||
INT32 Len;
|
INT32 Len;
|
||||||
INT32 RangesLen;
|
INT32 RangesLen;
|
||||||
INT32 StatusLen;
|
INT32 StatusLen;
|
||||||
CONST UINT64 *RegProp;
|
CONST UINT64 *RegProp;
|
||||||
CONST UINT32 *RangesProp;
|
CONST UINT32 *RangesProp;
|
||||||
UINT64 UartBase;
|
UINT64 UartBase;
|
||||||
UINT64 TpmBase;
|
UINT64 TpmBase;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
|
||||||
Base = (VOID*)(UINTN)PcdGet64 (PcdDeviceTreeInitialBaseAddress);
|
Base = (VOID *)(UINTN)PcdGet64 (PcdDeviceTreeInitialBaseAddress);
|
||||||
ASSERT (Base != NULL);
|
ASSERT (Base != NULL);
|
||||||
ASSERT (fdt_check_header (Base) == 0);
|
ASSERT (fdt_check_header (Base) == 0);
|
||||||
|
|
||||||
FdtSize = fdt_totalsize (Base) + PcdGet32 (PcdDeviceTreeAllocationPadding);
|
FdtSize = fdt_totalsize (Base) + PcdGet32 (PcdDeviceTreeAllocationPadding);
|
||||||
FdtPages = EFI_SIZE_TO_PAGES (FdtSize);
|
FdtPages = EFI_SIZE_TO_PAGES (FdtSize);
|
||||||
NewBase = AllocatePages (FdtPages);
|
NewBase = AllocatePages (FdtPages);
|
||||||
ASSERT (NewBase != NULL);
|
ASSERT (NewBase != NULL);
|
||||||
fdt_open_into (Base, NewBase, EFI_PAGES_TO_SIZE (FdtPages));
|
fdt_open_into (Base, NewBase, EFI_PAGES_TO_SIZE (FdtPages));
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ PlatformPeim (
|
|||||||
//
|
//
|
||||||
Parent = 0;
|
Parent = 0;
|
||||||
|
|
||||||
for (Prev = Depth = 0;; Prev = Node) {
|
for (Prev = Depth = 0; ; Prev = Node) {
|
||||||
Node = fdt_next_node (Base, Prev, &Depth);
|
Node = fdt_next_node (Base, Prev, &Depth);
|
||||||
if (Node < 0) {
|
if (Node < 0) {
|
||||||
break;
|
break;
|
||||||
@ -98,11 +98,11 @@ PlatformPeim (
|
|||||||
// Iterate over the NULL-separated items in the compatible string
|
// Iterate over the NULL-separated items in the compatible string
|
||||||
//
|
//
|
||||||
for (CompItem = Compatible; CompItem != NULL && CompItem < Compatible + Len;
|
for (CompItem = Compatible; CompItem != NULL && CompItem < Compatible + Len;
|
||||||
CompItem += 1 + AsciiStrLen (CompItem)) {
|
CompItem += 1 + AsciiStrLen (CompItem))
|
||||||
|
{
|
||||||
if (AsciiStrCmp (CompItem, "arm,pl011") == 0) {
|
if (AsciiStrCmp (CompItem, "arm,pl011") == 0) {
|
||||||
NodeStatus = fdt_getprop (Base, Node, "status", &StatusLen);
|
NodeStatus = fdt_getprop (Base, Node, "status", &StatusLen);
|
||||||
if (NodeStatus != NULL && AsciiStrCmp (NodeStatus, "okay") != 0) {
|
if ((NodeStatus != NULL) && (AsciiStrCmp (NodeStatus, "okay") != 0)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,8 +116,8 @@ PlatformPeim (
|
|||||||
*UartHobData = UartBase;
|
*UartHobData = UartBase;
|
||||||
break;
|
break;
|
||||||
} else if (FeaturePcdGet (PcdTpm2SupportEnabled) &&
|
} else if (FeaturePcdGet (PcdTpm2SupportEnabled) &&
|
||||||
AsciiStrCmp (CompItem, "tcg,tpm-tis-mmio") == 0) {
|
(AsciiStrCmp (CompItem, "tcg,tpm-tis-mmio") == 0))
|
||||||
|
{
|
||||||
RegProp = fdt_getprop (Base, Node, "reg", &Len);
|
RegProp = fdt_getprop (Base, Node, "reg", &Len);
|
||||||
ASSERT (Len == 8 || Len == 16);
|
ASSERT (Len == 8 || Len == 16);
|
||||||
if (Len == 8) {
|
if (Len == 8) {
|
||||||
@ -145,9 +145,12 @@ PlatformPeim (
|
|||||||
// assume a single translated range with 2 cells for the parent base
|
// assume a single translated range with 2 cells for the parent base
|
||||||
//
|
//
|
||||||
if (RangesLen != Len + 2 * sizeof (UINT32)) {
|
if (RangesLen != Len + 2 * sizeof (UINT32)) {
|
||||||
DEBUG ((DEBUG_WARN,
|
DEBUG ((
|
||||||
|
DEBUG_WARN,
|
||||||
"%a: 'ranges' property has unexpected size %d\n",
|
"%a: 'ranges' property has unexpected size %d\n",
|
||||||
__FUNCTION__, RangesLen));
|
__FUNCTION__,
|
||||||
|
RangesLen
|
||||||
|
));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,9 +164,10 @@ PlatformPeim (
|
|||||||
// advance RangesProp to the parent bus address
|
// advance RangesProp to the parent bus address
|
||||||
//
|
//
|
||||||
RangesProp = (UINT32 *)((UINT8 *)RangesProp + Len / 2);
|
RangesProp = (UINT32 *)((UINT8 *)RangesProp + Len / 2);
|
||||||
TpmBase += fdt64_to_cpu (ReadUnaligned64 ((UINT64 *)RangesProp));
|
TpmBase += fdt64_to_cpu (ReadUnaligned64 ((UINT64 *)RangesProp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -180,6 +184,7 @@ PlatformPeim (
|
|||||||
} else {
|
} else {
|
||||||
Status = PeiServicesInstallPpi (&mTpm2InitializationDonePpi);
|
Status = PeiServicesInstallPpi (&mTpm2InitializationDonePpi);
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
#include <Library/MemoryAllocationLib.h>
|
#include <Library/MemoryAllocationLib.h>
|
||||||
|
|
||||||
// Number of Virtual Memory Map Descriptors
|
// Number of Virtual Memory Map Descriptors
|
||||||
#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS 5
|
#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS 5
|
||||||
|
|
||||||
//
|
//
|
||||||
// mach-virt's core peripherals such as the UART, the GIC and the RTC are
|
// mach-virt's core peripherals such as the UART, the GIC and the RTC are
|
||||||
@ -21,8 +21,8 @@
|
|||||||
// in its entirety rather than device by device. Note that it does not
|
// in its entirety rather than device by device. Note that it does not
|
||||||
// cover any of the NOR flash banks or PCI resource windows.
|
// cover any of the NOR flash banks or PCI resource windows.
|
||||||
//
|
//
|
||||||
#define MACH_VIRT_PERIPH_BASE 0x08000000
|
#define MACH_VIRT_PERIPH_BASE 0x08000000
|
||||||
#define MACH_VIRT_PERIPH_SIZE SIZE_128MB
|
#define MACH_VIRT_PERIPH_SIZE SIZE_128MB
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Return the Virtual Memory Map of your platform
|
Return the Virtual Memory Map of your platform
|
||||||
@ -39,15 +39,17 @@
|
|||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
ArmVirtGetMemoryMap (
|
ArmVirtGetMemoryMap (
|
||||||
OUT ARM_MEMORY_REGION_DESCRIPTOR **VirtualMemoryMap
|
OUT ARM_MEMORY_REGION_DESCRIPTOR **VirtualMemoryMap
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ARM_MEMORY_REGION_DESCRIPTOR *VirtualMemoryTable;
|
ARM_MEMORY_REGION_DESCRIPTOR *VirtualMemoryTable;
|
||||||
|
|
||||||
ASSERT (VirtualMemoryMap != NULL);
|
ASSERT (VirtualMemoryMap != NULL);
|
||||||
|
|
||||||
VirtualMemoryTable = AllocatePool (sizeof (ARM_MEMORY_REGION_DESCRIPTOR) *
|
VirtualMemoryTable = AllocatePool (
|
||||||
MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS);
|
sizeof (ARM_MEMORY_REGION_DESCRIPTOR) *
|
||||||
|
MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS
|
||||||
|
);
|
||||||
|
|
||||||
if (VirtualMemoryTable == NULL) {
|
if (VirtualMemoryTable == NULL) {
|
||||||
DEBUG ((DEBUG_ERROR, "%a: Error: Failed AllocatePool()\n", __FUNCTION__));
|
DEBUG ((DEBUG_ERROR, "%a: Error: Failed AllocatePool()\n", __FUNCTION__));
|
||||||
@ -60,14 +62,17 @@ ArmVirtGetMemoryMap (
|
|||||||
VirtualMemoryTable[0].Length = PcdGet64 (PcdSystemMemorySize);
|
VirtualMemoryTable[0].Length = PcdGet64 (PcdSystemMemorySize);
|
||||||
VirtualMemoryTable[0].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK;
|
VirtualMemoryTable[0].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK;
|
||||||
|
|
||||||
DEBUG ((DEBUG_INFO, "%a: Dumping System DRAM Memory Map:\n"
|
DEBUG ((
|
||||||
"\tPhysicalBase: 0x%lX\n"
|
DEBUG_INFO,
|
||||||
"\tVirtualBase: 0x%lX\n"
|
"%a: Dumping System DRAM Memory Map:\n"
|
||||||
"\tLength: 0x%lX\n",
|
"\tPhysicalBase: 0x%lX\n"
|
||||||
__FUNCTION__,
|
"\tVirtualBase: 0x%lX\n"
|
||||||
VirtualMemoryTable[0].PhysicalBase,
|
"\tLength: 0x%lX\n",
|
||||||
VirtualMemoryTable[0].VirtualBase,
|
__FUNCTION__,
|
||||||
VirtualMemoryTable[0].Length));
|
VirtualMemoryTable[0].PhysicalBase,
|
||||||
|
VirtualMemoryTable[0].VirtualBase,
|
||||||
|
VirtualMemoryTable[0].Length
|
||||||
|
));
|
||||||
|
|
||||||
// Memory mapped peripherals (UART, RTC, GIC, virtio-mmio, etc)
|
// Memory mapped peripherals (UART, RTC, GIC, virtio-mmio, etc)
|
||||||
VirtualMemoryTable[1].PhysicalBase = MACH_VIRT_PERIPH_BASE;
|
VirtualMemoryTable[1].PhysicalBase = MACH_VIRT_PERIPH_BASE;
|
||||||
|
@ -17,14 +17,14 @@ QemuVirtMemInfoPeiLibConstructor (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
VOID *DeviceTreeBase;
|
VOID *DeviceTreeBase;
|
||||||
INT32 Node, Prev;
|
INT32 Node, Prev;
|
||||||
UINT64 NewBase, CurBase;
|
UINT64 NewBase, CurBase;
|
||||||
UINT64 NewSize, CurSize;
|
UINT64 NewSize, CurSize;
|
||||||
CONST CHAR8 *Type;
|
CONST CHAR8 *Type;
|
||||||
INT32 Len;
|
INT32 Len;
|
||||||
CONST UINT64 *RegProp;
|
CONST UINT64 *RegProp;
|
||||||
RETURN_STATUS PcdStatus;
|
RETURN_STATUS PcdStatus;
|
||||||
|
|
||||||
NewBase = 0;
|
NewBase = 0;
|
||||||
NewSize = 0;
|
NewSize = 0;
|
||||||
@ -40,7 +40,7 @@ QemuVirtMemInfoPeiLibConstructor (
|
|||||||
//
|
//
|
||||||
// Look for the lowest memory node
|
// Look for the lowest memory node
|
||||||
//
|
//
|
||||||
for (Prev = 0;; Prev = Node) {
|
for (Prev = 0; ; Prev = Node) {
|
||||||
Node = fdt_next_node (DeviceTreeBase, Prev, NULL);
|
Node = fdt_next_node (DeviceTreeBase, Prev, NULL);
|
||||||
if (Node < 0) {
|
if (Node < 0) {
|
||||||
break;
|
break;
|
||||||
@ -50,27 +50,34 @@ QemuVirtMemInfoPeiLibConstructor (
|
|||||||
// Check for memory node
|
// Check for memory node
|
||||||
//
|
//
|
||||||
Type = fdt_getprop (DeviceTreeBase, Node, "device_type", &Len);
|
Type = fdt_getprop (DeviceTreeBase, Node, "device_type", &Len);
|
||||||
if (Type && AsciiStrnCmp (Type, "memory", Len) == 0) {
|
if (Type && (AsciiStrnCmp (Type, "memory", Len) == 0)) {
|
||||||
//
|
//
|
||||||
// Get the 'reg' property of this node. For now, we will assume
|
// Get the 'reg' property of this node. For now, we will assume
|
||||||
// two 8 byte quantities for base and size, respectively.
|
// two 8 byte quantities for base and size, respectively.
|
||||||
//
|
//
|
||||||
RegProp = fdt_getprop (DeviceTreeBase, Node, "reg", &Len);
|
RegProp = fdt_getprop (DeviceTreeBase, Node, "reg", &Len);
|
||||||
if (RegProp != 0 && Len == (2 * sizeof (UINT64))) {
|
if ((RegProp != 0) && (Len == (2 * sizeof (UINT64)))) {
|
||||||
|
|
||||||
CurBase = fdt64_to_cpu (ReadUnaligned64 (RegProp));
|
CurBase = fdt64_to_cpu (ReadUnaligned64 (RegProp));
|
||||||
CurSize = fdt64_to_cpu (ReadUnaligned64 (RegProp + 1));
|
CurSize = fdt64_to_cpu (ReadUnaligned64 (RegProp + 1));
|
||||||
|
|
||||||
DEBUG ((DEBUG_INFO, "%a: System RAM @ 0x%lx - 0x%lx\n",
|
DEBUG ((
|
||||||
__FUNCTION__, CurBase, CurBase + CurSize - 1));
|
DEBUG_INFO,
|
||||||
|
"%a: System RAM @ 0x%lx - 0x%lx\n",
|
||||||
|
__FUNCTION__,
|
||||||
|
CurBase,
|
||||||
|
CurBase + CurSize - 1
|
||||||
|
));
|
||||||
|
|
||||||
if (NewBase > CurBase || NewBase == 0) {
|
if ((NewBase > CurBase) || (NewBase == 0)) {
|
||||||
NewBase = CurBase;
|
NewBase = CurBase;
|
||||||
NewSize = CurSize;
|
NewSize = CurSize;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DEBUG ((DEBUG_ERROR, "%a: Failed to parse FDT memory node\n",
|
DEBUG ((
|
||||||
__FUNCTION__));
|
DEBUG_ERROR,
|
||||||
|
"%a: Failed to parse FDT memory node\n",
|
||||||
|
__FUNCTION__
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -94,7 +101,8 @@ QemuVirtMemInfoPeiLibConstructor (
|
|||||||
ASSERT (
|
ASSERT (
|
||||||
(((UINT64)PcdGet64 (PcdFdBaseAddress) +
|
(((UINT64)PcdGet64 (PcdFdBaseAddress) +
|
||||||
(UINT64)PcdGet32 (PcdFdSize)) <= NewBase) ||
|
(UINT64)PcdGet32 (PcdFdSize)) <= NewBase) ||
|
||||||
((UINT64)PcdGet64 (PcdFdBaseAddress) >= (NewBase + NewSize)));
|
((UINT64)PcdGet64 (PcdFdBaseAddress) >= (NewBase + NewSize))
|
||||||
|
);
|
||||||
|
|
||||||
return RETURN_SUCCESS;
|
return RETURN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,9 @@ ArmGenericTimerEnableTimer (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINTN TimerCtrlReg;
|
UINTN TimerCtrlReg;
|
||||||
|
|
||||||
TimerCtrlReg = ArmReadCntvCtl ();
|
TimerCtrlReg = ArmReadCntvCtl ();
|
||||||
TimerCtrlReg |= ARM_ARCH_TIMER_ENABLE;
|
TimerCtrlReg |= ARM_ARCH_TIMER_ENABLE;
|
||||||
ArmWriteCntvCtl (TimerCtrlReg);
|
ArmWriteCntvCtl (TimerCtrlReg);
|
||||||
}
|
}
|
||||||
@ -29,9 +29,9 @@ ArmGenericTimerReenableTimer (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINTN TimerCtrlReg;
|
UINTN TimerCtrlReg;
|
||||||
|
|
||||||
TimerCtrlReg = ArmReadCntvCtl ();
|
TimerCtrlReg = ArmReadCntvCtl ();
|
||||||
TimerCtrlReg |= ARM_ARCH_TIMER_ENABLE;
|
TimerCtrlReg |= ARM_ARCH_TIMER_ENABLE;
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -50,9 +50,9 @@ ArmGenericTimerDisableTimer (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINTN TimerCtrlReg;
|
UINTN TimerCtrlReg;
|
||||||
|
|
||||||
TimerCtrlReg = ArmReadCntvCtl ();
|
TimerCtrlReg = ArmReadCntvCtl ();
|
||||||
TimerCtrlReg &= ~ARM_ARCH_TIMER_ENABLE;
|
TimerCtrlReg &= ~ARM_ARCH_TIMER_ENABLE;
|
||||||
ArmWriteCntvCtl (TimerCtrlReg);
|
ArmWriteCntvCtl (TimerCtrlReg);
|
||||||
}
|
}
|
||||||
@ -84,11 +84,10 @@ ArmGenericTimerGetTimerVal (
|
|||||||
return ArmReadCntvTval ();
|
return ArmReadCntvTval ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
ArmGenericTimerSetTimerVal (
|
ArmGenericTimerSetTimerVal (
|
||||||
IN UINTN Value
|
IN UINTN Value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ArmWriteCntvTval (Value);
|
ArmWriteCntvTval (Value);
|
||||||
@ -115,7 +114,7 @@ ArmGenericTimerGetTimerCtrlReg (
|
|||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
ArmGenericTimerSetTimerCtrlReg (
|
ArmGenericTimerSetTimerCtrlReg (
|
||||||
UINTN Value
|
UINTN Value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ArmWriteCntvCtl (Value);
|
ArmWriteCntvCtl (Value);
|
||||||
@ -133,7 +132,7 @@ ArmGenericTimerGetCompareVal (
|
|||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
ArmGenericTimerSetCompareVal (
|
ArmGenericTimerSetCompareVal (
|
||||||
IN UINT64 Value
|
IN UINT64 Value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ArmWriteCntvCval (Value);
|
ArmWriteCntvCval (Value);
|
||||||
|
@ -29,10 +29,10 @@ STATIC ARM_MEMORY_REGION_DESCRIPTOR mVirtualMemoryTable[2];
|
|||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
ArmVirtGetMemoryMap (
|
ArmVirtGetMemoryMap (
|
||||||
OUT ARM_MEMORY_REGION_DESCRIPTOR **VirtualMemoryMap
|
OUT ARM_MEMORY_REGION_DESCRIPTOR **VirtualMemoryMap
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_PHYSICAL_ADDRESS TopOfAddressSpace;
|
EFI_PHYSICAL_ADDRESS TopOfAddressSpace;
|
||||||
|
|
||||||
ASSERT (VirtualMemoryMap != NULL);
|
ASSERT (VirtualMemoryMap != NULL);
|
||||||
|
|
||||||
|
@ -18,20 +18,20 @@
|
|||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
PlatformHasAcpiDt (
|
PlatformHasAcpiDt (
|
||||||
IN EFI_HANDLE ImageHandle,
|
IN EFI_HANDLE ImageHandle,
|
||||||
IN EFI_SYSTEM_TABLE *SystemTable
|
IN EFI_SYSTEM_TABLE *SystemTable
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
FIRMWARE_CONFIG_ITEM FwCfgItem;
|
FIRMWARE_CONFIG_ITEM FwCfgItem;
|
||||||
UINTN FwCfgSize;
|
UINTN FwCfgSize;
|
||||||
|
|
||||||
//
|
//
|
||||||
// If we fail to install any of the necessary protocols below, the OS will be
|
// If we fail to install any of the necessary protocols below, the OS will be
|
||||||
// unbootable anyway (due to lacking hardware description), so tolerate no
|
// unbootable anyway (due to lacking hardware description), so tolerate no
|
||||||
// errors here.
|
// errors here.
|
||||||
//
|
//
|
||||||
if (MAX_UINTN == MAX_UINT64 &&
|
if ((MAX_UINTN == MAX_UINT64) &&
|
||||||
!PcdGetBool (PcdForceNoAcpi) &&
|
!PcdGetBool (PcdForceNoAcpi) &&
|
||||||
!EFI_ERROR (
|
!EFI_ERROR (
|
||||||
QemuFwCfgFindFile (
|
QemuFwCfgFindFile (
|
||||||
@ -39,7 +39,8 @@ PlatformHasAcpiDt (
|
|||||||
&FwCfgItem,
|
&FwCfgItem,
|
||||||
&FwCfgSize
|
&FwCfgSize
|
||||||
)
|
)
|
||||||
)) {
|
))
|
||||||
|
{
|
||||||
//
|
//
|
||||||
// Only make ACPI available on 64-bit systems, and only if QEMU generates
|
// Only make ACPI available on 64-bit systems, and only if QEMU generates
|
||||||
// (a subset of) the ACPI tables.
|
// (a subset of) the ACPI tables.
|
||||||
|
@ -14,11 +14,11 @@ FindMemnode (
|
|||||||
OUT UINT64 *SystemMemorySize
|
OUT UINT64 *SystemMemorySize
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
INT32 MemoryNode;
|
INT32 MemoryNode;
|
||||||
INT32 AddressCells;
|
INT32 AddressCells;
|
||||||
INT32 SizeCells;
|
INT32 SizeCells;
|
||||||
INT32 Length;
|
INT32 Length;
|
||||||
CONST INT32 *Prop;
|
CONST INT32 *Prop;
|
||||||
|
|
||||||
if (fdt_check_header (DeviceTreeBlob) != 0) {
|
if (fdt_check_header (DeviceTreeBlob) != 0) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -37,7 +37,7 @@ FindMemnode (
|
|||||||
// from the root node, or use the default if not provided.
|
// from the root node, or use the default if not provided.
|
||||||
//
|
//
|
||||||
AddressCells = 1;
|
AddressCells = 1;
|
||||||
SizeCells = 1;
|
SizeCells = 1;
|
||||||
|
|
||||||
Prop = fdt_getprop (DeviceTreeBlob, 0, "#address-cells", &Length);
|
Prop = fdt_getprop (DeviceTreeBlob, 0, "#address-cells", &Length);
|
||||||
if (Length == 4) {
|
if (Length == 4) {
|
||||||
@ -63,6 +63,7 @@ FindMemnode (
|
|||||||
if (AddressCells > 1) {
|
if (AddressCells > 1) {
|
||||||
*SystemMemoryBase = (*SystemMemoryBase << 32) | fdt32_to_cpu (Prop[1]);
|
*SystemMemoryBase = (*SystemMemoryBase << 32) | fdt32_to_cpu (Prop[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Prop += AddressCells;
|
Prop += AddressCells;
|
||||||
|
|
||||||
*SystemMemorySize = fdt32_to_cpu (Prop[0]);
|
*SystemMemorySize = fdt32_to_cpu (Prop[0]);
|
||||||
@ -75,10 +76,10 @@ FindMemnode (
|
|||||||
|
|
||||||
VOID
|
VOID
|
||||||
CopyFdt (
|
CopyFdt (
|
||||||
IN VOID *FdtDest,
|
IN VOID *FdtDest,
|
||||||
IN VOID *FdtSource
|
IN VOID *FdtSource
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
fdt_pack(FdtSource);
|
fdt_pack (FdtSource);
|
||||||
CopyMem (FdtDest, FdtSource, fdt_totalsize (FdtSource));
|
CopyMem (FdtDest, FdtSource, fdt_totalsize (FdtSource));
|
||||||
}
|
}
|
||||||
|
@ -30,27 +30,27 @@ ProcessLibraryConstructorList (
|
|||||||
|
|
||||||
VOID
|
VOID
|
||||||
PrePiMain (
|
PrePiMain (
|
||||||
IN UINTN UefiMemoryBase,
|
IN UINTN UefiMemoryBase,
|
||||||
IN UINTN StacksBase,
|
IN UINTN StacksBase,
|
||||||
IN UINT64 StartTimeStamp
|
IN UINT64 StartTimeStamp
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_HOB_HANDOFF_INFO_TABLE* HobList;
|
EFI_HOB_HANDOFF_INFO_TABLE *HobList;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
CHAR8 Buffer[100];
|
CHAR8 Buffer[100];
|
||||||
UINTN CharCount;
|
UINTN CharCount;
|
||||||
UINTN StacksSize;
|
UINTN StacksSize;
|
||||||
|
|
||||||
// Initialize the architecture specific bits
|
// Initialize the architecture specific bits
|
||||||
ArchInitialize ();
|
ArchInitialize ();
|
||||||
|
|
||||||
// Declare the PI/UEFI memory region
|
// Declare the PI/UEFI memory region
|
||||||
HobList = HobConstructor (
|
HobList = HobConstructor (
|
||||||
(VOID*)UefiMemoryBase,
|
(VOID *)UefiMemoryBase,
|
||||||
FixedPcdGet32 (PcdSystemMemoryUefiRegionSize),
|
FixedPcdGet32 (PcdSystemMemoryUefiRegionSize),
|
||||||
(VOID*)UefiMemoryBase,
|
(VOID *)UefiMemoryBase,
|
||||||
(VOID*)StacksBase // The top of the UEFI Memory is reserved for the stacks
|
(VOID *)StacksBase // The top of the UEFI Memory is reserved for the stacks
|
||||||
);
|
);
|
||||||
PrePeiSetHobList (HobList);
|
PrePeiSetHobList (HobList);
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -58,7 +58,7 @@ PrePiMain (
|
|||||||
// modifications we made with the caches and MMU off (such as the applied
|
// modifications we made with the caches and MMU off (such as the applied
|
||||||
// relocations) don't become invisible once we turn them on.
|
// relocations) don't become invisible once we turn them on.
|
||||||
//
|
//
|
||||||
InvalidateDataCacheRange((VOID *)(UINTN)PcdGet64 (PcdFdBaseAddress), PcdGet32 (PcdFdSize));
|
InvalidateDataCacheRange ((VOID *)(UINTN)PcdGet64 (PcdFdBaseAddress), PcdGet32 (PcdFdSize));
|
||||||
|
|
||||||
// Initialize MMU and Memory HOBs (Resource Descriptor HOBs)
|
// Initialize MMU and Memory HOBs (Resource Descriptor HOBs)
|
||||||
Status = MemoryPeim (UefiMemoryBase, FixedPcdGet32 (PcdSystemMemoryUefiRegionSize));
|
Status = MemoryPeim (UefiMemoryBase, FixedPcdGet32 (PcdSystemMemoryUefiRegionSize));
|
||||||
@ -66,15 +66,21 @@ PrePiMain (
|
|||||||
|
|
||||||
// Initialize the Serial Port
|
// Initialize the Serial Port
|
||||||
SerialPortInitialize ();
|
SerialPortInitialize ();
|
||||||
CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"UEFI firmware (version %s built at %a on %a)\n\r",
|
CharCount = AsciiSPrint (
|
||||||
(CHAR16*)PcdGetPtr(PcdFirmwareVersionString), __TIME__, __DATE__);
|
Buffer,
|
||||||
SerialPortWrite ((UINT8 *) Buffer, CharCount);
|
sizeof (Buffer),
|
||||||
|
"UEFI firmware (version %s built at %a on %a)\n\r",
|
||||||
|
(CHAR16 *)PcdGetPtr (PcdFirmwareVersionString),
|
||||||
|
__TIME__,
|
||||||
|
__DATE__
|
||||||
|
);
|
||||||
|
SerialPortWrite ((UINT8 *)Buffer, CharCount);
|
||||||
|
|
||||||
// Create the Stacks HOB (reserve the memory for all stacks)
|
// Create the Stacks HOB (reserve the memory for all stacks)
|
||||||
StacksSize = PcdGet32 (PcdCPUCorePrimaryStackSize);
|
StacksSize = PcdGet32 (PcdCPUCorePrimaryStackSize);
|
||||||
BuildStackHob (StacksBase, StacksSize);
|
BuildStackHob (StacksBase, StacksSize);
|
||||||
|
|
||||||
//TODO: Call CpuPei as a library
|
// TODO: Call CpuPei as a library
|
||||||
BuildCpuHob (ArmGetPhysicalAddressBits (), PcdGet8 (PcdPrePiCpuIoSize));
|
BuildCpuHob (ArmGetPhysicalAddressBits (), PcdGet8 (PcdPrePiCpuIoSize));
|
||||||
|
|
||||||
// Set the Boot Mode
|
// Set the Boot Mode
|
||||||
@ -101,12 +107,12 @@ PrePiMain (
|
|||||||
|
|
||||||
VOID
|
VOID
|
||||||
CEntryPoint (
|
CEntryPoint (
|
||||||
IN UINTN MpId,
|
IN UINTN MpId,
|
||||||
IN UINTN UefiMemoryBase,
|
IN UINTN UefiMemoryBase,
|
||||||
IN UINTN StacksBase
|
IN UINTN StacksBase
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINT64 StartTimeStamp;
|
UINT64 StartTimeStamp;
|
||||||
|
|
||||||
if (PerformanceMeasurementEnabled ()) {
|
if (PerformanceMeasurementEnabled ()) {
|
||||||
// Initialize the Timer Library to setup the Timer HW controller
|
// Initialize the Timer Library to setup the Timer HW controller
|
||||||
@ -132,8 +138,8 @@ CEntryPoint (
|
|||||||
|
|
||||||
VOID
|
VOID
|
||||||
RelocatePeCoffImage (
|
RelocatePeCoffImage (
|
||||||
IN EFI_PEI_FV_HANDLE FwVolHeader,
|
IN EFI_PEI_FV_HANDLE FwVolHeader,
|
||||||
IN PE_COFF_LOADER_READ_FILE ImageRead
|
IN PE_COFF_LOADER_READ_FILE ImageRead
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_PEI_FILE_HANDLE FileHandle;
|
EFI_PEI_FILE_HANDLE FileHandle;
|
||||||
@ -142,20 +148,24 @@ RelocatePeCoffImage (
|
|||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
|
||||||
FileHandle = NULL;
|
FileHandle = NULL;
|
||||||
Status = FfsFindNextFile (EFI_FV_FILETYPE_SECURITY_CORE, FwVolHeader,
|
Status = FfsFindNextFile (
|
||||||
&FileHandle);
|
EFI_FV_FILETYPE_SECURITY_CORE,
|
||||||
|
FwVolHeader,
|
||||||
|
&FileHandle
|
||||||
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
Status = FfsFindSectionData (EFI_SECTION_PE32, FileHandle, &SectionData);
|
Status = FfsFindSectionData (EFI_SECTION_PE32, FileHandle, &SectionData);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
Status = FfsFindSectionData (EFI_SECTION_TE, FileHandle, &SectionData);
|
Status = FfsFindSectionData (EFI_SECTION_TE, FileHandle, &SectionData);
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
ZeroMem (&ImageContext, sizeof ImageContext);
|
ZeroMem (&ImageContext, sizeof ImageContext);
|
||||||
|
|
||||||
ImageContext.Handle = (EFI_HANDLE)SectionData;
|
ImageContext.Handle = (EFI_HANDLE)SectionData;
|
||||||
ImageContext.ImageRead = ImageRead;
|
ImageContext.ImageRead = ImageRead;
|
||||||
PeCoffLoaderGetImageInfo (&ImageContext);
|
PeCoffLoaderGetImageInfo (&ImageContext);
|
||||||
|
|
||||||
if (ImageContext.ImageAddress != (UINTN)SectionData) {
|
if (ImageContext.ImageAddress != (UINTN)SectionData) {
|
||||||
|
@ -30,16 +30,16 @@ TimerConstructor (
|
|||||||
|
|
||||||
VOID
|
VOID
|
||||||
PrePiMain (
|
PrePiMain (
|
||||||
IN UINTN UefiMemoryBase,
|
IN UINTN UefiMemoryBase,
|
||||||
IN UINTN StacksBase,
|
IN UINTN StacksBase,
|
||||||
IN UINT64 StartTimeStamp
|
IN UINT64 StartTimeStamp
|
||||||
);
|
);
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
MemoryPeim (
|
MemoryPeim (
|
||||||
IN EFI_PHYSICAL_ADDRESS UefiMemoryBase,
|
IN EFI_PHYSICAL_ADDRESS UefiMemoryBase,
|
||||||
IN UINT64 UefiMemorySize
|
IN UINT64 UefiMemorySize
|
||||||
);
|
);
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
|
@ -32,33 +32,44 @@ STATIC
|
|||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
GetXenArmAcpiRsdp (
|
GetXenArmAcpiRsdp (
|
||||||
OUT EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER **RsdpPtr
|
OUT EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER **RsdpPtr
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *RsdpStructurePtr;
|
EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *RsdpStructurePtr;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
FDT_CLIENT_PROTOCOL *FdtClient;
|
FDT_CLIENT_PROTOCOL *FdtClient;
|
||||||
CONST UINT64 *Reg;
|
CONST UINT64 *Reg;
|
||||||
UINT32 RegSize;
|
UINT32 RegSize;
|
||||||
UINTN AddressCells, SizeCells;
|
UINTN AddressCells, SizeCells;
|
||||||
UINT64 RegBase;
|
UINT64 RegBase;
|
||||||
UINT8 Sum;
|
UINT8 Sum;
|
||||||
|
|
||||||
RsdpStructurePtr = NULL;
|
RsdpStructurePtr = NULL;
|
||||||
FdtClient = NULL;
|
FdtClient = NULL;
|
||||||
//
|
//
|
||||||
// Get the RSDP structure address from DeviceTree
|
// Get the RSDP structure address from DeviceTree
|
||||||
//
|
//
|
||||||
Status = gBS->LocateProtocol (&gFdtClientProtocolGuid, NULL,
|
Status = gBS->LocateProtocol (
|
||||||
(VOID **)&FdtClient);
|
&gFdtClientProtocolGuid,
|
||||||
|
NULL,
|
||||||
|
(VOID **)&FdtClient
|
||||||
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
Status = FdtClient->FindCompatibleNodeReg (FdtClient, "xen,guest-acpi",
|
Status = FdtClient->FindCompatibleNodeReg (
|
||||||
(CONST VOID **)&Reg, &AddressCells, &SizeCells,
|
FdtClient,
|
||||||
&RegSize);
|
"xen,guest-acpi",
|
||||||
|
(CONST VOID **)&Reg,
|
||||||
|
&AddressCells,
|
||||||
|
&SizeCells,
|
||||||
|
&RegSize
|
||||||
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_WARN, "%a: No 'xen,guest-acpi' compatible DT node found\n",
|
DEBUG ((
|
||||||
__FUNCTION__));
|
DEBUG_WARN,
|
||||||
|
"%a: No 'xen,guest-acpi' compatible DT node found\n",
|
||||||
|
__FUNCTION__
|
||||||
|
));
|
||||||
return EFI_NOT_FOUND;
|
return EFI_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,13 +77,15 @@ GetXenArmAcpiRsdp (
|
|||||||
ASSERT (SizeCells == 2);
|
ASSERT (SizeCells == 2);
|
||||||
ASSERT (RegSize == 2 * sizeof (UINT64));
|
ASSERT (RegSize == 2 * sizeof (UINT64));
|
||||||
|
|
||||||
RegBase = SwapBytes64(Reg[0]);
|
RegBase = SwapBytes64 (Reg[0]);
|
||||||
RsdpStructurePtr =
|
RsdpStructurePtr =
|
||||||
(EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *)(UINTN)RegBase;
|
(EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *)(UINTN)RegBase;
|
||||||
|
|
||||||
if (RsdpStructurePtr && RsdpStructurePtr->Revision >= 2) {
|
if (RsdpStructurePtr && (RsdpStructurePtr->Revision >= 2)) {
|
||||||
Sum = CalculateSum8 ((CONST UINT8 *)RsdpStructurePtr,
|
Sum = CalculateSum8 (
|
||||||
sizeof (EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER));
|
(CONST UINT8 *)RsdpStructurePtr,
|
||||||
|
sizeof (EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER)
|
||||||
|
);
|
||||||
if (Sum != 0) {
|
if (Sum != 0) {
|
||||||
return EFI_ABORTED;
|
return EFI_ABORTED;
|
||||||
}
|
}
|
||||||
@ -101,26 +114,26 @@ STATIC
|
|||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
InstallXenArmTables (
|
InstallXenArmTables (
|
||||||
IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol
|
IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
UINTN TableHandle;
|
UINTN TableHandle;
|
||||||
VOID *CurrentTableEntry;
|
VOID *CurrentTableEntry;
|
||||||
UINTN CurrentTablePointer;
|
UINTN CurrentTablePointer;
|
||||||
EFI_ACPI_DESCRIPTION_HEADER *CurrentTable;
|
EFI_ACPI_DESCRIPTION_HEADER *CurrentTable;
|
||||||
UINTN Index;
|
UINTN Index;
|
||||||
UINTN NumberOfTableEntries;
|
UINTN NumberOfTableEntries;
|
||||||
EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *XenAcpiRsdpStructurePtr;
|
EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *XenAcpiRsdpStructurePtr;
|
||||||
EFI_ACPI_DESCRIPTION_HEADER *Xsdt;
|
EFI_ACPI_DESCRIPTION_HEADER *Xsdt;
|
||||||
EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *FadtTable;
|
EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *FadtTable;
|
||||||
EFI_ACPI_DESCRIPTION_HEADER *DsdtTable;
|
EFI_ACPI_DESCRIPTION_HEADER *DsdtTable;
|
||||||
|
|
||||||
XenAcpiRsdpStructurePtr = NULL;
|
XenAcpiRsdpStructurePtr = NULL;
|
||||||
FadtTable = NULL;
|
FadtTable = NULL;
|
||||||
DsdtTable = NULL;
|
DsdtTable = NULL;
|
||||||
TableHandle = 0;
|
TableHandle = 0;
|
||||||
NumberOfTableEntries = 0;
|
NumberOfTableEntries = 0;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Try to find Xen ARM ACPI tables
|
// Try to find Xen ARM ACPI tables
|
||||||
@ -139,11 +152,11 @@ InstallXenArmTables (
|
|||||||
// Retrieve the addresses of XSDT and
|
// Retrieve the addresses of XSDT and
|
||||||
// calculate the number of its table entries.
|
// calculate the number of its table entries.
|
||||||
//
|
//
|
||||||
Xsdt = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN)
|
Xsdt = (EFI_ACPI_DESCRIPTION_HEADER *)(UINTN)
|
||||||
XenAcpiRsdpStructurePtr->XsdtAddress;
|
XenAcpiRsdpStructurePtr->XsdtAddress;
|
||||||
NumberOfTableEntries = (Xsdt->Length -
|
NumberOfTableEntries = (Xsdt->Length -
|
||||||
sizeof (EFI_ACPI_DESCRIPTION_HEADER)) /
|
sizeof (EFI_ACPI_DESCRIPTION_HEADER)) /
|
||||||
sizeof (UINT64);
|
sizeof (UINT64);
|
||||||
//
|
//
|
||||||
// Install ACPI tables found in XSDT.
|
// Install ACPI tables found in XSDT.
|
||||||
//
|
//
|
||||||
@ -151,21 +164,21 @@ InstallXenArmTables (
|
|||||||
//
|
//
|
||||||
// Get the table entry from XSDT
|
// Get the table entry from XSDT
|
||||||
//
|
//
|
||||||
CurrentTableEntry = (VOID *) ((UINT8 *) Xsdt +
|
CurrentTableEntry = (VOID *)((UINT8 *)Xsdt +
|
||||||
sizeof (EFI_ACPI_DESCRIPTION_HEADER) +
|
sizeof (EFI_ACPI_DESCRIPTION_HEADER) +
|
||||||
Index * sizeof (UINT64));
|
Index * sizeof (UINT64));
|
||||||
CurrentTablePointer = (UINTN) *(UINT64 *)CurrentTableEntry;
|
CurrentTablePointer = (UINTN)*(UINT64 *)CurrentTableEntry;
|
||||||
CurrentTable = (EFI_ACPI_DESCRIPTION_HEADER *) CurrentTablePointer;
|
CurrentTable = (EFI_ACPI_DESCRIPTION_HEADER *)CurrentTablePointer;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Install the XSDT tables
|
// Install the XSDT tables
|
||||||
//
|
//
|
||||||
Status = AcpiProtocol->InstallAcpiTable (
|
Status = AcpiProtocol->InstallAcpiTable (
|
||||||
AcpiProtocol,
|
AcpiProtocol,
|
||||||
CurrentTable,
|
CurrentTable,
|
||||||
CurrentTable->Length,
|
CurrentTable->Length,
|
||||||
&TableHandle
|
&TableHandle
|
||||||
);
|
);
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
@ -174,10 +187,10 @@ InstallXenArmTables (
|
|||||||
//
|
//
|
||||||
// Get the FACS and DSDT table address from the table FADT
|
// Get the FACS and DSDT table address from the table FADT
|
||||||
//
|
//
|
||||||
if (!AsciiStrnCmp ((CHAR8 *) &CurrentTable->Signature, "FACP", 4)) {
|
if (!AsciiStrnCmp ((CHAR8 *)&CurrentTable->Signature, "FACP", 4)) {
|
||||||
FadtTable = (EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *)
|
FadtTable = (EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *)
|
||||||
(UINTN) CurrentTablePointer;
|
(UINTN)CurrentTablePointer;
|
||||||
DsdtTable = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) FadtTable->Dsdt;
|
DsdtTable = (EFI_ACPI_DESCRIPTION_HEADER *)(UINTN)FadtTable->Dsdt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -186,11 +199,11 @@ InstallXenArmTables (
|
|||||||
// Install DSDT table.
|
// Install DSDT table.
|
||||||
//
|
//
|
||||||
Status = AcpiProtocol->InstallAcpiTable (
|
Status = AcpiProtocol->InstallAcpiTable (
|
||||||
AcpiProtocol,
|
AcpiProtocol,
|
||||||
DsdtTable,
|
DsdtTable,
|
||||||
DsdtTable->Length,
|
DsdtTable->Length,
|
||||||
&TableHandle
|
&TableHandle
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
@ -204,15 +217,15 @@ FindAcpiTableProtocol (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_ACPI_TABLE_PROTOCOL *AcpiTable;
|
EFI_ACPI_TABLE_PROTOCOL *AcpiTable;
|
||||||
|
|
||||||
AcpiTable = NULL;
|
AcpiTable = NULL;
|
||||||
Status = gBS->LocateProtocol (
|
Status = gBS->LocateProtocol (
|
||||||
&gEfiAcpiTableProtocolGuid,
|
&gEfiAcpiTableProtocolGuid,
|
||||||
NULL,
|
NULL,
|
||||||
(VOID**)&AcpiTable
|
(VOID **)&AcpiTable
|
||||||
);
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
return AcpiTable;
|
return AcpiTable;
|
||||||
}
|
}
|
||||||
@ -228,15 +241,14 @@ FindAcpiTableProtocol (
|
|||||||
@return EFI_OUT_OF_RESOURCES
|
@return EFI_OUT_OF_RESOURCES
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
XenAcpiPlatformEntryPoint (
|
XenAcpiPlatformEntryPoint (
|
||||||
IN EFI_HANDLE ImageHandle,
|
IN EFI_HANDLE ImageHandle,
|
||||||
IN EFI_SYSTEM_TABLE *SystemTable
|
IN EFI_SYSTEM_TABLE *SystemTable
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
|
||||||
Status = InstallXenArmTables (FindAcpiTableProtocol ());
|
Status = InstallXenArmTables (FindAcpiTableProtocol ());
|
||||||
return Status;
|
return Status;
|
||||||
|
@ -16,11 +16,11 @@
|
|||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
XenPlatformHasAcpiDt (
|
XenPlatformHasAcpiDt (
|
||||||
IN EFI_HANDLE ImageHandle,
|
IN EFI_HANDLE ImageHandle,
|
||||||
IN EFI_SYSTEM_TABLE *SystemTable
|
IN EFI_SYSTEM_TABLE *SystemTable
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
|
||||||
//
|
//
|
||||||
// If we fail to install any of the necessary protocols below, the OS will be
|
// If we fail to install any of the necessary protocols below, the OS will be
|
||||||
|
@ -18,28 +18,39 @@
|
|||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
InitializeXenioFdtDxe (
|
InitializeXenioFdtDxe (
|
||||||
IN EFI_HANDLE ImageHandle,
|
IN EFI_HANDLE ImageHandle,
|
||||||
IN EFI_SYSTEM_TABLE *SystemTable
|
IN EFI_SYSTEM_TABLE *SystemTable
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
FDT_CLIENT_PROTOCOL *FdtClient;
|
FDT_CLIENT_PROTOCOL *FdtClient;
|
||||||
CONST UINT64 *Reg;
|
CONST UINT64 *Reg;
|
||||||
UINT32 RegSize;
|
UINT32 RegSize;
|
||||||
UINTN AddressCells, SizeCells;
|
UINTN AddressCells, SizeCells;
|
||||||
EFI_HANDLE Handle;
|
EFI_HANDLE Handle;
|
||||||
UINT64 RegBase;
|
UINT64 RegBase;
|
||||||
|
|
||||||
Status = gBS->LocateProtocol (&gFdtClientProtocolGuid, NULL,
|
Status = gBS->LocateProtocol (
|
||||||
(VOID **)&FdtClient);
|
&gFdtClientProtocolGuid,
|
||||||
|
NULL,
|
||||||
|
(VOID **)&FdtClient
|
||||||
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
Status = FdtClient->FindCompatibleNodeReg (FdtClient, "xen,xen",
|
Status = FdtClient->FindCompatibleNodeReg (
|
||||||
(CONST VOID **)&Reg, &AddressCells, &SizeCells,
|
FdtClient,
|
||||||
&RegSize);
|
"xen,xen",
|
||||||
|
(CONST VOID **)&Reg,
|
||||||
|
&AddressCells,
|
||||||
|
&SizeCells,
|
||||||
|
&RegSize
|
||||||
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_WARN, "%a: No 'xen,xen' compatible DT node found\n",
|
DEBUG ((
|
||||||
__FUNCTION__));
|
DEBUG_WARN,
|
||||||
|
"%a: No 'xen,xen' compatible DT node found\n",
|
||||||
|
__FUNCTION__
|
||||||
|
));
|
||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,11 +63,16 @@ InitializeXenioFdtDxe (
|
|||||||
// MMIO flavor of the XenBus root device I/O protocol
|
// MMIO flavor of the XenBus root device I/O protocol
|
||||||
//
|
//
|
||||||
RegBase = SwapBytes64 (Reg[0]);
|
RegBase = SwapBytes64 (Reg[0]);
|
||||||
Handle = NULL;
|
Handle = NULL;
|
||||||
Status = XenIoMmioInstall (&Handle, RegBase);
|
Status = XenIoMmioInstall (&Handle, RegBase);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_ERROR, "%a: XenIoMmioInstall () failed on a new handle "
|
DEBUG ((
|
||||||
"(Status == %r)\n", __FUNCTION__, Status));
|
DEBUG_ERROR,
|
||||||
|
"%a: XenIoMmioInstall () failed on a new handle "
|
||||||
|
"(Status == %r)\n",
|
||||||
|
__FUNCTION__,
|
||||||
|
Status
|
||||||
|
));
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user