Update contrib.
1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32test/debug/d_context.h
18 #ifndef __D_CONTEXT_H__
19 #define __D_CONTEXT_H__
25 #include <kernel/arm/arm_types.h>
27 _LIT(KTestLddName, "TestContext");
29 enum TUserCallbackState
31 ENoCallback, // thread does nothing special
32 ESpinningCallback, // thread will be given a callback that spins forever
33 ESleepingCallback, // thread will be given a callback that sleeps for a long time
36 struct TArmFullContext
38 TArmRegSet iUserContext;
40 TArmRegSet iSystemContext;
44 class RContextLdd : public RBusLogicalChannel
67 TRequestStatus* iStatusPtr;
72 static inline TVersion Version() { return TVersion(1, 0, 1); }
73 #ifndef __KERNEL_MODE__
77 inline TInt Hook(TInt* aCounterPtr);
78 inline TExcType LastException();
79 inline TBool IsHooked() const;
80 inline void TrapNextHwExc(TThreadId aId, TAny* aContext, TRequestStatus& aStatus, TBool aKillThread);
81 inline void TrapNextSwExc(TThreadId aId, TAny* aContext, TRequestStatus& aStatus, TBool aKillThread);
82 inline void TrapNextDeath(TThreadId aId, TAny* aContext, TRequestStatus& aStatus);
83 inline TInt SetAndGetBackContext(TThreadId aId, TAny* aContext);
84 inline TInt SetAndGetFullContext(TThreadId aId, TArmFullContext* aContextData);
85 inline void GetContext(TThreadId aId, TAny* aContext);
86 inline void GetKernelContext(TThreadId aId, TAny* aContext);
87 inline TUint32 SpinInKernel(TBool aReallySpin);
88 inline void AddUserCallback(TThreadId aId, TUserCallbackState aCallback);
89 inline void ResumeTrappedThread(TThreadId aId);
96 #ifndef __KERNEL_MODE__
98 inline RContextLdd::RContextLdd()
103 inline TBool RContextLdd::IsHooked() const
108 inline TInt RContextLdd::Open()
110 return DoCreate(KTestLddName, Version(), KNullUnit, NULL, NULL, EOwnerProcess);
113 inline TInt RContextLdd::Hook(TInt* aCounterPtr)
115 TInt r = DoControl(EHook, aCounterPtr);
116 iHooked = (r == KErrNone);
120 inline TExcType RContextLdd::LastException()
122 return static_cast<TExcType>(DoControl(EGetLastExc));
125 inline void RContextLdd::TrapNextHwExc(TThreadId aId, TAny* aExcContext, TRequestStatus& aStatus, TBool aKillThread)
127 aStatus = KRequestPending;
129 info.iThreadId = aId;
130 info.iContextPtr = aExcContext;
131 info.iStatusPtr = &aStatus;
132 info.iKillThread = aKillThread;
133 DoControl(ETrapNextHwExc, &info);
136 inline void RContextLdd::TrapNextSwExc(TThreadId aId, TAny* aContext, TRequestStatus& aStatus, TBool aKillThread)
138 aStatus = KRequestPending;
140 info.iThreadId = aId;
141 info.iContextPtr = aContext;
142 info.iStatusPtr = &aStatus;
143 info.iKillThread = aKillThread;
144 DoControl(ETrapNextSwExc, &info);
147 inline void RContextLdd::TrapNextDeath(TThreadId aId, TAny* aContext, TRequestStatus& aStatus)
149 aStatus = KRequestPending;
151 info.iThreadId = aId;
152 info.iContextPtr = aContext;
153 info.iStatusPtr = &aStatus;
154 DoControl(ETrapNextDeath, &info);
157 inline TInt RContextLdd::SetAndGetBackContext(TThreadId aId, TAny* aContext)
159 return DoControl(ESetGetContext, (TAny*)(TUint)aId, aContext);
162 inline TInt RContextLdd::SetAndGetFullContext(TThreadId aId, TArmFullContext* aContextData)
164 return DoControl(ESetGetFullContext, (TAny*)(TUint)aId, (TAny*)aContextData);
167 inline void RContextLdd::GetContext(TThreadId aId, TAny* aContext)
169 DoControl(EGetContext, (TAny*)(TUint)aId, aContext);
172 inline void RContextLdd::GetKernelContext(TThreadId aId, TAny* aContext)
174 DoControl(EGetKernelContext, (TAny*)(TUint)aId, aContext);
177 inline TUint32 RContextLdd::SpinInKernel(TBool aReallySpin)
179 return DoControl(ESpinInKernel, (TAny*)aReallySpin);
182 inline void RContextLdd::AddUserCallback(TThreadId aId, TUserCallbackState aCallback)
184 DoControl(EAddUserCallback, (TAny*)(TUint)aId, (TAny*)aCallback);
187 inline void RContextLdd::ResumeTrappedThread(TThreadId aId)
189 DoControl(EResumeTrappedThread, (TAny*)(TUint)aId);
192 #endif // __KERNEL_MODE__