OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [c/] [src/] [libmisc/] [monitor/] [mon-dname.c] - Blame information for rev 1026

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
/*
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
 *  mon-dname.c,v 1.8 1997/10/21 18:39:47 joel Exp
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
 
34
void
35
rtems_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
 
47
void *
48
rtems_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
 
66
done:
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
 
80
void
81
rtems_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
88
 
89
    rtems_monitor_separator();
90
}
91
 
92
void
93
rtems_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
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.