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   INCLUDE AsmMacroIoLib.inc
     20 
     21   EXPORT  ArmPlatformPeiBootAction
     22   EXPORT  ArmPlatformGetCorePosition
     23   EXPORT  ArmPlatformIsPrimaryCore
     24   EXPORT  ArmPlatformGetPrimaryCoreMpId
     25 
     26   PRESERVE8
     27   AREA    CTA15A7Helper, CODE, READONLY
     28 
     29 ArmPlatformPeiBootAction FUNCTION
     30   bx    lr
     31   ENDFUNC
     32 
     33 //UINTN
     34 //ArmPlatformGetCorePosition (
     35 //  IN UINTN MpId
     36 //  );
     37 ArmPlatformGetCorePosition FUNCTION
     38   and   r1, r0, #ARM_CORE_MASK
     39   and   r0, r0, #ARM_CLUSTER_MASK
     40   add   r0, r1, r0, LSR #7
     41   bx    lr
     42   ENDFUNC
     43 
     44 //UINTN
     45 //ArmPlatformIsPrimaryCore (
     46 //  IN UINTN MpId
     47 //  );
     48 ArmPlatformIsPrimaryCore FUNCTION
     49   // Extract cpu_id and cluster_id from ARM_SCC_CFGREG48
     50   // with cpu_id[0:3] and cluster_id[4:7]
     51   LoadConstantToReg (ARM_CTA15A7_SCC_CFGREG48, r1)
     52   ldr   r1, [r1]
     53   lsr   r1, #24
     54 
     55   // Shift the SCC value to get the cluster ID at the offset #8
     56   lsl   r2, r1, #4
     57   and   r2, r2, #0xF00
     58 
     59   // Keep only the cpu ID from the original SCC
     60   and   r1, r1, #0x0F
     61   // Add the Cluster ID to the Cpu ID
     62   orr   r1, r1, r2
     63 
     64   // Keep the Cluster ID and Core ID from the MPID
     65   LoadConstantToReg (ARM_CLUSTER_MASK :OR: ARM_CORE_MASK, r2)
     66   and   r0, r0, r2
     67 
     68   // Compare mpid and boot cpu from ARM_SCC_CFGREG48
     69   cmp   r0, r1
     70   moveq r0, #1
     71   movne r0, #0
     72   bx    lr
     73   ENDFUNC
     74 
     75 //UINTN
     76 //ArmPlatformGetPrimaryCoreMpId (
     77 //  VOID
     78 //  );
     79 ArmPlatformGetPrimaryCoreMpId FUNCTION
     80   // Extract cpu_id and cluster_id from ARM_SCC_CFGREG48
     81   // with cpu_id[0:3] and cluster_id[4:7]
     82   LoadConstantToReg (ARM_CTA15A7_SCC_CFGREG48, r0)
     83   ldr   r0, [r0]
     84   lsr   r0, #24
     85 
     86   // Shift the SCC value to get the cluster ID at the offset #8
     87   lsl   r1, r0, #4
     88   and   r1, r1, #0xF00
     89 
     90   // Keep only the cpu ID from the original SCC
     91   and   r0, r0, #0x0F
     92   // Add the Cluster ID to the Cpu ID
     93   orr   r0, r0, r1
     94   bx    lr
     95   ENDFUNC
     96 
     97   END
     98