diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/AArch64/ArmFvpDxeAArch64.c b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/AArch64/ArmFvpDxeAArch64.c index 1e990d140d..c368957dcd 100644 --- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/AArch64/ArmFvpDxeAArch64.c +++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/AArch64/ArmFvpDxeAArch64.c @@ -22,10 +22,14 @@ // model or hardware platforms). // CONST ARM_VEXPRESS_PLATFORM ArmVExpressPlatforms[] = { - { ARM_FVP_VEXPRESS_AEMv8x4, FixedPcdGetPtr (PcdFdtFvpVExpressAEMv8x4), L"rtsm_ve-aemv8a.dtb" }, - { ARM_FVP_BASE, FixedPcdGetPtr (PcdFdtFvpBaseAEMv8x4), L"fvp-base.dtb" }, - { ARM_FVP_FOUNDATION, FixedPcdGetPtr (PcdFdtFvpFoundation), L"fvp-foundation.dtb" }, - { ARM_FVP_VEXPRESS_UNKNOWN, &gZeroGuid } + { ARM_FVP_VEXPRESS_AEMv8x4, FixedPcdGetPtr (PcdFdtFvpVExpressAEMv8x4), L"rtsm_ve-aemv8a.dtb" }, + { ARM_FVP_BASE_AEMv8x4_AEMv8x4_GICV2, FixedPcdGetPtr (PcdFdtFvpBaseAEMv8x4GicV2), L"fvp-base-gicv2-psci.dtb" }, + { ARM_FVP_BASE_AEMv8x4_AEMv8x4_GICV2_LEGACY, FixedPcdGetPtr (PcdFdtFvpBaseAEMv8x4GicV2Legacy), L"fvp-base-gicv2legacy-psci.dtb" }, + { ARM_FVP_BASE_AEMv8x4_AEMv8x4_GICV3, FixedPcdGetPtr (PcdFdtFvpBaseAEMv8x4GicV3), L"fvp-base-gicv3-psci.dtb" }, + { ARM_FVP_FOUNDATION_GICV2, FixedPcdGetPtr (PcdFdtFvpFoundationGicV2), L"fvp-foundation-gicv2-psci.dtb" }, + { ARM_FVP_FOUNDATION_GICV2_LEGACY, FixedPcdGetPtr (PcdFdtFvpFoundationGicV2Legacy), L"fvp-foundation-gicv2legacy-psci.dtb" }, + { ARM_FVP_FOUNDATION_GICV3, FixedPcdGetPtr (PcdFdtFvpFoundationGicV3), L"fvp-foundation-gicv3-psci.dtb" }, + { ARM_FVP_VEXPRESS_UNKNOWN } }; /** @@ -45,9 +49,11 @@ ArmVExpressGetPlatform ( OUT CONST ARM_VEXPRESS_PLATFORM** Platform ) { - EFI_STATUS Status; - UINT32 SysId; - UINT32 FvpSysId; + EFI_STATUS Status; + UINT32 SysId; + UINT32 FvpSysId; + UINT32 VariantSysId; + ARM_GIC_ARCH_REVISION GicRevision; ASSERT (Platform != NULL); @@ -55,23 +61,46 @@ ArmVExpressGetPlatform ( SysId = MmioRead32 (ARM_VE_SYS_ID_REG); if (SysId != ARM_RTSM_SYS_ID) { - // - // Keep only the HBI board number and the platform type fields of the - // system id register to identify if we are running on the FVP base or - // foundation model. - // - FvpSysId = SysId & (ARM_FVP_SYS_ID_HBI_MASK | - ARM_FVP_SYS_ID_PLAT_MASK ); + // Remove the GIC variant to identify if we are running on the FVP Base or + // Foundation models + FvpSysId = SysId & (ARM_FVP_SYS_ID_HBI_MASK | + ARM_FVP_SYS_ID_PLAT_MASK ); + // Extract the variant from the SysId + VariantSysId = SysId & ARM_FVP_SYS_ID_VARIANT_MASK; if (FvpSysId == ARM_FVP_BASE_BOARD_SYS_ID) { - Status = ArmVExpressGetPlatformFromId (ARM_FVP_BASE, Platform); + if (VariantSysId == ARM_FVP_GIC_VE_MMAP) { + // FVP Base Model with legacy GIC memory map + Status = ArmVExpressGetPlatformFromId (ARM_FVP_BASE_AEMv8x4_AEMv8x4_GICV2_LEGACY, Platform); + } else { + GicRevision = ArmGicGetSupportedArchRevision (); + + if (GicRevision == ARM_GIC_ARCH_REVISION_2) { + // FVP Base Model with GICv2 support + Status = ArmVExpressGetPlatformFromId (ARM_FVP_BASE_AEMv8x4_AEMv8x4_GICV2, Platform); + } else { + // FVP Base Model with GICv3 support + Status = ArmVExpressGetPlatformFromId (ARM_FVP_BASE_AEMv8x4_AEMv8x4_GICV3, Platform); + } + } } else if (FvpSysId == ARM_FVP_FOUNDATION_BOARD_SYS_ID) { - Status = ArmVExpressGetPlatformFromId (ARM_FVP_FOUNDATION, Platform); + if (VariantSysId == ARM_FVP_GIC_VE_MMAP) { + // FVP Foundation Model with legacy GIC memory map + Status = ArmVExpressGetPlatformFromId (ARM_FVP_FOUNDATION_GICV2_LEGACY, Platform); + } else { + GicRevision = ArmGicGetSupportedArchRevision (); + + if (GicRevision == ARM_GIC_ARCH_REVISION_2) { + // FVP Foundation Model with GICv2 + Status = ArmVExpressGetPlatformFromId (ARM_FVP_FOUNDATION_GICV2, Platform); + } else { + // FVP Foundation Model with GICv3 + Status = ArmVExpressGetPlatformFromId (ARM_FVP_FOUNDATION_GICV3, Platform); + } + } } } else { - // // FVP Versatile Express AEMv8 - // Status = ArmVExpressGetPlatformFromId (ARM_FVP_VEXPRESS_AEMv8x4, Platform); } diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/ArmFvpDxe.c b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/ArmFvpDxe.c index cbd526e60c..8c42814a04 100644 --- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/ArmFvpDxe.c +++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/ArmFvpDxe.c @@ -24,7 +24,6 @@ #include #define ARM_FVP_BASE_VIRTIO_BLOCK_BASE 0x1c130000 -STATIC CONST CHAR16 *mFdtFallbackName = L"fdt.dtb"; #pragma pack(1) typedef struct { @@ -156,20 +155,16 @@ ArmFvpInitialise ( IN EFI_SYSTEM_TABLE *SystemTable ) { + CONST ARM_VEXPRESS_PLATFORM* Platform; EFI_STATUS Status; - CONST ARM_VEXPRESS_PLATFORM *Platform; - BOOLEAN NeedFallback; - UINTN TextDevicePathBaseSize; - UINTN TextDevicePathSize; CHAR16 *TextDevicePath; + UINTN TextDevicePathSize; VOID *Buffer; EFI_DEVICE_PATH *FdtDevicePath; - Status = gBS->InstallProtocolInterface ( - &ImageHandle, - &gEfiDevicePathProtocolGuid, EFI_NATIVE_INTERFACE, - &mVirtioBlockDevicePath - ); + Status = gBS->InstallProtocolInterface (&ImageHandle, + &gEfiDevicePathProtocolGuid, EFI_NATIVE_INTERFACE, + &mVirtioBlockDevicePath); if (EFI_ERROR (Status)) { return Status; } @@ -185,32 +180,13 @@ ArmFvpInitialise ( } FreePool (FdtDevicePath); } else { - // - // In the case of the FVP base and foundation platforms, two default - // text device paths for the FDT are defined. The first one, like every - // other platform, ends with a file name that identifies the platform. The - // second one ends with the fallback file name "fdt.dtb" for historical - // backward compatibility reasons. - // - NeedFallback = (Platform->Id == ARM_FVP_BASE) || - (Platform->Id == ARM_FVP_FOUNDATION); - - TextDevicePathBaseSize = StrSize ((CHAR16*)PcdGetPtr (PcdFvpFdtDevicePathsBase)) - sizeof (CHAR16); - TextDevicePathSize = TextDevicePathBaseSize + StrSize (Platform->FdtName); - if (NeedFallback) { - TextDevicePathSize += TextDevicePathBaseSize + StrSize (mFdtFallbackName); - } + TextDevicePathSize = StrSize ((CHAR16*)PcdGetPtr (PcdFvpFdtDevicePathsBase)) - sizeof (CHAR16); + TextDevicePathSize += StrSize (Platform->FdtName); TextDevicePath = AllocatePool (TextDevicePathSize); if (TextDevicePath != NULL) { StrCpy (TextDevicePath, ((CHAR16*)PcdGetPtr (PcdFvpFdtDevicePathsBase))); StrCat (TextDevicePath, Platform->FdtName); - - if (NeedFallback) { - StrCat (TextDevicePath, L";"); - StrCat (TextDevicePath, ((CHAR16*)PcdGetPtr (PcdFvpFdtDevicePathsBase))); - StrCat (TextDevicePath, mFdtFallbackName); - } } } if (TextDevicePath != NULL) { @@ -222,11 +198,6 @@ ArmFvpInitialise ( )); } FreePool (TextDevicePath); - } else { - DEBUG (( - EFI_D_ERROR, - "ArmFvpDxe: Setting of FDT device path in PcdFdtDevicePaths failed - %r\n", EFI_OUT_OF_RESOURCES - )); } } diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/ArmFvpDxe.inf b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/ArmFvpDxe.inf index 4b9b57bc04..327c5101dd 100644 --- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/ArmFvpDxe.inf +++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/ArmFvpDxe.inf @@ -32,7 +32,6 @@ [Packages] MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec ArmPkg/ArmPkg.dec ArmPlatformPkg/ArmPlatformPkg.dec ArmPlatformPkg/ArmVExpressPkg/ArmVExpressPkg.dec @@ -55,9 +54,6 @@ [LibraryClasses.AARCH64] ArmGicLib -[Guids] - gZeroGuid - [Protocols] gEfiFirmwareVolume2ProtocolGuid gEfiDevicePathProtocolGuid @@ -73,8 +69,12 @@ [FixedPcd.AARCH64] gArmVExpressTokenSpaceGuid.PcdFdtFvpVExpressAEMv8x4 - gArmVExpressTokenSpaceGuid.PcdFdtFvpBaseAEMv8x4 - gArmVExpressTokenSpaceGuid.PcdFdtFvpFoundation + gArmVExpressTokenSpaceGuid.PcdFdtFvpBaseAEMv8x4GicV2 + gArmVExpressTokenSpaceGuid.PcdFdtFvpBaseAEMv8x4GicV2Legacy + gArmVExpressTokenSpaceGuid.PcdFdtFvpBaseAEMv8x4GicV3 + gArmVExpressTokenSpaceGuid.PcdFdtFvpFoundationGicV2 + gArmVExpressTokenSpaceGuid.PcdFdtFvpFoundationGicV2Legacy + gArmVExpressTokenSpaceGuid.PcdFdtFvpFoundationGicV3 [Pcd] gEmbeddedTokenSpaceGuid.PcdFdtDevicePaths diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/ArmHwDxe.c b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/ArmHwDxe.c index 1f18197c7c..351c73312d 100644 --- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/ArmHwDxe.c +++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/ArmHwDxe.c @@ -19,6 +19,7 @@ CONST EFI_GUID ArmHwA9x4Guid = { 0x2fd21cf6, 0xe6e8, 0x4ff2, { 0xa9, 0xca, 0x3b, CONST EFI_GUID ArmHwA15x2A7x3Guid = { 0xd5e606eb, 0x83df, 0x4e90, { 0x81, 0xe8, 0xc3, 0xdb, 0x2f, 0x77, 0x17, 0x9a } }; CONST EFI_GUID ArmHwA15Guid = { 0x6b8947c2, 0x4287, 0x4d91, { 0x8f, 0xe0, 0xa3, 0x81, 0xea, 0x5b, 0x56, 0x8f } }; CONST EFI_GUID ArmHwA5Guid = { 0xa2cc7663, 0x4d7c, 0x448a, { 0xaa, 0xb5, 0x4c, 0x03, 0x4b, 0x6f, 0xda, 0xb7 } }; +CONST EFI_GUID NullGuid = { 0x0, 0x0, 0x0, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }; // // Description of the four hardware platforms : @@ -33,7 +34,7 @@ CONST ARM_VEXPRESS_PLATFORM ArmVExpressPlatforms[] = { { ARM_HW_A15x2_A7x3, &ArmHwA15x2A7x3Guid, L"ca15a7" }, { ARM_HW_A15, &ArmHwA15Guid, L"ca15a7" }, { ARM_HW_A5, &ArmHwA5Guid, L"ca5s" }, - { ARM_FVP_VEXPRESS_UNKNOWN, &gZeroGuid, NULL } + { ARM_FVP_VEXPRESS_UNKNOWN, &NullGuid, NULL } }; /** diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/ArmHwDxe.inf b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/ArmHwDxe.inf index 14035e478b..1a007627ad 100644 --- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/ArmHwDxe.inf +++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/ArmHwDxe.inf @@ -29,7 +29,6 @@ ArmPlatformPkg/ArmPlatformPkg.dec EmbeddedPkg/EmbeddedPkg.dec MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec [LibraryClasses] ArmShellCmdRunAxfLib @@ -37,8 +36,5 @@ MemoryAllocationLib UefiDriverEntryPoint -[Guids] - gZeroGuid - [Protocols] gEfiDevicePathProtocolGuid diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/ArmVExpressInternal.h b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/ArmVExpressInternal.h index 6788788590..e123eea2d2 100644 --- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/ArmVExpressInternal.h +++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/ArmVExpressInternal.h @@ -24,8 +24,6 @@ #include #include -#include - #include // This 'enum' is needed as variations based on existing platform exist @@ -38,8 +36,12 @@ typedef enum { ARM_FVP_VEXPRESS_A15x1_A7x1, ARM_FVP_VEXPRESS_A15x4_A7x4, ARM_FVP_VEXPRESS_AEMv8x4, - ARM_FVP_BASE, - ARM_FVP_FOUNDATION, + ARM_FVP_BASE_AEMv8x4_AEMv8x4_GICV2, + ARM_FVP_BASE_AEMv8x4_AEMv8x4_GICV2_LEGACY, + ARM_FVP_BASE_AEMv8x4_AEMv8x4_GICV3, + ARM_FVP_FOUNDATION_GICV2, + ARM_FVP_FOUNDATION_GICV2_LEGACY, + ARM_FVP_FOUNDATION_GICV3, ARM_HW_A9x4, ARM_HW_A15x2_A7x3, ARM_HW_A15, diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressPkg.dec b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressPkg.dec index dba08dbae5..d375ed3b97 100644 --- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressPkg.dec +++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressPkg.dec @@ -73,5 +73,9 @@ # AArch64 FVP platforms gArmVExpressTokenSpaceGuid.PcdFdtFvpVExpressAEMv8x4|{ 0xa8, 0x95, 0x5f, 0xf6, 0x32, 0x7b, 0xf3, 0x16, 0x12, 0x32, 0x45, 0x50, 0xbd, 0x54, 0xca, 0xe5 }|VOID*|0x00000010 - gArmVExpressTokenSpaceGuid.PcdFdtFvpBaseAEMv8x4|{ 0x66, 0xcf, 0x57, 0xa4, 0xac, 0x7e, 0x7f, 0x3d, 0x21, 0x88, 0x3a, 0x58, 0x3c, 0x27, 0xd7, 0xe8 }|VOID*|0x00000011 - gArmVExpressTokenSpaceGuid.PcdFdtFvpFoundation|{ 0x36, 0x4f, 0x61, 0x92, 0x86, 0xb1, 0xa2, 0x16, 0x32, 0x65, 0x35, 0x3f, 0x01, 0xf3, 0x3b, 0x64 }|VOID*|0x00000014 + gArmVExpressTokenSpaceGuid.PcdFdtFvpBaseAEMv8x4GicV2|{ 0x66, 0xcf, 0x57, 0xa4, 0xac, 0x7e, 0x7f, 0x3d, 0x21, 0x88, 0x3a, 0x58, 0x3c, 0x27, 0xd7, 0xe8 }|VOID*|0x00000011 + gArmVExpressTokenSpaceGuid.PcdFdtFvpBaseAEMv8x4GicV2Legacy|{ 0x8b, 0xcb, 0xe0, 0x14, 0xd1, 0x46, 0x79, 0xae, 0x7f, 0x20, 0xcf, 0x84, 0x22, 0xc7, 0x94, 0x4a }|VOID*|0x00000012 + gArmVExpressTokenSpaceGuid.PcdFdtFvpBaseAEMv8x4GicV3|{ 0x4d, 0x03, 0xb8, 0x77, 0x63, 0x25, 0x0a, 0x7f, 0xe9, 0x72, 0xfa, 0x68, 0x74, 0xc7, 0x5e, 0xb5 }|VOID*|0x00000013 + gArmVExpressTokenSpaceGuid.PcdFdtFvpFoundationGicV2|{ 0x36, 0x4f, 0x61, 0x92, 0x86, 0xb1, 0xa2, 0x16, 0x32, 0x65, 0x35, 0x3f, 0x01, 0xf3, 0x3b, 0x64 }|VOID*|0x00000014 + gArmVExpressTokenSpaceGuid.PcdFdtFvpFoundationGicV2Legacy|{ 0xf6, 0xcb, 0x9d, 0x86, 0x38, 0x74, 0x8a, 0xb0, 0xfe, 0x40, 0x08, 0x0f, 0x3f, 0xb3, 0x50, 0x7c }|VOID*|0x00000015 + gArmVExpressTokenSpaceGuid.PcdFdtFvpFoundationGicV3|{ 0x51, 0xd0, 0x75, 0x6b, 0x9d, 0x35, 0x1b, 0x1b, 0xa6, 0xc6, 0xab, 0xa0, 0x90, 0xf9, 0xf0, 0x0a }|VOID*|0x00000016