]>
Commit | Line | Data |
---|---|---|
dff72027 OM |
1 | /** @file\r |
2 | \r | |
3 | Copyright (c) 2014, ARM Ltd. All rights reserved.\r | |
4 | \r | |
5 | This program and the accompanying materials are licensed and made available\r | |
6 | under the terms and conditions of the BSD License which accompanies this\r | |
7 | distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT\r | |
11 | WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | **/\r | |
14 | \r | |
15 | #include "ArmVExpressInternal.h"\r | |
16 | #include <Library/ArmPlatformLib.h> // To get Core Count\r | |
17 | \r | |
18 | //\r | |
19 | // Description of the four ARM model platforms :\r | |
dff72027 OM |
20 | // Platform ids are defined in ArmVExpressInternal.h for\r |
21 | // all "ArmVExpress-like" platforms (AARCH64 or ARM architecture,\r | |
22 | // model or hardware platforms).\r | |
23 | //\r | |
24 | CONST ARM_VEXPRESS_PLATFORM ArmVExpressPlatforms[] = {\r | |
f66eab9b OM |
25 | { ARM_FVP_VEXPRESS_A9x4, FixedPcdGetPtr (PcdFdtVExpressFvpA9x4), L"rtsm_ve-cortex_a9x4.dtb" },\r |
26 | { ARM_FVP_VEXPRESS_A15x1, FixedPcdGetPtr (PcdFdtVExpressFvpA15x1), L"rtsm_ve-cortex_a15x1.dtb" },\r | |
27 | { ARM_FVP_VEXPRESS_A15x2, FixedPcdGetPtr (PcdFdtVExpressFvpA15x2), L"rtsm_ve-cortex_a15x2.dtb" },\r | |
28 | { ARM_FVP_VEXPRESS_A15x4, FixedPcdGetPtr (PcdFdtVExpressFvpA15x4), L"rtsm_ve-cortex_a15x4.dtb" },\r | |
29 | { ARM_FVP_VEXPRESS_UNKNOWN, }\r | |
dff72027 OM |
30 | };\r |
31 | \r | |
32 | /**\r | |
33 | Get information about the VExpress platform the firmware is running on.\r | |
34 | \r | |
35 | @param[out] Platform Address where the pointer to the platform information\r | |
36 | (type ARM_VEXPRESS_PLATFORM*) should be stored.\r | |
37 | The returned pointer does not point to an allocated\r | |
38 | memory area.\r | |
39 | \r | |
40 | @retval EFI_SUCCESS The platform information was returned.\r | |
41 | @retval EFI_NOT_FOUND The platform was not recognised.\r | |
42 | \r | |
43 | **/\r | |
44 | EFI_STATUS\r | |
45 | ArmVExpressGetPlatform (\r | |
46 | OUT CONST ARM_VEXPRESS_PLATFORM** Platform\r | |
47 | )\r | |
48 | {\r | |
49 | UINT32 SysId;\r | |
50 | UINTN CpuType;\r | |
51 | EFI_STATUS Status;\r | |
52 | UINTN CoreCount;\r | |
53 | \r | |
54 | ASSERT (Platform != NULL);\r | |
55 | \r | |
56 | CpuType = 0;\r | |
57 | Status = EFI_NOT_FOUND;\r | |
58 | *Platform = NULL;\r | |
59 | \r | |
60 | SysId = MmioRead32 (ARM_VE_SYS_ID_REG);\r | |
61 | if (SysId == ARM_RTSM_SYS_ID) {\r | |
62 | // Get the Cortex-A version\r | |
63 | CpuType = (ArmReadMidr () >> 4) & ARM_CPU_TYPE_MASK;\r | |
64 | if (CpuType == ARM_CPU_TYPE_A9) {\r | |
65 | Status = ArmVExpressGetPlatformFromId (ARM_FVP_VEXPRESS_A9x4, Platform);\r | |
66 | } else if (CpuType == ARM_CPU_TYPE_A15) {\r | |
67 | CoreCount = ArmGetCpuCountPerCluster ();\r | |
68 | if (CoreCount == 1) {\r | |
69 | Status = ArmVExpressGetPlatformFromId (ARM_FVP_VEXPRESS_A15x1, Platform);\r | |
70 | } else if (CoreCount == 2) {\r | |
71 | Status = ArmVExpressGetPlatformFromId (ARM_FVP_VEXPRESS_A15x2, Platform);\r | |
72 | } else if (CoreCount == 4) {\r | |
73 | Status = ArmVExpressGetPlatformFromId (ARM_FVP_VEXPRESS_A15x4, Platform);\r | |
74 | }\r | |
75 | }\r | |
76 | }\r | |
77 | \r | |
78 | if (EFI_ERROR (Status)) {\r | |
79 | DEBUG ((EFI_D_ERROR, "Unsupported platform (SysId:0x%X, CpuType:0x%X)\n", SysId, CpuType));\r | |
80 | ASSERT_EFI_ERROR (Status);\r | |
81 | }\r | |
82 | \r | |
83 | return Status;\r | |
84 | }\r |