os/kernelhwsrv/kernel/eka/memmodel/epoc/direct/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\direct\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(KLitRamAlloc,"RamAlloc");
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
	__KTRACE_OPT2(KBOOT,KMMU,Kern::Printf("M::Init1"));
sl@0
    28
	MM::UserDataSectionBase=TheRomHeader().iUserDataAddress;
sl@0
    29
	MM::UserRomDataSectionEnd=TheRomHeader().iUserDataAddress+TheRomHeader().iTotalUserDataSize;
sl@0
    30
	MM::UserDataSectionEnd = TheSuperPage().iRamBase + TheSuperPage().iTotalRamSize;
sl@0
    31
sl@0
    32
	__KTRACE_OPT2(KBOOT,KMMU,Kern::Printf("MM::UserDataSectionBase=%08x",MM::UserDataSectionBase));
sl@0
    33
	__KTRACE_OPT2(KBOOT,KMMU,Kern::Printf("MM::UserRomDataSectionEnd=%08x",MM::UserRomDataSectionEnd));
sl@0
    34
	__KTRACE_OPT2(KBOOT,KMMU,Kern::Printf("MM::UserDataSectionEnd=%08x",MM::UserDataSectionEnd));
sl@0
    35
sl@0
    36
	// Memory model dependent CPU stuff
sl@0
    37
	MM::Init1();
sl@0
    38
sl@0
    39
	// Set up cache info
sl@0
    40
	CacheMaintenance::Init1();
sl@0
    41
	}
sl@0
    42
sl@0
    43
void M::Init2()
sl@0
    44
	{
sl@0
    45
	__KTRACE_OPT2(KBOOT,KMMU,Kern::Printf("M::Init2"));
sl@0
    46
	TInt userRam=MM::UserDataSectionEnd-MM::UserDataSectionBase;
sl@0
    47
	TInt blocks=userRam>>MM::RamBlockShift;
sl@0
    48
	MM::RamAllocator=TBitMapAllocator::New(blocks,ETrue);
sl@0
    49
	if (!MM::RamAllocator)
sl@0
    50
		MM::Panic(MM::ERamAllocCreateFailed);
sl@0
    51
	TInt used_blocks=(MM::UserRomDataSectionEnd-MM::UserDataSectionBase)>>MM::RamBlockShift;
sl@0
    52
	if (used_blocks)
sl@0
    53
		MM::RamAllocator->Alloc(0,used_blocks);
sl@0
    54
	__KTRACE_OPT(KBOOT,Kern::Printf("%d blocks, %d used",blocks,used_blocks));
sl@0
    55
	TInt r=K::MutexCreate((DMutex*&)MM::RamAllocatorMutex, KLitRamAlloc, NULL, EFalse, KMutexOrdRamAlloc);
sl@0
    56
	if (r!=KErrNone)
sl@0
    57
		MM::Panic(MM::ERamAllocMutexCreateFailed);
sl@0
    58
	const SRamBank* banks = (const SRamBank*)TheSuperPage().iRamBootData;
sl@0
    59
	TInt nBanks = 0;
sl@0
    60
	TInt maxBankBlocks = 0;
sl@0
    61
	TInt bnum = 0;
sl@0
    62
	const SRamBank* pB = banks;
sl@0
    63
	for (; pB->iSize; ++nBanks, ++pB)
sl@0
    64
		{
sl@0
    65
		TInt nblocks = pB->iSize >> MM::RamBlockShift;
sl@0
    66
		TInt abnum = bnum &~ 31;
sl@0
    67
		TInt a_end = (bnum + nblocks + 31)&~31;
sl@0
    68
		TInt a_count = a_end - abnum;
sl@0
    69
		if (a_count > maxBankBlocks)
sl@0
    70
			maxBankBlocks = a_count;
sl@0
    71
		bnum += (pB->iSize >> MM::RamBlockShift);
sl@0
    72
		}
sl@0
    73
	__KTRACE_OPT(KBOOT,Kern::Printf("%d banks, max bank blocks %08x", nBanks, maxBankBlocks));
sl@0
    74
	if (nBanks>1)
sl@0
    75
		{
sl@0
    76
		MM::SecondaryAllocator = TBitMapAllocator::New(maxBankBlocks, ETrue);
sl@0
    77
		if (!MM::SecondaryAllocator)
sl@0
    78
			MM::Panic(MM::ESecAllocCreateFailed);
sl@0
    79
		}
sl@0
    80
	}
sl@0
    81
sl@0
    82
void M::Init3()
sl@0
    83
	{
sl@0
    84
	// Third phase MMU initialisation
sl@0
    85
	}
sl@0
    86
sl@0
    87
TInt M::InitSvHeapChunk(DChunk* aChunk, TInt aSize)
sl@0
    88
	{
sl@0
    89
	DMemModelChunk* pC=(DMemModelChunk*)aChunk;
sl@0
    90
	TLinAddr base = TheRomHeader().iKernDataAddress;
sl@0
    91
	K::HeapInfo.iChunk = aChunk;
sl@0
    92
	K::HeapInfo.iBase = (TUint8*)base;
sl@0
    93
	K::HeapInfo.iMaxSize = pC->MaxSize();
sl@0
    94
	pC->SetFixedAddress(base, aSize);
sl@0
    95
	__KTRACE_OPT(KBOOT,Kern::Printf("Created SvHeap chunk, addr %08X, init size %08X max size %08X",pC->Base(),aSize,pC->MaxSize()));
sl@0
    96
	return KErrNone;
sl@0
    97
	}
sl@0
    98
sl@0
    99
TInt M::InitSvStackChunk()
sl@0
   100
	{
sl@0
   101
	return KErrNone;
sl@0
   102
	}
sl@0
   103