os/kernelhwsrv/kernel/eka/euser/epoc/x86/uc_exe.cia
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kernel/eka/euser/epoc/x86/uc_exe.cia	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,90 @@
     1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// e32\euser\epoc\x86\uc_exe.cia
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#include <u32std.h>
    1.22 +#include "x86hlp.inl"
    1.23 +
    1.24 +static const TLinAddr User_HandleException = (TLinAddr)&User::HandleException;
    1.25 +static const TLinAddr User_Invariant = (TLinAddr)&User::Invariant;
    1.26 +
    1.27 +extern "C" {
    1.28 +void __fastcall RunThread(TBool aNotFirst, SThreadCreateInfo& aInfo);
    1.29 +
    1.30 +// NOTE: This MUST be the first function in this module
    1.31 +__NAKED__ TInt _E32Startup()
    1.32 +	{
    1.33 +	// Process entry point
    1.34 +	// EBX = entry reason
    1.35 +	// ESP points to information block
    1.36 +	BYTE(0xeb)			// JMP .+16
    1.37 +	BYTE(0x0e)
    1.38 +	BYTE(0x00)
    1.39 +	BYTE(0x00)
    1.40 +	BYTE(0x00)
    1.41 +	BYTE(0x00)
    1.42 +	BYTE(0x00)
    1.43 +	BYTE(0x00)
    1.44 +	BYTE(0x00)
    1.45 +	BYTE(0x00)
    1.46 +	BYTE(0x00)
    1.47 +	BYTE(0x00)
    1.48 +	BYTE(0x00)			// need zero word at offset 12 from entry point
    1.49 +	BYTE(0x00)
    1.50 +	BYTE(0x00)
    1.51 +	BYTE(0x00)
    1.52 +
    1.53 +	asm("cmp ebx, 2");
    1.54 +	asm("jae not_thread_entry");
    1.55 +	asm("mov ecx, ebx");
    1.56 +	asm("mov edx, esp");
    1.57 +	asm("jmp %a0": :"i"(&RunThread));
    1.58 +
    1.59 +	asm("not_thread_entry:");
    1.60 +	asm("cmp ebx, 4");
    1.61 +	asm("jne invalid_entry");
    1.62 +	asm("mov eax, esp");
    1.63 +	asm("push eax");
    1.64 +	asm("mov eax, %0": : "i"(User_HandleException));
    1.65 +	asm("call eax");
    1.66 +	asm("pop eax");	// parameter
    1.67 +	asm("pop eax");	// exc type
    1.68 +	asm("pop eax");	// exc id
    1.69 +	asm("pop eax");	// exc error code
    1.70 +	asm("pop eax");	// fault address
    1.71 +	asm("pop eax");
    1.72 +	asm("pop ecx");
    1.73 +	asm("pop edx");
    1.74 +	asm("pop ebx");
    1.75 +	asm("pop esi");	// ESP - ignore
    1.76 +	asm("pop ebp");
    1.77 +	asm("pop esi");
    1.78 +	asm("pop edi");
    1.79 +	asm("add esp, 4");	// SS - ignore
    1.80 +	asm("pop ds");
    1.81 +	asm("pop es");
    1.82 +	asm("pop fs");
    1.83 +	asm("pop gs");
    1.84 +	asm("popfd");
    1.85 +	BYTE(0xcb) //asm("retf"); GCC doesn't recognise retf
    1.86 +
    1.87 +	asm("invalid_entry:");
    1.88 +	asm("call %a0": : "i"(User_Invariant));
    1.89 +	}
    1.90 +
    1.91 +}
    1.92 +
    1.93 +