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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32\memmodel\epoc\direct\minit.cpp
19 #include "cache_maintenance.h"
21 _LIT(KLitRamAlloc,"RamAlloc");
23 const TInt KMaxSupervisorStackSpace=0x200000;
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;
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));
36 // Memory model dependent CPU stuff
40 CacheMaintenance::Init1();
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;
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);
57 MM::Panic(MM::ERamAllocMutexCreateFailed);
58 const SRamBank* banks = (const SRamBank*)TheSuperPage().iRamBootData;
60 TInt maxBankBlocks = 0;
62 const SRamBank* pB = banks;
63 for (; pB->iSize; ++nBanks, ++pB)
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);
73 __KTRACE_OPT(KBOOT,Kern::Printf("%d banks, max bank blocks %08x", nBanks, maxBankBlocks));
76 MM::SecondaryAllocator = TBitMapAllocator::New(maxBankBlocks, ETrue);
77 if (!MM::SecondaryAllocator)
78 MM::Panic(MM::ESecAllocCreateFailed);
84 // Third phase MMU initialisation
87 TInt M::InitSvHeapChunk(DChunk* aChunk, TInt aSize)
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()));
99 TInt M::InitSvStackChunk()