sl@0: // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32\memmodel\epoc\moving\minit.cpp sl@0: // sl@0: // sl@0: sl@0: #include "memmodel.h" sl@0: #include "cache_maintenance.h" sl@0: sl@0: _LIT(KLitSvStack,"SvStack"); sl@0: sl@0: const TInt KMaxSupervisorStackSpace=0x200000; sl@0: sl@0: void M::Init1() sl@0: { sl@0: TheCurrentAddressSpace=NULL; sl@0: TheCurrentVMProcess=NULL; sl@0: TheCurrentDataSectionProcess=NULL; sl@0: TheCompleteDataSectionProcess=NULL; sl@0: sl@0: // Memory model dependent CPU stuff sl@0: MM::Init1(); sl@0: sl@0: // Set up cache info sl@0: CacheMaintenance::Init1(); sl@0: sl@0: // First phase MMU initialisation sl@0: Mmu& m=Mmu::Get(); sl@0: m.Init1(); sl@0: } sl@0: sl@0: void M::Init2() sl@0: { sl@0: // Second phase MMU initialisation sl@0: Mmu& m=Mmu::Get(); sl@0: m.Init2(); sl@0: } sl@0: sl@0: void M::Init3() sl@0: { sl@0: // Third phase MMU initialisation sl@0: Mmu& m=Mmu::Get(); sl@0: m.Init3(); sl@0: } sl@0: sl@0: TInt M::InitSvHeapChunk(DChunk* aChunk, TInt aSize) sl@0: { sl@0: TInt r; sl@0: DMemModelChunk* pC=(DMemModelChunk*)aChunk; sl@0: TLinAddr base = TheRomHeader().iKernDataAddress; sl@0: K::HeapInfo.iChunk = aChunk; sl@0: K::HeapInfo.iBase = (TUint8*)base; sl@0: K::HeapInfo.iMaxSize = pC->MaxSize(); sl@0: pC->SetFixedAddress(base, aSize); sl@0: __KTRACE_OPT(KBOOT,Kern::Printf("Created SvHeap chunk, addr %08X, init size %08X max size %08X",pC->Base(),aSize,pC->MaxSize())); sl@0: TLinAddr dataSectionBase=0; sl@0: r=((DMemModelProcess*)K::TheKernelProcess)->AddChunk(pC,dataSectionBase,EFalse); sl@0: __KTRACE_OPT(KBOOT,Kern::Printf("Added kernel heap chunk to current process, %d",r)); sl@0: return r; sl@0: } sl@0: sl@0: TInt M::InitSvStackChunk() sl@0: { sl@0: // create a chunk to hold supervisor-mode stacks sl@0: DMemModelChunk* pC=NULL; sl@0: DMemModelProcess* pP=(DMemModelProcess*)K::TheKernelProcess; sl@0: TInt maxsize=Mmu::RoundToChunkSize(KMaxSupervisorStackSpace); sl@0: TLinAddr dataSectionBase=0; sl@0: SChunkCreateInfo cinfo; sl@0: cinfo.iGlobal=EFalse; sl@0: cinfo.iAtt=TChunkCreate::EDisconnected; sl@0: cinfo.iForceFixed=EFalse; sl@0: cinfo.iOperations=0; sl@0: cinfo.iType=EKernelStack; sl@0: cinfo.iMaxSize=maxsize; sl@0: cinfo.iPreallocated=0; sl@0: cinfo.iName.Set(KLitSvStack); sl@0: cinfo.iOwner=K::TheKernelProcess; sl@0: TInt r=pP->NewChunk((DChunk*&)pC,cinfo,dataSectionBase); sl@0: __KTRACE_OPT(KBOOT,Kern::Printf("Created SvStack, %d",r)); sl@0: if (r!=KErrNone) sl@0: return r; sl@0: r=pC->Reserve(0); sl@0: if (r!=KErrNone) sl@0: return r; sl@0: __KTRACE_OPT(KBOOT,Kern::Printf("Created SvStack chunk, addr %08X, max size %08X",pC->Base(),maxsize)); sl@0: MM::SvStackChunk=pC; sl@0: r=pP->AddChunk(pC,dataSectionBase,EFalse); sl@0: __KTRACE_OPT(KBOOT,Kern::Printf("Added SvStack chunk to current process, %d",r)); sl@0: sl@0: // create user code chunk sl@0: if (r==KErrNone) sl@0: r = MM::CreateCodeChunk(EFalse); sl@0: sl@0: // create kernel code chunk sl@0: if (r==KErrNone) sl@0: r = MM::CreateCodeChunk(ETrue); sl@0: return r; sl@0: } sl@0: