]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPkg/Library/ArmLib/ArmV7/ArmV7Support.S
Cleanup Cache an MMU operations.
[mirror_edk2.git] / ArmPkg / Library / ArmLib / ArmV7 / ArmV7Support.S
index 2cde8e20395d610364020cba3e04516f0d09f962..c9dbce3e1248e9ba4c48904fc5d2b601cded4ca2 100644 (file)
@@ -12,8 +12,6 @@
 #
 #------------------------------------------------------------------------------
 
-.text
-.align 2
 .globl ASM_PFX(ArmInvalidateInstructionCache)
 .globl ASM_PFX(ArmInvalidateDataCacheEntryByMVA)
 .globl ASM_PFX(ArmCleanDataCacheEntryByMVA)
 .globl ASM_PFX(ArmDisableDataCache)
 .globl ASM_PFX(ArmEnableInstructionCache)
 .globl ASM_PFX(ArmDisableInstructionCache)
-.globl ASM_PFX(ArmEnableExtendPTConfig)
-.globl ASM_PFX(ArmDisableExtendPTConfig)
 .globl ASM_PFX(ArmEnableBranchPrediction)
 .globl ASM_PFX(ArmDisableBranchPrediction)
 .globl ASM_PFX(ArmV7AllDataCachesOperation)
+.globl ASM_PFX(ArmDataMemoryBarrier)
+.globl ASM_PFX(ArmDataSyncronizationBarrier) 
+.globl ASM_PFX(ArmInstructionSynchronizationBarrier)
+
+.text
+.align 2
 
 .set DC_ON, (0x1<<2)
 .set IC_ON, (0x1<<12)
 
 
+
 ASM_PFX(ArmInvalidateDataCacheEntryByMVA):
   mcr     p15, 0, r0, c7, c6, 1   @invalidate single data cache line       
   dsb
@@ -81,17 +84,8 @@ ASM_PFX(ArmCleanDataCacheEntryBySetWay):
   bx      lr
 
 
-ASM_PFX(ArmDrainWriteBuffer):
-  mcr     p15, 0, r0, c7, c10, 4       @ Drain write buffer for sync
-  dsb
-  isb
-  bx      lr
-  
-
 ASM_PFX(ArmInvalidateInstructionCache):
-  mov     R0,#0
   mcr     p15,0,R0,c7,c5,0      @Invalidate entire instruction cache
-  mov     R0,#0
   dsb
   isb
   bx      LR
@@ -100,6 +94,8 @@ ASM_PFX(ArmEnableMmu):
   mrc     p15,0,R0,c1,c0,0
   orr     R0,R0,#1
   mcr     p15,0,R0,c1,c0,0
+  dsb
+  isb
   bx      LR
 
 ASM_PFX(ArmMmuEnabled):
@@ -107,14 +103,13 @@ ASM_PFX(ArmMmuEnabled):
   and     R0,R0,#1
   bx      LR
 
-
 ASM_PFX(ArmDisableMmu):
-  mov     R0,#0
-  mcr     p15,0,R0,c13,c0,0     @FCSE PID register must be cleared before disabling MMU
   mrc     p15,0,R0,c1,c0,0
   bic     R0,R0,#1
   mcr     p15,0,R0,c1,c0,0      @Disable MMU
-  mov     R0,#0
+
+       mcr             p15,0,R0,c8,c7,0      @Invalidate TLB
+  mcr     p15,0,R0,c7,c5,6      @Invalidate Branch predictor array
   dsb
   isb
   bx      LR
@@ -188,14 +183,16 @@ Loop1:
   cmp   R12, #2
   blt   L_Skip                  @ no cache or only instruction cache at this level
   mcr   p15, 2, R10, c0, c0, 0  @ write the Cache Size selection register (CSSELR) // OR in 1 for Instruction
-  isb                           @ ISB to sync the change to the CacheSizeID reg 
-  mcr   p15, 1, R12, c0, c0, 0  @ reads current Cache Size ID register (CCSIDR)
+  isb                           @ isb to sync the change to the CacheSizeID reg 
+  mrc   p15, 1, R12, c0, c0, 0  @ reads current Cache Size ID register (CCSIDR)
   and   R2, R12, #0x7           @ extract the line length field
-  and   R2, R2, #4              @ add 4 for the line length offset (log2 16 bytes)
+  add   R2, R2, #4              @ add 4 for the line length offset (log2 16 bytes)
+@  ldr   R4, =0x3FF
   mov   R4, #0x400
   sub   R4, R4, #1
   ands  R4, R4, R12, LSR #3     @ R4 is the max number on the way size (right aligned)
   clz   R5, R4                  @ R5 is the bit position of the way size increment
+@  ldr   R7, =0x00007FFF
   mov   R7, #0x00008000
   sub   R7, R7, #1
   ands  R7, R7, R12, LSR #13    @ R7 is the max number of the index size (right aligned)
@@ -219,8 +216,22 @@ L_Skip:
   bgt   Loop1
   
 L_Finished:
+  dsb
   ldmfd SP!, {r4-r12, lr}
   bx    LR
 
+ASM_PFX(ArmDataMemoryBarrier):
+  dmb
+  bx      LR
+  
+ASM_PFX(ArmDataSyncronizationBarrier):
+ASM_PFX(ArmDrainWriteBuffer):
+  dsb
+  bx      LR
+  
+ASM_PFX(ArmInstructionSynchronizationBarrier):
+  isb
+  bx      LR
 
 ASM_FUNCTION_REMOVE_IF_UNREFERENCED