os/kernelhwsrv/kernel/eka/memmodel/epoc/moving/minit.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kernel/eka/memmodel/epoc/moving/minit.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,111 @@
     1.4 +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// e32\memmodel\epoc\moving\minit.cpp
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#include "memmodel.h"
    1.22 +#include "cache_maintenance.h"
    1.23 +
    1.24 +_LIT(KLitSvStack,"SvStack");
    1.25 +
    1.26 +const TInt KMaxSupervisorStackSpace=0x200000;
    1.27 +
    1.28 +void M::Init1()
    1.29 +	{
    1.30 +	TheCurrentAddressSpace=NULL;
    1.31 +	TheCurrentVMProcess=NULL;
    1.32 +	TheCurrentDataSectionProcess=NULL;
    1.33 +	TheCompleteDataSectionProcess=NULL;
    1.34 +
    1.35 +	// Memory model dependent CPU stuff
    1.36 +	MM::Init1();
    1.37 +
    1.38 +	// Set up cache info
    1.39 +	CacheMaintenance::Init1();
    1.40 +
    1.41 +	// First phase MMU initialisation
    1.42 +	Mmu& m=Mmu::Get();
    1.43 +	m.Init1();
    1.44 +	}
    1.45 +
    1.46 +void M::Init2()
    1.47 +	{
    1.48 +	// Second phase MMU initialisation
    1.49 +	Mmu& m=Mmu::Get();
    1.50 +	m.Init2();
    1.51 +	}
    1.52 +
    1.53 +void M::Init3()
    1.54 +	{
    1.55 +	// Third phase MMU initialisation
    1.56 +	Mmu& m=Mmu::Get();
    1.57 +	m.Init3();
    1.58 +	}
    1.59 +
    1.60 +TInt M::InitSvHeapChunk(DChunk* aChunk, TInt aSize)
    1.61 +	{
    1.62 +	TInt r;
    1.63 +	DMemModelChunk* pC=(DMemModelChunk*)aChunk;
    1.64 +	TLinAddr base = TheRomHeader().iKernDataAddress;
    1.65 +	K::HeapInfo.iChunk = aChunk;
    1.66 +	K::HeapInfo.iBase = (TUint8*)base;
    1.67 +	K::HeapInfo.iMaxSize = pC->MaxSize();
    1.68 +	pC->SetFixedAddress(base, aSize);
    1.69 +	__KTRACE_OPT(KBOOT,Kern::Printf("Created SvHeap chunk, addr %08X, init size %08X max size %08X",pC->Base(),aSize,pC->MaxSize()));
    1.70 +	TLinAddr dataSectionBase=0;
    1.71 +	r=((DMemModelProcess*)K::TheKernelProcess)->AddChunk(pC,dataSectionBase,EFalse);
    1.72 + 	__KTRACE_OPT(KBOOT,Kern::Printf("Added kernel heap chunk to current process, %d",r));
    1.73 +	return r;
    1.74 +	}
    1.75 +
    1.76 +TInt M::InitSvStackChunk()
    1.77 +	{
    1.78 +	// create a chunk to hold supervisor-mode stacks
    1.79 +	DMemModelChunk* pC=NULL;
    1.80 +	DMemModelProcess* pP=(DMemModelProcess*)K::TheKernelProcess;
    1.81 +	TInt maxsize=Mmu::RoundToChunkSize(KMaxSupervisorStackSpace);
    1.82 +	TLinAddr dataSectionBase=0;
    1.83 +	SChunkCreateInfo cinfo;
    1.84 +	cinfo.iGlobal=EFalse;
    1.85 +	cinfo.iAtt=TChunkCreate::EDisconnected;
    1.86 +	cinfo.iForceFixed=EFalse;
    1.87 +	cinfo.iOperations=0;
    1.88 +	cinfo.iType=EKernelStack;
    1.89 +	cinfo.iMaxSize=maxsize;
    1.90 +	cinfo.iPreallocated=0;
    1.91 +	cinfo.iName.Set(KLitSvStack);
    1.92 +	cinfo.iOwner=K::TheKernelProcess;
    1.93 +	TInt r=pP->NewChunk((DChunk*&)pC,cinfo,dataSectionBase);
    1.94 +	__KTRACE_OPT(KBOOT,Kern::Printf("Created SvStack, %d",r));
    1.95 +	if (r!=KErrNone)
    1.96 +		return r;
    1.97 +	r=pC->Reserve(0);
    1.98 +	if (r!=KErrNone)
    1.99 +		return r;
   1.100 +	__KTRACE_OPT(KBOOT,Kern::Printf("Created SvStack chunk, addr %08X, max size %08X",pC->Base(),maxsize));
   1.101 +	MM::SvStackChunk=pC;
   1.102 +	r=pP->AddChunk(pC,dataSectionBase,EFalse);
   1.103 + 	__KTRACE_OPT(KBOOT,Kern::Printf("Added SvStack chunk to current process, %d",r));
   1.104 +
   1.105 +	// create user code chunk
   1.106 +	if (r==KErrNone)
   1.107 +		r = MM::CreateCodeChunk(EFalse);
   1.108 +
   1.109 +	// create kernel code chunk
   1.110 +	if (r==KErrNone)
   1.111 +		r = MM::CreateCodeChunk(ETrue);
   1.112 +	return r;
   1.113 +	}
   1.114 +