sl@0
|
1 |
// Copyright (c) 1996-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\multiple\minit.cpp
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#include "memmodel.h"
|
sl@0
|
19 |
#include "cache_maintenance.h"
|
sl@0
|
20 |
|
sl@0
|
21 |
_LIT(KLitSvStack,"SvStack");
|
sl@0
|
22 |
|
sl@0
|
23 |
const TInt KMaxThreads=1024;
|
sl@0
|
24 |
|
sl@0
|
25 |
void M::Init1()
|
sl@0
|
26 |
{
|
sl@0
|
27 |
// Memory model dependent CPU stuff
|
sl@0
|
28 |
MM::Init1();
|
sl@0
|
29 |
|
sl@0
|
30 |
// Set up cache info
|
sl@0
|
31 |
CacheMaintenance::Init1();
|
sl@0
|
32 |
|
sl@0
|
33 |
// First phase MMU initialisation
|
sl@0
|
34 |
Mmu& m=Mmu::Get();
|
sl@0
|
35 |
m.Init1();
|
sl@0
|
36 |
}
|
sl@0
|
37 |
|
sl@0
|
38 |
void M::Init2()
|
sl@0
|
39 |
{
|
sl@0
|
40 |
// Second phase MMU initialisation
|
sl@0
|
41 |
Mmu& m=Mmu::Get();
|
sl@0
|
42 |
m.Init2();
|
sl@0
|
43 |
}
|
sl@0
|
44 |
|
sl@0
|
45 |
void M::Init3()
|
sl@0
|
46 |
{
|
sl@0
|
47 |
// Third phase MMU initialisation
|
sl@0
|
48 |
Mmu& m=Mmu::Get();
|
sl@0
|
49 |
m.Init3();
|
sl@0
|
50 |
}
|
sl@0
|
51 |
|
sl@0
|
52 |
TInt M::InitSvHeapChunk(DChunk* aChunk, TInt aSize)
|
sl@0
|
53 |
{
|
sl@0
|
54 |
TInt r;
|
sl@0
|
55 |
TLinAddr base = TheRomHeader().iKernDataAddress;
|
sl@0
|
56 |
DMemModelChunk* pC = (DMemModelChunk*)aChunk;
|
sl@0
|
57 |
K::HeapInfo.iChunk = aChunk;
|
sl@0
|
58 |
K::HeapInfo.iBase = (TUint8*)base;
|
sl@0
|
59 |
K::HeapInfo.iMaxSize = pC->MaxSize();
|
sl@0
|
60 |
pC->SetFixedAddress(base, aSize);
|
sl@0
|
61 |
__KTRACE_OPT(KBOOT,Kern::Printf("Created SvHeap chunk, addr %08X, init size %08X max size %08X",pC->Base(),aSize,pC->MaxSize()));
|
sl@0
|
62 |
TLinAddr dataSectionBase=0;
|
sl@0
|
63 |
r=((DMemModelProcess*)K::TheKernelProcess)->AddChunk(pC,dataSectionBase,EFalse);
|
sl@0
|
64 |
__KTRACE_OPT(KBOOT,Kern::Printf("Added kernel heap chunk to current process, %d",r));
|
sl@0
|
65 |
return r;
|
sl@0
|
66 |
}
|
sl@0
|
67 |
|
sl@0
|
68 |
TInt M::InitSvStackChunk()
|
sl@0
|
69 |
{
|
sl@0
|
70 |
// create a chunk to hold supervisor-mode stacks
|
sl@0
|
71 |
Mmu& m=Mmu::Get();
|
sl@0
|
72 |
TInt alias_space=m.iAliasSize+m.iPageSize;
|
sl@0
|
73 |
TInt total=alias_space+K::SupervisorThreadStackSize+PP::SupervisorThreadStackGuard;
|
sl@0
|
74 |
total=(total+m.iAliasMask)&~m.iAliasMask;
|
sl@0
|
75 |
DMemModelChunk* pC=NULL;
|
sl@0
|
76 |
DMemModelProcess* pP=(DMemModelProcess*)K::TheKernelProcess;
|
sl@0
|
77 |
TInt maxsize=total*KMaxThreads;
|
sl@0
|
78 |
TLinAddr dataSectionBase=0;
|
sl@0
|
79 |
SChunkCreateInfo cinfo;
|
sl@0
|
80 |
cinfo.iGlobal=EFalse;
|
sl@0
|
81 |
cinfo.iAtt=TChunkCreate::EDisconnected;
|
sl@0
|
82 |
cinfo.iForceFixed=EFalse;
|
sl@0
|
83 |
cinfo.iOperations=0;
|
sl@0
|
84 |
cinfo.iType=EKernelStack;
|
sl@0
|
85 |
cinfo.iMaxSize=maxsize;
|
sl@0
|
86 |
cinfo.iPreallocated=0;
|
sl@0
|
87 |
cinfo.iName.Set(KLitSvStack);
|
sl@0
|
88 |
cinfo.iOwner=K::TheKernelProcess;
|
sl@0
|
89 |
TInt r=pP->NewChunk((DChunk*&)pC,cinfo,dataSectionBase);
|
sl@0
|
90 |
__KTRACE_OPT(KBOOT,Kern::Printf("Created SvStack, %d",r));
|
sl@0
|
91 |
if (r!=KErrNone)
|
sl@0
|
92 |
return r;
|
sl@0
|
93 |
r=pC->Reserve(0);
|
sl@0
|
94 |
if (r!=KErrNone)
|
sl@0
|
95 |
return r;
|
sl@0
|
96 |
__KTRACE_OPT(KBOOT,Kern::Printf("Created SvStack chunk, addr %08X, max size %08X",pC->Base(),maxsize));
|
sl@0
|
97 |
MM::SvStackChunk=pC;
|
sl@0
|
98 |
r=pP->AddChunk(pC,dataSectionBase,EFalse);
|
sl@0
|
99 |
__KTRACE_OPT(KBOOT,Kern::Printf("Added SvStack chunk to current process, %d",r));
|
sl@0
|
100 |
return r;
|
sl@0
|
101 |
}
|
sl@0
|
102 |
|