[b06e68ef] | 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 | |
---|
| 36 | void |
---|
| 37 | rtems_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 | |
---|
| 49 | void * |
---|
| 50 | rtems_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 | |
---|
[3a4ae6c] | 60 | /* XXX should we be using _IO_Number_of_devices */ |
---|
| 61 | for (np = table + n ; n<_IO_Number_of_devices; n++, np++) |
---|
[b06e68ef] | 62 | if (np->device_name) |
---|
| 63 | goto done; |
---|
| 64 | |
---|
| 65 | *next_id = RTEMS_OBJECT_ID_FINAL; |
---|
| 66 | return 0; |
---|
| 67 | |
---|
| 68 | done: |
---|
| 69 | _Thread_Disable_dispatch(); |
---|
| 70 | |
---|
| 71 | /* |
---|
| 72 | * dummy up a fake id and name for this item |
---|
| 73 | */ |
---|
| 74 | |
---|
| 75 | canonical_dname->id = n; |
---|
| 76 | canonical_dname->name = rtems_build_name('-', '-', '-', '-'); |
---|
| 77 | |
---|
| 78 | *next_id += 1; |
---|
| 79 | return np; |
---|
| 80 | } |
---|
| 81 | |
---|
| 82 | void |
---|
| 83 | rtems_monitor_dname_dump_header( |
---|
| 84 | boolean verbose |
---|
| 85 | ) |
---|
| 86 | { |
---|
| 87 | printf("\ |
---|
| 88 | Major:Minor Name\n"); |
---|
| 89 | /*23456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 |
---|
| 90 | 0 1 2 3 4 5 6 7 */ |
---|
| 91 | rtems_monitor_separator(); |
---|
| 92 | } |
---|
| 93 | |
---|
| 94 | void |
---|
| 95 | rtems_monitor_dname_dump( |
---|
| 96 | rtems_monitor_dname_t *monitor_dname, |
---|
| 97 | boolean verbose |
---|
| 98 | ) |
---|
| 99 | { |
---|
| 100 | unsigned32 length = 0; |
---|
| 101 | |
---|
| 102 | length += rtems_monitor_pad(6, length); |
---|
| 103 | length += rtems_monitor_dump_hex(monitor_dname->major); |
---|
| 104 | length += printf(":"); |
---|
| 105 | length += rtems_monitor_dump_hex(monitor_dname->minor); |
---|
| 106 | |
---|
| 107 | length += rtems_monitor_pad(16, length); |
---|
| 108 | length += printf("%.*s", |
---|
| 109 | (int) sizeof(monitor_dname->name_string), |
---|
| 110 | (char *) monitor_dname->name_string); |
---|
| 111 | |
---|
| 112 | length += printf("\n"); |
---|
| 113 | length = 0; |
---|
| 114 | } |
---|