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

4.115
Last change on this file since 037cfd1 was ae75429, checked in by Sebastian Huber <sebastian.huber@…>, on 08/06/13 at 14:10:26

PR766: Delete RTEMS_VIOLATE_KERNEL_VISIBILITY

  • Property mode set to 100644
File size: 4.2 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 __attribute__((unused)),
62    rtems_monitor_driver_t *canonical_driver,
63    rtems_id              *next_id
64)
65{
66    const rtems_configuration_table *c = &Configuration;
67    uint32_t   n = rtems_object_id_get_index(*next_id);
68
69    if (n >= c->number_of_device_drivers)
70        goto failed;
71
72    _Thread_Disable_dispatch();
73
74    /*
75     * dummy up a fake id and name for this item
76     */
77
78    canonical_driver->id = n;
79    canonical_driver->name = rtems_build_name('-', '-', '-', '-');
80
81    *next_id += 1;
82    return (const void *) (c->Device_driver_table + n);
83
84failed:
85    *next_id = RTEMS_OBJECT_ID_FINAL;
86    return 0;
87}
88
89
90void
91rtems_monitor_driver_dump_header(
92    bool verbose __attribute__((unused))
93)
94{
95    fprintf(stdout,"\
96  Major      Entry points\n");
97/*23456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
980         1         2         3         4         5         6         7       */
99    rtems_monitor_separator();
100}
101
102void
103rtems_monitor_driver_dump(
104    rtems_monitor_driver_t *monitor_driver,
105    bool                    verbose
106)
107{
108    uint32_t            length = 0;
109
110#if defined(RTEMS_USE_16_BIT_OBJECT)
111    length += fprintf(stdout,"  %" PRId16 "", monitor_driver->id);
112#else
113    length += fprintf(stdout,"  %" PRId32 "", monitor_driver->id);
114#endif
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}
Note: See TracBrowser for help on using the repository browser.