diff -r 000000000000 -r a41df078684a kernel/eka/memmodel/epoc/direct/mkernel.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/kernel/eka/memmodel/epoc/direct/mkernel.cpp Mon Oct 19 15:55:17 2009 +0100 @@ -0,0 +1,95 @@ +// Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of the License "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// e32\memmodel\epoc\direct\mkernel.cpp +// +// + +#include + +EXPORT_C TInt Kern::FreeRamInBytes() + { + return MM::RamAllocator->Avail()<PP::MaxUserThreadStack) + return KErrTooBig; + TInt r; + MM::WaitRamAlloc(); + r=MM::AllocRegion(iUserStackRunAddress, aSize); + if (r==KErrNone) + iUserStackSize=aSize; + else + { + iUserStackSize=0; + MM::AllocFailed=ETrue; + } + MM::SignalRamAlloc(); + __KTRACE_OPT(KTHREAD,Kern::Printf("User stack run address at %x",iUserStackRunAddress)); + return r; + } + +void DThread::FreeUserStack() + { + __KTRACE_OPT(KTHREAD,Kern::Printf("DThread::FreeUserStack %O",this)); + TLinAddr usr_stack_size = (TLinAddr)__e32_atomic_swp_ord32(&iUserStackSize, 0); + if (usr_stack_size) + { + __KTRACE_OPT(KTHREAD,Kern::Printf("Freeing user stack at %x+%x",iUserStackRunAddress,usr_stack_size)); + MM::WaitRamAlloc(); + MM::FreeRegion(iUserStackRunAddress, usr_stack_size); + iUserStackRunAddress=0; + MM::SignalRamAlloc(); + } + } +