BOOTLOADER
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
mmu.c
Go to the documentation of this file.
1 /******************************************************
2 * Function: s3c2440 mmu driver
3 * Only the section table is used.
4 * The cachable/non-cachable area can be changed by MMT_DEFAULT value.
5 * The section size is 1MB.
6 *
7 * Only the section table is used.
8 * The cachable/non-cachable area can be changed by MMT_DEFAULT value.
9 * The section size is 1MB.
10 *
11 * File: mmu.c
12 * Author: Book Chen
13 * Date: 2008.07.18
14 *******************************************************
15 */
16 #include "includes.h"
17 
18 extern char __ENTRY[]; //hzh
19 void F_MmuMttSet(int vaddrStart,int vaddrEnd,int paddrStart,int attr);
20 
21 void F_MmuInit(void)
22 {
23  int i,j;
24  //========================== IMPORTANT NOTE =========================
25  //The current stack and code area can't be re-mapped in this routine.
26  //If you want memory map mapped freely, your own sophiscated MMU
27  //initialization code is needed.
28  //===================================================================
29 
32 
33  //If write-back is used,the DCache should be cleared.
34  for(i=0;i<64;i++)
35  for(j=0;j<8;j++)
36  MMU_CleanInvalidateDCacheIndex((i<<26)|(j<<5));
38 
39  #if 0
40  //To complete MMU_Init() fast, Icache may be turned on here.
42  #endif
43 
46 
47  //F_MmuMttSet(int vaddrStart,int vaddrEnd,int paddrStart,int attr)
48  //F_MmuMttSet(0x00000000,0x07f00000,0x00000000,RW_CNB); //bank0
49  F_MmuMttSet(0x00000000,0x03f00000,(int)__ENTRY,RW_CB); //bank0, hzh
50  F_MmuMttSet(0x04000000,0x07f00000,0,RW_NCNB); //bank0, hzh
51  F_MmuMttSet(0x08000000,0x0ff00000,0x08000000,RW_CNB); //bank1
52  F_MmuMttSet(0x10000000,0x17f00000,0x10000000,RW_NCNB); //bank2
53  F_MmuMttSet(0x18000000,0x1ff00000,0x18000000,RW_NCNB); //bank3
54  //F_MmuMttSet(0x20000000,0x27f00000,0x20000000,RW_CB); //bank4
55  F_MmuMttSet(0x20000000,0x27f00000,0x20000000,RW_CNB); //bank4 for STRATA Flash
56  F_MmuMttSet(0x28000000,0x2ff00000,0x28000000,RW_NCNB); //bank5
57  //30f00000->30100000, 31000000->30200000, hzh
58  F_MmuMttSet(0x30000000,0x30100000,0x30000000,RW_CB); //bank6-1
59  F_MmuMttSet(0x30200000,0x33e00000,0x30200000,RW_NCNB); //bank6-2
60  //
61  F_MmuMttSet(0x33f00000,0x33f00000,0x33f00000,RW_CB); //bank6-3
62  F_MmuMttSet(0x38000000,0x3ff00000,0x38000000,RW_NCNB); //bank7
63 
64  F_MmuMttSet(0x40000000,0x47f00000,0x40000000,RW_NCNB); //SFR
65  F_MmuMttSet(0x48000000,0x5af00000,0x48000000,RW_NCNB); //SFR
66  F_MmuMttSet(0x5b000000,0x5b000000,0x5b000000,RW_NCNB); //SFR
67  F_MmuMttSet(0x5b100000,0xfff00000,0x5b100000,RW_FAULT);//not used
68 
69 
72  //DOMAIN1: no_access, DOMAIN0,2~15=client(AP is checked)
73  MMU_SetProcessId(0x0);
75 
76  MMU_EnableMMU();
78  MMU_EnableDCache(); //DCache should be turned on after MMU is turned on.
79 }
80 
81 
82 // attr=RW_CB,RW_CNB,RW_NCNB,RW_FAULT
83 void ChangeRomCacheStatus(int attr)
84 {
85  int i,j;
88  //If write-back is used,the DCache should be cleared.
89  for(i=0;i<64;i++)
90  for(j=0;j<8;j++)
91  MMU_CleanInvalidateDCacheIndex((i<<26)|(j<<5));
95  F_MmuMttSet(0x00000000,0x07f00000,0x00000000,attr); //bank0
96  F_MmuMttSet(0x08000000,0x0ff00000,0x08000000,attr); //bank1
97  MMU_EnableMMU();
100 }
101 
102 
103 void F_MmuMttSet(int vaddrStart,int vaddrEnd,int paddrStart,int attr)
104 {
105  volatile U32 *pTT;
106  volatile int i,nSec;
107  pTT=(U32 *)_MMUTT_STARTADDRESS+(vaddrStart>>20);
108  nSec=(vaddrEnd>>20)-(vaddrStart>>20);
109  for(i=0;i<=nSec;i++)*pTT++=attr |(((paddrStart>>20)+i)<<20);
110 }
111 
112 
113 
114 
115 
116