1 | /* SPDX-License-Identifier: BSD-2-Clause */ |
---|
2 | |
---|
3 | /** |
---|
4 | * @file |
---|
5 | * |
---|
6 | * @brief RTEMS monitor IO (device drivers) support |
---|
7 | * |
---|
8 | * There are 2 "driver" things the monitor knows about. |
---|
9 | * |
---|
10 | * 1. Regular RTEMS drivers. |
---|
11 | * This is a table indexed by major device number and |
---|
12 | * containing driver entry points only. |
---|
13 | * |
---|
14 | * 2. Driver name table. |
---|
15 | * A separate table of names for drivers. |
---|
16 | * The table converts driver names to a major number |
---|
17 | * as index into the driver table and a minor number |
---|
18 | * for an argument to driver. |
---|
19 | * |
---|
20 | * Drivers are displayed with 'driver' command. |
---|
21 | * Names are displayed with 'name' command. |
---|
22 | */ |
---|
23 | |
---|
24 | /* |
---|
25 | * COPYRIGHT (c) 1989-2022. On-Line Applications Research Corporation (OAR). |
---|
26 | * |
---|
27 | * Redistribution and use in source and binary forms, with or without |
---|
28 | * modification, are permitted provided that the following conditions |
---|
29 | * are met: |
---|
30 | * 1. Redistributions of source code must retain the above copyright |
---|
31 | * notice, this list of conditions and the following disclaimer. |
---|
32 | * 2. Redistributions in binary form must reproduce the above copyright |
---|
33 | * notice, this list of conditions and the following disclaimer in the |
---|
34 | * documentation and/or other materials provided with the distribution. |
---|
35 | * |
---|
36 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
37 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
38 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
39 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
---|
40 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
41 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
42 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
43 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
44 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
45 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
---|
46 | * POSSIBILITY OF SUCH DAMAGE. |
---|
47 | */ |
---|
48 | |
---|
49 | #ifdef HAVE_CONFIG_H |
---|
50 | #include "config.h" |
---|
51 | #endif |
---|
52 | |
---|
53 | #include <rtems.h> |
---|
54 | #include <rtems/ioimpl.h> |
---|
55 | #include <rtems/monitor.h> |
---|
56 | |
---|
57 | #include <stdio.h> |
---|
58 | #include <stdlib.h> /* strtoul() */ |
---|
59 | #include <inttypes.h> |
---|
60 | |
---|
61 | #define DATACOL 15 |
---|
62 | #define CONTCOL DATACOL /* continued col */ |
---|
63 | |
---|
64 | |
---|
65 | void |
---|
66 | rtems_monitor_driver_canonical( |
---|
67 | rtems_monitor_driver_t *canonical_driver, |
---|
68 | const void *driver_void |
---|
69 | ) |
---|
70 | { |
---|
71 | const rtems_driver_address_table *d = (const rtems_driver_address_table *) driver_void; |
---|
72 | |
---|
73 | rtems_monitor_symbol_canonical_by_value(&canonical_driver->initialization, |
---|
74 | (void *) d->initialization_entry); |
---|
75 | |
---|
76 | rtems_monitor_symbol_canonical_by_value(&canonical_driver->open, |
---|
77 | (void *) d->open_entry); |
---|
78 | rtems_monitor_symbol_canonical_by_value(&canonical_driver->close, |
---|
79 | (void *) d->close_entry); |
---|
80 | rtems_monitor_symbol_canonical_by_value(&canonical_driver->read, |
---|
81 | (void *) d->read_entry); |
---|
82 | rtems_monitor_symbol_canonical_by_value(&canonical_driver->write, |
---|
83 | (void *) d->write_entry); |
---|
84 | rtems_monitor_symbol_canonical_by_value(&canonical_driver->control, |
---|
85 | (void *) d->control_entry); |
---|
86 | } |
---|
87 | |
---|
88 | |
---|
89 | const void * |
---|
90 | rtems_monitor_driver_next( |
---|
91 | void *object_info RTEMS_UNUSED, |
---|
92 | rtems_monitor_driver_t *canonical_driver, |
---|
93 | rtems_id *next_id |
---|
94 | ) |
---|
95 | { |
---|
96 | uint32_t n = rtems_object_id_get_index(*next_id); |
---|
97 | |
---|
98 | if (n >= _IO_Number_of_drivers) |
---|
99 | goto failed; |
---|
100 | |
---|
101 | _Objects_Allocator_lock(); |
---|
102 | |
---|
103 | /* |
---|
104 | * dummy up a fake id and name for this item |
---|
105 | */ |
---|
106 | |
---|
107 | canonical_driver->id = n; |
---|
108 | canonical_driver->name = rtems_build_name('-', '-', '-', '-'); |
---|
109 | |
---|
110 | *next_id += 1; |
---|
111 | return (const void *) (&_IO_Driver_address_table[n]); |
---|
112 | |
---|
113 | failed: |
---|
114 | *next_id = RTEMS_OBJECT_ID_FINAL; |
---|
115 | return 0; |
---|
116 | } |
---|
117 | |
---|
118 | |
---|
119 | void |
---|
120 | rtems_monitor_driver_dump_header( |
---|
121 | bool verbose RTEMS_UNUSED |
---|
122 | ) |
---|
123 | { |
---|
124 | fprintf(stdout,"\ |
---|
125 | Major Entry points\n"); |
---|
126 | /*23456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 |
---|
127 | 0 1 2 3 4 5 6 7 */ |
---|
128 | rtems_monitor_separator(); |
---|
129 | } |
---|
130 | |
---|
131 | void |
---|
132 | rtems_monitor_driver_dump( |
---|
133 | rtems_monitor_driver_t *monitor_driver, |
---|
134 | bool verbose |
---|
135 | ) |
---|
136 | { |
---|
137 | uint32_t length = 0; |
---|
138 | |
---|
139 | length += fprintf(stdout," %" PRId32 "", monitor_driver->id); |
---|
140 | length += rtems_monitor_pad(13, length); |
---|
141 | length += fprintf(stdout,"init: "); |
---|
142 | length += rtems_monitor_symbol_dump(&monitor_driver->initialization, verbose); |
---|
143 | length += fprintf(stdout,"; control: "); |
---|
144 | length += rtems_monitor_symbol_dump(&monitor_driver->control, verbose); |
---|
145 | length += fprintf(stdout,"\n"); |
---|
146 | length = 0; |
---|
147 | |
---|
148 | length += rtems_monitor_pad(13, length); |
---|
149 | |
---|
150 | length += fprintf(stdout,"open: "); |
---|
151 | length += rtems_monitor_symbol_dump(&monitor_driver->open, verbose); |
---|
152 | length += fprintf(stdout,"; close: "); |
---|
153 | length += rtems_monitor_symbol_dump(&monitor_driver->close, verbose); |
---|
154 | length += fprintf(stdout,"\n"); |
---|
155 | length = 0; |
---|
156 | |
---|
157 | length += rtems_monitor_pad(13, length); |
---|
158 | |
---|
159 | length += fprintf(stdout,"read: "); |
---|
160 | length += rtems_monitor_symbol_dump(&monitor_driver->read, verbose); |
---|
161 | length += fprintf(stdout,"; write: "); |
---|
162 | length += rtems_monitor_symbol_dump(&monitor_driver->write, verbose); |
---|
163 | length += fprintf(stdout,"\n"); |
---|
164 | length = 0; |
---|
165 | } |
---|