os/kernelhwsrv/kernel/eka/include/u32exec.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kernel/eka/include/u32exec.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,214 @@
     1.4 +// Copyright (c) 1995-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\include\u32exec.h
    1.18 +// 
    1.19 +// WARNING: This file contains some APIs which are internal and are subject
    1.20 +//          to change without notice. Such APIs should therefore not be used
    1.21 +//          outside the Kernel and Hardware Services package.
    1.22 +//
    1.23 +
    1.24 +/**
    1.25 + @file
    1.26 + @internalComponent
    1.27 +*/
    1.28 +
    1.29 +#ifndef __U32EXEC_H__
    1.30 +#define __U32EXEC_H__
    1.31 +#include <u32std.h>
    1.32 +#include <cpudefs.h>
    1.33 +
    1.34 +#ifdef __KERNEL_MODE__
    1.35 +#define	EXEC_INT64		Int64
    1.36 +#define	EXEC_TIME		TTimeK
    1.37 +#else
    1.38 +#define	EXEC_INT64		TInt64
    1.39 +#define	EXEC_TIME		TInt64
    1.40 +#endif
    1.41 +
    1.42 +//#ifdef __SYMC__
    1.43 +//#define __EXECDECL__
    1.44 +//#else
    1.45 +#define __EXECDECL__	__NAKED__
    1.46 +//#endif
    1.47 +
    1.48 +#if defined(__WINS__)
    1.49 +
    1.50 +// Executive call macros for WINS
    1.51 +
    1.52 +#define EXECUTIVE_FAST	0x00800000
    1.53 +#define EXECUTIVE_SLOW	0x00000000
    1.54 +
    1.55 +#define __DISPATCH(func)			\
    1.56 +	__asm lea	edx, [esp + 0x4]	\
    1.57 +	__asm mov	ecx, (func)			\
    1.58 +	__asm jmp  [TheDispatcher]
    1.59 +
    1.60 +
    1.61 +#define	FAST_EXEC0(n)	__DISPATCH((n)|EXECUTIVE_FAST)
    1.62 +#define	FAST_EXEC1(n)	__DISPATCH((n)|EXECUTIVE_FAST)
    1.63 +#define	SLOW_EXEC0(n)	__DISPATCH((n)|EXECUTIVE_SLOW)
    1.64 +#define	SLOW_EXEC1(n)	__DISPATCH((n)|EXECUTIVE_SLOW)
    1.65 +#define	SLOW_EXEC2(n)	__DISPATCH((n)|EXECUTIVE_SLOW)
    1.66 +#define SLOW_EXEC3(n)	__DISPATCH((n)|EXECUTIVE_SLOW)
    1.67 +#define SLOW_EXEC4(n)	__DISPATCH((n)|EXECUTIVE_SLOW)
    1.68 +
    1.69 +#define	KFAST_EXEC0(n)	__DISPATCH((n)|EXECUTIVE_FAST)
    1.70 +#define	KFAST_EXEC1(n)	__DISPATCH((n)|EXECUTIVE_FAST)
    1.71 +#define	KSLOW_EXEC0(n)	__DISPATCH((n)|EXECUTIVE_SLOW)
    1.72 +#define	KSLOW_EXEC1(n)	__DISPATCH((n)|EXECUTIVE_SLOW)
    1.73 +#define	KSLOW_EXEC2(n)	__DISPATCH((n)|EXECUTIVE_SLOW)
    1.74 +#define KSLOW_EXEC3(n)	__DISPATCH((n)|EXECUTIVE_SLOW)
    1.75 +#define KSLOW_EXEC4(n)	__DISPATCH((n)|EXECUTIVE_SLOW)
    1.76 +
    1.77 +#elif defined(__CPU_X86)
    1.78 +
    1.79 +// Executive call macros for X86
    1.80 +#ifdef __GCC32__
    1.81 +#define	FAST_EXEC0(n)	asm("mov eax, %0": :"i"(n)); \
    1.82 +						asm("int 0x20 \n ret")
    1.83 +#define	FAST_EXEC1(n)	asm("mov eax, %0": :"i"(n)); \
    1.84 +						asm("mov ecx, [esp+4] \n int 0x20 \n ret")
    1.85 +#define	SLOW_EXEC0(n)	asm("mov eax, %0": :"i"(n)); \
    1.86 +						asm("int 0x21 \n ret")
    1.87 +#define	SLOW_EXEC1(n)	asm("mov eax, %0": :"i"(n)); \
    1.88 +						asm("mov ecx, [esp+4] \n int 0x21 \n ret")
    1.89 +#define	SLOW_EXEC2(n)	asm("mov eax, %0": :"i"(n)); \
    1.90 +						asm("mov ecx, [esp+4] \n mov edx, [esp+8] \n int 0x21 \n ret")
    1.91 +#define SLOW_EXEC3(n)	asm("mov eax, %0": :"i"(n)); \
    1.92 +						asm("push ebx         \n" \
    1.93 +							"mov ecx, [esp+8] \n" \
    1.94 +							"mov edx, [esp+12]\n" \
    1.95 +							"mov ebx, [esp+16]\n" \
    1.96 +							"int 0x21         \n" \
    1.97 +							"pop ebx          \n" \
    1.98 +						    "ret")
    1.99 +
   1.100 +#define SLOW_EXEC4(n)	asm("mov eax, %0": :"i"(n)); \
   1.101 +						asm("push ebx         \n" \
   1.102 +							"push esi         \n" \
   1.103 +							"mov ecx, [esp+12]\n" \
   1.104 +							"mov edx, [esp+16]\n" \
   1.105 +							"mov ebx, [esp+20]\n" \
   1.106 +							"mov esi, [esp+24]\n" \
   1.107 +							"int 0x21         \n" \
   1.108 +							"pop esi          \n" \
   1.109 +							"pop ebx          \n" \
   1.110 +							"ret")
   1.111 +#else
   1.112 +#define	FAST_EXEC0(n)	_asm mov eax, n _asm int 20h _asm ret
   1.113 +#define	FAST_EXEC1(n)	_asm mov eax, n _asm mov ecx, [esp+4] _asm int 20h _asm ret
   1.114 +
   1.115 +#define	SLOW_EXEC0(n)	_asm mov eax, n _asm int 21h _asm ret
   1.116 +#define	SLOW_EXEC1(n)	_asm mov eax, n _asm mov ecx, [esp+4] _asm int 21h _asm ret
   1.117 +#define	SLOW_EXEC2(n)	_asm mov eax, n _asm mov ecx, [esp+4] _asm mov edx, [esp+8] _asm int 21h _asm ret
   1.118 +
   1.119 +#define SLOW_EXEC3(n)	_asm mov eax, n			\
   1.120 +						_asm push ebx			\
   1.121 +						_asm mov ecx, [esp+8]	\
   1.122 +						_asm mov edx, [esp+12]	\
   1.123 +						_asm mov ebx, [esp+16]	\
   1.124 +						_asm int 21h			\
   1.125 +						_asm pop ebx			\
   1.126 +						_asm ret
   1.127 +
   1.128 +#define SLOW_EXEC4(n)	_asm mov eax, n			\
   1.129 +						_asm push ebx			\
   1.130 +						_asm push esi			\
   1.131 +						_asm mov ecx, [esp+12]	\
   1.132 +						_asm mov edx, [esp+16]	\
   1.133 +						_asm mov ebx, [esp+20]	\
   1.134 +						_asm mov esi, [esp+24]	\
   1.135 +						_asm int 21h			\
   1.136 +						_asm pop esi			\
   1.137 +						_asm pop ebx			\
   1.138 +						_asm ret
   1.139 +#endif
   1.140 +
   1.141 +#define	KFAST_EXEC0(n)	FAST_EXEC0(n)
   1.142 +#define	KFAST_EXEC1(n)	FAST_EXEC1(n)
   1.143 +#define	KSLOW_EXEC0(n)	SLOW_EXEC0(n)
   1.144 +#define	KSLOW_EXEC1(n)	SLOW_EXEC1(n)
   1.145 +#define	KSLOW_EXEC2(n)	SLOW_EXEC2(n)
   1.146 +#define KSLOW_EXEC3(n)	SLOW_EXEC3(n)
   1.147 +#define KSLOW_EXEC4(n)	SLOW_EXEC4(n)
   1.148 +
   1.149 +#elif defined(__CPU_ARM)
   1.150 +
   1.151 +// Executive call macros for ARM
   1.152 +
   1.153 +#define EXECUTIVE_FAST	0x00800000
   1.154 +#define EXECUTIVE_SLOW	0x00000000
   1.155 +
   1.156 +#define __DISPATCH(n)				\
   1.157 +	asm("swi %a0" : : "i" (n));     \
   1.158 +	__JUMP(,lr);
   1.159 +
   1.160 +#define	FAST_EXEC0(n)		__DISPATCH((n)|EXECUTIVE_FAST)
   1.161 +#define	FAST_EXEC1(n)		__DISPATCH((n)|EXECUTIVE_FAST)
   1.162 +#define	SLOW_EXEC0(n)		__DISPATCH((n)|EXECUTIVE_SLOW)
   1.163 +#define	SLOW_EXEC1(n)		__DISPATCH((n)|EXECUTIVE_SLOW)
   1.164 +#define	SLOW_EXEC2(n)		__DISPATCH((n)|EXECUTIVE_SLOW)
   1.165 +#define SLOW_EXEC3(n)		__DISPATCH((n)|EXECUTIVE_SLOW)
   1.166 +#define SLOW_EXEC4(n)		__DISPATCH((n)|EXECUTIVE_SLOW)
   1.167 +
   1.168 +#define __KDISPATCH(n)				\
   1.169 +	asm("stmfd sp!, {ip,lr} ");		\
   1.170 +	asm("swi %a0" : : "i" (n));     \
   1.171 +	__POPRET("ip,");
   1.172 +
   1.173 +#define	KFAST_EXEC0(n)		__KDISPATCH((n)|EXECUTIVE_FAST)
   1.174 +#define	KFAST_EXEC1(n)		__KDISPATCH((n)|EXECUTIVE_FAST)
   1.175 +#define	KSLOW_EXEC0(n)		__KDISPATCH((n)|EXECUTIVE_SLOW)
   1.176 +#define	KSLOW_EXEC1(n)		__KDISPATCH((n)|EXECUTIVE_SLOW)
   1.177 +#define	KSLOW_EXEC2(n)		__KDISPATCH((n)|EXECUTIVE_SLOW)
   1.178 +#define KSLOW_EXEC3(n)		__KDISPATCH((n)|EXECUTIVE_SLOW)
   1.179 +#define KSLOW_EXEC4(n)		__KDISPATCH((n)|EXECUTIVE_SLOW)
   1.180 +
   1.181 +#define __DISPATCH_NR(n)			\
   1.182 +	asm("swi %a0" : : "i" (n));
   1.183 +
   1.184 +#define	FAST_EXEC0_NR(n)	__DISPATCH_NR((n)|EXECUTIVE_FAST)
   1.185 +#define	FAST_EXEC1_NR(n)	__DISPATCH_NR((n)|EXECUTIVE_FAST)
   1.186 +#define	SLOW_EXEC0_NR(n)	__DISPATCH_NR((n)|EXECUTIVE_SLOW)
   1.187 +#define	SLOW_EXEC1_NR(n)	__DISPATCH_NR((n)|EXECUTIVE_SLOW)
   1.188 +#define	SLOW_EXEC2_NR(n)	__DISPATCH_NR((n)|EXECUTIVE_SLOW)
   1.189 +#define SLOW_EXEC3_NR(n)	__DISPATCH_NR((n)|EXECUTIVE_SLOW)
   1.190 +#define SLOW_EXEC4_NR(n)	__DISPATCH_NR((n)|EXECUTIVE_SLOW)
   1.191 +
   1.192 +#define __KDISPATCH_NR(n)			\
   1.193 +	asm("swi %a0" : : "i" (n));
   1.194 +
   1.195 +#define	KFAST_EXEC0_NR(n)	__KDISPATCH_NR((n)|EXECUTIVE_FAST)
   1.196 +#define	KFAST_EXEC1_NR(n)	__KDISPATCH_NR((n)|EXECUTIVE_FAST)
   1.197 +#define	KSLOW_EXEC0_NR(n)	__KDISPATCH_NR((n)|EXECUTIVE_SLOW)
   1.198 +#define	KSLOW_EXEC1_NR(n)	__KDISPATCH_NR((n)|EXECUTIVE_SLOW)
   1.199 +#define	KSLOW_EXEC2_NR(n)	__KDISPATCH_NR((n)|EXECUTIVE_SLOW)
   1.200 +#define KSLOW_EXEC3_NR(n)	__KDISPATCH_NR((n)|EXECUTIVE_SLOW)
   1.201 +#define KSLOW_EXEC4_NR(n)	__KDISPATCH_NR((n)|EXECUTIVE_SLOW)
   1.202 +
   1.203 +#else
   1.204 +#error Unknown CPU
   1.205 +#endif
   1.206 +
   1.207 +#ifdef __LEAVE_EQUALS_THROW__
   1.208 +// Hide TTrap to catch unwary uses of the old cleanup
   1.209 +// mechanism at compile time
   1.210 +class TTrap;
   1.211 +#endif //__LEAVE_EQUALS_THROW__
   1.212 +
   1.213 +#include <exec_enum.h>
   1.214 +#include <e32btrace.h>
   1.215 +#include <exec_user.h>
   1.216 +
   1.217 +#endif