]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/AArch64/ArmFvpDxeAArch64.c
1e990d140ddb9848f34c4cd32243b95cc745e618
[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 #include <Library/ArmGicLib.h>
17
18 //
19 // Description of the AARCH64 model platforms :
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, FixedPcdGetPtr (PcdFdtFvpVExpressAEMv8x4), L"rtsm_ve-aemv8a.dtb" },
26 { ARM_FVP_BASE, FixedPcdGetPtr (PcdFdtFvpBaseAEMv8x4), L"fvp-base.dtb" },
27 { ARM_FVP_FOUNDATION, FixedPcdGetPtr (PcdFdtFvpFoundation), L"fvp-foundation.dtb" },
28 { ARM_FVP_VEXPRESS_UNKNOWN, &gZeroGuid }
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 UINT32 FvpSysId;
51
52 ASSERT (Platform != NULL);
53
54 Status = EFI_NOT_FOUND;
55
56 SysId = MmioRead32 (ARM_VE_SYS_ID_REG);
57 if (SysId != ARM_RTSM_SYS_ID) {
58 //
59 // Keep only the HBI board number and the platform type fields of the
60 // system id register to identify if we are running on the FVP base or
61 // foundation model.
62 //
63 FvpSysId = SysId & (ARM_FVP_SYS_ID_HBI_MASK |
64 ARM_FVP_SYS_ID_PLAT_MASK );
65
66 if (FvpSysId == ARM_FVP_BASE_BOARD_SYS_ID) {
67 Status = ArmVExpressGetPlatformFromId (ARM_FVP_BASE, Platform);
68 } else if (FvpSysId == ARM_FVP_FOUNDATION_BOARD_SYS_ID) {
69 Status = ArmVExpressGetPlatformFromId (ARM_FVP_FOUNDATION, Platform);
70 }
71 } else {
72 //
73 // FVP Versatile Express AEMv8
74 //
75 Status = ArmVExpressGetPlatformFromId (ARM_FVP_VEXPRESS_AEMv8x4, Platform);
76 }
77
78 if (EFI_ERROR (Status)) {
79 DEBUG ((EFI_D_ERROR, "Unsupported AArch64 RTSM (SysId:0x%X).\n", SysId));
80 ASSERT_EFI_ERROR (Status);
81 }
82
83 return Status;
84 }