.armfunc _SetVectorLocation .armfunc _EnableCache .armfunc _CleanCache2 .armfunc _FlushCache2 .armfunc _InstMemBarrier .armfunc _InstMemBarrier2 .armfunc _SetTranslationTableBase .armfunc _SetDomainControl .armfunc _DisableMMUandCache .armfunc _EnableMMUandCache .armfunc _LockTLB .global _SetVectorLocation .global _EnableCache .global _CleanCache2 .global _FlushCache2 .global _InstMemBarrier .global _InstMemBarrier2 .global _SetTranslationTableBase .global _SetDomainControl .global _DisableMMUandCache .global _EnableMMUandCache .global _LockTLB .if .TMS470_16BIS _SetVectorLocation: .asmfunc BX PC NOP .state32 MRC P15, #0, R1, C1, C0, #0 BIC R1, R1, #0x2000 ORR R1, R1, #0x2000 MCR P15, #0, R1, C1, C0, #0 ADD R1, PC, #1 BX R1 .state16 BX R14 .endasmfunc _EnableCache: .asmfunc BX PC NOP .state32 MRC P15, #0, R1, C1, C0, #0 ORR R1, R1, #0x1000 ; I cache ORR R1, R1, #0x4 ; D cache MCR P15, #0, R1, C1, C0, #0 ADD R1, PC, #1 BX R1 .state16 BX R14 .endasmfunc _CleanCache2: .asmfunc ; R0 : address ; R1 : length BX PC NOP .state32 ADD R1, R0, R1, LSL #2 BIC R0, R0, #0x1F CMP R0, R1 BCS _CleanCache_End _CleanCache_Loop: MCR P15, #0, R0, C7, C10, #1 ADD R0, R0, #0x20 CMP R0, R1 BCC _CleanCache_Loop _CleanCache_End: ADD R1, PC, #1 BX R1 .state16 BX R14 .endasmfunc _FlushCache2: .asmfunc ; R0 : address ; R1 : length BX PC NOP .state32 ADD R1, R0, R1, LSL #2 BIC R0, R0, #0x1F CMP R0, R1 BCS _FlushCache_End _FlushCache_Loop: MCR P15, #0, R0, C7, C6, #1 ADD R0, R0, #0x20 CMP R0, R1 BCC _FlushCache_Loop _FlushCache_End: ADD R1, PC, #1 BX R1 .state16 BX R14 .endasmfunc _InstMemBarrier: .asmfunc BX PC NOP .state32 ; clean entire D cache using test clean and invalidate. loop: MRC P15, #0, R15, C7, C14, #3 BNE loop ; drain write buffer. MOV R0, #0 MCR P15, #0, R0, C7, C10, #4 ; invalidate I cache MCR P15, #0, R0, C7, C5, #0 ADD R1, PC, #1 BX R1 .state16 BX R14 .endasmfunc .else _SetVectorLocation: .asmfunc MRC P15, #0, R1, C1, C0, #0 BIC R1, R1, #0x2000 ORR R1, R1, #0x2000 MCR P15, #0, R1, C1, C0, #0 BX R14 .endasmfunc _EnableCache: .asmfunc MRC P15, #0, R1, C1, C0, #0 ORR R1, R1, #0x1000 ; I cache ORR R1, R1, #0x4 ; D cache MCR P15, #0, R1, C1, C0, #0 BX R14 .endasmfunc _CleanCache2: .asmfunc ; R0 : address ; R1 : length ADD R1, R0, R1, LSL #2 BIC R0, R0, #0x1F CMP R0, R1 BCS _CleanCache_End _CleanCache_Loop: MCR P15, #0, R0, C7, C10, #1 ADD R0, R0, #0x20 CMP R0, R1 BCC _CleanCache_Loop _CleanCache_End: BX R14 .endasmfunc _FlushCache2: .asmfunc ; R0 : address ; R1 : length ADD R1, R0, R1, LSL #2 BIC R0, R0, #0x1F CMP R0, R1 BCS _FlushCache_End _FlushCache_Loop: MCR P15, #0, R0, C7, C6, #1 ADD R0, R0, #0x20 CMP R0, R1 BCC _FlushCache_Loop _FlushCache_End: BX R14 .endasmfunc _InstMemBarrier: .asmfunc ; clean entire D cache using test clean and invalidate. loop: MRC P15, #0, R15, C7, C14, #3 BNE loop ; drain write buffer. MOV R0, #0 MCR P15, #0, R0, C7, C10, #4 ; invalidate I cache MCR P15, #0, R0, C7, C5, #0 BX R14 .endasmfunc _InstMemBarrier2: .asmfunc ; invalidate D cache. MCR P15, #0, R0, C7, C6, #0 ; drain write buffer. MOV R0, #0 MCR P15, #0, R0, C7, C10, #4 ; invalidate I cache MCR P15, #0, R0, C7, C5, #0 BX R14 .endasmfunc _SetTranslationTableBase: .asmfunc ; R0 : base address MCR P15, #0, R0, C2, C0, #0 BX R14 .endasmfunc _SetDomainControl: .asmfunc ; R0 : domain control MCR P15, #0, R0, C3, C0, #0 BX R14 .endasmfunc _DisableMMUandCache: .asmfunc MRC P15, #0, R1, C1, C0, #0 BIC R1, R1, #0x1000 ; I cache BIC R1, R1, #0x0004 ; D cache BIC R1, R1, #0x0001 ; MMU MCR P15, #0, R1, C1, C0, #0 NOP NOP BX R14 .endasmfunc _EnableMMUandCache: .asmfunc MRC P15, #0, R1, C1, C0, #0 ORR R1, R1, #0x1000 ; I cache ORR R1, R1, #0x0004 ; D cache ORR R1, R1, #0x0001 ; MMU MCR P15, #0, R1, C1, C0, #0 NOP NOP BX R14 .endasmfunc _LockTLB: .asmfunc ; R0 : base address MCR P15, #0, R0, C8, C7, #1 ; invalidate TLB single entry to ensure that ; LockAddr is not already in the TLB MRC P15, #0, R1, C10,C0, #0 ; read the lockdown register ORR R1, R1, #1 ; set the preserve bit MCR P15, #0, R1, C10,C0, #0 ; write to the lockdown register LDR R0, [R0] ; TLB will miss, and entry will be loaded MRC P15, #0, R1, C10,C0, #0 ; read the lockdown register (victim will have incremented) BIC R1, R1, #1 ; clear preserve bit MCR P15, #0, R1, C10,C0, #0 ; write to the lockdown register BX R14 .endasmfunc .endif