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.
sl@0
     1
// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// e32\memmodel\epoc\moving\minit.cpp
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include "memmodel.h"
sl@0
    19
#include "cache_maintenance.h"
sl@0
    20
sl@0
    21
_LIT(KLitSvStack,"SvStack");
sl@0
    22
sl@0
    23
const TInt KMaxSupervisorStackSpace=0x200000;
sl@0
    24
sl@0
    25
void M::Init1()
sl@0
    26
	{
sl@0
    27
	TheCurrentAddressSpace=NULL;
sl@0
    28
	TheCurrentVMProcess=NULL;
sl@0
    29
	TheCurrentDataSectionProcess=NULL;
sl@0
    30
	TheCompleteDataSectionProcess=NULL;
sl@0
    31
sl@0
    32
	// Memory model dependent CPU stuff
sl@0
    33
	MM::Init1();
sl@0
    34
sl@0
    35
	// Set up cache info
sl@0
    36
	CacheMaintenance::Init1();
sl@0
    37
sl@0
    38
	// First phase MMU initialisation
sl@0
    39
	Mmu& m=Mmu::Get();
sl@0
    40
	m.Init1();
sl@0
    41
	}
sl@0
    42
sl@0
    43
void M::Init2()
sl@0
    44
	{
sl@0
    45
	// Second phase MMU initialisation
sl@0
    46
	Mmu& m=Mmu::Get();
sl@0
    47
	m.Init2();
sl@0
    48
	}
sl@0
    49
sl@0
    50
void M::Init3()
sl@0
    51
	{
sl@0
    52
	// Third phase MMU initialisation
sl@0
    53
	Mmu& m=Mmu::Get();
sl@0
    54
	m.Init3();
sl@0
    55
	}
sl@0
    56
sl@0
    57
TInt M::InitSvHeapChunk(DChunk* aChunk, TInt aSize)
sl@0
    58
	{
sl@0
    59
	TInt r;
sl@0
    60
	DMemModelChunk* pC=(DMemModelChunk*)aChunk;
sl@0
    61
	TLinAddr base = TheRomHeader().iKernDataAddress;
sl@0
    62
	K::HeapInfo.iChunk = aChunk;
sl@0
    63
	K::HeapInfo.iBase = (TUint8*)base;
sl@0
    64
	K::HeapInfo.iMaxSize = pC->MaxSize();
sl@0
    65
	pC->SetFixedAddress(base, aSize);
sl@0
    66
	__KTRACE_OPT(KBOOT,Kern::Printf("Created SvHeap chunk, addr %08X, init size %08X max size %08X",pC->Base(),aSize,pC->MaxSize()));
sl@0
    67
	TLinAddr dataSectionBase=0;
sl@0
    68
	r=((DMemModelProcess*)K::TheKernelProcess)->AddChunk(pC,dataSectionBase,EFalse);
sl@0
    69
 	__KTRACE_OPT(KBOOT,Kern::Printf("Added kernel heap chunk to current process, %d",r));
sl@0
    70
	return r;
sl@0
    71
	}
sl@0
    72
sl@0
    73
TInt M::InitSvStackChunk()
sl@0
    74
	{
sl@0
    75
	// create a chunk to hold supervisor-mode stacks
sl@0
    76
	DMemModelChunk* pC=NULL;
sl@0
    77
	DMemModelProcess* pP=(DMemModelProcess*)K::TheKernelProcess;
sl@0
    78
	TInt maxsize=Mmu::RoundToChunkSize(KMaxSupervisorStackSpace);
sl@0
    79
	TLinAddr dataSectionBase=0;
sl@0
    80
	SChunkCreateInfo cinfo;
sl@0
    81
	cinfo.iGlobal=EFalse;
sl@0
    82
	cinfo.iAtt=TChunkCreate::EDisconnected;
sl@0
    83
	cinfo.iForceFixed=EFalse;
sl@0
    84
	cinfo.iOperations=0;
sl@0
    85
	cinfo.iType=EKernelStack;
sl@0
    86
	cinfo.iMaxSize=maxsize;
sl@0
    87
	cinfo.iPreallocated=0;
sl@0
    88
	cinfo.iName.Set(KLitSvStack);
sl@0
    89
	cinfo.iOwner=K::TheKernelProcess;
sl@0
    90
	TInt r=pP->NewChunk((DChunk*&)pC,cinfo,dataSectionBase);
sl@0
    91
	__KTRACE_OPT(KBOOT,Kern::Printf("Created SvStack, %d",r));
sl@0
    92
	if (r!=KErrNone)
sl@0
    93
		return r;
sl@0
    94
	r=pC->Reserve(0);
sl@0
    95
	if (r!=KErrNone)
sl@0
    96
		return r;
sl@0
    97
	__KTRACE_OPT(KBOOT,Kern::Printf("Created SvStack chunk, addr %08X, max size %08X",pC->Base(),maxsize));
sl@0
    98
	MM::SvStackChunk=pC;
sl@0
    99
	r=pP->AddChunk(pC,dataSectionBase,EFalse);
sl@0
   100
 	__KTRACE_OPT(KBOOT,Kern::Printf("Added SvStack chunk to current process, %d",r));
sl@0
   101
sl@0
   102
	// create user code chunk
sl@0
   103
	if (r==KErrNone)
sl@0
   104
		r = MM::CreateCodeChunk(EFalse);
sl@0
   105
sl@0
   106
	// create kernel code chunk
sl@0
   107
	if (r==KErrNone)
sl@0
   108
		r = MM::CreateCodeChunk(ETrue);
sl@0
   109
	return r;
sl@0
   110
	}
sl@0
   111