source: rtems/cpukit/libmisc/monitor/mon-driver.c @ f97536d

5
Last change on this file since f97536d was f97536d, checked in by Sebastian Huber <sebastian.huber@…>, on 10/16/15 at 06:21:48

basdefs.h: Add and use RTEMS_UNUSED

  • Property mode set to 100644
File size: 4.1 KB
Line 
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
20#ifdef HAVE_CONFIG_H
21#include "config.h"
22#endif
23
24#include <rtems.h>
25#include <rtems/monitor.h>
26
27#include <stdio.h>
28#include <stdlib.h>             /* strtoul() */
29#include <inttypes.h>
30
31#define DATACOL 15
32#define CONTCOL DATACOL         /* continued col */
33
34
35void
36rtems_monitor_driver_canonical(
37    rtems_monitor_driver_t *canonical_driver,
38    const void             *driver_void
39)
40{
41    const rtems_driver_address_table *d = (const rtems_driver_address_table *) driver_void;
42
43    rtems_monitor_symbol_canonical_by_value(&canonical_driver->initialization,
44                                            (void *) d->initialization_entry);
45
46    rtems_monitor_symbol_canonical_by_value(&canonical_driver->open,
47                                            (void *) d->open_entry);
48    rtems_monitor_symbol_canonical_by_value(&canonical_driver->close,
49                                            (void *) d->close_entry);
50    rtems_monitor_symbol_canonical_by_value(&canonical_driver->read,
51                                            (void *) d->read_entry);
52    rtems_monitor_symbol_canonical_by_value(&canonical_driver->write,
53                                            (void *) d->write_entry);
54    rtems_monitor_symbol_canonical_by_value(&canonical_driver->control,
55                                            (void *) d->control_entry);
56}
57
58
59const void *
60rtems_monitor_driver_next(
61    void                  *object_info RTEMS_UNUSED,
62    rtems_monitor_driver_t *canonical_driver,
63    rtems_id              *next_id
64)
65{
66    uint32_t   n = rtems_object_id_get_index(*next_id);
67
68    if (n >= _IO_Number_of_drivers)
69        goto failed;
70
71    _Thread_Disable_dispatch();
72
73    /*
74     * dummy up a fake id and name for this item
75     */
76
77    canonical_driver->id = n;
78    canonical_driver->name = rtems_build_name('-', '-', '-', '-');
79
80    *next_id += 1;
81    return (const void *) (&_IO_Driver_address_table[n]);
82
83failed:
84    *next_id = RTEMS_OBJECT_ID_FINAL;
85    return 0;
86}
87
88
89void
90rtems_monitor_driver_dump_header(
91    bool verbose RTEMS_UNUSED
92)
93{
94    fprintf(stdout,"\
95  Major      Entry points\n");
96/*23456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
970         1         2         3         4         5         6         7       */
98    rtems_monitor_separator();
99}
100
101void
102rtems_monitor_driver_dump(
103    rtems_monitor_driver_t *monitor_driver,
104    bool                    verbose
105)
106{
107    uint32_t            length = 0;
108
109#if defined(RTEMS_USE_16_BIT_OBJECT)
110    length += fprintf(stdout,"  %" PRId16 "", monitor_driver->id);
111#else
112    length += fprintf(stdout,"  %" PRId32 "", monitor_driver->id);
113#endif
114    length += rtems_monitor_pad(13, length);
115    length += fprintf(stdout,"init: ");
116    length += rtems_monitor_symbol_dump(&monitor_driver->initialization, verbose);
117    length += fprintf(stdout,";  control: ");
118    length += rtems_monitor_symbol_dump(&monitor_driver->control, verbose);
119    length += fprintf(stdout,"\n");
120    length = 0;
121
122    length += rtems_monitor_pad(13, length);
123
124    length += fprintf(stdout,"open: ");
125    length += rtems_monitor_symbol_dump(&monitor_driver->open, verbose);
126    length += fprintf(stdout,";  close: ");
127    length += rtems_monitor_symbol_dump(&monitor_driver->close, verbose);
128    length += fprintf(stdout,"\n");
129    length = 0;
130
131    length += rtems_monitor_pad(13, length);
132
133    length += fprintf(stdout,"read: ");
134    length += rtems_monitor_symbol_dump(&monitor_driver->read, verbose);
135    length += fprintf(stdout,";  write: ");
136    length += rtems_monitor_symbol_dump(&monitor_driver->write, verbose);
137    length += fprintf(stdout,"\n");
138    length = 0;
139}
Note: See TracBrowser for help on using the repository browser.