source: rtems/c/src/lib/libmisc/monitor/mon-dname.c @ 72c440e

4.104.114.84.95
Last change on this file since 72c440e was 72c440e, checked in by Joel Sherrill <joel.sherrill@…>, on 01/17/96 at 20:13:45

Update from Tony Bennett (tbennett@…)

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