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