author | Slion |
Thu, 07 Jan 2010 01:23:42 +0100 | |
branch | anywhere |
changeset 25 | 57330c35d3d7 |
parent 0 | a41df078684a |
child 28 | 9642313072c3 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 1995-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 |
// e32\euser\epoc\win32\uc_utl.cpp |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
#include "u32std.h" |
|
19 |
#include <e32base.h> |
|
20 |
#include <e32base_private.h> |
|
21 |
#include <e32hashtab.h> |
|
22 |
#include <emulator.h> |
|
23 |
#include "uc_std.h" |
|
24 |
||
25 |
typedef void (*TBootEpoc)(TBool); |
|
26 |
||
27 |
#ifdef __LEAVE_EQUALS_THROW__ |
|
28 |
||
29 |
// Stub versions of TTrap exports to keep X86 and WINS versions of euser.def |
|
30 |
// the same. |
|
31 |
||
32 |
class TTrap |
|
33 |
{ |
|
34 |
public: |
|
35 |
IMPORT_C TInt Trap(TInt& aResult); |
|
36 |
IMPORT_C static void UnTrap(); |
|
37 |
}; |
|
38 |
||
39 |
EXPORT_C TInt TTrap::Trap(TInt&) |
|
40 |
{ |
|
41 |
return 0; |
|
42 |
} |
|
43 |
||
44 |
EXPORT_C void TTrap::UnTrap() |
|
45 |
{ |
|
46 |
} |
|
47 |
||
48 |
#endif |
|
49 |
||
50 |
EXPORT_C void EmptyFunction() |
|
51 |
//Function with an empty body |
|
52 |
{ |
|
53 |
} |
|
54 |
||
55 |
GLDEF_C void Panic(TCdtArchitecturePanic aPanic) |
|
56 |
// |
|
57 |
// Panic the process with USER as the category. |
|
58 |
// |
|
59 |
{ |
|
60 |
_LIT(KCategory,"USER-Arch"); |
|
61 |
User::Panic(KCategory,aPanic); |
|
62 |
} |
|
63 |
||
64 |
||
65 |
||
66 |
||
67 |
EXPORT_C TInt User::IsRomAddress(TBool& aBool, TAny* aPtr) |
|
68 |
// |
|
69 |
// The FileServer loads ROM files as ReadOnly Memory Mapped Files |
|
70 |
// We check the access rights of the given address for : |
|
71 |
// Read access |
|
72 |
// No write access |
|
73 |
// |
|
74 |
/** |
|
75 |
Tests whether the specified address is in the ROM. |
|
76 |
||
77 |
@param aBool True, if the address at aPtr is within the ROM; false, |
|
78 |
otherwise. |
|
79 |
@param aPtr The address to be tested. |
|
80 |
||
81 |
@return Always KErrNone. |
|
82 |
*/ |
|
83 |
{ |
|
84 |
const TInt KRomMask = 0xFF; |
|
85 |
const TInt KRomAccess = PAGE_READONLY; |
|
86 |
||
87 |
aBool=EFalse; |
|
88 |
MEMORY_BASIC_INFORMATION mi; |
|
89 |
||
90 |
__LOCK_HOST; |
|
91 |
if (VirtualQuery(aPtr, &mi, sizeof(mi)) != 0 && (mi.Protect & KRomMask) == KRomAccess) |
|
92 |
aBool=ETrue; |
|
93 |
return KErrNone; |
|
94 |
} |
|
95 |
||
96 |
||
97 |
||
98 |
||
99 |
EXPORT_C void BootEpoc(TBool aAutoRun) |
|
100 |
{ |
|
25
57330c35d3d7
Adding epoc target. Tried to define our own entry point but it fails at runtime trying to load msvcr80d.dll. Try using /NODEFAULTLIB for all targets maybe. Must somehow export ekern.dll for it to be loadable by epoc.exe.
Slion
parents:
0
diff
changeset
|
101 |
//SL: |
57330c35d3d7
Adding epoc target. Tried to define our own entry point but it fails at runtime trying to load msvcr80d.dll. Try using /NODEFAULTLIB for all targets maybe. Must somehow export ekern.dll for it to be loadable by epoc.exe.
Slion
parents:
0
diff
changeset
|
102 |
HINSTANCE epoc = LoadLibraryA("ekern.dll"); |
57330c35d3d7
Adding epoc target. Tried to define our own entry point but it fails at runtime trying to load msvcr80d.dll. Try using /NODEFAULTLIB for all targets maybe. Must somehow export ekern.dll for it to be loadable by epoc.exe.
Slion
parents:
0
diff
changeset
|
103 |
//HINSTANCE epoc = LoadLibraryA("ekern.exe"); |
0 | 104 |
if (epoc) |
105 |
{ |
|
106 |
TBootEpoc ep = (TBootEpoc)GetProcAddress(epoc, "_E32Startup"); |
|
107 |
if (ep) |
|
108 |
ep(aAutoRun); |
|
109 |
} |
|
110 |
ExitProcess(102); |
|
111 |
} |
|
112 |
||
113 |
EXPORT_C void RFastLock::Wait() |
|
114 |
{ |
|
115 |
if (InterlockedDecrement((LPLONG)&iCount) < -1) |
|
116 |
RSemaphore::Wait(); |
|
117 |
} |
|
118 |
||
119 |
EXPORT_C void RFastLock::Signal() |
|
120 |
{ |
|
121 |
if (InterlockedIncrement((LPLONG)&iCount) < 0) |
|
122 |
RSemaphore::Signal(); |
|
123 |
} |
|
124 |
||
125 |
// Hash an 8 bit string at aPtr, length aLen bytes. |
|
126 |
__NAKED__ TUint32 DefaultStringHash(const TUint8* /*aPtr*/, TInt /*aLen*/) |
|
127 |
{ |
|
128 |
_asm push esi |
|
129 |
_asm mov esi, [esp+8] |
|
130 |
_asm mov ecx, [esp+12] |
|
131 |
_asm xor eax, eax |
|
132 |
_asm sub ecx, 4 |
|
133 |
_asm jb lt4 |
|
134 |
ge4: |
|
135 |
_asm xor eax, [esi] |
|
136 |
_asm add esi, 4 |
|
137 |
_asm mov edx, 9E3779B9h |
|
138 |
_asm mul edx |
|
139 |
_asm sub ecx, 4 |
|
140 |
_asm jae ge4 |
|
141 |
lt4: |
|
142 |
_asm add ecx, 4 |
|
143 |
_asm jz done |
|
144 |
_asm xor edx, edx |
|
145 |
_asm cmp ecx, 2 |
|
146 |
_asm jbe le2 |
|
147 |
_asm mov dl, [esi+2] |
|
148 |
_asm shl edx, 16 |
|
149 |
le2: |
|
150 |
_asm cmp ecx, 2 |
|
151 |
_asm jb onemore |
|
152 |
_asm mov dh, [esi+1] |
|
153 |
onemore: |
|
154 |
_asm mov dl, [esi] |
|
155 |
_asm xor eax, edx |
|
156 |
_asm mov edx, 9E3779B9h |
|
157 |
_asm mul edx |
|
158 |
done: |
|
159 |
_asm pop esi |
|
160 |
_asm ret |
|
161 |
} |
|
162 |
||
163 |
// Hash a 16 bit string at aPtr, length aLen bytes. |
|
164 |
__NAKED__ TUint32 DefaultWStringHash(const TUint16* /*aPtr*/, TInt /*aLen*/) |
|
165 |
{ |
|
166 |
_asm push esi |
|
167 |
_asm mov esi, [esp+8] |
|
168 |
_asm mov ecx, [esp+12] |
|
169 |
_asm xor eax, eax |
|
170 |
_asm sub ecx, 8 |
|
171 |
_asm jb lt8 |
|
172 |
ge8: |
|
173 |
_asm mov edx, [esi+4] |
|
174 |
_asm xor eax, [esi] |
|
175 |
_asm add esi, 8 |
|
176 |
_asm rol edx, 8 |
|
177 |
_asm xor eax, edx |
|
178 |
_asm mov edx, 9E3779B9h |
|
179 |
_asm mul edx |
|
180 |
_asm sub ecx, 8 |
|
181 |
_asm jae ge8 |
|
182 |
lt8: |
|
183 |
_asm add ecx, 8 |
|
184 |
_asm jz done |
|
185 |
_asm xor edx, edx |
|
186 |
_asm cmp ecx, 4 |
|
187 |
_asm jbe le4 |
|
188 |
_asm mov dx, [esi+4] |
|
189 |
_asm rol edx, 8 |
|
190 |
_asm xor eax, edx |
|
191 |
_asm xor edx, edx |
|
192 |
le4: |
|
193 |
_asm cmp ecx, 4 |
|
194 |
_asm jb onemore |
|
195 |
_asm mov dx, [esi+2] |
|
196 |
_asm shl edx, 16 |
|
197 |
onemore: |
|
198 |
_asm mov dx, [esi] |
|
199 |
_asm xor eax, edx |
|
200 |
_asm mov edx, 9E3779B9h |
|
201 |
_asm mul edx |
|
202 |
done: |
|
203 |
_asm pop esi |
|
204 |
_asm ret |
|
205 |
} |
|
206 |
||
207 |
/** |
|
208 |
@publishedAll |
|
209 |
@released |
|
210 |
||
211 |
Calculate a 32 bit hash from a 32 bit integer. |
|
212 |
||
213 |
@param aInt The integer to be hashed. |
|
214 |
@return The calculated 32 bit hash value. |
|
215 |
*/ |
|
216 |
EXPORT_C __NAKED__ TUint32 DefaultHash::Integer(const TInt& /*aInt*/) |
|
217 |
{ |
|
218 |
_asm mov edx, [esp+4] |
|
219 |
_asm mov eax, 9E3779B9h |
|
220 |
_asm mul dword ptr [edx] |
|
221 |
_asm ret |
|
222 |
} |
|
223 |