source: rtems/c/src/libmisc/monitor/mon-dname.c @ 48bfd992

4.104.114.84.95
Last change on this file since 48bfd992 was a18ccfe, checked in by Joel Sherrill <joel.sherrill@…>, on 10/21/97 at 18:39:49

Fixed a number of warnings regarding comparisons between signed and
unsigned numbers.

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