os/kernelhwsrv/kernel/eka/include/nkern/arm/nk_plat.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 1998-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\nkern\arm\nk_plat.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 __NK_ARM_H__
sl@0
    27
#define __NK_ARM_H__
sl@0
    28
#include <nk_cpu.h>
sl@0
    29
sl@0
    30
// These macros are intended for Symbian use only.
sl@0
    31
// It may not be possible to build the kernel if any of these macros are undefined
sl@0
    32
#define __SCHEDULER_MACHINE_CODED__
sl@0
    33
#define __DFC_MACHINE_CODED__
sl@0
    34
#define __MSTIM_MACHINE_CODED__
sl@0
    35
#define __PRI_LIST_MACHINE_CODED__
sl@0
    36
#define __FAST_SEM_MACHINE_CODED__
sl@0
    37
#define __FAST_MUTEX_MACHINE_CODED__
sl@0
    38
#define __USER_CONTEXT_TYPE_MACHINE_CODED__
sl@0
    39
#define __CLIENT_REQUEST_MACHINE_CODED__
sl@0
    40
sl@0
    41
// TScheduler member data
sl@0
    42
#define	i_Regs				iExtras[14]
sl@0
    43
#define	i_ExcInfo			iExtras[15]		// pointer to exception info for crash debugger
sl@0
    44
sl@0
    45
const TUint32 KNThreadContextFlagThumbBit0=1;
sl@0
    46
sl@0
    47
#ifdef __CPU_ARM_USE_DOMAINS
sl@0
    48
#define DOMAIN_STACK_SPACE	4
sl@0
    49
#else
sl@0
    50
#define DOMAIN_STACK_SPACE	0
sl@0
    51
#endif
sl@0
    52
#ifdef __CPU_HAS_COPROCESSOR_ACCESS_REG
sl@0
    53
#define CAR_STACK_SPACE	4
sl@0
    54
#else
sl@0
    55
#define CAR_STACK_SPACE	0
sl@0
    56
#endif
sl@0
    57
#ifdef __CPU_HAS_VFP
sl@0
    58
#define VFP_STACK_SPACE	4
sl@0
    59
#else
sl@0
    60
#define VFP_STACK_SPACE	0
sl@0
    61
#endif
sl@0
    62
#ifdef __CPU_HAS_CP15_THREAD_ID_REG
sl@0
    63
#define TID_STACK_SPACE	4
sl@0
    64
#else 
sl@0
    65
#define TID_STACK_SPACE	0
sl@0
    66
#endif 
sl@0
    67
#ifdef __CPU_SUPPORT_THUMB2EE
sl@0
    68
#define THUMB2EE_STACK_SPACE 4
sl@0
    69
#else
sl@0
    70
#define THUMB2EE_STACK_SPACE 0
sl@0
    71
#endif
sl@0
    72
sl@0
    73
#define EXTRA_STACK_SPACE	(DOMAIN_STACK_SPACE+CAR_STACK_SPACE+VFP_STACK_SPACE+TID_STACK_SPACE+THUMB2EE_STACK_SPACE)
sl@0
    74
sl@0
    75
#ifdef __INCLUDE_REG_OFFSETS__
sl@0
    76
// Positions of registers on stack, relative to saved SP
sl@0
    77
#define EXTRA_WORDS	(EXTRA_STACK_SPACE/4)
sl@0
    78
sl@0
    79
#ifdef __CPU_HAS_VFP
sl@0
    80
#define SP_FPEXC	((THUMB2EE_STACK_SPACE+TID_STACK_SPACE)/4)
sl@0
    81
#endif
sl@0
    82
#ifdef __CPU_HAS_COPROCESSOR_ACCESS_REG
sl@0
    83
#define	SP_CAR		((THUMB2EE_STACK_SPACE+TID_STACK_SPACE+VFP_STACK_SPACE)/4)
sl@0
    84
#endif
sl@0
    85
#ifdef __CPU_ARM_USE_DOMAINS
sl@0
    86
#define SP_DACR		((THUMB2EE_STACK_SPACE+TID_STACK_SPACE+VFP_STACK_SPACE+CAR_STACK_SPACE)/4)
sl@0
    87
#endif
sl@0
    88
sl@0
    89
#define	SP_R13U		EXTRA_WORDS
sl@0
    90
#define	SP_R14U		(SP_R13U+1)
sl@0
    91
#define	SP_SPSR		(SP_R13U+2)
sl@0
    92
#define	SP_R4		(SP_R13U+3)
sl@0
    93
#define	SP_R5		(SP_R13U+4)
sl@0
    94
#define	SP_R6		(SP_R13U+5)
sl@0
    95
#define	SP_R7		(SP_R13U+6)
sl@0
    96
#define	SP_R8		(SP_R13U+7)
sl@0
    97
#define	SP_R9		(SP_R13U+8)
sl@0
    98
#define	SP_R10		(SP_R13U+9)
sl@0
    99
#define	SP_R11		(SP_R13U+10)
sl@0
   100
#define	SP_PC		(SP_R13U+11)
sl@0
   101
sl@0
   102
#define SP_NEXT		(SP_PC+1)		// first word on stack before reschedule
sl@0
   103
#endif	// __INCLUDE_REG_OFFSETS__
sl@0
   104
sl@0
   105
class TArmContextElement;
sl@0
   106
class TArmRegSet;
sl@0
   107
sl@0
   108
/** ARM-specific part of the nano-thread abstraction.
sl@0
   109
	@internalComponent
sl@0
   110
 */
sl@0
   111
class NThread : public NThreadBase
sl@0
   112
	{
sl@0
   113
public:
sl@0
   114
	TInt Create(SNThreadCreateInfo& aInfo, TBool aInitial);
sl@0
   115
	inline void Stillborn()
sl@0
   116
		{}
sl@0
   117
sl@0
   118
	/** Value indicating what event caused thread to enter privileged mode.
sl@0
   119
		@publishedPartner
sl@0
   120
		@released
sl@0
   121
	 */
sl@0
   122
	enum TUserContextType
sl@0
   123
		{
sl@0
   124
		EContextNone=0,             /**< Thread has no user context */
sl@0
   125
		EContextException=1,		/**< Hardware exception while in user mode */
sl@0
   126
		EContextUndefined,			
sl@0
   127
		EContextUserInterrupt,		/**< Preempted by interrupt taken in user mode */
sl@0
   128
		EContextUserInterruptDied,  /**< Killed while preempted by interrupt taken in user mode */
sl@0
   129
		EContextSvsrInterrupt1,     /**< Preempted by interrupt taken in executive call handler */
sl@0
   130
		EContextSvsrInterrupt1Died, /**< Killed while preempted by interrupt taken in executive call handler */
sl@0
   131
		EContextSvsrInterrupt2,     /**< Preempted by interrupt taken in executive call handler */
sl@0
   132
		EContextSvsrInterrupt2Died, /**< Killed while preempted by interrupt taken in executive call handler */
sl@0
   133
		EContextWFAR,               /**< Blocked on User::WaitForAnyRequest() */
sl@0
   134
		EContextWFARDied,           /**< Killed while blocked on User::WaitForAnyRequest() */
sl@0
   135
		EContextExec,				/**< Slow executive call */
sl@0
   136
		EContextKernel,				/**< Kernel side context (for kernel threads) */
sl@0
   137
		EContextUserIntrCallback,	/**< Blocked/preempted in a user callback on the way back from interrupt */
sl@0
   138
		EContextWFARCallback,		/**< Blocked/preempted in a user callback on the way back from User::WFAR */
sl@0
   139
		};
sl@0
   140
sl@0
   141
	IMPORT_C static const TArmContextElement* const* UserContextTables();
sl@0
   142
	IMPORT_C TUserContextType UserContextType();
sl@0
   143
	inline TInt SetUserContextType()
sl@0
   144
		{ return iSpare3=UserContextType(); }
sl@0
   145
	inline void ResetUserContextType()
sl@0
   146
		{ if(iSpare3>EContextUndefined && iSpare3<EContextUserIntrCallback) iSpare3=EContextUndefined; }
sl@0
   147
	void GetContext(TArmRegSet& aContext, TUint32& aAvailRegistersMask, const TArmContextElement* aContextTable);
sl@0
   148
	void GetUserContext(TArmRegSet& aContext, TUint32& aAvailRegistersMask);
sl@0
   149
	void SetUserContext(const TArmRegSet& aContext);
sl@0
   150
	void GetSystemContext(TArmRegSet& aContext, TUint32& aAvailRegistersMask);
sl@0
   151
sl@0
   152
	void ModifyUsp(TLinAddr aUsp);
sl@0
   153
sl@0
   154
#ifdef __CPU_ARM_USE_DOMAINS
sl@0
   155
	TUint32 Dacr();
sl@0
   156
	void SetDacr(TUint32 aDacr);
sl@0
   157
	TUint32 ModifyDacr(TUint32 aClearMask, TUint32 aSetMask);
sl@0
   158
#endif
sl@0
   159
sl@0
   160
#ifdef __CPU_HAS_COPROCESSOR_ACCESS_REG
sl@0
   161
	void SetCar(TUint32 aDacr);
sl@0
   162
#endif
sl@0
   163
	IMPORT_C TUint32 Car();
sl@0
   164
	IMPORT_C TUint32 ModifyCar(TUint32 aClearMask, TUint32 aSetMask);
sl@0
   165
sl@0
   166
#ifdef __CPU_HAS_VFP
sl@0
   167
	void SetFpExc(TUint32 aDacr);
sl@0
   168
#endif
sl@0
   169
	IMPORT_C TUint32 FpExc();
sl@0
   170
	IMPORT_C TUint32 ModifyFpExc(TUint32 aClearMask, TUint32 aSetMask);
sl@0
   171
	};
sl@0
   172
sl@0
   173
sl@0
   174
struct SArmInterruptInfo
sl@0
   175
	{
sl@0
   176
	TLinAddr iIrqHandler;
sl@0
   177
	TLinAddr iFiqHandler;
sl@0
   178
	TUint8	 iCpuUsageFilter;
sl@0
   179
	BTrace::THandler iBTraceHandler;
sl@0
   180
	SCpuIdleHandler iCpuIdleHandler;
sl@0
   181
	};
sl@0
   182
sl@0
   183
extern "C" SArmInterruptInfo ArmInterruptInfo;
sl@0
   184
sl@0
   185
#endif