RTEMS: cpukit/include/rtems/monitor.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
monitor.h
Go to the documentation of this file.
1
8#ifndef __MONITOR_H
9#define __MONITOR_H
10
11#include <rtems/score/objectimpl.h>
12#include <rtems/error.h> /* rtems_error() */
13#include <rtems/config.h>
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19/* Forward decls from symbols.h */
20typedef struct _rtems_symbol_t rtems_symbol_t;
21typedef struct _rtems_symbol_table_t rtems_symbol_table_t;
22
23/*
24 * Monitor types are derived from rtems object classes
25 */
26
27typedef enum {
28 RTEMS_MONITOR_OBJECT_INVALID = OBJECTS_CLASSIC_NO_CLASS,
29 RTEMS_MONITOR_OBJECT_TASK = OBJECTS_RTEMS_TASKS,
30 RTEMS_MONITOR_OBJECT_EXTENSION = OBJECTS_RTEMS_EXTENSIONS,
31 RTEMS_MONITOR_OBJECT_QUEUE = OBJECTS_RTEMS_MESSAGE_QUEUES,
32 RTEMS_MONITOR_OBJECT_SEMAPHORE = OBJECTS_RTEMS_SEMAPHORES,
33 RTEMS_MONITOR_OBJECT_PARTITION = OBJECTS_RTEMS_PARTITIONS,
34 RTEMS_MONITOR_OBJECT_REGION = OBJECTS_RTEMS_REGIONS,
35 RTEMS_MONITOR_OBJECT_PORT = OBJECTS_RTEMS_PORTS,
36
37 /* following monitor objects are not known to RTEMS, but
38 * we like to have "types" for them anyway */
39
40 RTEMS_MONITOR_OBJECT_DRIVER = OBJECTS_RTEMS_CLASSES_LAST+1,
41 RTEMS_MONITOR_OBJECT_DNAME,
42 RTEMS_MONITOR_OBJECT_CONFIG,
43 RTEMS_MONITOR_OBJECT_INIT_TASK,
44 RTEMS_MONITOR_OBJECT_MPCI,
45 RTEMS_MONITOR_OBJECT_SYMBOL,
46 RTEMS_MONITOR_OBJECT_PTHREAD
47} rtems_monitor_object_type_t;
48
49/*
50 * rtems_monitor_init() flags
51 */
52
53#define RTEMS_MONITOR_SUSPEND 0x0001 /* suspend monitor on startup */
54#define RTEMS_MONITOR_GLOBAL 0x0002 /* monitor should be global */
55#define RTEMS_MONITOR_NOTASK 0x0004 /* do not start monitor task */
56#define RTEMS_MONITOR_NOSYMLOAD 0x0008 /* do not load symbols */
57#define RTEMS_MONITOR_WAITQUIT 0x0010 /* wait for monitor task to terminate */
58
59/*
60 * Public interfaces for RTEMS data structures monitor is aware of.
61 * These are only used by the monitor.
62 *
63 * NOTE:
64 * All the canonical objects that correspond to RTEMS managed "objects"
65 * must have an identical first portion with 'id' and 'name' fields.
66 *
67 * Others do not have that restriction, even tho we would like them to.
68 * This is because some of the canonical structures are almost too big
69 * for shared memory driver (eg: mpci) and we are nickel and diming it.
70 */
71
72/*
73 * Type of a pointer that may be a symbol
74 */
75
76#define MONITOR_SYMBOL_LEN 20
77 typedef struct {
78 char name[MONITOR_SYMBOL_LEN];
79 uint32_t value;
80 uint32_t offset;
81} rtems_monitor_symbol_t;
82
83 typedef struct {
84 rtems_id id;
85 rtems_name name;
86 /* end of common portion */
87} rtems_monitor_generic_t;
88
89/*
90 * Task
91 */
92 typedef struct {
93 rtems_id id;
94 rtems_name name;
95 /* end of common portion */
96 char short_name[5];
97 char long_name[16];
98 Thread_Entry_information entry;
99 void *stack;
100 uint32_t stack_size;
101 char scheduler_name[5];
102 rtems_task_priority priority;
103 States_Control state;
104 rtems_event_set events;
105 rtems_mode modes;
106 rtems_attribute attributes;
107 char wait[17];
108 uint32_t ticks;
109} rtems_monitor_task_t;
110
111/*
112 * Init task
113 */
114
115 typedef struct {
116 rtems_id id; /* not really an id */
117 rtems_name name;
118 /* end of common portion */
119 rtems_monitor_symbol_t entry;
120 uint32_t argument;
121 uint32_t stack_size;
122 rtems_task_priority priority;
123 rtems_mode modes;
124 rtems_attribute attributes;
125} rtems_monitor_init_task_t;
126
127
128/*
129 * Message queue
130 */
131 typedef struct {
132 rtems_id id;
133 rtems_name name;
134 /* end of common portion */
135 rtems_attribute attributes;
136 uint32_t number_of_pending_messages;
137 uint32_t maximum_pending_messages;
138 size_t maximum_message_size;
139} rtems_monitor_queue_t;
140
141/*
142 * Semaphore
143 */
144 typedef struct {
145 rtems_id id;
146 rtems_name name;
147 /* end of common portion */
148 rtems_attribute attribute;
149 rtems_task_priority priority_ceiling;
150 uint32_t max_count;
151 uint32_t cur_count;
152 rtems_id holder_id;
153} rtems_monitor_sema_t;
154
155/*
156 * Extension
157 */
158 typedef struct {
159 rtems_id id;
160 rtems_name name;
161 /* end of common portion */
162 rtems_monitor_symbol_t e_create;
163 rtems_monitor_symbol_t e_start;
164 rtems_monitor_symbol_t e_restart;
165 rtems_monitor_symbol_t e_delete;
166 rtems_monitor_symbol_t e_tswitch;
167 rtems_monitor_symbol_t e_begin;
168 rtems_monitor_symbol_t e_exitted;
169 rtems_monitor_symbol_t e_fatal;
170} rtems_monitor_extension_t;
171
172 /*
173 * Region
174 */
175 typedef struct {
176 rtems_id id;
177 rtems_name name;
178 /* end of common portion */
179 rtems_attribute attribute;
180 void * start_addr;
181 uint32_t length;
182 uint32_t page_size;
183 uint32_t max_seg_size;
184 uint32_t used_blocks;
185} rtems_monitor_region_t;
186
187/*
188 * Partition
189 */
190 typedef struct {
191 rtems_id id;
192 rtems_name name;
193 /* end of common portion */
194 rtems_attribute attribute;
195 void * start_addr;
196 uint32_t length;
197 uint32_t buf_size;
198 uint32_t used_blocks;
199} rtems_monitor_part_t;
200
201/*
202 * Device driver
203 */
204
205 typedef struct {
206 rtems_id id; /* not really an id (should be tho) */
207 rtems_name name; /* ditto */
208 /* end of common portion */
209 rtems_monitor_symbol_t initialization; /* initialization procedure */
210 rtems_monitor_symbol_t open; /* open request procedure */
211 rtems_monitor_symbol_t close; /* close request procedure */
212 rtems_monitor_symbol_t read; /* read request procedure */
213 rtems_monitor_symbol_t write; /* write request procedure */
214 rtems_monitor_symbol_t control; /* special functions procedure */
215} rtems_monitor_driver_t;
216
217/*
218 * System config
219 */
220
221 typedef struct {
222 void *work_space_start;
223 uint32_t work_space_size;
224 uint32_t maximum_tasks;
225 uint32_t maximum_timers;
226 uint32_t maximum_semaphores;
227 uint32_t maximum_message_queues;
228 uint32_t maximum_partitions;
229 uint32_t maximum_regions;
230 uint32_t maximum_ports;
231 uint32_t maximum_periods;
232 uint32_t maximum_extensions;
233 uint32_t microseconds_per_tick;
234 uint32_t ticks_per_timeslice;
235 uint32_t number_of_initialization_tasks;
236} rtems_monitor_config_t;
237
238/*
239 * MPCI config
240 */
241
242#if defined(RTEMS_MULTIPROCESSING)
243typedef struct {
244 uint32_t node; /* local node number */
245 uint32_t maximum_nodes; /* maximum # nodes in system */
246 uint32_t maximum_global_objects; /* maximum # global objects */
247 uint32_t maximum_proxies; /* maximum # proxies */
248
249 uint32_t default_timeout; /* in ticks */
250 size_t maximum_packet_size;
251 rtems_monitor_symbol_t initialization;
252 rtems_monitor_symbol_t get_packet;
253 rtems_monitor_symbol_t return_packet;
254 rtems_monitor_symbol_t send_packet;
255 rtems_monitor_symbol_t receive_packet;
256} rtems_monitor_mpci_t;
257#endif
258
259/*
260 * The generic canonical information union
261 */
262
263 typedef union {
264 rtems_monitor_generic_t generic;
265 rtems_monitor_task_t task;
266 rtems_monitor_queue_t queue;
267 rtems_monitor_sema_t sema;
268 rtems_monitor_extension_t extension;
269 rtems_monitor_driver_t driver;
270 rtems_monitor_config_t config;
271 rtems_monitor_region_t region;
272 rtems_monitor_part_t part;
273#if defined(RTEMS_MULTIPROCESSING)
274 rtems_monitor_mpci_t mpci;
275#endif
276 rtems_monitor_init_task_t itask;
277} rtems_monitor_union_t;
278
279/*
280 * Support for talking to other monitors
281 */
282
283/*
284 * Names of other monitors
285 */
286
287#define RTEMS_MONITOR_NAME (rtems_build_name('R', 'M', 'O', 'N'))
288#define RTEMS_MONITOR_SERVER_NAME (rtems_build_name('R', 'M', 'S', 'V'))
289#define RTEMS_MONITOR_QUEUE_NAME (rtems_build_name('R', 'M', 'S', 'Q'))
290#define RTEMS_MONITOR_RESPONSE_QUEUE_NAME (rtems_build_name('R', 'M', 'R', 'Q'))
291
292#define RTEMS_MONITOR_SERVER_RESPONSE 0x0001
293#define RTEMS_MONITOR_SERVER_CANONICAL 0x0002
294
295 typedef struct
296{
297 uint32_t command;
298 rtems_id return_id;
299 uint32_t argument0;
300 uint32_t argument1;
301 uint32_t argument2;
302 uint32_t argument3;
303 uint32_t argument4;
304 uint32_t argument5;
305} rtems_monitor_server_request_t;
306
307 typedef struct
308{
309 uint32_t command;
310 uint32_t result0;
311 uint32_t result1;
312 rtems_monitor_union_t payload;
313} rtems_monitor_server_response_t;
314
315extern rtems_id rtems_monitor_task_id;
316
317extern uint32_t rtems_monitor_node; /* our node number */
318extern uint32_t rtems_monitor_default_node; /* current default for commands */
319
320/*
321 * Monitor command function and table entry
322 */
323
324typedef struct rtems_monitor_command_entry_s rtems_monitor_command_entry_t;
325typedef union _rtems_monitor_command_arg_t rtems_monitor_command_arg_t;
326
327typedef void (*rtems_monitor_command_function_t)(
328 int argc,
329 char **argv,
330 const rtems_monitor_command_arg_t *command_arg,
331 bool verbose
332);
333
334 union _rtems_monitor_command_arg_t {
335 rtems_monitor_object_type_t monitor_object;
336 rtems_status_code status_code;
337 rtems_symbol_table_t **symbol_table;
338 const rtems_monitor_command_entry_t *monitor_command_entry;
339};
340
341 struct rtems_monitor_command_entry_s {
342 const char *command; /* command name */
343 const char *usage; /* usage string for the command */
344 uint32_t arguments_required; /* # of required args */
345 rtems_monitor_command_function_t command_function;
346 /* Some argument for the command */
347 rtems_monitor_command_arg_t command_arg;
348 const rtems_monitor_command_entry_t *next;
349};
350
351
352typedef const void *(*rtems_monitor_object_next_fn)(void *, void *, rtems_id *);
353typedef void (*rtems_monitor_object_canonical_fn)(void *, const void *);
354typedef void (*rtems_monitor_object_dump_header_fn)(bool);
355typedef void (*rtems_monitor_object_dump_fn)(void *, bool);
356
357 typedef struct {
358 rtems_monitor_object_type_t type;
359 void *object_information;
360 int size; /* of canonical object */
361 rtems_monitor_object_next_fn next;
362 rtems_monitor_object_canonical_fn canonical;
363 rtems_monitor_object_dump_header_fn dump_header;
364 rtems_monitor_object_dump_fn dump;
365} rtems_monitor_object_info_t;
366
367typedef bool (*rtems_monitor_per_command_routine)(const rtems_monitor_command_entry_t *, void *);
368
369/* monitor.c */
370void rtems_monitor_pause_cmd(int, char **, const rtems_monitor_command_arg_t*, bool);
371void rtems_monitor_fatal_cmd(int, char **, const rtems_monitor_command_arg_t*, bool);
372void rtems_monitor_continue_cmd(int, char **, const rtems_monitor_command_arg_t*, bool);
373void rtems_monitor_debugger_cmd(int, char **, const rtems_monitor_command_arg_t*, bool);
374void rtems_monitor_reset_cmd(int, char **, const rtems_monitor_command_arg_t*, bool);
375void rtems_monitor_node_cmd(int, char **, const rtems_monitor_command_arg_t*, bool);
376void rtems_monitor_symbols_loadup(void);
377int rtems_monitor_insert_cmd(rtems_monitor_command_entry_t *);
378void rtems_monitor_wakeup(void);
379void rtems_monitor_command_iterate(rtems_monitor_per_command_routine routine, void *arg);
380 rtems_status_code rtems_monitor_suspend(rtems_interval timeout);
381
382/* editor.c */
383void rtems_monitor_kill(void);
384void rtems_monitor_init(uint32_t);
385void rtems_monitor_task(rtems_task_argument);
386
387/* server.c */
388void rtems_monitor_server_kill(void);
389 rtems_status_code rtems_monitor_server_request(uint32_t , rtems_monitor_server_request_t *, rtems_monitor_server_response_t *);
390void rtems_monitor_server_task(rtems_task_argument);
391void rtems_monitor_server_init(uint32_t);
392
393/* command.c */
394int rtems_monitor_make_argv(char *, int *, char **);
395int rtems_monitor_command_read(char *, int *, char **);
396void rtems_monitor_command_usage(const rtems_monitor_command_entry_t *, const char *);
397void rtems_monitor_help_cmd(int, char **, const rtems_monitor_command_arg_t *, bool);
398const rtems_monitor_command_entry_t *rtems_monitor_command_lookup(const char *name);
399
400/* prmisc.c */
401void rtems_monitor_separator(void);
402uint32_t rtems_monitor_pad(uint32_t dest_col, uint32_t curr_col);
403int rtems_monitor_dump_decimal(uint32_t num);
404int rtems_monitor_dump_hex(uint32_t num);
405int rtems_monitor_dump_addr(const void *addr);
406int rtems_monitor_dump_id(rtems_id id);
407int rtems_monitor_dump_name(rtems_id id);
408int rtems_monitor_dump_priority(rtems_task_priority priority);
409int rtems_monitor_dump_state(States_Control state);
410int rtems_monitor_dump_modes(rtems_mode modes);
411int rtems_monitor_dump_attributes(rtems_attribute attributes);
412int rtems_monitor_dump_events(rtems_event_set events);
413
414/* object.c */
415 rtems_id rtems_monitor_id_fixup(rtems_id, uint32_t , rtems_monitor_object_type_t);
416const rtems_monitor_object_info_t *rtems_monitor_object_lookup(rtems_monitor_object_type_t type);
417 rtems_id rtems_monitor_object_canonical_get(rtems_monitor_object_type_t, rtems_id, void *, size_t *size_p);
418 rtems_id rtems_monitor_object_canonical_next(const rtems_monitor_object_info_t *, rtems_id, void *);
419const void *rtems_monitor_object_next(void *, void *, rtems_id, rtems_id *);
420 rtems_id rtems_monitor_object_canonical(rtems_id, const void *);
421void rtems_monitor_object_cmd(int, char **, const rtems_monitor_command_arg_t*, bool);
422
423/* manager.c */
424const void *rtems_monitor_manager_next(void *, void *, rtems_id *);
425
426/* config.c */
427void rtems_monitor_config_canonical(rtems_monitor_config_t *, const void *);
428const void *rtems_monitor_config_next(void *, rtems_monitor_config_t *, rtems_id *);
429void rtems_monitor_config_dump_header(bool);
430int rtems_monitor_config_dump(rtems_monitor_config_t *, bool verbose);
431
432/* mpci.c */
433#if defined(RTEMS_MULTIPROCESSING)
434void rtems_monitor_mpci_canonical(rtems_monitor_mpci_t *, const void *);
435const void *rtems_monitor_mpci_next(void *, rtems_monitor_mpci_t *, rtems_id *);
436void rtems_monitor_mpci_dump_header(bool);
437void rtems_monitor_mpci_dump(rtems_monitor_mpci_t *, bool verbose);
438#endif
439
440/* itask.c */
441void rtems_monitor_init_task_canonical(rtems_monitor_init_task_t *, const void *);
442const void *rtems_monitor_init_task_next(void *, rtems_monitor_init_task_t *, rtems_id *);
443void rtems_monitor_init_task_dump_header(bool);
444void rtems_monitor_init_task_dump(rtems_monitor_init_task_t *, bool verbose);
445
446/* extension.c */
447void rtems_monitor_extension_canonical(rtems_monitor_extension_t *, const void *);
448void rtems_monitor_extension_dump_header(bool verbose);
449void rtems_monitor_extension_dump(rtems_monitor_extension_t *, bool);
450
451/* task.c */
452void rtems_monitor_task_canonical(rtems_monitor_task_t *, const void *);
453void rtems_monitor_task_dump_header(bool verbose);
454void rtems_monitor_task_dump(rtems_monitor_task_t *, bool);
455
456/* sema.c */
457void rtems_monitor_sema_canonical(rtems_monitor_sema_t *, const void *);
458void rtems_monitor_sema_dump_header(bool verbose);
459void rtems_monitor_sema_dump(rtems_monitor_sema_t *, bool);
460
461/* queue.c */
462void rtems_monitor_queue_canonical(rtems_monitor_queue_t *, const void *);
463void rtems_monitor_queue_dump_header(bool verbose);
464void rtems_monitor_queue_dump(rtems_monitor_queue_t *, bool);
465
466/* region.c */
467void rtems_monitor_region_canonical(rtems_monitor_region_t *, const void *);
468void rtems_monitor_region_dump_header(bool verbose);
469void rtems_monitor_region_dump(rtems_monitor_region_t *, bool);
470
471/* partition.c */
472void rtems_monitor_part_canonical(rtems_monitor_part_t *, const void *);
473void rtems_monitor_part_dump_header(bool verbose);
474void rtems_monitor_part_dump(rtems_monitor_part_t *, bool);
475
476/* driver.c */
477const void *rtems_monitor_driver_next(void *, rtems_monitor_driver_t *, rtems_id *);
478void rtems_monitor_driver_canonical(rtems_monitor_driver_t *, const void *);
479void rtems_monitor_driver_dump_header(bool);
480void rtems_monitor_driver_dump(rtems_monitor_driver_t *, bool);
481
482/* symbols.c */
483 rtems_symbol_table_t *rtems_symbol_table_create(void);
484void rtems_symbol_table_destroy(rtems_symbol_table_t *table);
485
486 rtems_symbol_t *rtems_symbol_create(rtems_symbol_table_t *, const char *, uint32_t);
487 rtems_symbol_t *rtems_symbol_value_lookup(rtems_symbol_table_t *, uint32_t);
488const rtems_symbol_t *rtems_symbol_value_lookup_exact(rtems_symbol_table_t *, uint32_t);
489 rtems_symbol_t *rtems_symbol_name_lookup(rtems_symbol_table_t *, const char *);
490const void *rtems_monitor_symbol_next(void *object_info, rtems_monitor_symbol_t *, rtems_id *);
491void rtems_monitor_symbol_canonical(rtems_monitor_symbol_t *, rtems_symbol_t *);
492void rtems_monitor_symbol_canonical_by_name(rtems_monitor_symbol_t *, const char *);
493void rtems_monitor_symbol_canonical_by_value(rtems_monitor_symbol_t *, void *);
494uint32_t rtems_monitor_symbol_dump(rtems_monitor_symbol_t *, bool);
495void rtems_monitor_symbol_cmd(int, char **, const rtems_monitor_command_arg_t*, bool);
496
497#if defined(RTEMS_NETWORKING)
498void mon_ifconfig(
499 int argc,
500 char *argv[],
501 uint32_t command_arg,
502 bool verbose
503);
504void mon_route(
505 int argc,
506 char *argv[],
507 uint32_t command_arg,
508 bool verbose
509);
510#endif
511
512/* mon-object.c */
513const rtems_monitor_object_info_t *rtems_monitor_object_lookup(
514 rtems_monitor_object_type_t type
515);
516
517/* shared data */
518extern rtems_symbol_table_t *rtems_monitor_symbols;
519
520#define MONITOR_WAKEUP_EVENT RTEMS_EVENT_0
521
522#ifdef __cplusplus
523}
524#endif
525
526#endif /* ! __MONITOR_H */
error.h
RTEMS Error Reporting.
rtems_attribute
uint32_t rtems_attribute
Definition: attr.h:41
rtems_event_set
uint32_t rtems_event_set
Integer type to hold an event set of up to 32 events represented as a bit field.
Definition: event.h:40
rtems_mode
uint32_t rtems_mode
Definition: modes.h:41
rtems_status_code
rtems_status_code
Classic API Status.
Definition: status.h:43
rtems_name
uint32_t rtems_name
Classic API object name type.
Definition: types.h:77
rtems_task_priority
uint32_t rtems_task_priority
Definition: tasks.h:55
rtems_id
Objects_Id rtems_id
Used to manage and manipulate RTEMS object identifiers.
Definition: types.h:83
rtems_interval
Watchdog_Interval rtems_interval
Used to manage and manipulate intervals specified by clock ticks.
Definition: types.h:127
rtems_task_argument
CPU_Uint32ptr rtems_task_argument
Definition: tasks.h:106
OBJECTS_RTEMS_CLASSES_LAST
#define OBJECTS_RTEMS_CLASSES_LAST
Definition: objectimpl.h:54
States_Control
uint32_t States_Control
Definition: states.h:46
read
ssize_t read(int fd, void *buffer, size_t count)
Definition: read.c:27
write
ssize_t write(int fd, const void *buffer, size_t count)
Definition: write.c:30
rtems_monitor_command_lookup
const rtems_monitor_command_entry_t * rtems_monitor_command_lookup(const char *name)
Looks for a command with the name name in the list of registered commands.
Definition: mon-command.c:229
rtems_monitor_command_iterate
void rtems_monitor_command_iterate(rtems_monitor_per_command_routine routine, void *arg)
Iterates through all registerd commands.
Definition: mon-monitor.c:484
objectimpl.h
Inlined Routines in the Object Handler.
open
int open(const char *path, int oflag,...)
Definition: open.c:149
Thread_Entry_information
Thread entry information.
Definition: thread.h:136
_rtems_symbol_t
Definition: symbols.h:21
_rtems_symbol_table_t
Definition: symbols.h:32
config_s
Definition: deflate.c:115
control
Definition: intercom.c:74
entry
Definition: mmu-config.c:40
rtems_monitor_command_entry_s
Definition: monitor.h:341
rtems_monitor_config_t
Definition: monitor.h:221
rtems_monitor_driver_t
Definition: monitor.h:205
rtems_monitor_extension_t
Definition: monitor.h:158
rtems_monitor_generic_t
Definition: monitor.h:83
rtems_monitor_init_task_t
Definition: monitor.h:115
rtems_monitor_object_info_t
Definition: monitor.h:357
rtems_monitor_part_t
Definition: monitor.h:190
rtems_monitor_queue_t
Definition: monitor.h:131
rtems_monitor_region_t
Definition: monitor.h:175
rtems_monitor_sema_t
Definition: monitor.h:144
rtems_monitor_server_request_t
Definition: monitor.h:296
rtems_monitor_server_response_t
Definition: monitor.h:308
rtems_monitor_symbol_t
Definition: monitor.h:77
rtems_monitor_task_t
Definition: monitor.h:92
_rtems_monitor_command_arg_t
Definition: monitor.h:334
rtems_monitor_union_t
Definition: monitor.h:263