source: rtems/cpukit/libmisc/monitor/mon-driver.c @ df91dd9

Last change on this file since df91dd9 was df91dd9, checked in by Sebastian Huber <sebastian.huber@…>, on Mar 14, 2016 at 11:31:12 AM

monitor: Use object allocator lock

Use object allocator lock instead of disabled thread dispatching.

Update #2555.

  • Property mode set to 100644
File size: 4.1 KB
Line 
1/*
2 * RTEMS monitor IO (device drivers) 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 'name' command.
18 */
19
20#ifdef HAVE_CONFIG_H
21#include "config.h"
22#endif
23
24#include <rtems.h>
25#include <rtems/ioimpl.h>
26#include <rtems/monitor.h>
27
28#include <stdio.h>
29#include <stdlib.h>             /* strtoul() */
30#include <inttypes.h>
31
32#define DATACOL 15
33#define CONTCOL DATACOL         /* continued col */
34
35
36void
37rtems_monitor_driver_canonical(
38    rtems_monitor_driver_t *canonical_driver,
39    const void             *driver_void
40)
41{
42    const rtems_driver_address_table *d = (const rtems_driver_address_table *) driver_void;
43
44    rtems_monitor_symbol_canonical_by_value(&canonical_driver->initialization,
45                                            (void *) d->initialization_entry);
46
47    rtems_monitor_symbol_canonical_by_value(&canonical_driver->open,
48                                            (void *) d->open_entry);
49    rtems_monitor_symbol_canonical_by_value(&canonical_driver->close,
50                                            (void *) d->close_entry);
51    rtems_monitor_symbol_canonical_by_value(&canonical_driver->read,
52                                            (void *) d->read_entry);
53    rtems_monitor_symbol_canonical_by_value(&canonical_driver->write,
54                                            (void *) d->write_entry);
55    rtems_monitor_symbol_canonical_by_value(&canonical_driver->control,
56                                            (void *) d->control_entry);
57}
58
59
60const void *
61rtems_monitor_driver_next(
62    void                  *object_info RTEMS_UNUSED,
63    rtems_monitor_driver_t *canonical_driver,
64    rtems_id              *next_id
65)
66{
67    uint32_t   n = rtems_object_id_get_index(*next_id);
68
69    if (n >= _IO_Number_of_drivers)
70        goto failed;
71
72    _Objects_Allocator_lock();
73
74    /*
75     * dummy up a fake id and name for this item
76     */
77
78    canonical_driver->id = n;
79    canonical_driver->name = rtems_build_name('-', '-', '-', '-');
80
81    *next_id += 1;
82    return (const void *) (&_IO_Driver_address_table[n]);
83
84failed:
85    *next_id = RTEMS_OBJECT_ID_FINAL;
86    return 0;
87}
88
89
90void
91rtems_monitor_driver_dump_header(
92    bool verbose RTEMS_UNUSED
93)
94{
95    fprintf(stdout,"\
96  Major      Entry points\n");
97/*23456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
980         1         2         3         4         5         6         7       */
99    rtems_monitor_separator();
100}
101
102void
103rtems_monitor_driver_dump(
104    rtems_monitor_driver_t *monitor_driver,
105    bool                    verbose
106)
107{
108    uint32_t            length = 0;
109
110#if defined(RTEMS_USE_16_BIT_OBJECT)
111    length += fprintf(stdout,"  %" PRId16 "", monitor_driver->id);
112#else
113    length += fprintf(stdout,"  %" PRId32 "", monitor_driver->id);
114#endif
115    length += rtems_monitor_pad(13, length);
116    length += fprintf(stdout,"init: ");
117    length += rtems_monitor_symbol_dump(&monitor_driver->initialization, verbose);
118    length += fprintf(stdout,";  control: ");
119    length += rtems_monitor_symbol_dump(&monitor_driver->control, verbose);
120    length += fprintf(stdout,"\n");
121    length = 0;
122
123    length += rtems_monitor_pad(13, length);
124
125    length += fprintf(stdout,"open: ");
126    length += rtems_monitor_symbol_dump(&monitor_driver->open, verbose);
127    length += fprintf(stdout,";  close: ");
128    length += rtems_monitor_symbol_dump(&monitor_driver->close, verbose);
129    length += fprintf(stdout,"\n");
130    length = 0;
131
132    length += rtems_monitor_pad(13, length);
133
134    length += fprintf(stdout,"read: ");
135    length += rtems_monitor_symbol_dump(&monitor_driver->read, verbose);
136    length += fprintf(stdout,";  write: ");
137    length += rtems_monitor_symbol_dump(&monitor_driver->write, verbose);
138    length += fprintf(stdout,"\n");
139    length = 0;
140}
Note: See TracBrowser for help on using the repository browser.