]>
Commit | Line | Data |
---|---|---|
88d4f51d | 1 | //\r |
2d45f194 | 2 | // Copyright (c) 2011-2013, ARM Limited. All rights reserved.\r |
88d4f51d | 3 | //\r |
3402aac7 RC |
4 | // This program and the accompanying materials\r |
5 | // are licensed and made available under the terms and conditions of the BSD License\r | |
6 | // which accompanies this distribution. The full text of the license may be found at\r | |
7 | // http://opensource.org/licenses/bsd-license.php\r | |
8 | //\r | |
9 | // THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
10 | // WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
88d4f51d | 11 | //\r |
12 | //\r | |
13 | \r | |
88d4f51d | 14 | #include <Base.h>\r |
2d45f194 | 15 | #include <Library/ArmLib.h>\r |
88d4f51d | 16 | #include <Library/PcdLib.h>\r |
17 | \r | |
18 | #include <Chipset/ArmCortexA9.h>\r | |
19 | \r | |
20 | #include <AutoGen.h>\r | |
21 | \r | |
22 | INCLUDE AsmMacroIoLib.inc\r | |
23 | \r | |
b5a57223 | 24 | EXPORT ArmPlatformPeiBootAction\r |
88d4f51d | 25 | EXPORT ArmGetCpuCountPerCluster\r |
bebda7ce | 26 | EXPORT ArmPlatformIsPrimaryCore\r |
d05ca26c | 27 | EXPORT ArmPlatformGetPrimaryCoreMpId\r |
2d45f194 | 28 | EXPORT ArmPlatformGetCorePosition\r |
bebda7ce | 29 | \r |
88d4f51d | 30 | AREA RTSMHelper, CODE, READONLY\r |
31 | \r | |
b5a57223 | 32 | ArmPlatformPeiBootAction FUNCTION\r |
33 | bx lr\r | |
34 | ENDFUNC\r | |
35 | \r | |
88d4f51d | 36 | // IN None\r |
37 | // OUT r0 = SCU Base Address\r | |
bebda7ce | 38 | ArmGetScuBaseAddress FUNCTION\r |
88d4f51d | 39 | // Read Configuration Base Address Register. ArmCBar cannot be called to get\r |
40 | // the Configuration BAR as a stack is not necessary setup. The SCU is at the\r | |
41 | // offset 0x0000 from the Private Memory Region.\r | |
42 | mrc p15, 4, r0, c15, c0, 0\r | |
43 | bx lr\r | |
bebda7ce | 44 | ENDFUNC\r |
88d4f51d | 45 | \r |
d05ca26c | 46 | //UINTN\r |
47 | //ArmPlatformGetPrimaryCoreMpId (\r | |
48 | // VOID\r | |
49 | // );\r | |
50 | ArmPlatformGetPrimaryCoreMpId FUNCTION\r | |
66edb631 | 51 | mov32 r0, FixedPcdGet32(PcdArmPrimaryCore)\r |
d05ca26c | 52 | bx lr\r |
53 | ENDFUNC\r | |
54 | \r | |
88d4f51d | 55 | // IN None\r |
56 | // OUT r0 = number of cores present in the system\r | |
bebda7ce | 57 | ArmGetCpuCountPerCluster FUNCTION\r |
88d4f51d | 58 | stmfd SP!, {r1-r2}\r |
59 | \r | |
60 | // Read CP15 MIDR\r | |
61 | mrc p15, 0, r1, c0, c0, 0\r | |
62 | \r | |
63 | // Check if the CPU is A15\r | |
64 | mov r1, r1, LSR #4\r | |
65 | mov r0, #ARM_CPU_TYPE_MASK\r | |
66 | and r1, r1, r0\r | |
67 | \r | |
68 | mov r0, #ARM_CPU_TYPE_A15\r | |
69 | cmp r1, r0\r | |
70 | beq _Read_cp15_reg\r | |
71 | \r | |
72 | _CPU_is_not_A15\r | |
73 | mov r2, lr ; Save link register\r | |
74 | bl ArmGetScuBaseAddress ; Read SCU Base Address\r | |
75 | mov lr, r2 ; Restore link register val\r | |
76 | ldr r0, [r0, #A9_SCU_CONFIG_OFFSET] ; Read SCU Config reg to get CPU count\r | |
77 | b _Return\r | |
78 | \r | |
79 | _Read_cp15_reg\r | |
80 | mrc p15, 1, r0, c9, c0, 2 ; Read C9 register of CP15 to get CPU count\r | |
81 | lsr r0, #24\r | |
82 | \r | |
83 | \r | |
84 | _Return\r | |
85 | and r0, r0, #3\r | |
86 | // Add '1' to the number of CPU on the Cluster\r | |
87 | add r0, r0, #1\r | |
88 | ldmfd SP!, {r1-r2}\r | |
89 | bx lr\r | |
bebda7ce | 90 | ENDFUNC\r |
91 | \r | |
92 | //UINTN\r | |
93 | //ArmPlatformIsPrimaryCore (\r | |
94 | // IN UINTN MpId\r | |
95 | // );\r | |
96 | ArmPlatformIsPrimaryCore FUNCTION\r | |
66edb631 | 97 | mov32 r1, FixedPcdGet32(PcdArmPrimaryCoreMask)\r |
bebda7ce | 98 | and r0, r0, r1\r |
66edb631 | 99 | mov32 r1, FixedPcdGet32(PcdArmPrimaryCore)\r |
bebda7ce | 100 | ldr r1, [r1]\r |
101 | cmp r0, r1\r | |
102 | moveq r0, #1\r | |
103 | movne r0, #0\r | |
91c38d4e | 104 | bx lr\r |
bebda7ce | 105 | ENDFUNC\r |
88d4f51d | 106 | \r |
2d45f194 | 107 | //UINTN\r |
108 | //ArmPlatformGetCorePosition (\r | |
109 | // IN UINTN MpId\r | |
110 | // );\r | |
111 | ArmPlatformGetCorePosition FUNCTION\r | |
112 | and r1, r0, #ARM_CORE_MASK\r | |
113 | and r0, r0, #ARM_CLUSTER_MASK\r | |
114 | add r0, r1, r0, LSR #7\r | |
115 | bx lr\r | |
116 | ENDFUNC\r | |
117 | \r | |
88d4f51d | 118 | END\r |