20 #define D_DEBUG_AGENT_H |
20 #define D_DEBUG_AGENT_H |
21 |
21 |
22 #include <rm_debug_api.h> |
22 #include <rm_debug_api.h> |
23 #include "d_driver_event_info.h" |
23 #include "d_driver_event_info.h" |
24 |
24 |
|
25 /** |
|
26 * Handles events from the kernel, filters them according to the debug agent's requests, |
|
27 * and signals these events to the user side in FIFO-style. |
|
28 * @see TKernelEventAction |
|
29 * @see TEventInfo |
|
30 */ |
25 class DDebugAgent : public DBase |
31 class DDebugAgent : public DBase |
26 { |
32 { |
27 public: |
33 public: |
28 static DDebugAgent* New(TUint64); |
34 static DDebugAgent* New(TUint64); |
29 ~DDebugAgent(); |
35 ~DDebugAgent(); |
30 |
36 |
31 TInt SetEventAction(Debug::TEventType aEvent, Debug::TKernelEventAction aEventAction); |
37 TInt SetEventAction(Debug::TEventType aEvent, Debug::TKernelEventAction aEventAction); |
32 void GetEvent(TClientDataRequest<Debug::TEventInfo>* aAsyncGetValueRequest, Debug::TEventInfo* aEventInfo, DThread* aClientThread); |
38 void GetEvent(TClientDataRequest<Debug::TEventInfo>* aAsyncGetValueRequest, DThread* aClientThread); |
33 TInt EventAction(Debug::TEventType aEvent); |
39 TInt EventAction(Debug::TEventType aEvent); |
34 |
40 |
35 TInt CancelGetEvent(void); |
41 TInt CancelGetEvent(void); |
36 void NotifyEvent(const TDriverEventInfo& aEventInfo); |
42 void NotifyEvent(const TDriverEventInfo& aEventInfo); |
37 TUint64 Id(); |
43 TUint64 Id(); |
39 protected: |
45 protected: |
40 DDebugAgent(TUint64 aId); |
46 DDebugAgent(TUint64 aId); |
41 TInt Construct(); |
47 TInt Construct(); |
42 |
48 |
43 private: |
49 private: |
44 void QueueEvent(TDriverEventInfo& aEventInfo); |
50 void QueueEvent(const TDriverEventInfo& aEventInfo); |
45 TBool BufferEmpty() const; |
51 TBool BufferEmpty() const; |
46 TBool BufferFull() const; |
52 TBool BufferFull() const; |
47 TBool BufferCanStoreEvent() const; |
53 TBool BufferCanStoreEvent() const; |
48 TBool BufferAtCriticalLevel() const; |
54 TBool BufferAtCriticalLevel() const; |
49 void IncrementPosition(TInt& aPosition); |
55 void IncrementHeadPosition(void); |
|
56 void IncrementTailPosition(void); |
50 TInt NumberOfEmptySlots() const; |
57 TInt NumberOfEmptySlots() const; |
|
58 void LockEventQueue(void); |
|
59 void UnlockEventQueue(void); |
51 |
60 |
52 private: |
61 private: |
|
62 |
53 TUint64 iId; |
63 TUint64 iId; |
54 Debug::TKernelEventAction iEventActions[Debug::EEventsLast]; |
64 Debug::TKernelEventAction iEventActions[Debug::EEventsLast]; |
55 |
65 |
56 //iEventInfo is a pointer to an object owned by the security server, so |
66 /** |
57 //no clean up needs be performed on it |
67 * Object used to write events back to DSS thread |
58 Debug::TEventInfo* iEventInfo; |
68 * @see TEventInfo |
59 RArray<TDriverEventInfo> iEventQueue; // ring buffer. |
69 */ |
60 TClientDataRequest<Debug::TEventInfo>* iRequestGetEventStatus; |
70 TClientDataRequest<Debug::TEventInfo>* iRequestGetEventStatus; |
|
71 |
61 DThread* iClientThread; |
72 DThread* iClientThread; |
62 |
73 |
63 // Ring buffer data |
74 /** |
64 TInt iHead; // points to the next empty slot in iEventQueue (exc. when iFull == ETrue) |
75 * Ring buffer of pending events. Access to it is controlled by |
65 TInt iTail; // points to the oldest full slot in iEventQueue (exc. when iEmpty == ETrue) |
76 * @see iEventQueueLock |
|
77 */ |
|
78 RArray<TDriverEventInfo> iEventQueue; |
|
79 |
|
80 /** |
|
81 * Ring buffer head. Points to the next empty slot in iEventQueue |
|
82 * @see iEventQueue |
|
83 */ |
|
84 TInt iHead; |
|
85 |
|
86 /** |
|
87 * Ring buffer tail. Points to the oldest full slot in iEventQueue |
|
88 * @see iEventQueue |
|
89 */ |
|
90 TInt iTail; |
|
91 |
|
92 /** |
|
93 * Control access to event queue. |
|
94 * @see iEventQueue |
|
95 */ |
|
96 DSemaphore* iEventQueueLock; |
|
97 |
|
98 /** |
|
99 * Keeps track of how many free slots are available in the event queue. |
|
100 * @see iEventQueue |
|
101 */ |
|
102 TInt iFreeSlots; |
|
103 |
|
104 /** |
|
105 * Boolean to indicate if we have told the agent that we are ignoring trace events |
|
106 * @see QueueEvent |
|
107 */ |
|
108 TBool iIgnoringTrace; |
66 |
109 |
67 //if we have told the agent that we are ignoring trace events |
110 /** |
68 TBool iIgnoringTrace; |
111 * Used to control the delivery of events to the client so that only |
|
112 * when more requests than deliveries have taken place can we deliver the |
|
113 * next event |
|
114 * |
|
115 * Incremented when a request for event takes place |
|
116 * @see GetEvent |
|
117 * |
|
118 * Decremented when an event is delivered. |
|
119 * @see NotifyEvent |
|
120 * |
|
121 * Cleared when event requests are cancelled |
|
122 * @see CancelGetEvent |
|
123 * |
|
124 */ |
|
125 TInt iEventBalance; |
|
126 |
|
127 /** |
|
128 * Length of kernel-event queue. |
|
129 * This is a power of two for efficiency when using the |
|
130 * remainder operator |
|
131 * @see DDebugAgent::iEventQueue |
|
132 */ |
|
133 static const TUint KNumberOfEventsToQueue = 128; |
|
134 |
|
135 /** |
|
136 * This determines the number of events at which we stop accepting |
|
137 * low priority events into the event queue. |
|
138 * @see DDebugAgent::BufferAtCriticalLevel |
|
139 * @see DDebugAgent::iEventQueue |
|
140 */ |
|
141 static const TUint KCriticalBufferSize = 64; |
|
142 |
69 }; |
143 }; |
70 |
144 |
71 #endif // D_DEBUG_AGENT_H |
145 #endif // D_DEBUG_AGENT_H |
72 |
146 |