2013-01-08 21:05:02 +08:00
|
|
|
/*
|
2018-10-15 01:35:07 +08:00
|
|
|
* Copyright (c) 2006-2018, RT-Thread Development Team
|
2013-01-08 21:05:02 +08:00
|
|
|
*
|
2018-10-15 01:35:07 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2013-01-08 21:05:02 +08:00
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
2015-04-15 16:08:43 +08:00
|
|
|
* 2015-04-15 ArdaFu Add code for IAR
|
2013-01-08 21:05:02 +08:00
|
|
|
*/
|
|
|
|
|
2013-07-21 17:19:30 +08:00
|
|
|
#include "mmu.h"
|
2013-01-08 21:05:02 +08:00
|
|
|
|
2015-04-22 11:19:50 +08:00
|
|
|
/*----- Keil -----------------------------------------------------------------*/
|
2013-04-02 20:24:51 +08:00
|
|
|
#ifdef __CC_ARM
|
|
|
|
void mmu_setttbase(rt_uint32_t i)
|
|
|
|
{
|
2015-04-14 21:56:34 +08:00
|
|
|
register rt_uint32_t value;
|
2013-04-02 20:24:51 +08:00
|
|
|
|
2015-04-15 16:08:43 +08:00
|
|
|
/* Invalidates all TLBs.Domain access is selected as
|
|
|
|
* client by configuring domain access register,
|
|
|
|
* in that case access controlled by permission value
|
|
|
|
* set by page table entry
|
|
|
|
*/
|
2015-04-14 21:56:34 +08:00
|
|
|
value = 0;
|
2015-04-22 11:19:50 +08:00
|
|
|
__asm volatile{ mcr p15, 0, value, c8, c7, 0 }
|
2015-04-14 21:56:34 +08:00
|
|
|
value = 0x55555555;
|
2015-04-22 11:19:50 +08:00
|
|
|
__asm volatile { mcr p15, 0, value, c3, c0, 0 }
|
|
|
|
__asm volatile { mcr p15, 0, i, c2, c0, 0 }
|
2013-04-02 20:24:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void mmu_set_domain(rt_uint32_t i)
|
|
|
|
{
|
2015-04-22 11:19:50 +08:00
|
|
|
__asm volatile { mcr p15, 0, i, c3, c0, 0 }
|
2013-04-02 20:24:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void mmu_enable()
|
|
|
|
{
|
|
|
|
register rt_uint32_t value;
|
|
|
|
|
2015-04-22 11:19:50 +08:00
|
|
|
__asm volatile
|
2013-04-02 20:24:51 +08:00
|
|
|
{
|
|
|
|
mrc p15, 0, value, c1, c0, 0
|
|
|
|
orr value, value, #0x01
|
|
|
|
mcr p15, 0, value, c1, c0, 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void mmu_disable()
|
|
|
|
{
|
|
|
|
register rt_uint32_t value;
|
|
|
|
|
2015-04-22 11:19:50 +08:00
|
|
|
__asm volatile
|
2013-04-02 20:24:51 +08:00
|
|
|
{
|
|
|
|
mrc p15, 0, value, c1, c0, 0
|
|
|
|
bic value, value, #0x01
|
|
|
|
mcr p15, 0, value, c1, c0, 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void mmu_enable_icache()
|
|
|
|
{
|
|
|
|
register rt_uint32_t value;
|
|
|
|
|
2015-04-22 11:19:50 +08:00
|
|
|
__asm volatile
|
2013-04-02 20:24:51 +08:00
|
|
|
{
|
|
|
|
mrc p15, 0, value, c1, c0, 0
|
|
|
|
orr value, value, #0x1000
|
|
|
|
mcr p15, 0, value, c1, c0, 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void mmu_enable_dcache()
|
|
|
|
{
|
|
|
|
register rt_uint32_t value;
|
|
|
|
|
2015-04-22 11:19:50 +08:00
|
|
|
__asm volatile
|
2013-04-02 20:24:51 +08:00
|
|
|
{
|
|
|
|
mrc p15, 0, value, c1, c0, 0
|
|
|
|
orr value, value, #0x04
|
|
|
|
mcr p15, 0, value, c1, c0, 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void mmu_disable_icache()
|
|
|
|
{
|
|
|
|
register rt_uint32_t value;
|
|
|
|
|
2015-04-22 11:19:50 +08:00
|
|
|
__asm volatile
|
2013-04-02 20:24:51 +08:00
|
|
|
{
|
|
|
|
mrc p15, 0, value, c1, c0, 0
|
|
|
|
bic value, value, #0x1000
|
|
|
|
mcr p15, 0, value, c1, c0, 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void mmu_disable_dcache()
|
|
|
|
{
|
|
|
|
register rt_uint32_t value;
|
|
|
|
|
2015-04-22 11:19:50 +08:00
|
|
|
__asm volatile
|
2013-04-02 20:24:51 +08:00
|
|
|
{
|
|
|
|
mrc p15, 0, value, c1, c0, 0
|
|
|
|
bic value, value, #0x04
|
|
|
|
mcr p15, 0, value, c1, c0, 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void mmu_enable_alignfault()
|
|
|
|
{
|
|
|
|
register rt_uint32_t value;
|
|
|
|
|
2015-04-22 11:19:50 +08:00
|
|
|
__asm volatile
|
2013-04-02 20:24:51 +08:00
|
|
|
{
|
|
|
|
mrc p15, 0, value, c1, c0, 0
|
|
|
|
orr value, value, #0x02
|
|
|
|
mcr p15, 0, value, c1, c0, 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void mmu_disable_alignfault()
|
|
|
|
{
|
|
|
|
register rt_uint32_t value;
|
|
|
|
|
2015-04-22 11:19:50 +08:00
|
|
|
__asm volatile
|
2013-04-02 20:24:51 +08:00
|
|
|
{
|
|
|
|
mrc p15, 0, value, c1, c0, 0
|
|
|
|
bic value, value, #0x02
|
|
|
|
mcr p15, 0, value, c1, c0, 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void mmu_clean_invalidated_cache_index(int index)
|
|
|
|
{
|
2015-04-22 11:19:50 +08:00
|
|
|
__asm volatile { mcr p15, 0, index, c7, c14, 2 }
|
2013-04-02 20:24:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void mmu_clean_invalidated_dcache(rt_uint32_t buffer, rt_uint32_t size)
|
|
|
|
{
|
|
|
|
unsigned int ptr;
|
|
|
|
|
|
|
|
ptr = buffer & ~(CACHE_LINE_SIZE - 1);
|
|
|
|
|
|
|
|
while(ptr < buffer + size)
|
|
|
|
{
|
2015-04-22 11:19:50 +08:00
|
|
|
__asm volatile { MCR p15, 0, ptr, c7, c14, 1 }
|
2013-04-02 20:24:51 +08:00
|
|
|
ptr += CACHE_LINE_SIZE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void mmu_clean_dcache(rt_uint32_t buffer, rt_uint32_t size)
|
|
|
|
{
|
2015-04-14 21:56:34 +08:00
|
|
|
unsigned int ptr;
|
2013-04-02 20:24:51 +08:00
|
|
|
|
2015-04-14 21:56:34 +08:00
|
|
|
ptr = buffer & ~(CACHE_LINE_SIZE - 1);
|
2013-04-02 20:24:51 +08:00
|
|
|
|
2015-04-14 21:56:34 +08:00
|
|
|
while (ptr < buffer + size)
|
|
|
|
{
|
2015-04-22 11:19:50 +08:00
|
|
|
__asm volatile { MCR p15, 0, ptr, c7, c10, 1 }
|
2015-04-14 21:56:34 +08:00
|
|
|
ptr += CACHE_LINE_SIZE;
|
|
|
|
}
|
2013-04-02 20:24:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void mmu_invalidate_dcache(rt_uint32_t buffer, rt_uint32_t size)
|
|
|
|
{
|
2015-04-14 21:56:34 +08:00
|
|
|
unsigned int ptr;
|
2013-04-02 20:24:51 +08:00
|
|
|
|
2015-04-14 21:56:34 +08:00
|
|
|
ptr = buffer & ~(CACHE_LINE_SIZE - 1);
|
2013-04-02 20:24:51 +08:00
|
|
|
|
2015-04-14 21:56:34 +08:00
|
|
|
while (ptr < buffer + size)
|
|
|
|
{
|
2015-04-22 11:19:50 +08:00
|
|
|
__asm volatile { MCR p15, 0, ptr, c7, c6, 1 }
|
2015-04-14 21:56:34 +08:00
|
|
|
ptr += CACHE_LINE_SIZE;
|
|
|
|
}
|
2013-04-02 20:24:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void mmu_invalidate_tlb()
|
|
|
|
{
|
|
|
|
register rt_uint32_t value;
|
|
|
|
|
|
|
|
value = 0;
|
2015-04-22 11:19:50 +08:00
|
|
|
__asm volatile { mcr p15, 0, value, c8, c7, 0 }
|
2013-04-02 20:24:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void mmu_invalidate_icache()
|
|
|
|
{
|
|
|
|
register rt_uint32_t value;
|
|
|
|
|
|
|
|
value = 0;
|
|
|
|
|
2015-04-22 11:19:50 +08:00
|
|
|
__asm volatile { mcr p15, 0, value, c7, c5, 0 }
|
2013-04-02 20:24:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void mmu_invalidate_dcache_all()
|
|
|
|
{
|
|
|
|
register rt_uint32_t value;
|
|
|
|
|
|
|
|
value = 0;
|
|
|
|
|
2015-04-22 11:19:50 +08:00
|
|
|
__asm volatile { mcr p15, 0, value, c7, c6, 0 }
|
2013-04-02 20:24:51 +08:00
|
|
|
}
|
2015-04-22 11:19:50 +08:00
|
|
|
/*----- GNU ------------------------------------------------------------------*/
|
|
|
|
#elif defined(__GNUC__) || defined(__ICCARM__)
|
2013-01-08 21:05:02 +08:00
|
|
|
void mmu_setttbase(register rt_uint32_t i)
|
|
|
|
{
|
2015-04-14 21:56:34 +08:00
|
|
|
register rt_uint32_t value;
|
|
|
|
|
2015-04-15 16:08:43 +08:00
|
|
|
/* Invalidates all TLBs.Domain access is selected as
|
|
|
|
* client by configuring domain access register,
|
|
|
|
* in that case access controlled by permission value
|
|
|
|
* set by page table entry
|
|
|
|
*/
|
2015-04-14 21:56:34 +08:00
|
|
|
value = 0;
|
2015-04-22 11:19:50 +08:00
|
|
|
asm volatile ("mcr p15, 0, %0, c8, c7, 0"::"r"(value));
|
2015-04-14 21:56:34 +08:00
|
|
|
|
|
|
|
value = 0x55555555;
|
2015-04-22 11:19:50 +08:00
|
|
|
asm volatile ("mcr p15, 0, %0, c3, c0, 0"::"r"(value));
|
2015-04-14 21:56:34 +08:00
|
|
|
|
2015-04-22 11:19:50 +08:00
|
|
|
asm volatile ("mcr p15, 0, %0, c2, c0, 0"::"r"(i));
|
2013-04-02 20:24:51 +08:00
|
|
|
|
2013-01-08 21:05:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void mmu_set_domain(register rt_uint32_t i)
|
|
|
|
{
|
2015-04-22 11:19:50 +08:00
|
|
|
asm volatile ("mcr p15,0, %0, c3, c0, 0": :"r" (i));
|
2013-01-08 21:05:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void mmu_enable()
|
|
|
|
{
|
2015-04-22 11:19:50 +08:00
|
|
|
asm volatile
|
|
|
|
(
|
|
|
|
"mrc p15, 0, r0, c1, c0, 0 \n"
|
|
|
|
"orr r0, r0, #0x1 \n"
|
|
|
|
"mcr p15, 0, r0, c1, c0, 0 \n"
|
|
|
|
:::"r0"
|
|
|
|
);
|
2013-01-08 21:05:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void mmu_disable()
|
|
|
|
{
|
2015-04-22 11:19:50 +08:00
|
|
|
asm volatile
|
|
|
|
(
|
|
|
|
"mrc p15, 0, r0, c1, c0, 0 \n"
|
|
|
|
"bic r0, r0, #0x1 \n"
|
|
|
|
"mcr p15, 0, r0, c1, c0, 0 \n"
|
|
|
|
:::"r0"
|
|
|
|
);
|
2013-01-08 21:05:02 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void mmu_enable_icache()
|
|
|
|
{
|
2015-04-22 11:19:50 +08:00
|
|
|
asm volatile
|
|
|
|
(
|
|
|
|
"mrc p15, 0, r0, c1, c0, 0 \n"
|
|
|
|
"orr r0, r0, #(1<<12) \n"
|
|
|
|
"mcr p15, 0, r0, c1, c0, 0 \n"
|
|
|
|
:::"r0"
|
|
|
|
);
|
2013-01-08 21:05:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void mmu_enable_dcache()
|
|
|
|
{
|
2015-04-22 11:19:50 +08:00
|
|
|
asm volatile
|
|
|
|
(
|
|
|
|
"mrc p15, 0, r0, c1, c0, 0 \n"
|
|
|
|
"orr r0, r0, #(1<<2) \n"
|
|
|
|
"mcr p15, 0, r0, c1, c0, 0 \n"
|
|
|
|
:::"r0"
|
|
|
|
);
|
2013-01-08 21:05:02 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void mmu_disable_icache()
|
|
|
|
{
|
2015-04-22 11:19:50 +08:00
|
|
|
asm volatile
|
|
|
|
(
|
|
|
|
"mrc p15, 0, r0, c1, c0, 0 \n"
|
|
|
|
"bic r0, r0, #(1<<12) \n"
|
|
|
|
"mcr p15, 0, r0, c1, c0, 0 \n"
|
|
|
|
:::"r0"
|
|
|
|
);
|
2013-01-08 21:05:02 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void mmu_disable_dcache()
|
|
|
|
{
|
2015-04-22 11:19:50 +08:00
|
|
|
asm volatile
|
|
|
|
(
|
|
|
|
"mrc p15, 0, r0, c1, c0, 0 \n"
|
|
|
|
"bic r0, r0, #(1<<2) \n"
|
|
|
|
"mcr p15, 0, r0, c1, c0, 0 \n"
|
|
|
|
:::"r0"
|
|
|
|
);
|
2013-01-08 21:05:02 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void mmu_enable_alignfault()
|
|
|
|
{
|
2015-04-22 11:19:50 +08:00
|
|
|
asm volatile
|
|
|
|
(
|
|
|
|
"mrc p15, 0, r0, c1, c0, 0 \n"
|
|
|
|
"orr r0, r0, #1 \n"
|
|
|
|
"mcr p15, 0, r0, c1, c0, 0 \n"
|
|
|
|
:::"r0"
|
|
|
|
);
|
2013-01-08 21:05:02 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void mmu_disable_alignfault()
|
|
|
|
{
|
2015-04-22 11:19:50 +08:00
|
|
|
asm volatile
|
|
|
|
(
|
|
|
|
"mrc p15, 0, r0, c1, c0, 0 \n"
|
|
|
|
"bic r0, r0, #1 \n"
|
|
|
|
"mcr p15, 0, r0, c1, c0, 0 \n"
|
|
|
|
:::"r0"
|
|
|
|
);
|
2013-01-08 21:05:02 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void mmu_clean_invalidated_cache_index(int index)
|
|
|
|
{
|
2015-04-22 11:19:50 +08:00
|
|
|
asm volatile ("mcr p15, 0, %0, c7, c14, 2": :"r" (index));
|
2013-01-08 21:05:02 +08:00
|
|
|
}
|
|
|
|
|
2013-04-02 20:24:51 +08:00
|
|
|
void mmu_clean_invalidated_dcache(rt_uint32_t buffer, rt_uint32_t size)
|
2013-01-08 21:05:02 +08:00
|
|
|
{
|
2013-04-02 20:24:51 +08:00
|
|
|
unsigned int ptr;
|
2013-01-08 21:05:02 +08:00
|
|
|
|
2013-04-02 20:24:51 +08:00
|
|
|
ptr = buffer & ~(CACHE_LINE_SIZE - 1);
|
2013-01-08 21:05:02 +08:00
|
|
|
|
2013-04-02 20:24:51 +08:00
|
|
|
while(ptr < buffer + size)
|
2013-01-08 21:05:02 +08:00
|
|
|
{
|
2015-04-22 11:19:50 +08:00
|
|
|
asm volatile ("mcr p15, 0, %0, c7, c14, 1": :"r" (ptr));
|
|
|
|
|
2013-04-02 20:24:51 +08:00
|
|
|
ptr += CACHE_LINE_SIZE;
|
2013-01-08 21:05:02 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-04-02 20:24:51 +08:00
|
|
|
void mmu_clean_dcache(rt_uint32_t buffer, rt_uint32_t size)
|
2013-01-08 21:05:02 +08:00
|
|
|
{
|
2015-04-14 21:56:34 +08:00
|
|
|
unsigned int ptr;
|
2013-01-08 21:05:02 +08:00
|
|
|
|
2015-04-14 21:56:34 +08:00
|
|
|
ptr = buffer & ~(CACHE_LINE_SIZE - 1);
|
2013-01-08 21:05:02 +08:00
|
|
|
|
2015-04-14 21:56:34 +08:00
|
|
|
while (ptr < buffer + size)
|
|
|
|
{
|
2015-04-22 11:19:50 +08:00
|
|
|
asm volatile ("mcr p15, 0, %0, c7, c10, 1": :"r" (ptr));
|
|
|
|
|
2015-04-14 21:56:34 +08:00
|
|
|
ptr += CACHE_LINE_SIZE;
|
|
|
|
}
|
2013-01-08 21:05:02 +08:00
|
|
|
}
|
|
|
|
|
2013-04-02 20:24:51 +08:00
|
|
|
void mmu_invalidate_dcache(rt_uint32_t buffer, rt_uint32_t size)
|
2013-01-08 21:05:02 +08:00
|
|
|
{
|
2015-04-14 21:56:34 +08:00
|
|
|
unsigned int ptr;
|
2013-01-08 21:05:02 +08:00
|
|
|
|
2015-04-14 21:56:34 +08:00
|
|
|
ptr = buffer & ~(CACHE_LINE_SIZE - 1);
|
2013-01-08 21:05:02 +08:00
|
|
|
|
2015-04-14 21:56:34 +08:00
|
|
|
while (ptr < buffer + size)
|
|
|
|
{
|
2015-04-22 11:19:50 +08:00
|
|
|
asm volatile ("mcr p15, 0, %0, c7, c6, 1": :"r" (ptr));
|
|
|
|
|
2015-04-14 21:56:34 +08:00
|
|
|
ptr += CACHE_LINE_SIZE;
|
|
|
|
}
|
2013-01-08 21:05:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void mmu_invalidate_tlb()
|
|
|
|
{
|
2015-04-22 11:19:50 +08:00
|
|
|
asm volatile ("mcr p15, 0, %0, c8, c7, 0": :"r" (0));
|
|
|
|
|
2013-01-08 21:05:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void mmu_invalidate_icache()
|
|
|
|
{
|
2015-04-22 11:19:50 +08:00
|
|
|
asm volatile ("mcr p15, 0, %0, c7, c5, 0": :"r" (0));
|
|
|
|
|
2013-04-02 20:24:51 +08:00
|
|
|
}
|
2013-01-08 21:05:02 +08:00
|
|
|
|
2013-04-02 20:24:51 +08:00
|
|
|
void mmu_invalidate_dcache_all()
|
|
|
|
{
|
2015-04-22 11:19:50 +08:00
|
|
|
asm volatile ("mcr p15, 0, %0, c7, c6, 0": :"r" (0));
|
|
|
|
|
2013-01-08 21:05:02 +08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-04-02 20:24:51 +08:00
|
|
|
/* level1 page table */
|
2015-04-14 21:56:34 +08:00
|
|
|
#if defined(__ICCARM__)
|
|
|
|
#pragma data_alignment=(16*1024)
|
2015-04-22 11:19:50 +08:00
|
|
|
static volatile rt_uint32_t _page_table[4*1024];
|
2015-04-14 21:56:34 +08:00
|
|
|
#else
|
2015-04-22 11:19:50 +08:00
|
|
|
static volatile rt_uint32_t _page_table[4*1024] \
|
|
|
|
__attribute__((aligned(16*1024)));
|
2015-04-14 21:56:34 +08:00
|
|
|
#endif
|
2015-04-22 11:19:50 +08:00
|
|
|
|
2015-04-15 16:08:43 +08:00
|
|
|
void mmu_setmtt(rt_uint32_t vaddrStart, rt_uint32_t vaddrEnd,
|
|
|
|
rt_uint32_t paddrStart, rt_uint32_t attr)
|
2013-01-08 21:05:02 +08:00
|
|
|
{
|
|
|
|
volatile rt_uint32_t *pTT;
|
2015-04-14 21:56:34 +08:00
|
|
|
volatile int nSec;
|
|
|
|
int i = 0;
|
2013-04-02 20:24:51 +08:00
|
|
|
pTT=(rt_uint32_t *)_page_table+(vaddrStart>>20);
|
2013-01-08 21:05:02 +08:00
|
|
|
nSec=(vaddrEnd>>20)-(vaddrStart>>20);
|
2015-04-15 16:08:43 +08:00
|
|
|
for(i=0; i<=nSec; i++)
|
2013-01-08 21:05:02 +08:00
|
|
|
{
|
2015-04-14 21:56:34 +08:00
|
|
|
*pTT = attr |(((paddrStart>>20)+i)<<20);
|
|
|
|
pTT++;
|
2013-01-08 21:05:02 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-21 17:19:30 +08:00
|
|
|
void rt_hw_mmu_init(struct mem_desc *mdesc, rt_uint32_t size)
|
2013-01-08 21:05:02 +08:00
|
|
|
{
|
2015-04-14 21:56:34 +08:00
|
|
|
/* disable I/D cache */
|
|
|
|
mmu_disable_dcache();
|
|
|
|
mmu_disable_icache();
|
|
|
|
mmu_disable();
|
|
|
|
mmu_invalidate_tlb();
|
|
|
|
|
|
|
|
/* set page table */
|
|
|
|
for (; size > 0; size--)
|
|
|
|
{
|
2015-04-15 16:08:43 +08:00
|
|
|
mmu_setmtt(mdesc->vaddr_start, mdesc->vaddr_end,
|
|
|
|
mdesc->paddr_start, mdesc->attr);
|
2015-04-14 21:56:34 +08:00
|
|
|
mdesc++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set MMU table address */
|
|
|
|
mmu_setttbase((rt_uint32_t)_page_table);
|
2013-01-08 21:05:02 +08:00
|
|
|
|
2013-04-02 20:24:51 +08:00
|
|
|
/* enables MMU */
|
|
|
|
mmu_enable();
|
2013-01-08 21:05:02 +08:00
|
|
|
|
2013-04-02 20:24:51 +08:00
|
|
|
/* enable Instruction Cache */
|
|
|
|
mmu_enable_icache();
|
2013-01-08 21:05:02 +08:00
|
|
|
|
2013-04-02 20:24:51 +08:00
|
|
|
/* enable Data Cache */
|
|
|
|
mmu_enable_dcache();
|
|
|
|
|
|
|
|
mmu_invalidate_icache();
|
|
|
|
mmu_invalidate_dcache_all();
|
2013-01-08 21:05:02 +08:00
|
|
|
}
|