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