Update contrib.
1 // Copyright (c) 1994-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\mkernel.cpp
20 EXPORT_C TInt Kern::FreeRamInBytes()
22 return MM::RamAllocator->Avail()<<MM::RamBlockShift;
25 /********************************************
27 ********************************************/
29 TInt DThread::AllocateSupervisorStack()
31 __KTRACE_OPT(KTHREAD,Kern::Printf("DThread::AllocateSupervisorStack %O %x",this,iSupervisorStackSize));
32 iSupervisorStackSize=MM::RoundToBlockSize(iSupervisorStackSize);
33 if (iThreadType!=EThreadInitial)
35 TAny* p=Kern::Alloc(iSupervisorStackSize); // just allocate on kernel heap
39 iSupervisorStackAllocated = TRUE;
40 __KTRACE_OPT(KTHREAD,Kern::Printf("Supervisor stack at %x, size %x",iSupervisorStack,iSupervisorStackSize));
45 void DThread::FreeSupervisorStack()
47 __KTRACE_OPT(KTHREAD,Kern::Printf("DThread::FreeSupervisorStack %O",this));
48 if (iSupervisorStackAllocated)
50 TAny* pStack = __e32_atomic_swp_ord_ptr(&iSupervisorStack, 0);
51 if (pStack && iThreadType!=EThreadInitial)
53 __KTRACE_OPT(KTHREAD,Kern::Printf("Freeing supervisor stack at %08x, size %x",pStack,iSupervisorStackSize));
57 iSupervisorStackAllocated = FALSE;
60 TInt DThread::AllocateUserStack(TInt aSize, TBool /*aPaged*/)
62 __KTRACE_OPT(KTHREAD,Kern::Printf("DThread::AllocateUserStack %O %x",this,aSize));
64 aSize=MM::RoundToBlockSize(aSize);
65 if (aSize>PP::MaxUserThreadStack)
69 r=MM::AllocRegion(iUserStackRunAddress, aSize);
75 MM::AllocFailed=ETrue;
78 __KTRACE_OPT(KTHREAD,Kern::Printf("User stack run address at %x",iUserStackRunAddress));
82 void DThread::FreeUserStack()
84 __KTRACE_OPT(KTHREAD,Kern::Printf("DThread::FreeUserStack %O",this));
85 TLinAddr usr_stack_size = (TLinAddr)__e32_atomic_swp_ord32(&iUserStackSize, 0);
88 __KTRACE_OPT(KTHREAD,Kern::Printf("Freeing user stack at %x+%x",iUserStackRunAddress,usr_stack_size));
90 MM::FreeRegion(iUserStackRunAddress, usr_stack_size);
91 iUserStackRunAddress=0;