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