source: rtems/c/src/lib/libmisc/monitor/mon-dname.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: 2.9 KB
Line 
1/*
2 *      @(#)dname.c     1.5 - 96/01/03
3 *     
4 *
5 * RTEMS monitor driver names 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 'dname' 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#include <string.h>             /* strncpy() */
33
34#define DATACOL 15
35#define CONTCOL DATACOL         /* continued col */
36
37void
38rtems_monitor_dname_canonical(
39    rtems_monitor_dname_t  *canonical_dname,
40    void                  *dname_void
41)
42{
43    rtems_driver_name_t    *np = (rtems_driver_name_t *) dname_void;
44
45    (void) strncpy(canonical_dname->name_string, np->device_name, sizeof(canonical_dname->name_string));
46    canonical_dname->major = np->major;
47    canonical_dname->minor = np->minor;
48}   
49
50void *
51rtems_monitor_dname_next(
52    void                   *object_information,
53    rtems_monitor_dname_t  *canonical_dname,
54    rtems_id               *next_id
55)
56{
57    int n = rtems_get_index(*next_id);
58    rtems_driver_name_t    *table = _IO_Driver_name_table;
59    rtems_driver_name_t    *np = 0;
60
61/* XXX should we be using _IO_Number_of_devices */
62    for (np = table + n ; n<_IO_Number_of_devices; n++, np++)
63        if (np->device_name)
64            goto done;
65   
66    *next_id = RTEMS_OBJECT_ID_FINAL;
67    return 0;
68
69done:
70    _Thread_Disable_dispatch();
71
72    /*
73     * dummy up a fake id and name for this item
74     */
75
76    canonical_dname->id = n;
77    canonical_dname->name = rtems_build_name('-', '-', '-', '-');
78
79    *next_id += 1;
80    return np;
81}   
82
83void
84rtems_monitor_dname_dump_header(
85    boolean verbose
86)
87{
88    printf("\
89  Major:Minor   Name\n");
90/*23456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
910         1         2         3         4         5         6         7       */
92    rtems_monitor_separator();
93}
94
95void
96rtems_monitor_dname_dump(
97    rtems_monitor_dname_t *monitor_dname,
98    boolean                 verbose
99)
100{
101    unsigned32             length = 0;
102
103    length += rtems_monitor_pad(6, length);
104    length += rtems_monitor_dump_hex(monitor_dname->major);
105    length += printf(":");
106    length += rtems_monitor_dump_hex(monitor_dname->minor);
107
108    length += rtems_monitor_pad(16, length);
109    length += printf("%.*s",
110                     (int) sizeof(monitor_dname->name_string),
111                     (char *) monitor_dname->name_string);
112
113    length += printf("\n");
114    length = 0;
115}
Note: See TracBrowser for help on using the repository browser.