0
|
1 |
// Copyright (c) 2006-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".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// e32test\nkernsa\utils.h
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
#ifndef __UTILS_H__
|
|
19 |
#define __UTILS_H__
|
|
20 |
#include <e32err.h>
|
|
21 |
#include <nkern.h>
|
|
22 |
|
|
23 |
extern "C" {
|
|
24 |
|
|
25 |
extern TBool InitialThreadDefined;
|
|
26 |
|
|
27 |
extern void SetupMemoryAllocator();
|
|
28 |
extern TAny* malloc(TUint32 aSize);
|
|
29 |
extern void free(TAny* aCell);
|
|
30 |
extern TAny* realloc(TAny* aCell, TUint32 aSize);
|
|
31 |
|
|
32 |
extern TUint32 round_to_page(TUint32 x);
|
|
33 |
|
|
34 |
extern void SpinWait(TUint32 aTicks);
|
|
35 |
extern void nfcfspin(TUint32 aTicks);
|
|
36 |
extern void fcfspin(TUint64 aTicks);
|
|
37 |
extern void DebugPrint(const char*, int);
|
|
38 |
|
|
39 |
extern void __cpu_idle();
|
|
40 |
extern void __cpu_yield();
|
|
41 |
extern TLinAddr __stack_pointer();
|
|
42 |
extern TUint32 __cpu_status_reg();
|
|
43 |
extern TUint32 __cpu_id();
|
|
44 |
extern TUint32 __trace_cpu_num();
|
|
45 |
extern void __finish();
|
|
46 |
|
|
47 |
extern void* memcpy(void*, const void*, unsigned);
|
|
48 |
extern void* memset(void*, int, unsigned);
|
|
49 |
extern void* memclr(void*, unsigned);
|
|
50 |
extern void* wordmove(void*, const void*, unsigned);
|
|
51 |
|
|
52 |
extern TUint32 random(TUint32* aSeed);
|
|
53 |
extern void setup_block(TUint32* aBlock, TInt aNumWords);
|
|
54 |
extern TBool verify_block(const TUint32* aBlock, TInt aNumWords);
|
|
55 |
extern TBool verify_block_no_trace(const TUint32* aBlock, TInt aNumWords);
|
|
56 |
extern void setup_block_cpu(TUint32* aBlock, TInt aNumWords);
|
|
57 |
extern TInt verify_block_cpu_no_trace(const TUint32* aBlock, TInt aNumWords);
|
|
58 |
|
|
59 |
extern TUint64 fast_counter();
|
|
60 |
extern TUint64 fast_counter_freq();
|
|
61 |
extern TUint32 norm_fast_counter(); // normalised to count between 1-2MHz
|
|
62 |
extern TUint32 norm_fast_counter_freq(); // normalised to count between 1-2MHz
|
|
63 |
extern void init_fast_counter();
|
|
64 |
extern TInt __microseconds_to_fast_counter(TInt us);
|
|
65 |
extern TInt __microseconds_to_norm_fast_counter(TInt us);
|
|
66 |
|
|
67 |
extern void DumpMemory(const char* msg, const void* data, int length);
|
|
68 |
}
|
|
69 |
|
|
70 |
#define TEST_PRINT(s) \
|
|
71 |
DEBUGPRINT("NKTEST: " s)
|
|
72 |
#define TEST_PRINT1(s, a) \
|
|
73 |
DEBUGPRINT("NKTEST: " s, a)
|
|
74 |
#define TEST_PRINT2(s, a, b) \
|
|
75 |
DEBUGPRINT("NKTEST: " s, a, b)
|
|
76 |
#define TEST_PRINT3(s, a, b, c) \
|
|
77 |
DEBUGPRINT("NKTEST: " s, a, b, c)
|
|
78 |
#define TEST_PRINT4(s, a, b, c, d) \
|
|
79 |
DEBUGPRINT("NKTEST: " s, a, b, c, d)
|
|
80 |
#define TEST_PRINT5(s, a, b, c, d, e) \
|
|
81 |
DEBUGPRINT("NKTEST: " s, a, b, c, d, e)
|
|
82 |
#define TEST_PRINT6(s, a, b, c, d, e, f) \
|
|
83 |
DEBUGPRINT("NKTEST: " s, a, b, c, d, e, f)
|
|
84 |
#define TEST_PRINT7(s, a, b, c, d, e, f, g) \
|
|
85 |
DEBUGPRINT("NKTEST: " s, a, b, c, d, e, f, g)
|
|
86 |
#define TRACE_LINE() \
|
|
87 |
DEBUGPRINT("NKTEST: line %d", __LINE__)
|
|
88 |
|
|
89 |
#define TEST_RESULT(x, s) \
|
|
90 |
do { if (!(x)) {DEBUGPRINT("NKTEST: " s); DEBUGPRINT("Line %d File %s", __LINE__, __FILE__);}} while(0)
|
|
91 |
#define TEST_RESULT1(x, s, a) \
|
|
92 |
do { if (!(x)) {DEBUGPRINT("NKTEST: " s, a); DEBUGPRINT("Line %d File %s", __LINE__, __FILE__);}} while(0)
|
|
93 |
#define TEST_RESULT2(x, s, a, b) \
|
|
94 |
do { if (!(x)) {DEBUGPRINT("NKTEST: " s, a, b); DEBUGPRINT("Line %d File %s", __LINE__, __FILE__);}} while(0)
|
|
95 |
#define TEST_RESULT3(x, s, a, b, c) \
|
|
96 |
do { if (!(x)) {DEBUGPRINT("NKTEST: " s, a, b, c); DEBUGPRINT("Line %d File %s", __LINE__, __FILE__);}} while(0)
|
|
97 |
#define TEST_RESULT4(x, s, a, b, c, d) \
|
|
98 |
do { if (!(x)) {DEBUGPRINT("NKTEST: " s, a, b, c, d); DEBUGPRINT("Line %d File %s", __LINE__, __FILE__);}} while(0)
|
|
99 |
|
|
100 |
#define TEST_OOM(p) TEST_RESULT(p, "Out of memory");
|
|
101 |
|
|
102 |
#define RANGE_CHECK(l,x,h) ((l)<=(x) && (x)<=(h))
|
|
103 |
|
|
104 |
#ifdef __SMP__
|
|
105 |
#define for_each_cpu(cpu) \
|
|
106 |
for((cpu)=0; (cpu)<NKern::NumberOfCpus(); ++(cpu))
|
|
107 |
#else
|
|
108 |
#define for_each_cpu(cpu) \
|
|
109 |
for((cpu)=0; (cpu)<1; ++(cpu))
|
|
110 |
#endif
|
|
111 |
|
|
112 |
class CircBuf
|
|
113 |
{
|
|
114 |
public:
|
|
115 |
static CircBuf* New(TInt aSlots);
|
|
116 |
CircBuf();
|
|
117 |
~CircBuf();
|
|
118 |
TInt TryGet(TUint32& aOut);
|
|
119 |
TInt TryPut(TUint32 aIn);
|
|
120 |
TUint32 Get();
|
|
121 |
void Put(TUint32 aIn);
|
|
122 |
void Reset();
|
|
123 |
TInt Count();
|
|
124 |
public:
|
|
125 |
TUint32* iBufBase;
|
|
126 |
TInt iSlotCount;
|
|
127 |
TInt iGetIndex;
|
|
128 |
TInt iPutIndex;
|
|
129 |
TSpinLock iLock;
|
|
130 |
};
|
|
131 |
|
|
132 |
#endif
|
|
133 |
|
|
134 |
|