]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/AArch64/ArmFvpDxeAArch64.c
ArmPlatformPkg/ArmVExpressDxe: Identify the current platform
[mirror_edk2.git] / ArmPlatformPkg / ArmVExpressPkg / ArmVExpressDxe / AArch64 / ArmFvpDxeAArch64.c
1 /** @file
2
3 Copyright (c) 2014-2015, ARM Ltd. All rights reserved.
4
5 This program and the accompanying materials are licensed and made available
6 under the terms and conditions of the BSD License which accompanies this
7 distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
11 WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #include "ArmVExpressInternal.h"
16
17 //
18 // Description of the two AARCH64 model platforms :
19 // just the platform id for the time being.
20 // Platform ids are defined in ArmVExpressInternal.h for
21 // all "ArmVExpress-like" platforms (AARCH64 or ARM architecture,
22 // model or hardware platforms).
23 //
24 CONST ARM_VEXPRESS_PLATFORM ArmVExpressPlatforms[] = {
25 { ARM_FVP_VEXPRESS_AEMv8x4 },
26 { ARM_FVP_BASE_AEMv8x4_AEMv8x4 },
27 { ARM_FVP_FOUNDATION },
28 { ARM_FVP_VEXPRESS_UNKNOWN }
29 };
30
31 /**
32 Get information about the VExpress platform the firmware is running on.
33
34 @param[out] Platform Address where the pointer to the platform information
35 (type ARM_VEXPRESS_PLATFORM*) should be stored.
36 The returned pointer does not point to an allocated
37 memory area.
38
39 @retval EFI_SUCCESS The platform information was returned.
40 @retval EFI_NOT_FOUND The platform was not recognised.
41
42 **/
43 EFI_STATUS
44 ArmVExpressGetPlatform (
45 OUT CONST ARM_VEXPRESS_PLATFORM** Platform
46 )
47 {
48 EFI_STATUS Status;
49 UINT32 SysId;
50
51 ASSERT (Platform != NULL);
52
53 Status = EFI_NOT_FOUND;
54
55 SysId = MmioRead32 (ARM_VE_SYS_ID_REG);
56 if (SysId != ARM_RTSM_SYS_ID) {
57 // Take out the FVP GIC variant to reduce the permutations. The GIC driver
58 // detects the version and does the right thing.
59 SysId &= ~ARM_FVP_SYS_ID_VARIANT_MASK;
60 if (SysId == (ARM_FVP_BASE_SYS_ID & ~ARM_FVP_SYS_ID_VARIANT_MASK)) {
61 Status = ArmVExpressGetPlatformFromId (ARM_FVP_BASE_AEMv8x4_AEMv8x4, Platform);
62 } else if (SysId == (ARM_FVP_FOUNDATION_SYS_ID & ~ARM_FVP_SYS_ID_VARIANT_MASK)) {
63 Status = ArmVExpressGetPlatformFromId (ARM_FVP_FOUNDATION, Platform);
64 }
65 } else {
66 Status = ArmVExpressGetPlatformFromId (ARM_FVP_VEXPRESS_AEMv8x4, Platform);
67 }
68
69 if (EFI_ERROR (Status)) {
70 DEBUG ((EFI_D_ERROR, "Unsupported AArch64 RTSM (SysId:0x%X).\n", SysId));
71 ASSERT_EFI_ERROR (Status);
72 }
73
74 return Status;
75 }