source: rtems/c/src/lib/libmisc/monitor/mon-dname.c @ 7f6a24ab

4.104.114.84.95
Last change on this file since 7f6a24ab was b06e68ef, checked in by Joel Sherrill <joel.sherrill@…>, on 08/17/95 at 19:51:51

Numerous miscellaneous features incorporated from Tony Bennett
(tbennett@…) including the following major additions:

+ variable length messages
+ named devices
+ debug monitor
+ association tables/variables

  • Property mode set to 100644
File size: 2.8 KB
Line 
1/*
2 *      @(#)dname.c     1.3 - 95/07/31
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 = object_information;
58    rtems_driver_name_t    *np = 0;
59
60    for (np = table + n ; n<RTEMS_MAX_DRIVER_NAMES; n++, np++)
61        if (np->device_name)
62            goto done;
63   
64    *next_id = RTEMS_OBJECT_ID_FINAL;
65    return 0;
66
67done:
68    _Thread_Disable_dispatch();
69
70    /*
71     * dummy up a fake id and name for this item
72     */
73
74    canonical_dname->id = n;
75    canonical_dname->name = rtems_build_name('-', '-', '-', '-');
76
77    *next_id += 1;
78    return np;
79}   
80
81void
82rtems_monitor_dname_dump_header(
83    boolean verbose
84)
85{
86    printf("\
87  Major:Minor   Name\n");
88/*23456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
890         1         2         3         4         5         6         7       */
90    rtems_monitor_separator();
91}
92
93void
94rtems_monitor_dname_dump(
95    rtems_monitor_dname_t *monitor_dname,
96    boolean                 verbose
97)
98{
99    unsigned32             length = 0;
100
101    length += rtems_monitor_pad(6, length);
102    length += rtems_monitor_dump_hex(monitor_dname->major);
103    length += printf(":");
104    length += rtems_monitor_dump_hex(monitor_dname->minor);
105
106    length += rtems_monitor_pad(16, length);
107    length += printf("%.*s",
108                     (int) sizeof(monitor_dname->name_string),
109                     (char *) monitor_dname->name_string);
110
111    length += printf("\n");
112    length = 0;
113}
Note: See TracBrowser for help on using the repository browser.