1 | /* |
---|
2 | * RTEMS monitor IO (device drivers) support |
---|
3 | * |
---|
4 | * There are 2 "driver" things the monitor knows about. |
---|
5 | * |
---|
6 | * 1. Regular RTEMS drivers. |
---|
7 | * This is a table indexed by major device number and |
---|
8 | * containing driver entry points only. |
---|
9 | * |
---|
10 | * 2. Driver name table. |
---|
11 | * A separate table of names for drivers. |
---|
12 | * The table converts driver names to a major number |
---|
13 | * as index into the driver table and a minor number |
---|
14 | * for an argument to driver. |
---|
15 | * |
---|
16 | * Drivers are displayed with 'driver' command. |
---|
17 | * Names are displayed with 'name' command. |
---|
18 | * |
---|
19 | * $Id$ |
---|
20 | */ |
---|
21 | |
---|
22 | #ifdef HAVE_CONFIG_H |
---|
23 | #include "config.h" |
---|
24 | #endif |
---|
25 | |
---|
26 | #define __RTEMS_VIOLATE_KERNEL_VISIBILITY__ |
---|
27 | #include <rtems.h> |
---|
28 | |
---|
29 | #include <rtems/monitor.h> |
---|
30 | |
---|
31 | #include <stdio.h> |
---|
32 | #include <stdlib.h> /* strtoul() */ |
---|
33 | |
---|
34 | #define DATACOL 15 |
---|
35 | #define CONTCOL DATACOL /* continued col */ |
---|
36 | |
---|
37 | |
---|
38 | void |
---|
39 | rtems_monitor_driver_canonical( |
---|
40 | rtems_monitor_driver_t *canonical_driver, |
---|
41 | void *driver_void |
---|
42 | ) |
---|
43 | { |
---|
44 | rtems_driver_address_table *d = (rtems_driver_address_table *) driver_void; |
---|
45 | |
---|
46 | rtems_monitor_symbol_canonical_by_value(&canonical_driver->initialization, |
---|
47 | (void *) d->initialization_entry); |
---|
48 | |
---|
49 | rtems_monitor_symbol_canonical_by_value(&canonical_driver->open, |
---|
50 | (void *) d->open_entry); |
---|
51 | rtems_monitor_symbol_canonical_by_value(&canonical_driver->close, |
---|
52 | (void *) d->close_entry); |
---|
53 | rtems_monitor_symbol_canonical_by_value(&canonical_driver->read, |
---|
54 | (void *) d->read_entry); |
---|
55 | rtems_monitor_symbol_canonical_by_value(&canonical_driver->write, |
---|
56 | (void *) d->write_entry); |
---|
57 | rtems_monitor_symbol_canonical_by_value(&canonical_driver->control, |
---|
58 | (void *) d->control_entry); |
---|
59 | } |
---|
60 | |
---|
61 | |
---|
62 | void * |
---|
63 | rtems_monitor_driver_next( |
---|
64 | void *object_info, |
---|
65 | rtems_monitor_driver_t *canonical_driver, |
---|
66 | rtems_id *next_id |
---|
67 | ) |
---|
68 | { |
---|
69 | rtems_configuration_table *c = _Configuration_Table; |
---|
70 | uint32_t n = rtems_get_index(*next_id); |
---|
71 | |
---|
72 | if (n >= c->number_of_device_drivers) |
---|
73 | goto failed; |
---|
74 | |
---|
75 | _Thread_Disable_dispatch(); |
---|
76 | |
---|
77 | /* |
---|
78 | * dummy up a fake id and name for this item |
---|
79 | */ |
---|
80 | |
---|
81 | canonical_driver->id = n; |
---|
82 | canonical_driver->name = rtems_build_name('-', '-', '-', '-'); |
---|
83 | |
---|
84 | *next_id += 1; |
---|
85 | return (void *) (c->Device_driver_table + n); |
---|
86 | |
---|
87 | failed: |
---|
88 | *next_id = RTEMS_OBJECT_ID_FINAL; |
---|
89 | return 0; |
---|
90 | } |
---|
91 | |
---|
92 | |
---|
93 | void |
---|
94 | rtems_monitor_driver_dump_header( |
---|
95 | boolean verbose |
---|
96 | ) |
---|
97 | { |
---|
98 | fprintf(stdout,"\ |
---|
99 | Major Entry points\n"); |
---|
100 | /*23456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 |
---|
101 | 0 1 2 3 4 5 6 7 */ |
---|
102 | rtems_monitor_separator(); |
---|
103 | } |
---|
104 | |
---|
105 | void |
---|
106 | rtems_monitor_driver_dump( |
---|
107 | rtems_monitor_driver_t *monitor_driver, |
---|
108 | boolean verbose |
---|
109 | ) |
---|
110 | { |
---|
111 | uint32_t length = 0; |
---|
112 | |
---|
113 | length += fprintf(stdout," %d", monitor_driver->id); |
---|
114 | |
---|
115 | length += rtems_monitor_pad(13, length); |
---|
116 | length += fprintf(stdout,"init: "); |
---|
117 | length += rtems_monitor_symbol_dump(&monitor_driver->initialization, verbose); |
---|
118 | length += fprintf(stdout,"; control: "); |
---|
119 | length += rtems_monitor_symbol_dump(&monitor_driver->control, verbose); |
---|
120 | length += fprintf(stdout,"\n"); |
---|
121 | length = 0; |
---|
122 | |
---|
123 | length += rtems_monitor_pad(13, length); |
---|
124 | |
---|
125 | length += fprintf(stdout,"open: "); |
---|
126 | length += rtems_monitor_symbol_dump(&monitor_driver->open, verbose); |
---|
127 | length += fprintf(stdout,"; close: "); |
---|
128 | length += rtems_monitor_symbol_dump(&monitor_driver->close, verbose); |
---|
129 | length += fprintf(stdout,"\n"); |
---|
130 | length = 0; |
---|
131 | |
---|
132 | length += rtems_monitor_pad(13, length); |
---|
133 | |
---|
134 | length += fprintf(stdout,"read: "); |
---|
135 | length += rtems_monitor_symbol_dump(&monitor_driver->read, verbose); |
---|
136 | length += fprintf(stdout,"; write: "); |
---|
137 | length += rtems_monitor_symbol_dump(&monitor_driver->write, verbose); |
---|
138 | length += fprintf(stdout,"\n"); |
---|
139 | length = 0; |
---|
140 | } |
---|