os/kernelhwsrv/kernel/eka/include/u32exec.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 1995-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\include\u32exec.h
sl@0
    15
// 
sl@0
    16
// WARNING: This file contains some APIs which are internal and are subject
sl@0
    17
//          to change without notice. Such APIs should therefore not be used
sl@0
    18
//          outside the Kernel and Hardware Services package.
sl@0
    19
//
sl@0
    20
sl@0
    21
/**
sl@0
    22
 @file
sl@0
    23
 @internalComponent
sl@0
    24
*/
sl@0
    25
sl@0
    26
#ifndef __U32EXEC_H__
sl@0
    27
#define __U32EXEC_H__
sl@0
    28
#include <u32std.h>
sl@0
    29
#include <cpudefs.h>
sl@0
    30
sl@0
    31
#ifdef __KERNEL_MODE__
sl@0
    32
#define	EXEC_INT64		Int64
sl@0
    33
#define	EXEC_TIME		TTimeK
sl@0
    34
#else
sl@0
    35
#define	EXEC_INT64		TInt64
sl@0
    36
#define	EXEC_TIME		TInt64
sl@0
    37
#endif
sl@0
    38
sl@0
    39
//#ifdef __SYMC__
sl@0
    40
//#define __EXECDECL__
sl@0
    41
//#else
sl@0
    42
#define __EXECDECL__	__NAKED__
sl@0
    43
//#endif
sl@0
    44
sl@0
    45
#if defined(__WINS__)
sl@0
    46
sl@0
    47
// Executive call macros for WINS
sl@0
    48
sl@0
    49
#define EXECUTIVE_FAST	0x00800000
sl@0
    50
#define EXECUTIVE_SLOW	0x00000000
sl@0
    51
sl@0
    52
#define __DISPATCH(func)			\
sl@0
    53
	__asm lea	edx, [esp + 0x4]	\
sl@0
    54
	__asm mov	ecx, (func)			\
sl@0
    55
	__asm jmp  [TheDispatcher]
sl@0
    56
sl@0
    57
sl@0
    58
#define	FAST_EXEC0(n)	__DISPATCH((n)|EXECUTIVE_FAST)
sl@0
    59
#define	FAST_EXEC1(n)	__DISPATCH((n)|EXECUTIVE_FAST)
sl@0
    60
#define	SLOW_EXEC0(n)	__DISPATCH((n)|EXECUTIVE_SLOW)
sl@0
    61
#define	SLOW_EXEC1(n)	__DISPATCH((n)|EXECUTIVE_SLOW)
sl@0
    62
#define	SLOW_EXEC2(n)	__DISPATCH((n)|EXECUTIVE_SLOW)
sl@0
    63
#define SLOW_EXEC3(n)	__DISPATCH((n)|EXECUTIVE_SLOW)
sl@0
    64
#define SLOW_EXEC4(n)	__DISPATCH((n)|EXECUTIVE_SLOW)
sl@0
    65
sl@0
    66
#define	KFAST_EXEC0(n)	__DISPATCH((n)|EXECUTIVE_FAST)
sl@0
    67
#define	KFAST_EXEC1(n)	__DISPATCH((n)|EXECUTIVE_FAST)
sl@0
    68
#define	KSLOW_EXEC0(n)	__DISPATCH((n)|EXECUTIVE_SLOW)
sl@0
    69
#define	KSLOW_EXEC1(n)	__DISPATCH((n)|EXECUTIVE_SLOW)
sl@0
    70
#define	KSLOW_EXEC2(n)	__DISPATCH((n)|EXECUTIVE_SLOW)
sl@0
    71
#define KSLOW_EXEC3(n)	__DISPATCH((n)|EXECUTIVE_SLOW)
sl@0
    72
#define KSLOW_EXEC4(n)	__DISPATCH((n)|EXECUTIVE_SLOW)
sl@0
    73
sl@0
    74
#elif defined(__CPU_X86)
sl@0
    75
sl@0
    76
// Executive call macros for X86
sl@0
    77
#ifdef __GCC32__
sl@0
    78
#define	FAST_EXEC0(n)	asm("mov eax, %0": :"i"(n)); \
sl@0
    79
						asm("int 0x20 \n ret")
sl@0
    80
#define	FAST_EXEC1(n)	asm("mov eax, %0": :"i"(n)); \
sl@0
    81
						asm("mov ecx, [esp+4] \n int 0x20 \n ret")
sl@0
    82
#define	SLOW_EXEC0(n)	asm("mov eax, %0": :"i"(n)); \
sl@0
    83
						asm("int 0x21 \n ret")
sl@0
    84
#define	SLOW_EXEC1(n)	asm("mov eax, %0": :"i"(n)); \
sl@0
    85
						asm("mov ecx, [esp+4] \n int 0x21 \n ret")
sl@0
    86
#define	SLOW_EXEC2(n)	asm("mov eax, %0": :"i"(n)); \
sl@0
    87
						asm("mov ecx, [esp+4] \n mov edx, [esp+8] \n int 0x21 \n ret")
sl@0
    88
#define SLOW_EXEC3(n)	asm("mov eax, %0": :"i"(n)); \
sl@0
    89
						asm("push ebx         \n" \
sl@0
    90
							"mov ecx, [esp+8] \n" \
sl@0
    91
							"mov edx, [esp+12]\n" \
sl@0
    92
							"mov ebx, [esp+16]\n" \
sl@0
    93
							"int 0x21         \n" \
sl@0
    94
							"pop ebx          \n" \
sl@0
    95
						    "ret")
sl@0
    96
sl@0
    97
#define SLOW_EXEC4(n)	asm("mov eax, %0": :"i"(n)); \
sl@0
    98
						asm("push ebx         \n" \
sl@0
    99
							"push esi         \n" \
sl@0
   100
							"mov ecx, [esp+12]\n" \
sl@0
   101
							"mov edx, [esp+16]\n" \
sl@0
   102
							"mov ebx, [esp+20]\n" \
sl@0
   103
							"mov esi, [esp+24]\n" \
sl@0
   104
							"int 0x21         \n" \
sl@0
   105
							"pop esi          \n" \
sl@0
   106
							"pop ebx          \n" \
sl@0
   107
							"ret")
sl@0
   108
#else
sl@0
   109
#define	FAST_EXEC0(n)	_asm mov eax, n _asm int 20h _asm ret
sl@0
   110
#define	FAST_EXEC1(n)	_asm mov eax, n _asm mov ecx, [esp+4] _asm int 20h _asm ret
sl@0
   111
sl@0
   112
#define	SLOW_EXEC0(n)	_asm mov eax, n _asm int 21h _asm ret
sl@0
   113
#define	SLOW_EXEC1(n)	_asm mov eax, n _asm mov ecx, [esp+4] _asm int 21h _asm ret
sl@0
   114
#define	SLOW_EXEC2(n)	_asm mov eax, n _asm mov ecx, [esp+4] _asm mov edx, [esp+8] _asm int 21h _asm ret
sl@0
   115
sl@0
   116
#define SLOW_EXEC3(n)	_asm mov eax, n			\
sl@0
   117
						_asm push ebx			\
sl@0
   118
						_asm mov ecx, [esp+8]	\
sl@0
   119
						_asm mov edx, [esp+12]	\
sl@0
   120
						_asm mov ebx, [esp+16]	\
sl@0
   121
						_asm int 21h			\
sl@0
   122
						_asm pop ebx			\
sl@0
   123
						_asm ret
sl@0
   124
sl@0
   125
#define SLOW_EXEC4(n)	_asm mov eax, n			\
sl@0
   126
						_asm push ebx			\
sl@0
   127
						_asm push esi			\
sl@0
   128
						_asm mov ecx, [esp+12]	\
sl@0
   129
						_asm mov edx, [esp+16]	\
sl@0
   130
						_asm mov ebx, [esp+20]	\
sl@0
   131
						_asm mov esi, [esp+24]	\
sl@0
   132
						_asm int 21h			\
sl@0
   133
						_asm pop esi			\
sl@0
   134
						_asm pop ebx			\
sl@0
   135
						_asm ret
sl@0
   136
#endif
sl@0
   137
sl@0
   138
#define	KFAST_EXEC0(n)	FAST_EXEC0(n)
sl@0
   139
#define	KFAST_EXEC1(n)	FAST_EXEC1(n)
sl@0
   140
#define	KSLOW_EXEC0(n)	SLOW_EXEC0(n)
sl@0
   141
#define	KSLOW_EXEC1(n)	SLOW_EXEC1(n)
sl@0
   142
#define	KSLOW_EXEC2(n)	SLOW_EXEC2(n)
sl@0
   143
#define KSLOW_EXEC3(n)	SLOW_EXEC3(n)
sl@0
   144
#define KSLOW_EXEC4(n)	SLOW_EXEC4(n)
sl@0
   145
sl@0
   146
#elif defined(__CPU_ARM)
sl@0
   147
sl@0
   148
// Executive call macros for ARM
sl@0
   149
sl@0
   150
#define EXECUTIVE_FAST	0x00800000
sl@0
   151
#define EXECUTIVE_SLOW	0x00000000
sl@0
   152
sl@0
   153
#define __DISPATCH(n)				\
sl@0
   154
	asm("swi %a0" : : "i" (n));     \
sl@0
   155
	__JUMP(,lr);
sl@0
   156
sl@0
   157
#define	FAST_EXEC0(n)		__DISPATCH((n)|EXECUTIVE_FAST)
sl@0
   158
#define	FAST_EXEC1(n)		__DISPATCH((n)|EXECUTIVE_FAST)
sl@0
   159
#define	SLOW_EXEC0(n)		__DISPATCH((n)|EXECUTIVE_SLOW)
sl@0
   160
#define	SLOW_EXEC1(n)		__DISPATCH((n)|EXECUTIVE_SLOW)
sl@0
   161
#define	SLOW_EXEC2(n)		__DISPATCH((n)|EXECUTIVE_SLOW)
sl@0
   162
#define SLOW_EXEC3(n)		__DISPATCH((n)|EXECUTIVE_SLOW)
sl@0
   163
#define SLOW_EXEC4(n)		__DISPATCH((n)|EXECUTIVE_SLOW)
sl@0
   164
sl@0
   165
#define __KDISPATCH(n)				\
sl@0
   166
	asm("stmfd sp!, {ip,lr} ");		\
sl@0
   167
	asm("swi %a0" : : "i" (n));     \
sl@0
   168
	__POPRET("ip,");
sl@0
   169
sl@0
   170
#define	KFAST_EXEC0(n)		__KDISPATCH((n)|EXECUTIVE_FAST)
sl@0
   171
#define	KFAST_EXEC1(n)		__KDISPATCH((n)|EXECUTIVE_FAST)
sl@0
   172
#define	KSLOW_EXEC0(n)		__KDISPATCH((n)|EXECUTIVE_SLOW)
sl@0
   173
#define	KSLOW_EXEC1(n)		__KDISPATCH((n)|EXECUTIVE_SLOW)
sl@0
   174
#define	KSLOW_EXEC2(n)		__KDISPATCH((n)|EXECUTIVE_SLOW)
sl@0
   175
#define KSLOW_EXEC3(n)		__KDISPATCH((n)|EXECUTIVE_SLOW)
sl@0
   176
#define KSLOW_EXEC4(n)		__KDISPATCH((n)|EXECUTIVE_SLOW)
sl@0
   177
sl@0
   178
#define __DISPATCH_NR(n)			\
sl@0
   179
	asm("swi %a0" : : "i" (n));
sl@0
   180
sl@0
   181
#define	FAST_EXEC0_NR(n)	__DISPATCH_NR((n)|EXECUTIVE_FAST)
sl@0
   182
#define	FAST_EXEC1_NR(n)	__DISPATCH_NR((n)|EXECUTIVE_FAST)
sl@0
   183
#define	SLOW_EXEC0_NR(n)	__DISPATCH_NR((n)|EXECUTIVE_SLOW)
sl@0
   184
#define	SLOW_EXEC1_NR(n)	__DISPATCH_NR((n)|EXECUTIVE_SLOW)
sl@0
   185
#define	SLOW_EXEC2_NR(n)	__DISPATCH_NR((n)|EXECUTIVE_SLOW)
sl@0
   186
#define SLOW_EXEC3_NR(n)	__DISPATCH_NR((n)|EXECUTIVE_SLOW)
sl@0
   187
#define SLOW_EXEC4_NR(n)	__DISPATCH_NR((n)|EXECUTIVE_SLOW)
sl@0
   188
sl@0
   189
#define __KDISPATCH_NR(n)			\
sl@0
   190
	asm("swi %a0" : : "i" (n));
sl@0
   191
sl@0
   192
#define	KFAST_EXEC0_NR(n)	__KDISPATCH_NR((n)|EXECUTIVE_FAST)
sl@0
   193
#define	KFAST_EXEC1_NR(n)	__KDISPATCH_NR((n)|EXECUTIVE_FAST)
sl@0
   194
#define	KSLOW_EXEC0_NR(n)	__KDISPATCH_NR((n)|EXECUTIVE_SLOW)
sl@0
   195
#define	KSLOW_EXEC1_NR(n)	__KDISPATCH_NR((n)|EXECUTIVE_SLOW)
sl@0
   196
#define	KSLOW_EXEC2_NR(n)	__KDISPATCH_NR((n)|EXECUTIVE_SLOW)
sl@0
   197
#define KSLOW_EXEC3_NR(n)	__KDISPATCH_NR((n)|EXECUTIVE_SLOW)
sl@0
   198
#define KSLOW_EXEC4_NR(n)	__KDISPATCH_NR((n)|EXECUTIVE_SLOW)
sl@0
   199
sl@0
   200
#else
sl@0
   201
#error Unknown CPU
sl@0
   202
#endif
sl@0
   203
sl@0
   204
#ifdef __LEAVE_EQUALS_THROW__
sl@0
   205
// Hide TTrap to catch unwary uses of the old cleanup
sl@0
   206
// mechanism at compile time
sl@0
   207
class TTrap;
sl@0
   208
#endif //__LEAVE_EQUALS_THROW__
sl@0
   209
sl@0
   210
#include <exec_enum.h>
sl@0
   211
#include <e32btrace.h>
sl@0
   212
#include <exec_user.h>
sl@0
   213
sl@0
   214
#endif