author | hgs |
Mon, 24 May 2010 18:38:55 +0100 | |
changeset 134 | 95847726fe57 |
parent 90 | 947f0dc9f7a8 |
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\emul\win32\minit.cpp |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
#include "memmodel.h" |
|
19 |
#include <emulator.h> |
|
20 |
#include <property.h> |
|
21 |
||
22 |
_LIT8(KKernelFullPathName,"EKern.exe"); |
|
23 |
_LIT8(KLitRamAlloc,"RamAlloc"); |
|
24 |
||
25 |
void M::Init1() |
|
26 |
{ |
|
27 |
__KTRACE_OPT2(KBOOT,KMMU,Kern::Printf("M::Init1")); |
|
28 |
||
29 |
SAddressInfo ainfo; |
|
30 |
Emul::TheAsic->AddressInfo(ainfo); |
|
31 |
||
32 |
MM::RamChunkSize = KRamChunkSize; |
|
33 |
MM::RamChunkShift = KRamChunkShift; |
|
34 |
MM::RamPageSize = KRamPageSize; |
|
35 |
MM::RamPageShift = KRamPageShift; |
|
36 |
MM::FreeMemory = ainfo.iTotalRamSize; |
|
37 |
TheSuperPage().iTotalRamSize = ainfo.iTotalRamSize; |
|
38 |
K::MaxFreeRam = ainfo.iTotalRamSize; |
|
39 |
PP::RamDriveMaxSize = ainfo.iRamDriveMaxSize; |
|
40 |
||
41 |
K::SupervisorThreadStackSize=0x1000; // 4K |
|
42 |
||
43 |
K::MachineConfig=(TMachineConfig*)A::MachineConfiguration().Ptr(); |
|
44 |
||
45 |
K::MaxMemCopyInOneGo=KDefaultMaxMemCopyInOneGo; |
|
46 |
__KTRACE_OPT(KBOOT,Kern::Printf("K::MaxMemCopyInOneGo=0x%x",K::MaxMemCopyInOneGo)); |
|
47 |
||
48 |
LPVOID kheap = VirtualAlloc(NULL, KKernelHeapSizeMax, MEM_RESERVE, PAGE_READWRITE); |
|
49 |
__ASSERT_ALWAYS(kheap, MM::Panic(MM::EKernelHeapReserveFailed)); |
|
50 |
kheap = VirtualAlloc(kheap, KKernelHeapSizeMin, MEM_COMMIT, PAGE_READWRITE); |
|
51 |
__ASSERT_ALWAYS(kheap, MM::Panic(MM::EKernelHeapCommitFailed)); |
|
52 |
MM::KernelHeapAddress = kheap; |
|
53 |
K::MemModelAttributes = (TUint32)(EMemModelTypeEmul|EMemModelAttrNonExProt|EMemModelAttrWriteProt|EMemModelAttrVA); |
|
54 |
||
55 |
MM::Init1(); |
|
56 |
} |
|
57 |
||
58 |
void M::Init2() |
|
59 |
{ |
|
60 |
__KTRACE_OPT2(KBOOT,KMMU,Kern::Printf("M::Init2")); |
|
61 |
TInt r=K::MutexCreate((DMutex*&)MM::RamAllocatorMutex, KLitRamAlloc, NULL, EFalse, KMutexOrdRamAlloc); |
|
62 |
__ASSERT_ALWAYS(r==KErrNone, MM::Panic(MM::ERamAllocMutexCreateFailed)); |
|
63 |
} |
|
64 |
||
65 |
void M::Init3() |
|
66 |
{ |
|
67 |
__KTRACE_OPT2(KBOOT,KMMU,Kern::Printf("M::Init3")); |
|
68 |
} |
|
69 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
70 |
void M::Init4() |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
71 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
72 |
// 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
|
73 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
74 |
|
0 | 75 |
// kernel heap construction |
76 |
||
77 |
void P::KernelInfo(TProcessCreateInfo& aInfo, TAny*& aStack, TAny*& aHeap) |
|
78 |
{ |
|
79 |
memclr(&aInfo.iUids, sizeof(TProcessCreateInfo)-sizeof(aInfo.iFileName)); |
|
80 |
aInfo.iFileName=KKernelFullPathName; |
|
81 |
aInfo.iRootNameOffset=0; |
|
82 |
aInfo.iRootNameLength=9; |
|
83 |
aInfo.iExtOffset=5; |
|
84 |
aInfo.iAttr=ECodeSegAttKernel|ECodeSegAttFixed; |
|
85 |
||
86 |
aStack=NULL; |
|
87 |
aHeap=(TAny*)MM::KernelHeapAddress; |
|
88 |
||
89 |
#ifdef _UNICODE |
|
90 |
TUint16 nameW[KMaxFileName+1]; |
|
91 |
int index; |
|
92 |
for(index=0;index<aInfo.iFileName.Length();index++) |
|
93 |
nameW[index] = (TUint16)aInfo.iFileName[index]; |
|
94 |
nameW[index] = 0; |
|
95 |
Emulator::RImageFile pefile; |
|
96 |
TInt r = pefile.Open((LPCTSTR)nameW); |
|
97 |
#else |
|
98 |
TFileName name=aInfo.iFileName; |
|
99 |
name.Append('\0'); |
|
100 |
Emulator::RImageFile pefile; |
|
101 |
TInt r = pefile.Open((LPCTSTR)name.Ptr()); |
|
102 |
#endif |
|
103 |
if (r == KErrNone) |
|
104 |
{ |
|
105 |
pefile.GetInfo(aInfo); |
|
106 |
pefile.Close(); |
|
107 |
} |
|
108 |
__ASSERT_ALWAYS(r==KErrNone, FAULT()); |
|
109 |
aInfo.iHeapSizeMin = KKernelHeapSizeMin; |
|
110 |
aInfo.iHeapSizeMax = KKernelHeapSizeMax; |
|
111 |
aInfo.iDataRunAddress = (TLinAddr)MM::KernelHeapAddress; |
|
112 |
aInfo.iStackSize = 0; |
|
113 |
} |
|
114 |
||
115 |
TInt M::InitSvHeapChunk(DChunk* aChunk, TInt aSize) |
|
116 |
{ |
|
117 |
DWin32Chunk* pC=(DWin32Chunk*)aChunk; |
|
118 |
aSize = MM::RoundToPageSize(aSize); |
|
119 |
pC->iSize = aSize; |
|
120 |
pC->iBase = (TUint8*)K::Allocator; |
|
121 |
// mark the kernel heap pages as allocated |
|
122 |
MM::FreeMemory -= aSize; |
|
123 |
__KTRACE_OPT(KBOOT,Kern::Printf("Created SvHeap chunk, addr %08X, init size %08X max size %08X",pC->Base(),aSize,pC->MaxSize())); |
|
124 |
K::HeapInfo.iChunk = aChunk; |
|
125 |
K::HeapInfo.iBase = pC->iBase; |
|
126 |
K::HeapInfo.iMaxSize = pC->MaxSize(); |
|
127 |
return KErrNone; |
|
128 |
} |
|
129 |
||
130 |
void RHeapK::Mutate(TInt aOffset, TInt aMaxLength) |
|
131 |
// |
|
132 |
// Used by the kernel to mutate a fixed heap into a chunk heap. |
|
133 |
// |
|
134 |
{ |
|
135 |
iMinLength += aOffset; |
|
136 |
iMaxLength = aMaxLength + aOffset; |
|
137 |
iOffset = aOffset; |
|
138 |
iChunkHandle = (TInt)K::HeapInfo.iChunk; |
|
139 |
iPageSize = M::PageSizeInBytes(); |
|
140 |
iGrowBy = iPageSize; |
|
141 |
iFlags &= ~(RAllocator::ESingleThreaded|RAllocator::EFixedSize); |
|
142 |
} |
|
143 |
||
144 |
// |
|
145 |
||
146 |
TInt M::InitSvStackChunk() |
|
147 |
{ |
|
148 |
return KErrNone; |
|
149 |
} |
|
150 |