1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kernel/eka/memmodel/epoc/direct/minit.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,103 @@
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\direct\minit.cpp
1.18 +//
1.19 +//
1.20 +
1.21 +#include <memmodel.h>
1.22 +#include "cache_maintenance.h"
1.23 +
1.24 +_LIT(KLitRamAlloc,"RamAlloc");
1.25 +
1.26 +const TInt KMaxSupervisorStackSpace=0x200000;
1.27 +
1.28 +void M::Init1()
1.29 + {
1.30 + __KTRACE_OPT2(KBOOT,KMMU,Kern::Printf("M::Init1"));
1.31 + MM::UserDataSectionBase=TheRomHeader().iUserDataAddress;
1.32 + MM::UserRomDataSectionEnd=TheRomHeader().iUserDataAddress+TheRomHeader().iTotalUserDataSize;
1.33 + MM::UserDataSectionEnd = TheSuperPage().iRamBase + TheSuperPage().iTotalRamSize;
1.34 +
1.35 + __KTRACE_OPT2(KBOOT,KMMU,Kern::Printf("MM::UserDataSectionBase=%08x",MM::UserDataSectionBase));
1.36 + __KTRACE_OPT2(KBOOT,KMMU,Kern::Printf("MM::UserRomDataSectionEnd=%08x",MM::UserRomDataSectionEnd));
1.37 + __KTRACE_OPT2(KBOOT,KMMU,Kern::Printf("MM::UserDataSectionEnd=%08x",MM::UserDataSectionEnd));
1.38 +
1.39 + // Memory model dependent CPU stuff
1.40 + MM::Init1();
1.41 +
1.42 + // Set up cache info
1.43 + CacheMaintenance::Init1();
1.44 + }
1.45 +
1.46 +void M::Init2()
1.47 + {
1.48 + __KTRACE_OPT2(KBOOT,KMMU,Kern::Printf("M::Init2"));
1.49 + TInt userRam=MM::UserDataSectionEnd-MM::UserDataSectionBase;
1.50 + TInt blocks=userRam>>MM::RamBlockShift;
1.51 + MM::RamAllocator=TBitMapAllocator::New(blocks,ETrue);
1.52 + if (!MM::RamAllocator)
1.53 + MM::Panic(MM::ERamAllocCreateFailed);
1.54 + TInt used_blocks=(MM::UserRomDataSectionEnd-MM::UserDataSectionBase)>>MM::RamBlockShift;
1.55 + if (used_blocks)
1.56 + MM::RamAllocator->Alloc(0,used_blocks);
1.57 + __KTRACE_OPT(KBOOT,Kern::Printf("%d blocks, %d used",blocks,used_blocks));
1.58 + TInt r=K::MutexCreate((DMutex*&)MM::RamAllocatorMutex, KLitRamAlloc, NULL, EFalse, KMutexOrdRamAlloc);
1.59 + if (r!=KErrNone)
1.60 + MM::Panic(MM::ERamAllocMutexCreateFailed);
1.61 + const SRamBank* banks = (const SRamBank*)TheSuperPage().iRamBootData;
1.62 + TInt nBanks = 0;
1.63 + TInt maxBankBlocks = 0;
1.64 + TInt bnum = 0;
1.65 + const SRamBank* pB = banks;
1.66 + for (; pB->iSize; ++nBanks, ++pB)
1.67 + {
1.68 + TInt nblocks = pB->iSize >> MM::RamBlockShift;
1.69 + TInt abnum = bnum &~ 31;
1.70 + TInt a_end = (bnum + nblocks + 31)&~31;
1.71 + TInt a_count = a_end - abnum;
1.72 + if (a_count > maxBankBlocks)
1.73 + maxBankBlocks = a_count;
1.74 + bnum += (pB->iSize >> MM::RamBlockShift);
1.75 + }
1.76 + __KTRACE_OPT(KBOOT,Kern::Printf("%d banks, max bank blocks %08x", nBanks, maxBankBlocks));
1.77 + if (nBanks>1)
1.78 + {
1.79 + MM::SecondaryAllocator = TBitMapAllocator::New(maxBankBlocks, ETrue);
1.80 + if (!MM::SecondaryAllocator)
1.81 + MM::Panic(MM::ESecAllocCreateFailed);
1.82 + }
1.83 + }
1.84 +
1.85 +void M::Init3()
1.86 + {
1.87 + // Third phase MMU initialisation
1.88 + }
1.89 +
1.90 +TInt M::InitSvHeapChunk(DChunk* aChunk, TInt aSize)
1.91 + {
1.92 + DMemModelChunk* pC=(DMemModelChunk*)aChunk;
1.93 + TLinAddr base = TheRomHeader().iKernDataAddress;
1.94 + K::HeapInfo.iChunk = aChunk;
1.95 + K::HeapInfo.iBase = (TUint8*)base;
1.96 + K::HeapInfo.iMaxSize = pC->MaxSize();
1.97 + pC->SetFixedAddress(base, aSize);
1.98 + __KTRACE_OPT(KBOOT,Kern::Printf("Created SvHeap chunk, addr %08X, init size %08X max size %08X",pC->Base(),aSize,pC->MaxSize()));
1.99 + return KErrNone;
1.100 + }
1.101 +
1.102 +TInt M::InitSvStackChunk()
1.103 + {
1.104 + return KErrNone;
1.105 + }
1.106 +