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\x86\x86utils.cpp
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
#include <x86.h>
|
|
19 |
#include <nktest/nkutils.h>
|
|
20 |
|
|
21 |
extern "C" {
|
|
22 |
|
|
23 |
void __fastcall thread_request_signal(NThread* aThread);
|
|
24 |
|
|
25 |
TUint64 fcf;
|
|
26 |
TUint32 nfcf;
|
|
27 |
TUint32 nfcfs;
|
|
28 |
|
|
29 |
|
|
30 |
TUint32 round_to_page(TUint32 x)
|
|
31 |
{
|
|
32 |
return (x + KPageSize - 1) &~ (KPageSize - 1);
|
|
33 |
}
|
|
34 |
|
|
35 |
|
|
36 |
TLinAddr __initial_stack_base()
|
|
37 |
{
|
|
38 |
return __stack_pointer() & ~0xfff;
|
|
39 |
}
|
|
40 |
|
|
41 |
TInt __initial_stack_size()
|
|
42 |
{
|
|
43 |
return 0x1000;
|
|
44 |
}
|
|
45 |
|
|
46 |
TUint64 fast_counter_freq()
|
|
47 |
{
|
|
48 |
return fcf;
|
|
49 |
}
|
|
50 |
|
|
51 |
TUint32 norm_fast_counter_freq()
|
|
52 |
{
|
|
53 |
return nfcf;
|
|
54 |
}
|
|
55 |
|
|
56 |
void init_fast_counter()
|
|
57 |
{
|
|
58 |
NKern::Sleep(2);
|
|
59 |
TUint64 initial = fast_counter();
|
|
60 |
NKern::Sleep(1000);
|
|
61 |
TUint64 final = fast_counter();
|
|
62 |
fcf = final - initial;
|
|
63 |
TUint64 f = fcf;
|
|
64 |
nfcfs = 0;
|
|
65 |
while (f > 2000000)
|
|
66 |
f>>=1, ++nfcfs;
|
|
67 |
nfcf = (TUint32)(fcf >> nfcfs);
|
|
68 |
|
|
69 |
DEBUGPRINT("fcf=%lx",fcf);
|
|
70 |
DEBUGPRINT("nfcf=%d",nfcf);
|
|
71 |
}
|
|
72 |
|
|
73 |
TInt __microseconds_to_fast_counter(TInt us)
|
|
74 |
{
|
|
75 |
TUint64 x = TUint64(TUint32(us));
|
|
76 |
x *= fcf;
|
|
77 |
x += TUint64(500000);
|
|
78 |
x /= TUint64(1000000);
|
|
79 |
|
|
80 |
return (TInt)x;
|
|
81 |
}
|
|
82 |
|
|
83 |
TInt __microseconds_to_norm_fast_counter(TInt us)
|
|
84 |
{
|
|
85 |
TUint64 x = TUint64(TUint32(us));
|
|
86 |
x *= nfcf;
|
|
87 |
x += TUint64(500000);
|
|
88 |
x /= TUint64(1000000);
|
|
89 |
|
|
90 |
return (TInt)x;
|
|
91 |
}
|
|
92 |
|
|
93 |
extern TUint32 __eflags();
|
|
94 |
void CheckPoint()
|
|
95 |
{
|
|
96 |
KPrintf("EFLAGS=%08x", __eflags());
|
|
97 |
}
|
|
98 |
|
|
99 |
void __fastcall thread_request_signal(NThread* aThread)
|
|
100 |
{
|
|
101 |
NKern::ThreadRequestSignal(aThread);
|
|
102 |
}
|
|
103 |
}
|