0
|
1 |
// Copyright (c) 2007-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\x86\uc_exe.cia
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
#include <u32std.h>
|
|
19 |
#include "x86hlp.inl"
|
|
20 |
|
|
21 |
static const TLinAddr User_HandleException = (TLinAddr)&User::HandleException;
|
|
22 |
static const TLinAddr User_Invariant = (TLinAddr)&User::Invariant;
|
|
23 |
|
|
24 |
extern "C" {
|
|
25 |
void __fastcall RunThread(TBool aNotFirst, SThreadCreateInfo& aInfo);
|
|
26 |
|
|
27 |
// NOTE: This MUST be the first function in this module
|
|
28 |
__NAKED__ TInt _E32Startup()
|
|
29 |
{
|
|
30 |
// Process entry point
|
|
31 |
// EBX = entry reason
|
|
32 |
// ESP points to information block
|
|
33 |
BYTE(0xeb) // JMP .+16
|
|
34 |
BYTE(0x0e)
|
|
35 |
BYTE(0x00)
|
|
36 |
BYTE(0x00)
|
|
37 |
BYTE(0x00)
|
|
38 |
BYTE(0x00)
|
|
39 |
BYTE(0x00)
|
|
40 |
BYTE(0x00)
|
|
41 |
BYTE(0x00)
|
|
42 |
BYTE(0x00)
|
|
43 |
BYTE(0x00)
|
|
44 |
BYTE(0x00)
|
|
45 |
BYTE(0x00) // need zero word at offset 12 from entry point
|
|
46 |
BYTE(0x00)
|
|
47 |
BYTE(0x00)
|
|
48 |
BYTE(0x00)
|
|
49 |
|
|
50 |
asm("cmp ebx, 2");
|
|
51 |
asm("jae not_thread_entry");
|
|
52 |
asm("mov ecx, ebx");
|
|
53 |
asm("mov edx, esp");
|
|
54 |
asm("jmp %a0": :"i"(&RunThread));
|
|
55 |
|
|
56 |
asm("not_thread_entry:");
|
|
57 |
asm("cmp ebx, 4");
|
|
58 |
asm("jne invalid_entry");
|
|
59 |
asm("mov eax, esp");
|
|
60 |
asm("push eax");
|
|
61 |
asm("mov eax, %0": : "i"(User_HandleException));
|
|
62 |
asm("call eax");
|
|
63 |
asm("pop eax"); // parameter
|
|
64 |
asm("pop eax"); // exc type
|
|
65 |
asm("pop eax"); // exc id
|
|
66 |
asm("pop eax"); // exc error code
|
|
67 |
asm("pop eax"); // fault address
|
|
68 |
asm("pop eax");
|
|
69 |
asm("pop ecx");
|
|
70 |
asm("pop edx");
|
|
71 |
asm("pop ebx");
|
|
72 |
asm("pop esi"); // ESP - ignore
|
|
73 |
asm("pop ebp");
|
|
74 |
asm("pop esi");
|
|
75 |
asm("pop edi");
|
|
76 |
asm("add esp, 4"); // SS - ignore
|
|
77 |
asm("pop ds");
|
|
78 |
asm("pop es");
|
|
79 |
asm("pop fs");
|
|
80 |
asm("pop gs");
|
|
81 |
asm("popfd");
|
|
82 |
BYTE(0xcb) //asm("retf"); GCC doesn't recognise retf
|
|
83 |
|
|
84 |
asm("invalid_entry:");
|
|
85 |
asm("call %a0": : "i"(User_Invariant));
|
|
86 |
}
|
|
87 |
|
|
88 |
}
|
|
89 |
|
|
90 |
|