|
1 /* |
|
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Implements OS platform specific functions declared in some |
|
15 * librarys |
|
16 * |
|
17 */ |
|
18 |
|
19 /* |
|
20 * %version: 18 % |
|
21 */ |
|
22 |
|
23 #include "WlLddWlanLddConfig.h" |
|
24 #include "wlanlddcommon.h" |
|
25 |
|
26 // ============================= LOCAL FUNCTIONS =============================== |
|
27 |
|
28 // --------------------------------------------------------------------------- |
|
29 // |
|
30 // --------------------------------------------------------------------------- |
|
31 // |
|
32 TUint32 random() |
|
33 { |
|
34 return ( static_cast<TUint32>(Kern::SystemTime() / 1000) ); |
|
35 } |
|
36 |
|
37 // --------------------------------------------------------------------------- |
|
38 // |
|
39 // --------------------------------------------------------------------------- |
|
40 // |
|
41 TAny* os_alloc( const TUint32 aLengthInBytes ) |
|
42 { |
|
43 TAny* ptr = new TUint8[aLengthInBytes]; |
|
44 |
|
45 TraceDump(MEMORY, (("WLANLDD: os_alloc: 0x%08x"), |
|
46 reinterpret_cast<TUint32>(ptr))); |
|
47 |
|
48 return ptr; |
|
49 } |
|
50 |
|
51 // --------------------------------------------------------------------------- |
|
52 // |
|
53 // --------------------------------------------------------------------------- |
|
54 // |
|
55 void os_free( const TAny* aPtr ) |
|
56 { |
|
57 TraceDump(MEMORY, (("WLANLDD: os_free: 0x%08x"), |
|
58 reinterpret_cast<TUint32>(aPtr))); |
|
59 |
|
60 delete [] aPtr; |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 TAny* os_memset( void* aDest, TInt aValue, TUint aCount ) |
|
68 { |
|
69 return memset( aDest, aValue, aCount ); |
|
70 } |
|
71 |
|
72 // --------------------------------------------------------------------------- |
|
73 // returns aDest |
|
74 // --------------------------------------------------------------------------- |
|
75 // |
|
76 TAny* os_memcpy( TAny* aDest, const TAny* aSrc, TUint32 aLengthinBytes ) |
|
77 { |
|
78 return memcpy( aDest, aSrc, aLengthinBytes ); |
|
79 } |
|
80 |
|
81 // --------------------------------------------------------------------------- |
|
82 // return 0 if equal |
|
83 // --------------------------------------------------------------------------- |
|
84 // |
|
85 TInt os_memcmp( |
|
86 const TAny* aLhs, |
|
87 const TAny* aRhs, |
|
88 TUint aNumOfBytes ) |
|
89 { |
|
90 return memcompare( |
|
91 static_cast<const TUint8*>(aLhs), aNumOfBytes, |
|
92 static_cast<const TUint8*>(aRhs), aNumOfBytes ); |
|
93 } |
|
94 |
|
95 // --------------------------------------------------------------------------- |
|
96 // |
|
97 // --------------------------------------------------------------------------- |
|
98 // |
|
99 void os_assert( const TUint8* aError, const TUint8* aFile, TUint32 aLine ) |
|
100 { |
|
101 TraceDump( ERROR_LEVEL, (reinterpret_cast<const char*>(aError)) ); |
|
102 TraceDump( ERROR_LEVEL, (reinterpret_cast<const char*>(aFile)) ); |
|
103 TraceDump( ERROR_LEVEL, (("Line: %d"), aLine)); |
|
104 |
|
105 TExitCategory category; |
|
106 |
|
107 _LIT( KWlanLdd, "WLANLDD " ); |
|
108 const TUint KWlanLddLength ( 8 ); |
|
109 |
|
110 category.Append( KWlanLdd ); |
|
111 |
|
112 TPtrC8 fileName( aFile ); |
|
113 const TUint KFileNameSuffixLen = 4; // length of ".cpp" or ".inl" |
|
114 |
|
115 const TInt KSpaceLeft = KMaxExitCategoryName - KWlanLddLength; |
|
116 |
|
117 const TUint8* KCopyFrom = |
|
118 aFile + |
|
119 fileName.Length() - |
|
120 KFileNameSuffixLen - |
|
121 KSpaceLeft; |
|
122 |
|
123 category.Append( KCopyFrom, KSpaceLeft ); |
|
124 |
|
125 WlanPanic( category, aLine ); |
|
126 } |
|
127 |
|
128 // --------------------------------------------------------------------------- |
|
129 // Returns the current time as the number of microseconds since midnight, |
|
130 // January 1st, 0 AD nominal Gregorian |
|
131 // --------------------------------------------------------------------------- |
|
132 // |
|
133 TInt64 os_systemTime() |
|
134 { |
|
135 return Kern::SystemTime(); |
|
136 } |
|
137 |
|
138 // --------------------------------------------------------------------------- |
|
139 // In our architecture also host byte order is LSB so no byte |
|
140 // re-ordering is necessary |
|
141 // --------------------------------------------------------------------------- |
|
142 // |
|
143 TUint16 os_Hton( TUint16 aHost ) |
|
144 { |
|
145 return aHost; |
|
146 } |
|
147 |
|
148 // --------------------------------------------------------------------------- |
|
149 // In our architecture also host byte order is LSB so no byte |
|
150 // re-ordering is necessary |
|
151 // --------------------------------------------------------------------------- |
|
152 // |
|
153 TUint16 os_Ntoh( TUint16 aNw ) |
|
154 { |
|
155 return aNw; |
|
156 } |
|
157 |
|
158 // --------------------------------------------------------------------------- |
|
159 // In our architecture also host byte order is LSB so no byte |
|
160 // re-ordering is necessary |
|
161 // --------------------------------------------------------------------------- |
|
162 // |
|
163 TUint32 os_H32ton( TUint32 aHost ) |
|
164 { |
|
165 return aHost; |
|
166 } |
|
167 |
|
168 // --------------------------------------------------------------------------- |
|
169 // In our architecture also host byte order is LSB so no byte |
|
170 // re-ordering is necessary |
|
171 // --------------------------------------------------------------------------- |
|
172 // |
|
173 TUint32 os_N32toh( TUint32 aNw ) |
|
174 { |
|
175 return aNw; |
|
176 } |