source: rtems/cpukit/libmisc/capture/capture.h @ 1af8634a

4.115
Last change on this file since 1af8634a was 1af8634a, checked in by Jennifer Averett <jennifer.averett@…>, on 04/11/14 at 15:18:20

capture: Update comment block style in capture engine.

Doxygen added and comment blocks standardized.

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