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\utils.h sl@0: // sl@0: // sl@0: sl@0: #ifndef __UTILS_H__ sl@0: #define __UTILS_H__ sl@0: #include sl@0: #include sl@0: sl@0: extern "C" { sl@0: sl@0: extern TBool InitialThreadDefined; sl@0: sl@0: extern void SetupMemoryAllocator(); sl@0: extern TAny* malloc(TUint32 aSize); sl@0: extern void free(TAny* aCell); sl@0: extern TAny* realloc(TAny* aCell, TUint32 aSize); sl@0: sl@0: extern TUint32 round_to_page(TUint32 x); sl@0: sl@0: extern void SpinWait(TUint32 aTicks); sl@0: extern void nfcfspin(TUint32 aTicks); sl@0: extern void fcfspin(TUint64 aTicks); sl@0: extern void DebugPrint(const char*, int); sl@0: sl@0: extern void __cpu_idle(); sl@0: extern void __cpu_yield(); sl@0: extern TLinAddr __stack_pointer(); sl@0: extern TUint32 __cpu_status_reg(); sl@0: extern TUint32 __cpu_id(); sl@0: extern TUint32 __trace_cpu_num(); sl@0: extern void __finish(); sl@0: sl@0: extern void* memcpy(void*, const void*, unsigned); sl@0: extern void* memset(void*, int, unsigned); sl@0: extern void* memclr(void*, unsigned); sl@0: extern void* wordmove(void*, const void*, unsigned); sl@0: sl@0: extern TUint32 random(TUint32* aSeed); sl@0: extern void setup_block(TUint32* aBlock, TInt aNumWords); sl@0: extern TBool verify_block(const TUint32* aBlock, TInt aNumWords); sl@0: extern TBool verify_block_no_trace(const TUint32* aBlock, TInt aNumWords); sl@0: extern void setup_block_cpu(TUint32* aBlock, TInt aNumWords); sl@0: extern TInt verify_block_cpu_no_trace(const TUint32* aBlock, TInt aNumWords); sl@0: sl@0: extern TUint64 fast_counter(); sl@0: extern TUint64 fast_counter_freq(); sl@0: extern TUint32 norm_fast_counter(); // normalised to count between 1-2MHz sl@0: extern TUint32 norm_fast_counter_freq(); // normalised to count between 1-2MHz sl@0: extern void init_fast_counter(); sl@0: extern TInt __microseconds_to_fast_counter(TInt us); sl@0: extern TInt __microseconds_to_norm_fast_counter(TInt us); sl@0: sl@0: extern void DumpMemory(const char* msg, const void* data, int length); sl@0: } sl@0: sl@0: #define TEST_PRINT(s) \ sl@0: DEBUGPRINT("NKTEST: " s) sl@0: #define TEST_PRINT1(s, a) \ sl@0: DEBUGPRINT("NKTEST: " s, a) sl@0: #define TEST_PRINT2(s, a, b) \ sl@0: DEBUGPRINT("NKTEST: " s, a, b) sl@0: #define TEST_PRINT3(s, a, b, c) \ sl@0: DEBUGPRINT("NKTEST: " s, a, b, c) sl@0: #define TEST_PRINT4(s, a, b, c, d) \ sl@0: DEBUGPRINT("NKTEST: " s, a, b, c, d) sl@0: #define TEST_PRINT5(s, a, b, c, d, e) \ sl@0: DEBUGPRINT("NKTEST: " s, a, b, c, d, e) sl@0: #define TEST_PRINT6(s, a, b, c, d, e, f) \ sl@0: DEBUGPRINT("NKTEST: " s, a, b, c, d, e, f) sl@0: #define TEST_PRINT7(s, a, b, c, d, e, f, g) \ sl@0: DEBUGPRINT("NKTEST: " s, a, b, c, d, e, f, g) sl@0: #define TRACE_LINE() \ sl@0: DEBUGPRINT("NKTEST: line %d", __LINE__) sl@0: sl@0: #define TEST_RESULT(x, s) \ sl@0: do { if (!(x)) {DEBUGPRINT("NKTEST: " s); DEBUGPRINT("Line %d File %s", __LINE__, __FILE__);}} while(0) sl@0: #define TEST_RESULT1(x, s, a) \ sl@0: do { if (!(x)) {DEBUGPRINT("NKTEST: " s, a); DEBUGPRINT("Line %d File %s", __LINE__, __FILE__);}} while(0) sl@0: #define TEST_RESULT2(x, s, a, b) \ sl@0: do { if (!(x)) {DEBUGPRINT("NKTEST: " s, a, b); DEBUGPRINT("Line %d File %s", __LINE__, __FILE__);}} while(0) sl@0: #define TEST_RESULT3(x, s, a, b, c) \ sl@0: do { if (!(x)) {DEBUGPRINT("NKTEST: " s, a, b, c); DEBUGPRINT("Line %d File %s", __LINE__, __FILE__);}} while(0) sl@0: #define TEST_RESULT4(x, s, a, b, c, d) \ sl@0: do { if (!(x)) {DEBUGPRINT("NKTEST: " s, a, b, c, d); DEBUGPRINT("Line %d File %s", __LINE__, __FILE__);}} while(0) sl@0: sl@0: #define TEST_OOM(p) TEST_RESULT(p, "Out of memory"); sl@0: sl@0: #define RANGE_CHECK(l,x,h) ((l)<=(x) && (x)<=(h)) sl@0: sl@0: #ifdef __SMP__ sl@0: #define for_each_cpu(cpu) \ sl@0: for((cpu)=0; (cpu)