Home | History | Annotate | Download | only in ArmVExpressLibCTA15-A7
      1 //
      2 //  Copyright (c) 2012-2013, ARM Limited. All rights reserved.
      3 //
      4 //  This program and the accompanying materials
      5 //  are licensed and made available under the terms and conditions of the BSD License
      6 //  which accompanies this distribution.  The full text of the license may be found at
      7 //  http://opensource.org/licenses/bsd-license.php
      8 //
      9 //  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     10 //  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     11 //
     12 //
     13 
     14 #include <AsmMacroIoLib.h>
     15 #include <Library/ArmLib.h>
     16 
     17 #include <ArmPlatform.h>
     18 
     19 .text
     20 .align 2
     21 
     22 GCC_ASM_EXPORT(ArmPlatformPeiBootAction)
     23 GCC_ASM_EXPORT(ArmPlatformGetCorePosition)
     24 GCC_ASM_EXPORT(ArmPlatformIsPrimaryCore)
     25 GCC_ASM_EXPORT(ArmPlatformGetPrimaryCoreMpId)
     26 
     27 ASM_PFX(ArmPlatformPeiBootAction):
     28   bx    lr
     29 
     30 //UINTN
     31 //ArmPlatformGetCorePosition (
     32 //  IN UINTN MpId
     33 //  );
     34 ASM_PFX(ArmPlatformGetCorePosition):
     35   and   r1, r0, #ARM_CORE_MASK
     36   and   r0, r0, #ARM_CLUSTER_MASK
     37   add   r0, r1, r0, LSR #7
     38   bx    lr
     39 
     40 //UINTN
     41 //ArmPlatformIsPrimaryCore (
     42 //  IN UINTN MpId
     43 //  );
     44 ASM_PFX(ArmPlatformIsPrimaryCore):
     45   // Extract cpu_id and cluster_id from ARM_SCC_CFGREG48
     46   // with cpu_id[0:3] and cluster_id[4:7]
     47   LoadConstantToReg (ARM_CTA15A7_SCC_CFGREG48, r1)
     48   ldr   r1, [r1]
     49   lsr   r1, #24
     50 
     51   // Shift the SCC value to get the cluster ID at the offset #8
     52   lsl   r2, r1, #4
     53   and   r2, r2, #0xF00
     54 
     55   // Keep only the cpu ID from the original SCC
     56   and   r1, r1, #0x0F
     57   // Add the Cluster ID to the Cpu ID
     58   orr   r1, r1, r2
     59 
     60   // Keep the Cluster ID and Core ID from the MPID
     61   LoadConstantToReg (ARM_CLUSTER_MASK | ARM_CORE_MASK, r2)
     62   and   r0, r0, r2
     63 
     64   // Compare mpid and boot cpu from ARM_SCC_CFGREG48
     65   cmp   r0, r1
     66   moveq r0, #1
     67   movne r0, #0
     68   bx    lr
     69 
     70 //UINTN
     71 //ArmPlatformGetPrimaryCoreMpId (
     72 //  VOID
     73 //  );
     74 ASM_PFX(ArmPlatformGetPrimaryCoreMpId):
     75   // Extract cpu_id and cluster_id from ARM_SCC_CFGREG48
     76   // with cpu_id[0:3] and cluster_id[4:7]
     77   LoadConstantToReg (ARM_CTA15A7_SCC_CFGREG48, r0)
     78   ldr   r0, [r0]
     79   lsr   r0, #24
     80 
     81   // Shift the SCC value to get the cluster ID at the offset #8
     82   lsl   r1, r0, #4
     83   and   r1, r1, #0xF00
     84 
     85   // Keep only the cpu ID from the original SCC
     86   and   r0, r0, #0x0F
     87   // Add the Cluster ID to the Cpu ID
     88   orr   r0, r0, r1
     89   bx    lr
     90