source: rtems/cpukit/libmisc/monitor/mon-dname.c @ a29d2e7

4.104.114.84.95
Last change on this file since a29d2e7 was 714f06c, checked in by Ralf Corsepius <ralf.corsepius@…>, on 04/17/04 at 08:12:02

2004-04-17 Ralf Corsepius <ralf_corsepius@…>

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