1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of the License "ARM EABI LICENCE.txt" |
4 // under the terms of the License "ARM EABI LICENCE.txt" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // in kernel/eka/compsupp. |
6 // in kernel/eka/compsupp. |
38 namespace NAMES { void default_unexpected_handler(void); } |
38 namespace NAMES { void default_unexpected_handler(void); } |
39 |
39 |
40 EXPORT_C TCppRTExceptionsGlobals::TCppRTExceptionsGlobals() |
40 EXPORT_C TCppRTExceptionsGlobals::TCppRTExceptionsGlobals() |
41 { |
41 { |
42 buffer.inuse = false; |
42 buffer.inuse = false; |
|
43 buffer.em_buf2_p = NULL; |
43 thread_globals.uncaughtExceptions = 0; |
44 thread_globals.uncaughtExceptions = 0; |
44 thread_globals.unexpectedHandler = NAMES::default_unexpected_handler; |
45 thread_globals.unexpectedHandler = NAMES::default_unexpected_handler; |
45 thread_globals.terminateHandler = __default_terminate_handler; |
46 thread_globals.terminateHandler = __default_terminate_handler; |
46 thread_globals.implementation_ever_called_terminate = false; |
47 thread_globals.implementation_ever_called_terminate = false; |
47 thread_globals.call_hook = NULL; |
48 thread_globals.call_hook = NULL; |
48 thread_globals.caughtExceptions = NULL; |
49 thread_globals.caughtExceptions = NULL; |
49 thread_globals.propagatingExceptions = NULL; |
50 thread_globals.propagatingExceptions = NULL; |
50 thread_globals.emergency_buffer = &buffer; |
51 thread_globals.emergency_buffer = &buffer; |
51 Dll::SetTls(this); |
52 Dll::SetTls(this); |
52 } |
53 } |
|
54 |
|
55 EXPORT_C void TCppRTExceptionsGlobals::Init2ndEmergencyBuffer() |
|
56 { |
|
57 ASSERT(buffer.em_buf2_p == NULL); |
|
58 |
|
59 TEmergencyBuffer2* p = (TEmergencyBuffer2*) User::Alloc( sizeof(TEmergencyBuffer2) ); |
|
60 if (!p) |
|
61 abort(); |
|
62 p->Init(); |
|
63 buffer.em_buf2_p = p; |
|
64 } |
|
65 |
|
66 EXPORT_C void TCppRTExceptionsGlobals::Kill2ndEmergencyBuffer() |
|
67 { |
|
68 ASSERT(buffer.em_buf2_p); |
|
69 |
|
70 User::Free(buffer.em_buf2_p); |
|
71 } |
|
72 |
53 #if __ARMCC_VERSION < 220000 |
73 #if __ARMCC_VERSION < 220000 |
54 extern "C" |
74 extern "C" |
55 { |
75 { |
56 /* |
76 /* |
57 we have to dummy up the following for 2.1. The names changed in the def file |
77 we have to dummy up the following for 2.1. The names changed in the def file |
58 since in 2.2 catch handlers should be able to deal with imported RTTI |
78 since in 2.2 catch handlers should be able to deal with imported RTTI |
59 |
79 |
222 if (!aEDp) |
242 if (!aEDp) |
223 { |
243 { |
224 // look in extension ROM if there is one |
244 // look in extension ROM if there is one |
225 TUint main_start = UserSvr::RomHeaderAddress(); |
245 TUint main_start = UserSvr::RomHeaderAddress(); |
226 TUint main_end = main_start + ((TRomHeader*)main_start)->iUncompressedSize; |
246 TUint main_end = main_start + ((TRomHeader*)main_start)->iUncompressedSize; |
227 |
247 |
228 TUint rda = UserSvr::RomRootDirectoryAddress(); |
248 TUint rda = UserSvr::RomRootDirectoryAddress(); |
229 |
249 |
230 // Assume rom starts on multiple of 4k |
250 // Assume rom starts on multiple of 4k |
231 if (rda > main_end) |
251 if (rda > main_end) |
232 { |
252 { |
233 // ASSUMPTIONS HERE |
253 // ASSUMPTIONS HERE |
234 // 1. root directory is past the end of the main ROM so there must be an extension ROM |
254 // 1. root directory is past the end of the main ROM so there must be an extension ROM |
235 // 2. the ROM file system in the extension ROM is at the beginning of the ROM (similar to the |
255 // 2. the ROM file system in the extension ROM is at the beginning of the ROM (similar to the |
236 // main ROM) |
256 // main ROM) |
237 // 3. the extension ROM is mapped starting at a megabyte boundary |
257 // 3. the extension ROM is mapped starting at a megabyte boundary |
238 // Thus the address of the extension ROM header may be obtained by rounding the root directory |
258 // Thus the address of the extension ROM header may be obtained by rounding the root directory |
239 // address down to the next megabyte boundary. |
259 // address down to the next megabyte boundary. |
240 |
260 |
241 TUint ext_start = rda &~ 0x000fffffu; |
261 TUint ext_start = rda &~ 0x000fffffu; |
242 TRomExceptionSearchTable* extrom_exctab = (TRomExceptionSearchTable*)(((TExtensionRomHeader*)ext_start)->iRomExceptionSearchTable); |
262 TRomExceptionSearchTable* extrom_exctab = (TRomExceptionSearchTable*)(((TExtensionRomHeader*)ext_start)->iRomExceptionSearchTable); |
243 if (extrom_exctab && addr >= extrom_exctab->iEntries[0] && addr < GET_EST_FENCEPOST(extrom_exctab)) |
263 if (extrom_exctab && addr >= extrom_exctab->iEntries[0] && addr < GET_EST_FENCEPOST(extrom_exctab)) |
244 aEDp = SearchEST(addr, extrom_exctab); |
264 aEDp = SearchEST(addr, extrom_exctab); |
245 } |
265 } |