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