RTEMS  5.0.0
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
16 extern "C" {
17 #endif
18 
19 /* Forward decls from symbols.h */
20 typedef struct _rtems_symbol_t rtems_symbol_t;
22 
23 /*
24  * Monitor types are derived from rtems object classes
25  */
26 
27 typedef 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;
82 
83 typedef struct {
84  rtems_id id;
85  rtems_name name;
86  /* end of common portion */
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];
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;
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 */
120  uint32_t argument;
121  uint32_t stack_size;
122  rtems_task_priority priority;
123  rtems_mode modes;
124  rtems_attribute attributes;
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;
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;
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;
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;
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;
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 */
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;
237 
238 /*
239  * MPCI config
240  */
241 
242 #if defined(RTEMS_MULTIPROCESSING)
243 typedef 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;
266  rtems_monitor_queue_t queue;
268  rtems_monitor_extension_t extension;
269  rtems_monitor_driver_t driver;
271  rtems_monitor_region_t region;
273 #if defined(RTEMS_MULTIPROCESSING)
274  rtems_monitor_mpci_t mpci;
275 #endif
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;
306 
307 typedef struct
308 {
309  uint32_t command;
310  uint32_t result0;
311  uint32_t result1;
312  rtems_monitor_union_t payload;
314 
315 extern rtems_id rtems_monitor_task_id;
316 
317 extern uint32_t rtems_monitor_node; /* our node number */
318 extern uint32_t rtems_monitor_default_node; /* current default for commands */
319 
320 /*
321  * Monitor command function and table entry
322  */
323 
326 
327 typedef 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 
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 
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 
352 typedef const void *(*rtems_monitor_object_next_fn)(void *, void *, rtems_id *);
353 typedef void (*rtems_monitor_object_canonical_fn)(void *, const void *);
354 typedef void (*rtems_monitor_object_dump_header_fn)(bool);
355 typedef 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;
366 
367 typedef bool (*rtems_monitor_per_command_routine)(const rtems_monitor_command_entry_t *, void *);
368 
369 /* monitor.c */
370 void rtems_monitor_pause_cmd(int, char **, const rtems_monitor_command_arg_t*, bool);
371 void rtems_monitor_fatal_cmd(int, char **, const rtems_monitor_command_arg_t*, bool);
372 void rtems_monitor_continue_cmd(int, char **, const rtems_monitor_command_arg_t*, bool);
373 void rtems_monitor_debugger_cmd(int, char **, const rtems_monitor_command_arg_t*, bool);
374 void rtems_monitor_reset_cmd(int, char **, const rtems_monitor_command_arg_t*, bool);
375 void rtems_monitor_node_cmd(int, char **, const rtems_monitor_command_arg_t*, bool);
376 void rtems_monitor_symbols_loadup(void);
377 int rtems_monitor_insert_cmd(rtems_monitor_command_entry_t *);
378 void rtems_monitor_wakeup(void);
379 void 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 */
383 void rtems_monitor_kill(void);
384 void rtems_monitor_init(uint32_t);
385 void rtems_monitor_task(rtems_task_argument);
386 
387 /* server.c */
388 void 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 *);
390 void rtems_monitor_server_task(rtems_task_argument);
391 void rtems_monitor_server_init(uint32_t);
392 
393 /* command.c */
394 int rtems_monitor_make_argv(char *, int *, char **);
395 int rtems_monitor_command_read(char *, int *, char **);
396 void rtems_monitor_command_usage(const rtems_monitor_command_entry_t *, const char *);
397 void rtems_monitor_help_cmd(int, char **, const rtems_monitor_command_arg_t *, bool);
398 const rtems_monitor_command_entry_t *rtems_monitor_command_lookup(const char *name);
399 
400 /* prmisc.c */
401 void rtems_monitor_separator(void);
402 uint32_t rtems_monitor_pad(uint32_t dest_col, uint32_t curr_col);
403 int rtems_monitor_dump_decimal(uint32_t num);
404 int rtems_monitor_dump_hex(uint32_t num);
405 int rtems_monitor_dump_addr(const void *addr);
406 int rtems_monitor_dump_id(rtems_id id);
407 int rtems_monitor_dump_name(rtems_id id);
408 int rtems_monitor_dump_priority(rtems_task_priority priority);
409 int rtems_monitor_dump_state(States_Control state);
410 int rtems_monitor_dump_modes(rtems_mode modes);
411 int rtems_monitor_dump_attributes(rtems_attribute attributes);
412 int 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);
416 const 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 *);
419 const void *rtems_monitor_object_next(void *, void *, rtems_id, rtems_id *);
420 rtems_id rtems_monitor_object_canonical(rtems_id, const void *);
421 void rtems_monitor_object_cmd(int, char **, const rtems_monitor_command_arg_t*, bool);
422 
423 /* manager.c */
424 const void *rtems_monitor_manager_next(void *, void *, rtems_id *);
425 
426 /* config.c */
427 void rtems_monitor_config_canonical(rtems_monitor_config_t *, const void *);
428 const void *rtems_monitor_config_next(void *, rtems_monitor_config_t *, rtems_id *);
429 void rtems_monitor_config_dump_header(bool);
430 int rtems_monitor_config_dump(rtems_monitor_config_t *, bool verbose);
431 
432 /* mpci.c */
433 #if defined(RTEMS_MULTIPROCESSING)
434 void rtems_monitor_mpci_canonical(rtems_monitor_mpci_t *, const void *);
435 const void *rtems_monitor_mpci_next(void *, rtems_monitor_mpci_t *, rtems_id *);
436 void rtems_monitor_mpci_dump_header(bool);
437 void rtems_monitor_mpci_dump(rtems_monitor_mpci_t *, bool verbose);
438 #endif
439 
440 /* itask.c */
441 void rtems_monitor_init_task_canonical(rtems_monitor_init_task_t *, const void *);
442 const void *rtems_monitor_init_task_next(void *, rtems_monitor_init_task_t *, rtems_id *);
443 void rtems_monitor_init_task_dump_header(bool);
444 void rtems_monitor_init_task_dump(rtems_monitor_init_task_t *, bool verbose);
445 
446 /* extension.c */
447 void rtems_monitor_extension_canonical(rtems_monitor_extension_t *, const void *);
448 void rtems_monitor_extension_dump_header(bool verbose);
449 void rtems_monitor_extension_dump(rtems_monitor_extension_t *, bool);
450 
451 /* task.c */
452 void rtems_monitor_task_canonical(rtems_monitor_task_t *, const void *);
453 void rtems_monitor_task_dump_header(bool verbose);
454 void rtems_monitor_task_dump(rtems_monitor_task_t *, bool);
455 
456 /* sema.c */
457 void rtems_monitor_sema_canonical(rtems_monitor_sema_t *, const void *);
458 void rtems_monitor_sema_dump_header(bool verbose);
459 void rtems_monitor_sema_dump(rtems_monitor_sema_t *, bool);
460 
461 /* queue.c */
462 void rtems_monitor_queue_canonical(rtems_monitor_queue_t *, const void *);
463 void rtems_monitor_queue_dump_header(bool verbose);
464 void rtems_monitor_queue_dump(rtems_monitor_queue_t *, bool);
465 
466 /* region.c */
467 void rtems_monitor_region_canonical(rtems_monitor_region_t *, const void *);
468 void rtems_monitor_region_dump_header(bool verbose);
469 void rtems_monitor_region_dump(rtems_monitor_region_t *, bool);
470 
471 /* partition.c */
472 void rtems_monitor_part_canonical(rtems_monitor_part_t *, const void *);
473 void rtems_monitor_part_dump_header(bool verbose);
474 void rtems_monitor_part_dump(rtems_monitor_part_t *, bool);
475 
476 /* driver.c */
477 const void *rtems_monitor_driver_next(void *, rtems_monitor_driver_t *, rtems_id *);
478 void rtems_monitor_driver_canonical(rtems_monitor_driver_t *, const void *);
479 void rtems_monitor_driver_dump_header(bool);
480 void rtems_monitor_driver_dump(rtems_monitor_driver_t *, bool);
481 
482 /* symbols.c */
483 rtems_symbol_table_t *rtems_symbol_table_create(void);
484 void 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);
488 const 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 *);
490 const void *rtems_monitor_symbol_next(void *object_info, rtems_monitor_symbol_t *, rtems_id *);
491 void rtems_monitor_symbol_canonical(rtems_monitor_symbol_t *, rtems_symbol_t *);
492 void rtems_monitor_symbol_canonical_by_name(rtems_monitor_symbol_t *, const char *);
493 void rtems_monitor_symbol_canonical_by_value(rtems_monitor_symbol_t *, void *);
494 uint32_t rtems_monitor_symbol_dump(rtems_monitor_symbol_t *, bool);
495 void rtems_monitor_symbol_cmd(int, char **, const rtems_monitor_command_arg_t*, bool);
496 
497 #if defined(RTEMS_NETWORKING)
498 void mon_ifconfig(
499  int argc,
500  char *argv[],
501  uint32_t command_arg,
502  bool verbose
503 );
504 void mon_route(
505  int argc,
506  char *argv[],
507  uint32_t command_arg,
508  bool verbose
509 );
510 #endif
511 
512 /* mon-object.c */
513 const rtems_monitor_object_info_t *rtems_monitor_object_lookup(
514  rtems_monitor_object_type_t type
515 );
516 
517 /* shared data */
518 extern 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 */
Definition: monitor.h:158
uint32_t rtems_attribute
Definition: attr.h:41
Definition: symbols.h:21
ssize_t read(int fd, void *buffer, size_t count)
Definition: read.c:27
Definition: monitor.h:92
Watchdog_Interval rtems_interval
Used to manage and manipulate intervals specified by clock ticks.
Definition: types.h:127
Definition: monitor.h:83
Thread entry information.
Definition: thread.h:131
uint32_t rtems_name
Classic API object name type.
Definition: types.h:77
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
ssize_t write(int fd, const void *buffer, size_t count)
Definition: write.c:30
Definition: monitor.h:295
RTEMS Error Reporting.
Definition: monitor.h:144
Definition: monitor.h:77
rtems_status_code
Classic API Status.
Definition: status.h:43
void rtems_monitor_command_iterate(rtems_monitor_per_command_routine routine, void *arg)
Iterates through all registerd commands.
Definition: mon-monitor.c:485
struct rtems_bsdnet_ifconfig * config
Network driver configuration.
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
Definition: monitor.h:131
Definition: monitor.h:307
Definition: monitor.h:357
Definition: intercom.c:74
Definition: symbols.h:32
uint32_t States_Control
Definition: states.h:41
Definition: monitor.h:175
Definition: monitor.h:205
Definition: monitor.h:334
Definition: monitor.h:190
CPU_Uint32ptr rtems_task_argument
Definition: tasks.h:105
#define OBJECTS_RTEMS_CLASSES_LAST
Definition: objectimpl.h:50
Objects_Id rtems_id
Used to manage and manipulate RTEMS object identifiers.
Definition: types.h:83
Definition: mmu-config.c:39
int open(const char *path, int oflag,...)
Definition: open.c:153
Inlined Routines in the Object Handler.
Definition: monitor.h:115
Definition: monitor.h:263
uint32_t rtems_mode
Definition: modes.h:41
Definition: monitor.h:341
Definition: monitor.h:221
uint32_t rtems_task_priority
Definition: tasks.h:54