1 /* ============================================================================
\r
3 @ Enable the MMU function
\r
5 @ @Liu Jun 2005-07-27
\r
6 @ Spreadtrum Communications Inc.
\r
9 @ 1. The ARM9 data cache must be used together with MMU, while the instruction
\r
10 @ cache can be used independently.
\r
13 @ mmu_c.c Create the MMU page table
\r
15 @ ============================================================================
\r
18 @AREA mmu_functions, CODE, READONLY
\r
22 @ Initialize the MMU
\r
24 .globl g_mmu_page_table
\r
25 @ IMPORT mmu_create_page_table
\r
26 .globl MMU_EnableIDCM
\r
27 .globl MMU_InvalideDCACHEALL
28 .globl MMU_InvalideICACHEALL
29 .globl Dcache_InvalRegion
31 @============================================================================
35 @ void Dcache_InvalRegion(void *addr, unsigned int length)@
39 @ Invalidate a memory region in the cache.
40 @============================================================================
42 STMFD sp!, {a1-a2, lr} @ save lr_USR and non-callee
43 ADD r1, r0, r1 @ End address
44 BIC r0, r0, #0x1f @ Align start address
47 MCRLT p15, 0x0, r0, c7, c6, 0x1 @ Invalidate cache line using MVA
48 ADDLT r0, r0, #0x20 @ Add a cache line
50 LDMFD sp!, {a1-a2, PC} @ restore registers
52 MMU_InvalideDCACHEALL:
53 STMFD sp!, {a1, lr} @ save lr_USR and non-callee
55 MRC p15, 0, r15, c7, c14, 3 @ test clean and invalidate
59 MCR p15, 0, r0, c8, c7, 0 @flush i+d-TLBs
61 LDMFD sp!, {a1, PC} @ restore registers
64 MMU_InvalideICACHEALL:
65 STMFD sp!, {a1-a4, lr} @ save lr_USR and non-callee
68 MCR p15, 0, r0, c7, c5, 0 @Invalidate(flush)the ICache
69 MCR p15, 0, r0, c8, c5, 0 @flush ITLB only
70 NOP @next few instructions may be via cache.
76 LDMFD sp!, {a1-a4, PC} @ restore registers
80 @ save lr_USR and non-callee
\r
81 STMFD sp!, {a1-a4, lr}
\r
83 @ Set the MMU page table address
\r
84 LDR r2, =g_mmu_page_table
\r
86 MCR p15, 0, r2, c2, c0, 0
\r
88 @ Domain Access Control: set all domains to manager
\r
91 @ We must set domain access before enble MMU, otherwise Bus-Error will occur!
\r
93 MCR p15, 0, r0, c3, c0, 0
\r
95 @ Enable the ICache, DCache, write buffer, MMU
\r
96 MRC p15, 0, r0, c1, c0, 0
\r
99 MCR p15, 0, r0, c1, c0, 0
\r
101 @ Delay for the operations to finish
\r
109 LDMFD sp!, {a1-a4, PC} @ restore registers
\r
111 .globl MMU_DisableIDCM
\r
114 @ save lr_USR and non-callee
\r
115 STMFD sp!, {a1-a4, lr}
\r
117 @ Disable the ICache, DCache, write buffer, MMU
\r
118 MRC p15, 0, r0, c1, c0, 0
\r
121 ORR r0, r0, #0x8 @Bit_7 must be one when write c1@
\r
122 MCR p15, 0, r0, c1, c0, 0
\r
124 @write back data in data cache to memory system @
\r
126 MRC p15, 0, r15, c7, c14, 3 @ test clean and invalidate
\r
129 @ Invalidate the ICache and DCache
\r
131 MCR p15, 0, r0, c7, c7, 0
\r
133 @ Delay for the operations to finish
\r
139 LDMFD sp!, {a1-a4, PC} @ restore registers
\r