sl@0: // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32test\nkernsa\x86\x86utils.cpp sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: sl@0: extern "C" { sl@0: sl@0: void __fastcall thread_request_signal(NThread* aThread); sl@0: sl@0: TUint64 fcf; sl@0: TUint32 nfcf; sl@0: TUint32 nfcfs; sl@0: sl@0: sl@0: TUint32 round_to_page(TUint32 x) sl@0: { sl@0: return (x + KPageSize - 1) &~ (KPageSize - 1); sl@0: } sl@0: sl@0: sl@0: TLinAddr __initial_stack_base() sl@0: { sl@0: return __stack_pointer() & ~0xfff; sl@0: } sl@0: sl@0: TInt __initial_stack_size() sl@0: { sl@0: return 0x1000; sl@0: } sl@0: sl@0: TUint64 fast_counter_freq() sl@0: { sl@0: return fcf; sl@0: } sl@0: sl@0: TUint32 norm_fast_counter_freq() sl@0: { sl@0: return nfcf; sl@0: } sl@0: sl@0: void init_fast_counter() sl@0: { sl@0: NKern::Sleep(2); sl@0: TUint64 initial = fast_counter(); sl@0: NKern::Sleep(1000); sl@0: TUint64 final = fast_counter(); sl@0: fcf = final - initial; sl@0: TUint64 f = fcf; sl@0: nfcfs = 0; sl@0: while (f > 2000000) sl@0: f>>=1, ++nfcfs; sl@0: nfcf = (TUint32)(fcf >> nfcfs); sl@0: sl@0: DEBUGPRINT("fcf=%lx",fcf); sl@0: DEBUGPRINT("nfcf=%d",nfcf); sl@0: } sl@0: sl@0: TInt __microseconds_to_fast_counter(TInt us) sl@0: { sl@0: TUint64 x = TUint64(TUint32(us)); sl@0: x *= fcf; sl@0: x += TUint64(500000); sl@0: x /= TUint64(1000000); sl@0: sl@0: return (TInt)x; sl@0: } sl@0: sl@0: TInt __microseconds_to_norm_fast_counter(TInt us) sl@0: { sl@0: TUint64 x = TUint64(TUint32(us)); sl@0: x *= nfcf; sl@0: x += TUint64(500000); sl@0: x /= TUint64(1000000); sl@0: sl@0: return (TInt)x; sl@0: } sl@0: sl@0: extern TUint32 __eflags(); sl@0: void CheckPoint() sl@0: { sl@0: KPrintf("EFLAGS=%08x", __eflags()); sl@0: } sl@0: sl@0: void __fastcall thread_request_signal(NThread* aThread) sl@0: { sl@0: NKern::ThreadRequestSignal(aThread); sl@0: } sl@0: }