os/kernelhwsrv/kernel/eka/euser/epoc/x86/uc_exe.cia
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// e32\euser\epoc\x86\uc_exe.cia
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include <u32std.h>
sl@0
    19
#include "x86hlp.inl"
sl@0
    20
sl@0
    21
static const TLinAddr User_HandleException = (TLinAddr)&User::HandleException;
sl@0
    22
static const TLinAddr User_Invariant = (TLinAddr)&User::Invariant;
sl@0
    23
sl@0
    24
extern "C" {
sl@0
    25
void __fastcall RunThread(TBool aNotFirst, SThreadCreateInfo& aInfo);
sl@0
    26
sl@0
    27
// NOTE: This MUST be the first function in this module
sl@0
    28
__NAKED__ TInt _E32Startup()
sl@0
    29
	{
sl@0
    30
	// Process entry point
sl@0
    31
	// EBX = entry reason
sl@0
    32
	// ESP points to information block
sl@0
    33
	BYTE(0xeb)			// JMP .+16
sl@0
    34
	BYTE(0x0e)
sl@0
    35
	BYTE(0x00)
sl@0
    36
	BYTE(0x00)
sl@0
    37
	BYTE(0x00)
sl@0
    38
	BYTE(0x00)
sl@0
    39
	BYTE(0x00)
sl@0
    40
	BYTE(0x00)
sl@0
    41
	BYTE(0x00)
sl@0
    42
	BYTE(0x00)
sl@0
    43
	BYTE(0x00)
sl@0
    44
	BYTE(0x00)
sl@0
    45
	BYTE(0x00)			// need zero word at offset 12 from entry point
sl@0
    46
	BYTE(0x00)
sl@0
    47
	BYTE(0x00)
sl@0
    48
	BYTE(0x00)
sl@0
    49
sl@0
    50
	asm("cmp ebx, 2");
sl@0
    51
	asm("jae not_thread_entry");
sl@0
    52
	asm("mov ecx, ebx");
sl@0
    53
	asm("mov edx, esp");
sl@0
    54
	asm("jmp %a0": :"i"(&RunThread));
sl@0
    55
sl@0
    56
	asm("not_thread_entry:");
sl@0
    57
	asm("cmp ebx, 4");
sl@0
    58
	asm("jne invalid_entry");
sl@0
    59
	asm("mov eax, esp");
sl@0
    60
	asm("push eax");
sl@0
    61
	asm("mov eax, %0": : "i"(User_HandleException));
sl@0
    62
	asm("call eax");
sl@0
    63
	asm("pop eax");	// parameter
sl@0
    64
	asm("pop eax");	// exc type
sl@0
    65
	asm("pop eax");	// exc id
sl@0
    66
	asm("pop eax");	// exc error code
sl@0
    67
	asm("pop eax");	// fault address
sl@0
    68
	asm("pop eax");
sl@0
    69
	asm("pop ecx");
sl@0
    70
	asm("pop edx");
sl@0
    71
	asm("pop ebx");
sl@0
    72
	asm("pop esi");	// ESP - ignore
sl@0
    73
	asm("pop ebp");
sl@0
    74
	asm("pop esi");
sl@0
    75
	asm("pop edi");
sl@0
    76
	asm("add esp, 4");	// SS - ignore
sl@0
    77
	asm("pop ds");
sl@0
    78
	asm("pop es");
sl@0
    79
	asm("pop fs");
sl@0
    80
	asm("pop gs");
sl@0
    81
	asm("popfd");
sl@0
    82
	BYTE(0xcb) //asm("retf"); GCC doesn't recognise retf
sl@0
    83
sl@0
    84
	asm("invalid_entry:");
sl@0
    85
	asm("call %a0": : "i"(User_Invariant));
sl@0
    86
	}
sl@0
    87
sl@0
    88
}
sl@0
    89
sl@0
    90