|
1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of the License "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // e32\memmodel\epoc\moving\mmu.cpp |
|
15 // |
|
16 // |
|
17 |
|
18 #include "memmodel.h" |
|
19 |
|
20 /******************************************************************************* |
|
21 * "Independent" MMU code |
|
22 *******************************************************************************/ |
|
23 |
|
24 void Mmu::Panic(TPanic aPanic) |
|
25 { |
|
26 Kern::Fault("MMU",aPanic); |
|
27 } |
|
28 |
|
29 void Mmu::Init1() |
|
30 { |
|
31 __KTRACE_OPT2(KBOOT,KMMU,Kern::Printf("Mmu::Init1")); |
|
32 __ASSERT_ALWAYS(TheRomHeader().iUserDataAddress==iDllDataBase+iMaxDllDataSize,Panic(ERomUserDataAddressInvalid)); |
|
33 __ASSERT_ALWAYS((TheRomHeader().iTotalUserDataSize&iPageMask)==0,Panic(ERomUserDataSizeInvalid)); |
|
34 __ASSERT_ALWAYS(::RomHeaderAddress==iRomLinearBase,Panic(ERomLinearAddressInvalid)); |
|
35 MmuBase::Init1(); |
|
36 } |
|
37 |
|
38 void Mmu::DoInit2() |
|
39 { |
|
40 __KTRACE_OPT2(KBOOT,KMMU,Kern::Printf("Mmu::DoInit2")); |
|
41 MM::DllDataAllocator=TBitMapAllocator::New(iMaxDllDataSize>>iPageShift, ETrue); |
|
42 __ASSERT_ALWAYS(MM::DllDataAllocator,Panic(EDllDataAllocatorCreateFailed)); |
|
43 TInt rom_dll_pages=TheRomHeader().iTotalUserDataSize>>iPageShift; |
|
44 __KTRACE_OPT2(KBOOT,KMMU,Kern::Printf("DllDataAllocator @ %08x, %d ROM DLL Data Pages", MM::DllDataAllocator, rom_dll_pages)); |
|
45 if (rom_dll_pages) |
|
46 MM::DllDataAllocator->Alloc(0, rom_dll_pages); // low bit numbers represent high addresses |
|
47 } |
|
48 |
|
49 //#ifndef __MMU_MACHINE_CODED__ |
|
50 TInt Mmu::PageTableId(TLinAddr aAddr) |
|
51 { |
|
52 NKern::LockSystem(); |
|
53 TInt id = GetPageTableId(aAddr); |
|
54 NKern::UnlockSystem(); |
|
55 return id; |
|
56 } |
|
57 //#endif |
|
58 |
|
59 void Mmu::AssignPageTable(TInt aId, TInt aUsage, TAny* aObject, TLinAddr aAddr, TPde aPdePerm) |
|
60 { |
|
61 __KTRACE_OPT(KMMU,Kern::Printf("Mmu::AssignPageTable id=%d, u=%08x, obj=%08x, addr=%08x, perm=%08x", |
|
62 aId, aUsage, aObject, aAddr, aPdePerm)); |
|
63 NKern::LockSystem(); |
|
64 SPageTableInfo& pti=PtInfo(aId); |
|
65 switch (aUsage) |
|
66 { |
|
67 // case SPageTableInfo::EChunk: |
|
68 // { |
|
69 // DMemModelChunk* pC=(DMemModelChunk*)aObject; |
|
70 // TUint32 ccp=K::CompressKHeapPtr(pC); |
|
71 // TUint32 offset=(aAddr-TLinAddr(pC->iBase))>>iChunkShift; |
|
72 // pti.SetChunk(ccp,offset); |
|
73 // break; |
|
74 // } |
|
75 // case SPageTableInfo::EHwChunk: |
|
76 // break; |
|
77 case SPageTableInfo::EGlobal: |
|
78 pti.SetGlobal(aAddr>>iChunkShift); |
|
79 break; |
|
80 default: |
|
81 Panic(EAssignPageTableInvalidUsage); |
|
82 } |
|
83 DoAssignPageTable(aId, aAddr, aPdePerm); |
|
84 NKern::UnlockSystem(); |
|
85 } |
|
86 |
|
87 TInt Mmu::UnassignPageTable(TLinAddr aAddr) |
|
88 { |
|
89 __KTRACE_OPT(KMMU,Kern::Printf("Mmu::UnassignPageTable addr=%08x", aAddr)); |
|
90 NKern::LockSystem(); |
|
91 TInt id=GetPageTableId(aAddr); |
|
92 if (id>=0) |
|
93 DoUnassignPageTable(aAddr); |
|
94 NKern::UnlockSystem(); |
|
95 return id; |
|
96 } |
|
97 |