source: rtems/c/src/libmisc/monitor/mon-driver.c @ e642446

4.104.114.84.95
Last change on this file since e642446 was e642446, checked in by Joel Sherrill <joel.sherrill@…>, on Mar 6, 1996 at 9:37:43 PM

As part of reducing visibility into rtems and hiding the .inl files
from the application code, this file required more visibility than
is given by default to application code.

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