author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Thu, 27 May 2010 14:17:14 +0300 | |
changeset 139 | 95f71bcdcdb7 |
parent 109 | b3a1d9898418 |
child 257 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 1996-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\direct\minit.cpp |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
#include <memmodel.h> |
|
19 |
#include "cache_maintenance.h" |
|
20 |
||
21 |
_LIT(KLitRamAlloc,"RamAlloc"); |
|
22 |
||
23 |
||
24 |
void M::Init1() |
|
25 |
{ |
|
26 |
__KTRACE_OPT2(KBOOT,KMMU,Kern::Printf("M::Init1")); |
|
27 |
MM::UserDataSectionBase=TheRomHeader().iUserDataAddress; |
|
28 |
MM::UserRomDataSectionEnd=TheRomHeader().iUserDataAddress+TheRomHeader().iTotalUserDataSize; |
|
29 |
MM::UserDataSectionEnd = TheSuperPage().iRamBase + TheSuperPage().iTotalRamSize; |
|
30 |
||
31 |
__KTRACE_OPT2(KBOOT,KMMU,Kern::Printf("MM::UserDataSectionBase=%08x",MM::UserDataSectionBase)); |
|
32 |
__KTRACE_OPT2(KBOOT,KMMU,Kern::Printf("MM::UserRomDataSectionEnd=%08x",MM::UserRomDataSectionEnd)); |
|
33 |
__KTRACE_OPT2(KBOOT,KMMU,Kern::Printf("MM::UserDataSectionEnd=%08x",MM::UserDataSectionEnd)); |
|
34 |
||
35 |
// Memory model dependent CPU stuff |
|
36 |
MM::Init1(); |
|
37 |
||
38 |
// Set up cache info |
|
39 |
CacheMaintenance::Init1(); |
|
40 |
} |
|
41 |
||
42 |
void M::Init2() |
|
43 |
{ |
|
44 |
__KTRACE_OPT2(KBOOT,KMMU,Kern::Printf("M::Init2")); |
|
45 |
TInt userRam=MM::UserDataSectionEnd-MM::UserDataSectionBase; |
|
46 |
TInt blocks=userRam>>MM::RamBlockShift; |
|
47 |
MM::RamAllocator=TBitMapAllocator::New(blocks,ETrue); |
|
48 |
if (!MM::RamAllocator) |
|
49 |
MM::Panic(MM::ERamAllocCreateFailed); |
|
50 |
TInt used_blocks=(MM::UserRomDataSectionEnd-MM::UserDataSectionBase)>>MM::RamBlockShift; |
|
51 |
if (used_blocks) |
|
52 |
MM::RamAllocator->Alloc(0,used_blocks); |
|
53 |
__KTRACE_OPT(KBOOT,Kern::Printf("%d blocks, %d used",blocks,used_blocks)); |
|
54 |
TInt r=K::MutexCreate((DMutex*&)MM::RamAllocatorMutex, KLitRamAlloc, NULL, EFalse, KMutexOrdRamAlloc); |
|
55 |
if (r!=KErrNone) |
|
56 |
MM::Panic(MM::ERamAllocMutexCreateFailed); |
|
57 |
const SRamBank* banks = (const SRamBank*)TheSuperPage().iRamBootData; |
|
58 |
TInt nBanks = 0; |
|
59 |
TInt maxBankBlocks = 0; |
|
60 |
TInt bnum = 0; |
|
61 |
const SRamBank* pB = banks; |
|
62 |
for (; pB->iSize; ++nBanks, ++pB) |
|
63 |
{ |
|
64 |
TInt nblocks = pB->iSize >> MM::RamBlockShift; |
|
65 |
TInt abnum = bnum &~ 31; |
|
66 |
TInt a_end = (bnum + nblocks + 31)&~31; |
|
67 |
TInt a_count = a_end - abnum; |
|
68 |
if (a_count > maxBankBlocks) |
|
69 |
maxBankBlocks = a_count; |
|
70 |
bnum += (pB->iSize >> MM::RamBlockShift); |
|
71 |
} |
|
72 |
__KTRACE_OPT(KBOOT,Kern::Printf("%d banks, max bank blocks %08x", nBanks, maxBankBlocks)); |
|
73 |
if (nBanks>1) |
|
74 |
{ |
|
75 |
MM::SecondaryAllocator = TBitMapAllocator::New(maxBankBlocks, ETrue); |
|
76 |
if (!MM::SecondaryAllocator) |
|
77 |
MM::Panic(MM::ESecAllocCreateFailed); |
|
78 |
} |
|
79 |
} |
|
80 |
||
81 |
void M::Init3() |
|
82 |
{ |
|
83 |
// Third phase MMU initialisation |
|
84 |
} |
|
85 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
86 |
void M::Init4() |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
87 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
88 |
// Fourth phase MMU initialisation - Not required on this memory model. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
89 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
90 |
|
0 | 91 |
TInt M::InitSvHeapChunk(DChunk* aChunk, TInt aSize) |
92 |
{ |
|
93 |
DMemModelChunk* pC=(DMemModelChunk*)aChunk; |
|
94 |
TLinAddr base = TheRomHeader().iKernDataAddress; |
|
95 |
K::HeapInfo.iChunk = aChunk; |
|
96 |
K::HeapInfo.iBase = (TUint8*)base; |
|
97 |
K::HeapInfo.iMaxSize = pC->MaxSize(); |
|
98 |
pC->SetFixedAddress(base, aSize); |
|
99 |
__KTRACE_OPT(KBOOT,Kern::Printf("Created SvHeap chunk, addr %08X, init size %08X max size %08X",pC->Base(),aSize,pC->MaxSize())); |
|
100 |
return KErrNone; |
|
101 |
} |
|
102 |
||
103 |
TInt M::InitSvStackChunk() |
|
104 |
{ |
|
105 |
return KErrNone; |
|
106 |
} |
|
107 |