source: rtems/cpukit/libmisc/capture/capture.h @ 78b867e2

4.10
Last change on this file since 78b867e2 was 78b867e2, checked in by Gedare Bloom <gedare@…>, on 12/21/17 at 16:49:30

score: replace current and real priority with priority node

Encapsulate the current_priority and real_priority fields of
the thread control block with a Thread_Priority_node struct.
Propagate modifications throughout the tree where the two
fields are directly accessed.

Updates #3359.

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