sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32\euser\epoc\x86\uc_exe.cia sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include "x86hlp.inl" sl@0: sl@0: static const TLinAddr User_HandleException = (TLinAddr)&User::HandleException; sl@0: static const TLinAddr User_Invariant = (TLinAddr)&User::Invariant; sl@0: sl@0: extern "C" { sl@0: void __fastcall RunThread(TBool aNotFirst, SThreadCreateInfo& aInfo); sl@0: sl@0: // NOTE: This MUST be the first function in this module sl@0: __NAKED__ TInt _E32Startup() sl@0: { sl@0: // Process entry point sl@0: // EBX = entry reason sl@0: // ESP points to information block sl@0: BYTE(0xeb) // JMP .+16 sl@0: BYTE(0x0e) sl@0: BYTE(0x00) sl@0: BYTE(0x00) sl@0: BYTE(0x00) sl@0: BYTE(0x00) sl@0: BYTE(0x00) sl@0: BYTE(0x00) sl@0: BYTE(0x00) sl@0: BYTE(0x00) sl@0: BYTE(0x00) sl@0: BYTE(0x00) sl@0: BYTE(0x00) // need zero word at offset 12 from entry point sl@0: BYTE(0x00) sl@0: BYTE(0x00) sl@0: BYTE(0x00) sl@0: sl@0: asm("cmp ebx, 2"); sl@0: asm("jae not_thread_entry"); sl@0: asm("mov ecx, ebx"); sl@0: asm("mov edx, esp"); sl@0: asm("jmp %a0": :"i"(&RunThread)); sl@0: sl@0: asm("not_thread_entry:"); sl@0: asm("cmp ebx, 4"); sl@0: asm("jne invalid_entry"); sl@0: asm("mov eax, esp"); sl@0: asm("push eax"); sl@0: asm("mov eax, %0": : "i"(User_HandleException)); sl@0: asm("call eax"); sl@0: asm("pop eax"); // parameter sl@0: asm("pop eax"); // exc type sl@0: asm("pop eax"); // exc id sl@0: asm("pop eax"); // exc error code sl@0: asm("pop eax"); // fault address sl@0: asm("pop eax"); sl@0: asm("pop ecx"); sl@0: asm("pop edx"); sl@0: asm("pop ebx"); sl@0: asm("pop esi"); // ESP - ignore sl@0: asm("pop ebp"); sl@0: asm("pop esi"); sl@0: asm("pop edi"); sl@0: asm("add esp, 4"); // SS - ignore sl@0: asm("pop ds"); sl@0: asm("pop es"); sl@0: asm("pop fs"); sl@0: asm("pop gs"); sl@0: asm("popfd"); sl@0: BYTE(0xcb) //asm("retf"); GCC doesn't recognise retf sl@0: sl@0: asm("invalid_entry:"); sl@0: asm("call %a0": : "i"(User_Invariant)); sl@0: } sl@0: sl@0: } sl@0: sl@0: