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