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