|
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_exe.cpp |
|
15 // |
|
16 // |
|
17 |
|
18 #include <e32std.h> |
|
19 #include <e32std_private.h> |
|
20 #include <e32wins.h> |
|
21 #include <u32exec.h> |
|
22 #include <e32svr.h> |
|
23 |
|
24 #ifdef __VC32__ |
|
25 #define __FLTUSED |
|
26 #endif //__VC32__ |
|
27 |
|
28 // include the static data definitions |
|
29 #include "win32crt.h" |
|
30 |
|
31 // include compiler helpers |
|
32 #include "x86hlp.inl" |
|
33 |
|
34 GLREF_C TInt E32Main(); |
|
35 |
|
36 #ifdef __CW32__ |
|
37 TBool InitCWRuntime(); |
|
38 TBool CleanupCWRuntime(); |
|
39 #endif |
|
40 |
|
41 void globalDestructorFunc() |
|
42 { |
|
43 #ifdef __CW32__ |
|
44 CleanupCWRuntime(); |
|
45 #else |
|
46 destroyStatics(); // this is a macro |
|
47 #endif |
|
48 } |
|
49 |
|
50 extern "C" |
|
51 EXPORT_C TInt _E32Startup(TInt aReason, TAny* aInfo) |
|
52 // |
|
53 // Ordinal 1 - the EPOC executable entrypoint |
|
54 // |
|
55 { |
|
56 if (TUint(aReason)<=TUint(KModuleEntryReasonThreadInit)) |
|
57 { |
|
58 SStdEpocThreadCreateInfo& cinfo = *(SStdEpocThreadCreateInfo*)aInfo; |
|
59 |
|
60 #ifdef USE_INSTRUMENTED_HEAP |
|
61 cinfo.iFlags |= ETraceHeapAllocs; |
|
62 #elif defined(ENABLE_HEAP_MONITORING) |
|
63 cinfo.iFlags |= ETraceHeapAllocs|EMonitorHeapMemory; |
|
64 #endif |
|
65 TInt r = UserHeap::SetupThreadHeap( (aReason!=KModuleEntryReasonProcessInit), cinfo); |
|
66 |
|
67 if (r==KErrNone) |
|
68 r = UserSvr::DllSetTls(KGlobalDestructorTlsKey, KDllUid_Special, (TAny*)globalDestructorFunc); |
|
69 |
|
70 if (r==KErrNone) |
|
71 { |
|
72 if (aReason==KModuleEntryReasonProcessInit) |
|
73 { |
|
74 // Init statics for implicitly linked DLLs |
|
75 User::InitProcess(); |
|
76 |
|
77 #ifdef __CW32__ |
|
78 // Ensure runtime library gets initialised |
|
79 r = InitCWRuntime() ? KErrNone : KErrGeneral; |
|
80 #endif |
|
81 |
|
82 if (r==KErrNone) |
|
83 { |
|
84 // Init statics for EXE |
|
85 constructStatics(); |
|
86 |
|
87 r = E32Main(); |
|
88 } |
|
89 } |
|
90 else |
|
91 r = (*cinfo.iFunction)(cinfo.iPtr); |
|
92 } |
|
93 User::Exit(r); |
|
94 } |
|
95 if (aReason==KModuleEntryReasonException) |
|
96 { |
|
97 User::HandleException(aInfo); |
|
98 return 0; |
|
99 } |
|
100 User::Invariant(); |
|
101 return 0; |
|
102 } |
|
103 |
|
104 GLDEF_C void __stdcall _E32Bootstrap() |
|
105 // |
|
106 // Win32 entrypoint, Boot epoc with auto-run |
|
107 // |
|
108 { |
|
109 BootEpoc(ETrue); |
|
110 } |