Update contrib.
1 // Copyright (c) 2008-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 // e32test\nkernsa\arm\armutils.cpp
19 #include <nktest/nkutils.h>
21 const TUint32 KPageSize = 0x1000u;
25 void thread_request_signal(NThread* aThread);
32 TUint32 round_to_page(TUint32 x)
34 return (x + KPageSize - 1) &~ (KPageSize - 1);
38 TLinAddr __initial_stack_base()
40 return __stack_pointer() & ~0xfff;
43 TInt __initial_stack_size()
48 TUint64 fast_counter_freq()
53 TUint32 norm_fast_counter_freq()
58 void init_fast_counter()
61 TUint64 initial = fast_counter();
63 TUint64 final = fast_counter();
64 fcf = final - initial;
69 nfcf = (TUint32)(fcf >> nfcfs);
71 DEBUGPRINT("fcf=%lx",fcf);
72 DEBUGPRINT("nfcf=%d",nfcf);
75 TInt __microseconds_to_fast_counter(TInt us)
77 TUint64 x = TUint64(TUint32(us));
80 x /= TUint64(1000000);
85 TInt __microseconds_to_norm_fast_counter(TInt us)
87 TUint64 x = TUint64(TUint32(us));
90 x /= TUint64(1000000);
95 void nfcfspin(TUint32 aTicks)
97 TUint64 ticks = aTicks;
102 void fcfspin(TUint64 aTicks)
104 TUint64 t0 = fast_counter();
112 extern TUint32 __cpsr();
115 KPrintf("CPSR=%08x", __cpsr());
118 void thread_request_signal(NThread* aThread)
120 NKern::ThreadRequestSignal(aThread);
124 TAny* operator new(TUint aSize) __NO_THROW
126 // The global new operator.
130 return malloc(aSize);
133 TAny* operator new[](TUint aSize) __NO_THROW
136 return malloc(aSize);
139 void operator delete(TAny* aPtr) __NO_THROW
141 // The replacement delete operator.
148 void operator delete[](TAny* aPtr) __NO_THROW
155 TAny* operator new(TUint aSize, const std::nothrow_t& aNoThrow) __NO_THROW
157 // The global new operator.
161 return malloc(aSize);
164 TAny* operator new[](TUint aSize, const std::nothrow_t& aNoThrow) __NO_THROW
167 return malloc(aSize);
174 void TickTimerFn(TAny*);
175 NFastSemaphore TTSem;
182 TDfc TTIDfc(&TTIDfcFn,0);
183 NTimer TickTimer(&TickTimerFn,0);
184 volatile TInt State=0;
185 volatile TInt Cycle=0;
186 volatile TInt WC[1024];
189 void TickTimerFn(TAny* aPtr)
191 ArmLocalTimer& T = LOCAL_TIMER;
192 TInt c = (TInt)T.iWatchdogCount;
203 T.iWatchdogCount = 1900000u;
210 void DoWatchdogTimerTest()
212 NKern::FSSetOwner(&TTSem, NKern::CurrentThread());
213 ArmLocalTimer& T = LOCAL_TIMER;
214 T.iWatchdogLoad = KMaxTUint32;
215 T.iWatchdogCount = 2097152;
216 T.iWatchdogIntStatus = 1;
217 __e32_io_completion_barrier();
219 __e32_io_completion_barrier();
220 TickTimer.OneShot(1);
221 NKern::FSWait(&TTSem);
223 for (i=0; i<WCI; ++i)
225 DEBUGPRINT("%03d: %d", i, WC[i]);