1 | /** |
---|
2 | * @file rtems/capture.h |
---|
3 | * |
---|
4 | * @brief Capture Engine Component of the RTEMS Measurement and |
---|
5 | * Monitoring System |
---|
6 | * |
---|
7 | * This is the Capture Engine component of the RTEMS Measurement and |
---|
8 | * Monitoring system. |
---|
9 | */ |
---|
10 | |
---|
11 | /* |
---|
12 | ------------------------------------------------------------------------ |
---|
13 | |
---|
14 | Copyright Objective Design Systems Pty Ltd, 2002 |
---|
15 | All rights reserved Objective Design Systems Pty Ltd, 2002 |
---|
16 | Chris Johns (ccj@acm.org) |
---|
17 | |
---|
18 | COPYRIGHT (c) 1989-1998. |
---|
19 | On-Line Applications Research Corporation (OAR). |
---|
20 | |
---|
21 | The license and distribution terms for this file may be |
---|
22 | found in the file LICENSE in this distribution. |
---|
23 | |
---|
24 | This software with is provided ``as is'' and with NO WARRANTY. |
---|
25 | |
---|
26 | ------------------------------------------------------------------------ |
---|
27 | |
---|
28 | RTEMS Performance Monitoring and Measurement Framework. |
---|
29 | This is the Capture Engine component. |
---|
30 | |
---|
31 | */ |
---|
32 | |
---|
33 | #ifndef __CAPTURE_H_ |
---|
34 | #define __CAPTURE_H_ |
---|
35 | |
---|
36 | /** |
---|
37 | * @defgroup libmisc_capture RTEMS Capture Engine |
---|
38 | * |
---|
39 | * @ingroup libmisc |
---|
40 | * |
---|
41 | * Capture Engine Component of the RTEMS Measurement and Monitoring System |
---|
42 | */ |
---|
43 | /**@{*/ |
---|
44 | #ifdef __cplusplus |
---|
45 | extern "C" { |
---|
46 | #endif |
---|
47 | |
---|
48 | #include <rtems.h> |
---|
49 | |
---|
50 | /** |
---|
51 | * The number of tasks in a trigger group. |
---|
52 | */ |
---|
53 | #define RTEMS_CAPTURE_TRIGGER_TASKS (32) |
---|
54 | |
---|
55 | /** |
---|
56 | * @brief A capture timestamp. |
---|
57 | * |
---|
58 | * This is a nanosecond capture timestamp |
---|
59 | */ |
---|
60 | typedef uint64_t rtems_capture_time_t; |
---|
61 | |
---|
62 | /** |
---|
63 | * @brief Task id and mask for the from trigger. |
---|
64 | * |
---|
65 | * A from capture is a task id and a mask for the type of |
---|
66 | * from trigger we are interested in. The mask uses the same |
---|
67 | * bit maps as the flags field in the control structure. There |
---|
68 | * will only be a from type trigger if the flags in the control |
---|
69 | * structure has the specific *_BY bit set. |
---|
70 | */ |
---|
71 | typedef struct rtems_capture_from_s |
---|
72 | { |
---|
73 | rtems_name name; |
---|
74 | rtems_id id; |
---|
75 | uint32_t trigger; |
---|
76 | } rtems_capture_from_t; |
---|
77 | |
---|
78 | /** |
---|
79 | * @brief Capture control structure for a group of tasks. |
---|
80 | * |
---|
81 | * RTEMS control holds the trigger and watch configuration for a group of |
---|
82 | * tasks with the same name. The flags hold global control flags. |
---|
83 | * |
---|
84 | * The to_triggers fields holds triggers TO this task. The from_triggers holds |
---|
85 | * triggers from this task. The by_triggers is an OR or triggers which are |
---|
86 | * caused BY the task listed TO this task. The by_valid flag which entries |
---|
87 | * in by are valid. |
---|
88 | */ |
---|
89 | typedef struct rtems_capture_control_s |
---|
90 | { |
---|
91 | rtems_name name; |
---|
92 | rtems_id id; |
---|
93 | uint32_t flags; |
---|
94 | uint32_t to_triggers; |
---|
95 | uint32_t from_triggers; |
---|
96 | uint32_t by_triggers; |
---|
97 | uint32_t by_valid; |
---|
98 | rtems_capture_from_t by[RTEMS_CAPTURE_TRIGGER_TASKS]; |
---|
99 | struct rtems_capture_control_s* next; |
---|
100 | } rtems_capture_control_t; |
---|
101 | |
---|
102 | /** |
---|
103 | * The from_valid mask. |
---|
104 | */ |
---|
105 | #define RTEMS_CAPTURE_CONTROL_FROM_MASK(_s) \ |
---|
106 | (UINT32_C(1) << (RTEMS_CAPTURE_TRIGGER_TASKS - ((_s) + 1))) |
---|
107 | |
---|
108 | /** |
---|
109 | * Control flags. |
---|
110 | */ |
---|
111 | #define RTEMS_CAPTURE_WATCH (1U << 0) |
---|
112 | |
---|
113 | /** |
---|
114 | * Control triggers. |
---|
115 | */ |
---|
116 | #define RTEMS_CAPTURE_SWITCH (1 << 0) |
---|
117 | #define RTEMS_CAPTURE_CREATE (1 << 1) |
---|
118 | #define RTEMS_CAPTURE_START (1 << 2) |
---|
119 | #define RTEMS_CAPTURE_RESTART (1 << 3) |
---|
120 | #define RTEMS_CAPTURE_DELETE (1 << 4) |
---|
121 | #define RTEMS_CAPTURE_BEGIN (1 << 5) |
---|
122 | #define RTEMS_CAPTURE_EXITTED (1 << 6) |
---|
123 | #define RTEMS_CAPTURE_TERMINATED (1 << 7) |
---|
124 | |
---|
125 | #define RTEMS_CAPTURE_FROM_TRIGS (RTEMS_CAPTURE_SWITCH | \ |
---|
126 | RTEMS_CAPTURE_CREATE | \ |
---|
127 | RTEMS_CAPTURE_START | \ |
---|
128 | RTEMS_CAPTURE_RESTART | \ |
---|
129 | RTEMS_CAPTURE_DELETE) |
---|
130 | |
---|
131 | #define RTEMS_CAPTURE_TO_TRIGS (RTEMS_CAPTURE_SWITCH | \ |
---|
132 | RTEMS_CAPTURE_CREATE | \ |
---|
133 | RTEMS_CAPTURE_START | \ |
---|
134 | RTEMS_CAPTURE_RESTART | \ |
---|
135 | RTEMS_CAPTURE_DELETE | \ |
---|
136 | RTEMS_CAPTURE_BEGIN | \ |
---|
137 | RTEMS_CAPTURE_EXITTED) |
---|
138 | |
---|
139 | /** |
---|
140 | * @brief Catpure task control |
---|
141 | * |
---|
142 | * RTEMS capture control provdes the information about a task, along |
---|
143 | * with its trigger state. The control is referenced by each |
---|
144 | * capture record. This is information neeed by the decoder. The |
---|
145 | * capture record cannot assume the task will exist when the record is |
---|
146 | * dumped via the target interface so task info needed for tracing is |
---|
147 | * copied and held here. Once the references in the trace buffer |
---|
148 | * have been removed and the task is deleted this structure is |
---|
149 | * released back to the heap. |
---|
150 | * |
---|
151 | * The inline helper functions provide more details about the info |
---|
152 | * contained in this structure. |
---|
153 | * |
---|
154 | * Note, the tracer code exploits the fact an rtems_name is a |
---|
155 | * 32bit value. |
---|
156 | */ |
---|
157 | typedef struct rtems_capture_task_s |
---|
158 | { |
---|
159 | rtems_name name; |
---|
160 | rtems_id id; |
---|
161 | uint32_t flags; |
---|
162 | uint32_t refcount; |
---|
163 | rtems_tcb* tcb; |
---|
164 | uint32_t in; |
---|
165 | uint32_t out; |
---|
166 | rtems_task_priority start_priority; |
---|
167 | uint32_t stack_size; |
---|
168 | uint32_t stack_clean; |
---|
169 | rtems_capture_time_t time; |
---|
170 | rtems_capture_time_t time_in; |
---|
171 | rtems_capture_time_t last_time; |
---|
172 | rtems_capture_control_t* control; |
---|
173 | struct rtems_capture_task_s* forw; |
---|
174 | struct rtems_capture_task_s* back; |
---|
175 | } rtems_capture_task_t; |
---|
176 | |
---|
177 | /** |
---|
178 | * Task flags. |
---|
179 | */ |
---|
180 | #define RTEMS_CAPTURE_TRACED (1U << 0) |
---|
181 | |
---|
182 | /* |
---|
183 | * @brief Capture record. |
---|
184 | * |
---|
185 | * This is a record that is written into |
---|
186 | * the buffer. The events includes the priority of the task |
---|
187 | * at the time of the context switch. |
---|
188 | */ |
---|
189 | typedef struct rtems_capture_record_s |
---|
190 | { |
---|
191 | rtems_capture_task_t* task; |
---|
192 | uint32_t events; |
---|
193 | rtems_capture_time_t time; |
---|
194 | } rtems_capture_record_t; |
---|
195 | |
---|
196 | /** |
---|
197 | * The capture record event flags. |
---|
198 | */ |
---|
199 | #define RTEMS_CAPTURE_REAL_PRI_EVENT_MASK UINT32_C (0x000000ff) |
---|
200 | #define RTEMS_CAPTURE_CURR_PRI_EVENT_MASK UINT32_C (0x0000ff00) |
---|
201 | #define RTEMS_CAPTURE_REAL_PRIORITY_EVENT (0) |
---|
202 | #define RTEMS_CAPTURE_CURR_PRIORITY_EVENT (8) |
---|
203 | #define RTEMS_CAPTURE_EVENT_START (16) |
---|
204 | #define RTEMS_CAPTURE_CREATED_BY_EVENT UINT32_C (0x00010000) |
---|
205 | #define RTEMS_CAPTURE_CREATED_EVENT UINT32_C (0x00020000) |
---|
206 | #define RTEMS_CAPTURE_STARTED_BY_EVENT UINT32_C (0x00040000) |
---|
207 | #define RTEMS_CAPTURE_STARTED_EVENT UINT32_C (0x00080000) |
---|
208 | #define RTEMS_CAPTURE_RESTARTED_BY_EVENT UINT32_C (0x00100000) |
---|
209 | #define RTEMS_CAPTURE_RESTARTED_EVENT UINT32_C (0x00200000) |
---|
210 | #define RTEMS_CAPTURE_DELETED_BY_EVENT UINT32_C (0x00400000) |
---|
211 | #define RTEMS_CAPTURE_DELETED_EVENT UINT32_C (0x00800000) |
---|
212 | #define RTEMS_CAPTURE_TERMINATED_EVENT UINT32_C (0x01000000) |
---|
213 | #define RTEMS_CAPTURE_BEGIN_EVENT UINT32_C (0x02000000) |
---|
214 | #define RTEMS_CAPTURE_EXITTED_EVENT UINT32_C (0x04000000) |
---|
215 | #define RTEMS_CAPTURE_SWITCHED_OUT_EVENT UINT32_C (0x08000000) |
---|
216 | #define RTEMS_CAPTURE_SWITCHED_IN_EVENT UINT32_C (0x10000000) |
---|
217 | #define RTEMS_CAPTURE_TIMESTAMP UINT32_C (0x20000000) |
---|
218 | #define RTEMS_CAPTURE_EVENT_END (29) |
---|
219 | |
---|
220 | /** |
---|
221 | * @brief Capture trigger modes |
---|
222 | * |
---|
223 | * The types of trigger modes that exist. |
---|
224 | */ |
---|
225 | typedef enum rtems_capture_trigger_mode_e |
---|
226 | { |
---|
227 | rtems_capture_to_any, |
---|
228 | rtems_capture_from_any, |
---|
229 | rtems_capture_from_to |
---|
230 | } rtems_capture_trigger_mode_t; |
---|
231 | |
---|
232 | /** |
---|
233 | * @brief Capture trigger. |
---|
234 | * |
---|
235 | * The types of triggers that exist. |
---|
236 | */ |
---|
237 | typedef enum rtems_capture_trigger_e |
---|
238 | { |
---|
239 | rtems_capture_switch, |
---|
240 | rtems_capture_create, |
---|
241 | rtems_capture_start, |
---|
242 | rtems_capture_restart, |
---|
243 | rtems_capture_delete, |
---|
244 | rtems_capture_begin, |
---|
245 | rtems_capture_exitted, |
---|
246 | rtems_capture_terminated |
---|
247 | } rtems_capture_trigger_t; |
---|
248 | |
---|
249 | /** |
---|
250 | * @brief Capture timestamp callout handler. |
---|
251 | * |
---|
252 | * This defines the callout handler to obtain a time stamp. The |
---|
253 | * value returned is time count since the last read. |
---|
254 | * |
---|
255 | */ |
---|
256 | |
---|
257 | typedef void (*rtems_capture_timestamp)(rtems_capture_time_t* time); |
---|
258 | |
---|
259 | /** |
---|
260 | * @brief Capture open |
---|
261 | * |
---|
262 | * This function initialises the realtime trace manager allocating the |
---|
263 | * capture buffer. It is assumed we have a working heap at stage of |
---|
264 | * initialisation. |
---|
265 | * |
---|
266 | * @param[in] size The number of capture records to define. |
---|
267 | * @param[in] timestamp The timestamp callout handler to use. If the |
---|
268 | * the handler is NULL a default nano-second timestamp |
---|
269 | * will be used. |
---|
270 | * |
---|
271 | * @retval This method returns RTEMS_SUCCESSFUL if there was not an |
---|
272 | * error. Otherwise, a status code is returned indicating the |
---|
273 | * source of the error. |
---|
274 | */ |
---|
275 | rtems_status_code |
---|
276 | rtems_capture_open (uint32_t size, |
---|
277 | rtems_capture_timestamp timestamp); |
---|
278 | |
---|
279 | /** |
---|
280 | * @brief Capture close |
---|
281 | * |
---|
282 | * This function shutdowns the tracer and release any claimed |
---|
283 | * resources. |
---|
284 | * |
---|
285 | * @retval This method returns RTEMS_SUCCESSFUL if there was not an |
---|
286 | * error. Otherwise, a status code is returned indicating the |
---|
287 | * source of the error. |
---|
288 | */ |
---|
289 | rtems_status_code |
---|
290 | rtems_capture_close (void); |
---|
291 | |
---|
292 | /** |
---|
293 | * @brief Capture control trace enable/disable. |
---|
294 | * |
---|
295 | * This function allows control of tracing at a global level. |
---|
296 | * |
---|
297 | * @param[in] enable The trace enable/disable flag. |
---|
298 | * |
---|
299 | * @retval This method returns RTEMS_SUCCESSFUL if there was not an |
---|
300 | * error. Otherwise, a status code is returned indicating the |
---|
301 | * source of the error. |
---|
302 | */ |
---|
303 | rtems_status_code |
---|
304 | rtems_capture_control (bool enable); |
---|
305 | |
---|
306 | /** |
---|
307 | * @brief Capture monitor enable/disable. |
---|
308 | * |
---|
309 | * This function enable the monitor mode. When in the monitor mode |
---|
310 | * the tasks are monitored but no data is saved. This can be used |
---|
311 | * to profile the load on a system. |
---|
312 | * |
---|
313 | * @param[in] enable The monitor enable/disable flag. |
---|
314 | * |
---|
315 | * @retval This method returns RTEMS_SUCCESSFUL if there was not an |
---|
316 | * error. Otherwise, a status code is returned indicating the |
---|
317 | * source of the error. |
---|
318 | */ |
---|
319 | rtems_status_code |
---|
320 | rtems_capture_monitor (bool enable); |
---|
321 | |
---|
322 | /* |
---|
323 | * @brief Capture flush trace buffer. |
---|
324 | * |
---|
325 | * This function flushes the trace buffer. The prime parameter allows the |
---|
326 | * capture engine to also be primed again. |
---|
327 | * |
---|
328 | * @param[in] prime The prime after flush flag. |
---|
329 | * |
---|
330 | * @retval This method returns RTEMS_SUCCESSFUL if there was not an |
---|
331 | * error. Otherwise, a status code is returned indicating the |
---|
332 | * source of the error. |
---|
333 | */ |
---|
334 | rtems_status_code |
---|
335 | rtems_capture_flush (bool prime); |
---|
336 | |
---|
337 | /** |
---|
338 | * @brief Capture add watch |
---|
339 | * |
---|
340 | * This function defines a watch for a specific task given a name. A watch |
---|
341 | * causes it to be traced either in or out of context. The watch can be |
---|
342 | * optionally enabled or disabled with the set routine. It is disabled by |
---|
343 | * default. |
---|
344 | * |
---|
345 | * @param[in] name The name of the @a capture_controls entry |
---|
346 | * @param[in] id The id of the @a capture_controls entry. |
---|
347 | * |
---|
348 | * @retval This method returns RTEMS_SUCCESSFUL if there was not an |
---|
349 | * error. Otherwise, a status code is returned indicating the |
---|
350 | * source of the error. |
---|
351 | */ |
---|
352 | rtems_status_code |
---|
353 | rtems_capture_watch_add (rtems_name name, rtems_id id); |
---|
354 | |
---|
355 | /** |
---|
356 | * @brief Capture delete watch. |
---|
357 | * |
---|
358 | * This function removes a watch for a specific task given a name. The task |
---|
359 | * description will still exist if referenced by a trace record in the trace |
---|
360 | * buffer or a global watch is defined. |
---|
361 | * |
---|
362 | * @param[in] name The name of the @a capture_controls entry |
---|
363 | * @param[in] id The id of the @a capture_controls entry. |
---|
364 | * |
---|
365 | * @retval This method returns RTEMS_SUCCESSFUL if there was not an |
---|
366 | * error. Otherwise, a status code is returned indicating the |
---|
367 | * source of the error. |
---|
368 | */ |
---|
369 | rtems_status_code |
---|
370 | rtems_capture_watch_del (rtems_name name, rtems_id id); |
---|
371 | |
---|
372 | /** |
---|
373 | * @brief Capture enable/disable watch. |
---|
374 | * |
---|
375 | * This function allows control of a watch. The watch can be enabled or |
---|
376 | * disabled. |
---|
377 | * |
---|
378 | * @param[in] name The name of the @a capture_controls entry |
---|
379 | * @param[in] id The id of the @a capture_controls entry. |
---|
380 | * @param[in] enable The enable/disable flag for the watch. |
---|
381 | * |
---|
382 | * @retval This method returns RTEMS_SUCCESSFUL if there was not an |
---|
383 | * error. Otherwise, a status code is returned indicating the |
---|
384 | * source of the error. |
---|
385 | */ |
---|
386 | rtems_status_code |
---|
387 | rtems_capture_watch_ctrl (rtems_name name, |
---|
388 | rtems_id id, |
---|
389 | bool enable); |
---|
390 | |
---|
391 | /** |
---|
392 | * @brief Capture enable/disable global watch. |
---|
393 | * |
---|
394 | * This function allows control of a global watch. The watch can |
---|
395 | * be enabled or disabled. A global watch configures all tasks below |
---|
396 | * the ceiling and above the floor to be traced. |
---|
397 | * |
---|
398 | * @param[in] enable The enable/disable flag for the watch. |
---|
399 | * |
---|
400 | * @retval This method returns RTEMS_SUCCESSFUL if there was not an |
---|
401 | * error. Otherwise, a status code is returned indicating the |
---|
402 | * source of the error. |
---|
403 | */ |
---|
404 | rtems_status_code |
---|
405 | rtems_capture_watch_global (bool enable); |
---|
406 | |
---|
407 | /** |
---|
408 | * @brief Get global watch state |
---|
409 | * |
---|
410 | * This function returns the global watch state. |
---|
411 | * |
---|
412 | * @retval This method returns true if the global watch |
---|
413 | * is on. Otherwise, it returns false. |
---|
414 | */ |
---|
415 | bool |
---|
416 | rtems_capture_watch_global_on (void); |
---|
417 | |
---|
418 | /** |
---|
419 | * @brief Set watch ceiling. |
---|
420 | * |
---|
421 | * This function sets a watch ceiling. Events from tasks at or greater |
---|
422 | * than the ceiling priority are ignored. This is a simple way to |
---|
423 | * monitor an application and exclude system tasks running at a higher |
---|
424 | * priority level. |
---|
425 | * |
---|
426 | * @param[in] ceiling specifies the priority level immediately above |
---|
427 | * that at which events from tasks are not captured. |
---|
428 | * |
---|
429 | * @retval This method returns RTEMS_SUCCESSFUL if there was not an |
---|
430 | * error. Otherwise, a status code is returned indicating the |
---|
431 | * source of the error. |
---|
432 | */ |
---|
433 | rtems_status_code |
---|
434 | rtems_capture_watch_ceiling (rtems_task_priority ceiling); |
---|
435 | |
---|
436 | /** |
---|
437 | * @brief Get watch ceiling. |
---|
438 | * |
---|
439 | * This function gets the watch ceiling. |
---|
440 | * |
---|
441 | * @retval The priority level immediately above that at which events |
---|
442 | * from tasks are not captured. |
---|
443 | */ |
---|
444 | rtems_task_priority |
---|
445 | rtems_capture_watch_get_ceiling (void); |
---|
446 | |
---|
447 | /** |
---|
448 | * @brief Capture set watch floor. |
---|
449 | * |
---|
450 | * This function sets a watch floor. Tasks at or less than the |
---|
451 | * floor priority are not watched. This is a simple way to monitor |
---|
452 | * an application and exclude system tasks running at a lower |
---|
453 | * priority level. |
---|
454 | * |
---|
455 | * @param[in] floor specifies the priority level immediately below |
---|
456 | * that at which events from tasks are not captured. |
---|
457 | * |
---|
458 | * @retval This method returns RTEMS_SUCCESSFUL if there was not an |
---|
459 | * error. Otherwise, a status code is returned indicating the |
---|
460 | * source of the error. |
---|
461 | */ |
---|
462 | rtems_status_code |
---|
463 | rtems_capture_watch_floor (rtems_task_priority floor); |
---|
464 | |
---|
465 | /** |
---|
466 | * @brief Capture set watch floor |
---|
467 | * |
---|
468 | * This function gets the watch floor. |
---|
469 | * |
---|
470 | * @retval The priority level immediately below |
---|
471 | * that at which events from tasks are not captured. |
---|
472 | */ |
---|
473 | rtems_task_priority |
---|
474 | rtems_capture_watch_get_floor (void); |
---|
475 | |
---|
476 | /** |
---|
477 | * @brief Capture set trigger |
---|
478 | * |
---|
479 | * This function sets a trigger. |
---|
480 | * |
---|
481 | * This set trigger routine will create a trace control for the |
---|
482 | * target task. The task list is searched and any existing tasks |
---|
483 | * are linked to the new control. |
---|
484 | * |
---|
485 | * We can have a number of tasks that have the same name so we |
---|
486 | * search using names. This means a number of tasks can be |
---|
487 | * linked to single control. |
---|
488 | * |
---|
489 | * Some events captured such as context switch include two |
---|
490 | * tasks. These are referred to as being "from" and "to" |
---|
491 | * Some events may only have one task specified. |
---|
492 | * |
---|
493 | * @param[in] from_name specifies the name of the from task. |
---|
494 | * @param[in] from_id specifies the id of the from task. |
---|
495 | * @param[in] to_name specifies the name of the to task. |
---|
496 | * @param[in] to_id specifies the id of the to task. |
---|
497 | * @param[in] mode specifies the trigger mode. |
---|
498 | * @param[in] trigger specifies the type of trigger. |
---|
499 | * |
---|
500 | * @retval This method returns RTEMS_SUCCESSFUL if there was not an |
---|
501 | * error. Otherwise, a status code is returned indicating the |
---|
502 | * source of the error. |
---|
503 | */ |
---|
504 | rtems_status_code |
---|
505 | rtems_capture_set_trigger (rtems_name from_name, |
---|
506 | rtems_id from_id, |
---|
507 | rtems_name to_name, |
---|
508 | rtems_id to_id, |
---|
509 | rtems_capture_trigger_mode_t mode, |
---|
510 | rtems_capture_trigger_t trigger); |
---|
511 | |
---|
512 | /** |
---|
513 | * @brief Capture clear trigger. |
---|
514 | * |
---|
515 | * This function clears a trigger. |
---|
516 | * |
---|
517 | * This clear trigger routine will not clear a watch. |
---|
518 | * |
---|
519 | * @param[in] from_name specifies the name of the from task. |
---|
520 | * @param[in] from_id specifies the id of the from task. |
---|
521 | * @param[in] to_name specifies the name of the to task. |
---|
522 | * @param[in] to_id specifies the id of the to task. |
---|
523 | * @param[in] mode specifies the trigger mode. |
---|
524 | * @param[in] trigger specifies the type of trigger. |
---|
525 | * |
---|
526 | * @retval This method returns RTEMS_SUCCESSFUL if there was not an |
---|
527 | * error. Otherwise, a status code is returned indicating the |
---|
528 | * source of the error. |
---|
529 | */ |
---|
530 | rtems_status_code |
---|
531 | rtems_capture_clear_trigger (rtems_name from_name, |
---|
532 | rtems_id from_id, |
---|
533 | rtems_name to_name, |
---|
534 | rtems_id to_id, |
---|
535 | rtems_capture_trigger_mode_t mode, |
---|
536 | rtems_capture_trigger_t trigger); |
---|
537 | |
---|
538 | /** |
---|
539 | * @brief Capture read records from capture buffer |
---|
540 | * |
---|
541 | * This function reads a number of records from the capture buffer. |
---|
542 | * The user can optionally block and wait until the buffer as a |
---|
543 | * specific number of records available or a specific time has |
---|
544 | * elasped. |
---|
545 | * |
---|
546 | * The function returns the number of record that is has that are |
---|
547 | * in a continous block of memory. If the number of available records |
---|
548 | * wrap then only those records are provided. This removes the need for |
---|
549 | * caller to be concerned about buffer wrappings. If the number of |
---|
550 | * requested records cannot be met due to the wrapping of the records |
---|
551 | * less than the specified number will be returned. |
---|
552 | * |
---|
553 | * The user must release the records. This is achieved with a call to |
---|
554 | * rtems_capture_release. Calls this function without a release will |
---|
555 | * result in at least the same number of records being released. |
---|
556 | * |
---|
557 | * The 'threshold' parameter is the number of records that must be |
---|
558 | * captured before returning. If a timeout period is specified (non-0) |
---|
559 | * any captured records will be returned. These parameters stop |
---|
560 | * thrashing occuring for a small number of records, yet allows |
---|
561 | * a user configured latiency to be applied for single events. |
---|
562 | * |
---|
563 | * The @a timeout parameter is in microseconds. A value of 0 will |
---|
564 | * disable the timeout. |
---|
565 | * |
---|
566 | * @param[in] threshold The number of records that must be captured |
---|
567 | * @param[in] timeout The micro-second timeout period |
---|
568 | * @param[out] read will contain the number of records read |
---|
569 | * @param[out] recs The capture records that are read. |
---|
570 | * |
---|
571 | * @retval This method returns RTEMS_SUCCESSFUL if there was not an |
---|
572 | * error. Otherwise, a status code is returned indicating the |
---|
573 | * source of the error. |
---|
574 | */ |
---|
575 | rtems_status_code |
---|
576 | rtems_capture_read (uint32_t threshold, |
---|
577 | uint32_t timeout, |
---|
578 | uint32_t* read, |
---|
579 | rtems_capture_record_t** recs); |
---|
580 | |
---|
581 | /** |
---|
582 | * @brief Capture release records. |
---|
583 | * |
---|
584 | * This function releases the requested number of record slots back |
---|
585 | * to the capture engine. The count must match the number read. |
---|
586 | * |
---|
587 | * @param[in] count The number of record slots to release |
---|
588 | * |
---|
589 | * @retval This method returns RTEMS_SUCCESSFUL if there was not an |
---|
590 | * error. Otherwise, a status code is returned indicating the |
---|
591 | * source of the error. |
---|
592 | */ |
---|
593 | rtems_status_code |
---|
594 | rtems_capture_release (uint32_t count); |
---|
595 | |
---|
596 | /* |
---|
597 | * @brief Capture nano-second time period. |
---|
598 | * |
---|
599 | * This function returns the time period in nano-seconds. |
---|
600 | * |
---|
601 | * @param[out] uptime The nano-second time period. |
---|
602 | */ |
---|
603 | void |
---|
604 | rtems_capture_time (rtems_capture_time_t* uptime); |
---|
605 | |
---|
606 | /** |
---|
607 | * @brief Capture get event text. |
---|
608 | * |
---|
609 | * This function returns a string for an event based on the bit in the |
---|
610 | * event. The functions takes the bit offset as a number not the bit |
---|
611 | * set in a bit map. |
---|
612 | * |
---|
613 | * @param[in] event specifies the event to describe |
---|
614 | * |
---|
615 | * @retval This method returns a string description of the given event. |
---|
616 | */ |
---|
617 | const char* |
---|
618 | rtems_capture_event_text (int event); |
---|
619 | |
---|
620 | /** |
---|
621 | * @brief Capture get task list. |
---|
622 | * |
---|
623 | * This function returns the head of the list of tasks that the |
---|
624 | * capture engine has detected. |
---|
625 | * |
---|
626 | * @retval This function returns the head of the list of tasks that |
---|
627 | * the capture engine has detected. |
---|
628 | */ |
---|
629 | rtems_capture_task_t* |
---|
630 | rtems_capture_get_task_list (void); |
---|
631 | |
---|
632 | /** |
---|
633 | * @brief Capture get next task in list. |
---|
634 | * |
---|
635 | * This function returns the pointer to the next task in the list. The |
---|
636 | * pointer NULL terminates the list. |
---|
637 | * |
---|
638 | * @param[in] task The capture task to get the next entry from. |
---|
639 | * |
---|
640 | * @retval This function returns the pointer to the next task in the list. The |
---|
641 | * pointer NULL terminates the list. |
---|
642 | */ |
---|
643 | static inline rtems_capture_task_t* |
---|
644 | rtems_capture_next_task (rtems_capture_task_t* task) |
---|
645 | { |
---|
646 | return task->forw; |
---|
647 | } |
---|
648 | |
---|
649 | /** |
---|
650 | * @brief Capture is valid task control block |
---|
651 | * |
---|
652 | * This function returns true if the task control block points to |
---|
653 | * a valid task. |
---|
654 | * |
---|
655 | * @param[in] task The capture task. |
---|
656 | * |
---|
657 | * @retval This function returns true if the task control block points to |
---|
658 | * a valid task. Otherwise, it returns false. |
---|
659 | */ |
---|
660 | static inline bool |
---|
661 | rtems_capture_task_valid (rtems_capture_task_t* task) |
---|
662 | { |
---|
663 | return task->tcb != NULL; |
---|
664 | } |
---|
665 | |
---|
666 | /** |
---|
667 | * @brief Capture get task id. |
---|
668 | * |
---|
669 | * This function returns the task id. |
---|
670 | * |
---|
671 | * @param[in] task The capture task. |
---|
672 | * |
---|
673 | * @retval This function returns the task id. |
---|
674 | */ |
---|
675 | static inline rtems_id |
---|
676 | rtems_capture_task_id (rtems_capture_task_t* task) |
---|
677 | { |
---|
678 | return task->id; |
---|
679 | } |
---|
680 | |
---|
681 | /** |
---|
682 | * @brief Capture get task state. |
---|
683 | * |
---|
684 | * This function returns the task state. |
---|
685 | * |
---|
686 | * @param[in] task The capture task. |
---|
687 | * |
---|
688 | * @retval This function returns the task state. |
---|
689 | */ |
---|
690 | static inline States_Control |
---|
691 | rtems_capture_task_state (rtems_capture_task_t* task) |
---|
692 | { |
---|
693 | if (rtems_capture_task_valid (task)) |
---|
694 | return task->tcb->current_state; |
---|
695 | return 0; |
---|
696 | } |
---|
697 | |
---|
698 | /** |
---|
699 | * @brief Capture get task name. |
---|
700 | * |
---|
701 | * This function returns the task name. |
---|
702 | * |
---|
703 | * @param[in] task The capture task. |
---|
704 | * |
---|
705 | * @retval This function returns the task name. |
---|
706 | */ |
---|
707 | static inline rtems_name |
---|
708 | rtems_capture_task_name (rtems_capture_task_t* task) |
---|
709 | { |
---|
710 | return task->name; |
---|
711 | } |
---|
712 | |
---|
713 | /** |
---|
714 | * @brief Capture get task flags. |
---|
715 | * |
---|
716 | * This function returns the task flags. |
---|
717 | * |
---|
718 | * @param[in] task The capture task. |
---|
719 | * |
---|
720 | * @retval This function returns the task flags. |
---|
721 | */ |
---|
722 | static inline uint32_t |
---|
723 | rtems_capture_task_flags (rtems_capture_task_t* task) |
---|
724 | { |
---|
725 | return task->flags; |
---|
726 | } |
---|
727 | |
---|
728 | /** |
---|
729 | * @brief Capture get task control |
---|
730 | * |
---|
731 | * This function returns the task control if present. |
---|
732 | * |
---|
733 | * @param[in] task The capture task. |
---|
734 | * |
---|
735 | * @retval This function returns the task control if present. |
---|
736 | */ |
---|
737 | static inline rtems_capture_control_t* |
---|
738 | rtems_capture_task_control (rtems_capture_task_t* task) |
---|
739 | { |
---|
740 | return task->control; |
---|
741 | } |
---|
742 | |
---|
743 | /** |
---|
744 | * @brief Capture get task control flags. |
---|
745 | * |
---|
746 | * This function returns the task control flags if a control is present. |
---|
747 | * |
---|
748 | * @param[in] task The capture task. |
---|
749 | * |
---|
750 | * @retval This function returns the task control flags if a control is present. |
---|
751 | */ |
---|
752 | static inline uint32_t |
---|
753 | rtems_capture_task_control_flags (rtems_capture_task_t* task) |
---|
754 | { |
---|
755 | if (!task->control) |
---|
756 | return 0; |
---|
757 | return task->control->flags; |
---|
758 | } |
---|
759 | |
---|
760 | /** |
---|
761 | * @brief Capture get number of times task switched in. |
---|
762 | * |
---|
763 | * This function returns the number of times the task has |
---|
764 | * been switched into context. |
---|
765 | * |
---|
766 | * @param[in] task The capture task. |
---|
767 | * |
---|
768 | * @retval This function returns the number of times the task has |
---|
769 | * been switched into context. |
---|
770 | */ |
---|
771 | static inline uint32_t |
---|
772 | rtems_capture_task_switched_in (rtems_capture_task_t* task) |
---|
773 | { |
---|
774 | return task->in; |
---|
775 | } |
---|
776 | |
---|
777 | /** |
---|
778 | * @brief Capture get number of times task switched out. |
---|
779 | * |
---|
780 | * This function returns the number of times the task has |
---|
781 | * been switched out of context. |
---|
782 | * |
---|
783 | * @param[in] task The capture task. |
---|
784 | * |
---|
785 | * @retval This function returns the number of times the task has |
---|
786 | * been switched out of context. |
---|
787 | */ |
---|
788 | static inline uint32_t |
---|
789 | rtems_capture_task_switched_out (rtems_capture_task_t* task) |
---|
790 | { |
---|
791 | return task->out; |
---|
792 | } |
---|
793 | |
---|
794 | /** |
---|
795 | * @brief Capture get task start priority. |
---|
796 | * |
---|
797 | * This function returns the tasks start priority. The tracer needs this |
---|
798 | * to track where the task's priority goes. |
---|
799 | * |
---|
800 | * @param[in] task The capture task. |
---|
801 | * |
---|
802 | * @retval This function returns the tasks start priority. The tracer needs this |
---|
803 | * to track where the task's priority goes. |
---|
804 | */ |
---|
805 | static inline rtems_task_priority |
---|
806 | rtems_capture_task_start_priority (rtems_capture_task_t* task) |
---|
807 | { |
---|
808 | return task->start_priority; |
---|
809 | } |
---|
810 | |
---|
811 | /** |
---|
812 | * @brief Capture get task real priority. |
---|
813 | * |
---|
814 | * This function returns the tasks real priority. |
---|
815 | * |
---|
816 | * @param[in] task The capture task. |
---|
817 | * |
---|
818 | * @retval This function returns the tasks real priority. |
---|
819 | */ |
---|
820 | static inline rtems_task_priority |
---|
821 | rtems_capture_task_real_priority (rtems_capture_task_t* task) |
---|
822 | { |
---|
823 | if (rtems_capture_task_valid (task)) |
---|
824 | return task->tcb->real_priority; |
---|
825 | return 0; |
---|
826 | } |
---|
827 | |
---|
828 | /** |
---|
829 | * @brief Capture get task current priority. |
---|
830 | * |
---|
831 | * This function returns the tasks current priority. |
---|
832 | * |
---|
833 | * @param[in] task The capture task. |
---|
834 | * |
---|
835 | * @retval This function returns the tasks current priority. |
---|
836 | */ |
---|
837 | static inline rtems_task_priority |
---|
838 | rtems_capture_task_curr_priority (rtems_capture_task_t* task) |
---|
839 | { |
---|
840 | if (rtems_capture_task_valid (task)) |
---|
841 | return task->tcb->current_priority; |
---|
842 | return 0; |
---|
843 | } |
---|
844 | |
---|
845 | /** |
---|
846 | * @brief Capture update stack usage. |
---|
847 | * |
---|
848 | * This function updates the stack usage. The task control block |
---|
849 | * is updated. |
---|
850 | * |
---|
851 | * @param[in] task The capture task. |
---|
852 | * |
---|
853 | * @retval This function updates the stack usage. The task control block |
---|
854 | * is updated. |
---|
855 | */ |
---|
856 | uint32_t |
---|
857 | rtems_capture_task_stack_usage (rtems_capture_task_t* task); |
---|
858 | |
---|
859 | /** |
---|
860 | * @brief Capture get stack size. |
---|
861 | * |
---|
862 | * This function returns the task's stack size. |
---|
863 | * |
---|
864 | * @param[in] task The capture task. |
---|
865 | * |
---|
866 | * @retval This function returns the task's stack size. |
---|
867 | */ |
---|
868 | static inline uint32_t |
---|
869 | rtems_capture_task_stack_size (rtems_capture_task_t* task) |
---|
870 | { |
---|
871 | return task->stack_size; |
---|
872 | } |
---|
873 | |
---|
874 | /** |
---|
875 | * @brief Capture get stack used. |
---|
876 | * |
---|
877 | * This function returns the amount of stack used. |
---|
878 | * |
---|
879 | * @param[in] task The capture task. |
---|
880 | * |
---|
881 | * @retval This function returns the amount of stack used. |
---|
882 | */ |
---|
883 | static inline uint32_t |
---|
884 | rtems_capture_task_stack_used (rtems_capture_task_t* task) |
---|
885 | { |
---|
886 | return task->stack_size - task->stack_clean; |
---|
887 | } |
---|
888 | |
---|
889 | /** |
---|
890 | * @brief Capture get task execution time. |
---|
891 | * |
---|
892 | * This function returns the current execution time. |
---|
893 | * |
---|
894 | * @param[in] task The capture task. |
---|
895 | * |
---|
896 | * @retval This function returns the current execution time. |
---|
897 | */ |
---|
898 | static inline uint64_t |
---|
899 | rtems_capture_task_time (rtems_capture_task_t* task) |
---|
900 | { |
---|
901 | return task->time; |
---|
902 | } |
---|
903 | |
---|
904 | /** |
---|
905 | * @brief Capture get delta in execution time. |
---|
906 | * |
---|
907 | * This function returns the execution time as a different between the |
---|
908 | * last time the detla time was and now. |
---|
909 | * |
---|
910 | * @param[in] task The capture task. |
---|
911 | * |
---|
912 | * @retval This function returns the execution time as a different between the |
---|
913 | * last time the detla time was and now. |
---|
914 | */ |
---|
915 | static inline uint64_t |
---|
916 | rtems_capture_task_delta_time (rtems_capture_task_t* task) |
---|
917 | { |
---|
918 | uint64_t t = task->time - task->last_time; |
---|
919 | task->last_time = task->time; |
---|
920 | return t; |
---|
921 | } |
---|
922 | |
---|
923 | /** |
---|
924 | * @brief Capture get task count. |
---|
925 | * |
---|
926 | * This function returns the number of tasks the capture |
---|
927 | * engine knows about. |
---|
928 | * |
---|
929 | * @retval This function returns the number of tasks the capture |
---|
930 | * engine knows about. |
---|
931 | */ |
---|
932 | static inline uint32_t |
---|
933 | rtems_capture_task_count (void) |
---|
934 | { |
---|
935 | rtems_capture_task_t* task = rtems_capture_get_task_list (); |
---|
936 | uint32_t count = 0; |
---|
937 | |
---|
938 | while (task) |
---|
939 | { |
---|
940 | count++; |
---|
941 | task = rtems_capture_next_task (task); |
---|
942 | } |
---|
943 | |
---|
944 | return count; |
---|
945 | } |
---|
946 | |
---|
947 | /** |
---|
948 | * @brief Capture get control list. |
---|
949 | * |
---|
950 | * This function returns the head of the list of controls in the |
---|
951 | * capture engine. |
---|
952 | * |
---|
953 | * @retval This function returns the head of the list of controls in the |
---|
954 | * capture engine. |
---|
955 | */ |
---|
956 | rtems_capture_control_t* |
---|
957 | rtems_capture_get_control_list (void); |
---|
958 | |
---|
959 | /** |
---|
960 | * @brief Capture get next capture control. |
---|
961 | * |
---|
962 | * This function returns the pointer to the next control in the list. The |
---|
963 | * pointer NULL terminates the list. |
---|
964 | * |
---|
965 | * @param[in] control the current capture control. |
---|
966 | * |
---|
967 | * @retval This function returns the pointer to the next control in the list. The |
---|
968 | * pointer NULL terminates the list. |
---|
969 | */ |
---|
970 | static inline rtems_capture_control_t* |
---|
971 | rtems_capture_next_control (rtems_capture_control_t* control) |
---|
972 | { |
---|
973 | return control->next; |
---|
974 | } |
---|
975 | |
---|
976 | /** |
---|
977 | * @brief Capture get capture control id. |
---|
978 | * |
---|
979 | * This function returns the control id. |
---|
980 | * |
---|
981 | * @param[in] control the capture control. |
---|
982 | * |
---|
983 | * @retval This function returns the control id. |
---|
984 | */ |
---|
985 | static inline rtems_id |
---|
986 | rtems_capture_control_id (rtems_capture_control_t* control) |
---|
987 | { |
---|
988 | return control->id; |
---|
989 | } |
---|
990 | |
---|
991 | /** |
---|
992 | * @brief Capture get capture control name. |
---|
993 | * |
---|
994 | * This function returns the control name. |
---|
995 | * |
---|
996 | * @param[in] control the capture control. |
---|
997 | * |
---|
998 | * @retval This function returns the control name. |
---|
999 | */ |
---|
1000 | static inline rtems_name |
---|
1001 | rtems_capture_control_name (rtems_capture_control_t* control) |
---|
1002 | { |
---|
1003 | return control->name; |
---|
1004 | } |
---|
1005 | |
---|
1006 | /** |
---|
1007 | * @brief Capture get capture control flags. |
---|
1008 | * |
---|
1009 | * This function returns the control flags. |
---|
1010 | * |
---|
1011 | * @param[in] control the capture control. |
---|
1012 | * |
---|
1013 | * @retval This function returns the control flags. |
---|
1014 | */ |
---|
1015 | static inline uint32_t |
---|
1016 | rtems_capture_control_flags (rtems_capture_control_t* control) |
---|
1017 | { |
---|
1018 | return control->flags; |
---|
1019 | } |
---|
1020 | |
---|
1021 | /** |
---|
1022 | * @brief Capture get capture control to triggers. |
---|
1023 | * |
---|
1024 | * This function returns the task control to triggers. |
---|
1025 | * |
---|
1026 | * @param[in] control the capture control. |
---|
1027 | * |
---|
1028 | * @retval This function returns the task control to triggers. |
---|
1029 | */ |
---|
1030 | static inline uint32_t |
---|
1031 | rtems_capture_control_to_triggers (rtems_capture_control_t* control) |
---|
1032 | { |
---|
1033 | return control->to_triggers; |
---|
1034 | } |
---|
1035 | |
---|
1036 | /** |
---|
1037 | * @brief Capture get capture control from triggers. |
---|
1038 | * |
---|
1039 | * This function returns the task control from triggers. |
---|
1040 | * |
---|
1041 | * @param[in] control the capture control. |
---|
1042 | * |
---|
1043 | * @retval This function returns the task control from triggers. |
---|
1044 | */ |
---|
1045 | static inline uint32_t |
---|
1046 | rtems_capture_control_from_triggers (rtems_capture_control_t* control) |
---|
1047 | { |
---|
1048 | return control->from_triggers; |
---|
1049 | } |
---|
1050 | |
---|
1051 | /** |
---|
1052 | * @brief Capture get capture control by triggers. |
---|
1053 | * |
---|
1054 | * This function returns the task control by triggers. |
---|
1055 | * |
---|
1056 | * @param[in] control the capture control. |
---|
1057 | * |
---|
1058 | * @retval This function returns the task control by triggers. |
---|
1059 | */ |
---|
1060 | static inline uint32_t |
---|
1061 | rtems_capture_control_all_by_triggers (rtems_capture_control_t* control) |
---|
1062 | { |
---|
1063 | return control->by_triggers; |
---|
1064 | } |
---|
1065 | |
---|
1066 | /** |
---|
1067 | * @brief Capture get capture control valid by flags. |
---|
1068 | * |
---|
1069 | * This function returns the control valid BY flags. |
---|
1070 | * |
---|
1071 | * @param[in] control The capture control. |
---|
1072 | * @param[in] slot The XXX. |
---|
1073 | * |
---|
1074 | * @retval This function returns the control valid BY flags. |
---|
1075 | */ |
---|
1076 | static inline int |
---|
1077 | rtems_capture_control_by_valid (rtems_capture_control_t* control, int slot) |
---|
1078 | { |
---|
1079 | return control->by_valid & RTEMS_CAPTURE_CONTROL_FROM_MASK (slot); |
---|
1080 | } |
---|
1081 | |
---|
1082 | /** |
---|
1083 | * @brief Capture get capture control by task name. |
---|
1084 | * |
---|
1085 | * This function returns the control @a by task name. |
---|
1086 | * |
---|
1087 | * @param[in] control The capture control. |
---|
1088 | * @param[in] by The XXX. |
---|
1089 | * |
---|
1090 | * @retval This function returns the control @a by task name. |
---|
1091 | */ |
---|
1092 | static inline rtems_name |
---|
1093 | rtems_capture_control_by_name (rtems_capture_control_t* control, int by) |
---|
1094 | { |
---|
1095 | if (by < RTEMS_CAPTURE_TRIGGER_TASKS) |
---|
1096 | return control->by[by].name; |
---|
1097 | return control->by[0].name; |
---|
1098 | } |
---|
1099 | |
---|
1100 | /** |
---|
1101 | * @brief Capture get capture control by task id. |
---|
1102 | * |
---|
1103 | * This function returns the control @a by task id |
---|
1104 | * |
---|
1105 | * @retval This function returns the control @a by task id. |
---|
1106 | */ |
---|
1107 | static inline rtems_id |
---|
1108 | rtems_capture_control_by_id (rtems_capture_control_t* control, int by) |
---|
1109 | { |
---|
1110 | if (by < RTEMS_CAPTURE_TRIGGER_TASKS) |
---|
1111 | return control->by[by].id; |
---|
1112 | return control->by[0].id; |
---|
1113 | } |
---|
1114 | |
---|
1115 | /** |
---|
1116 | * @brief Capture get capture control by task triggers. |
---|
1117 | * |
---|
1118 | * This function returns the control @a by task triggers. |
---|
1119 | * |
---|
1120 | * @retval This function returns the control @a by task triggers. |
---|
1121 | */ |
---|
1122 | static inline uint32_t |
---|
1123 | rtems_capture_control_by_triggers (rtems_capture_control_t* control, |
---|
1124 | int by) |
---|
1125 | { |
---|
1126 | if (by < RTEMS_CAPTURE_TRIGGER_TASKS) |
---|
1127 | return control->by[by].trigger; |
---|
1128 | return control->by[0].trigger; |
---|
1129 | } |
---|
1130 | |
---|
1131 | /** |
---|
1132 | * @brief Capture get capture control count. |
---|
1133 | * |
---|
1134 | * This function returns the number of controls the capture |
---|
1135 | * engine has. |
---|
1136 | * |
---|
1137 | * @retval This function returns the number of controls the capture |
---|
1138 | * engine has. |
---|
1139 | */ |
---|
1140 | static inline uint32_t |
---|
1141 | rtems_capture_control_count (void) |
---|
1142 | { |
---|
1143 | rtems_capture_control_t* control = rtems_capture_get_control_list (); |
---|
1144 | uint32_t count = 0; |
---|
1145 | |
---|
1146 | while (control) |
---|
1147 | { |
---|
1148 | count++; |
---|
1149 | control = rtems_capture_next_control (control); |
---|
1150 | } |
---|
1151 | |
---|
1152 | return count; |
---|
1153 | } |
---|
1154 | |
---|
1155 | #ifdef __cplusplus |
---|
1156 | } |
---|
1157 | #endif |
---|
1158 | |
---|
1159 | #endif |
---|