diff options
author | phk <phk@FreeBSD.org> | 1996-09-06 23:05:22 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1996-09-06 23:05:22 +0000 |
commit | 7d0d2d16096666a4387a4aa045b9246750336729 (patch) | |
tree | 35d30f5c026ae8ac98a87c7934515e548919cbf5 /usr.sbin | |
parent | 39220f3d9a3cfb8ce818fe3ccac085cf41f53546 (diff) | |
download | FreeBSD-src-7d0d2d16096666a4387a4aa045b9246750336729.zip FreeBSD-src-7d0d2d16096666a4387a4aa045b9246750336729.tar.gz |
Remove lsdev. Devconf never grew up.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/lsdev/Makefile | 8 | ||||
-rw-r--r-- | usr.sbin/lsdev/i386.c | 253 | ||||
-rw-r--r-- | usr.sbin/lsdev/lsdev.8 | 65 | ||||
-rw-r--r-- | usr.sbin/lsdev/lsdev.c | 227 | ||||
-rw-r--r-- | usr.sbin/lsdev/lsdev.h | 14 |
5 files changed, 0 insertions, 567 deletions
diff --git a/usr.sbin/lsdev/Makefile b/usr.sbin/lsdev/Makefile deleted file mode 100644 index 061a86f..0000000 --- a/usr.sbin/lsdev/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -# $Id$ - -PROG= lsdev -MAN8= lsdev.8 -SRCS= lsdev.c ${MACHINE}.c -CFLAGS+= -I${.CURDIR}/../../sys - -.include <bsd.prog.mk> diff --git a/usr.sbin/lsdev/i386.c b/usr.sbin/lsdev/i386.c deleted file mode 100644 index 6aeeb17..0000000 --- a/usr.sbin/lsdev/i386.c +++ /dev/null @@ -1,253 +0,0 @@ -/* - * This file written by Garrett A. Wollman is in the public domain. - */ -#include <sys/param.h> -#include <sys/devconf.h> - -#include <pci/pcivar.h> -#include <pci/pcireg.h> - -#include <scsi/scsiconf.h> - -#include <vm/vm.h> -#include <vm/vm_param.h> -#include <vm/pmap.h> - -#include <i386/isa/isa_device.h> -#include <i386/eisa/eisaconf.h> - -#include <stdio.h> -#include <string.h> - -#include "lsdev.h" - -static void print_isa(struct devconf *); -static void print_eisa(struct devconf *); -static void print_pci(struct devconf *); -static void print_scsi(struct devconf *); -static void print_disk(struct devconf *); - -void -hprint_config(void) -{ - printf("# This listing automatically generated by lsdev(1)\n"); -} - -void -print_config(struct devconf *dc) -{ - if(vflag) - printf("%d: ", dc->dc_number); - - switch(dc->dc_devtype) { - case MDDT_CPU: - printf("# CPU %s%d", dc->dc_name, dc->dc_unit); - break; - case MDDT_BUS: - printf("controller %s%d", dc->dc_name, dc->dc_unit); - break; - case MDDT_ISA: - if(dc->dc_datalen >= ISA_EXTERNALLEN) { - print_isa(dc); - } else { -printit: - printf("%s%d at %s%d", - dc->dc_name, dc->dc_unit, dc->dc_pname, - dc->dc_punit); - } - break; - case MDDT_EISA: - if(dc->dc_datalen >= EISA_EXTERNALLEN) { - print_eisa(dc); - } else { - goto printit; - } - break; - case MDDT_PCI: - if(dc->dc_datalen >= PCI_EXTERNAL_LEN) { - print_pci(dc); - } else { - goto printit; - } - break; - case MDDT_SCSI: - if(dc->dc_datalen >= SCSI_EXTERNALLEN) { - print_scsi(dc); - } else { - goto printit; - } - break; - case MDDT_DISK: - if(dc->dc_datalen >= DISK_EXTERNALLEN) { - print_disk(dc); - } else { - goto printit; - } - break; - - default: - if(dc->dc_devtype >= NDEVTYPES) { - printf("%s%d (#%d) at %s%d", - dc->dc_name, dc->dc_unit, dc->dc_devtype, - dc->dc_pname, dc->dc_punit); - } else { - printf("%s%d (%s) at %s%d", - dc->dc_name, dc->dc_unit, - devtypes[dc->dc_devtype], dc->dc_pname, - dc->dc_punit); - } - break; - } - fputc('\n', stdout); -} - -static void -print_isa(struct devconf *dc) -{ - struct isa_device *id = (struct isa_device *)dc->dc_data; - - printf("%s%d\tat isa?", dc->dc_name, dc->dc_unit); - - if(dc->dc_md.mddc_imask[0]) { - printf(" %3.3s", dc->dc_md.mddc_imask); - } - - if(vflag) { - printf(" (id %d)", id->id_id); - } - - if(id->id_iobase) { - if(id->id_iobase < 0) { - printf(" port ?"); - } else { - printf(" port 0x%x", id->id_iobase); - } - } - - if(id->id_irq) { - int bit = ffs(id->id_irq) - 1; - - if(id->id_irq & ~(1 << bit)) { - printf(" irq ?"); - } else { - printf(" irq %d", bit); - } - } - - if(id->id_drq >= 0) { - printf(" drq %d", id->id_drq); - } - - if(id->id_maddr) { - if((unsigned long)id->id_maddr == ~0UL) { - printf(" iomem ?"); - } else { - printf(" iomem 0x%lx", - (unsigned long)id->id_maddr & ~KERNBASE); - } - } - - if(id->id_msize) { - if(id->id_msize < 0) { - printf(" iosiz ?"); - } else { - printf(" iosiz %d", id->id_msize); - } - } - - if(id->id_flags) { - printf(" flags 0x%x", id->id_flags); - } -} - -static void -print_eisa_resvaddrs(struct resvlist *list) -{ - resvaddr_t *rp; - - for (rp = list->lh_first; rp; rp = rp->links.le_next) - printf(" %#lx-%#lx%s", rp->addr, rp->addr + rp->size - 1, - rp->links.le_next ? "," : ""); -} - -static void -print_eisa(struct devconf *dc) -{ - struct eisa_device *e_dev = (struct eisa_device *)dc->dc_data; - - printf("%s%d\tat eisa0 slot %d #", - dc->dc_name, - dc->dc_unit, - e_dev->ioconf.slot); - print_eisa_resvaddrs(&e_dev->ioconf.ioaddrs); - print_eisa_resvaddrs(&e_dev->ioconf.maddrs); - if(e_dev->ioconf.irq) - printf(" irq %d", ffs(e_dev->ioconf.irq) - 1); -} - -static void -print_pci(struct devconf *dc) -{ - /* - ** PCI is capable of true autoconfiguration. - ** The pci_device structure isn't required at all. - ** - ** You can retrieve the configuration info - ** from the configuration space. - */ - - struct pci_externalize_buffer *pd = - (struct pci_externalize_buffer *)dc->dc_data; - u_long data; - int pin, line; - - printf("%s%d\tat pci%d:%d", - dc->dc_name, dc->dc_unit, - pd->peb_pci_info.pi_bus, - pd->peb_pci_info.pi_device); - - /* - ** For now we show only the interrupt configuration, - ** because this may collide with other parts of the - ** configuration. - */ - - data = pd->peb_config[PCI_INTERRUPT_REG / 4]; - pin = PCI_INTERRUPT_PIN_EXTRACT (data); - line = PCI_INTERRUPT_LINE_EXTRACT (data); - - /* - ** You may of course display all the configuration registers. - ** Hint: The #defines are in <i386/pci/pcireg.h> - */ - - if (pin) printf (" # int %c irq %d", pin + ('a'-1), line); -} - -static void -print_scsi(struct devconf *dc) -{ - struct scsi_link *sl = (struct scsi_link *)dc->dc_data; - - printf("%s%d at SCSI bus %d:%d:%d", - dc->dc_name, dc->dc_unit, sl->scsibus, sl->target, - sl->lun); - if(vflag) { - if(sl->flags & SDEV_MEDIA_LOADED) - printf(" (ready)"); - if(sl->flags & SDEV_OPEN) - printf(" (open)"); - if(sl->flags & SDEV_BOUNCE) - printf(" (bounce)"); - } -} - -static void -print_disk(struct devconf *dc) -{ - int *slavep = (int *)dc->dc_data; - - printf("%s%d at %s%d drive %d", - dc->dc_name, dc->dc_unit, dc->dc_pname, dc->dc_punit, *slavep); -} - diff --git a/usr.sbin/lsdev/lsdev.8 b/usr.sbin/lsdev/lsdev.8 deleted file mode 100644 index fb54517..0000000 --- a/usr.sbin/lsdev/lsdev.8 +++ /dev/null @@ -1,65 +0,0 @@ -.\" $Id: lsdev.8,v 1.3 1994/12/12 00:35:01 ats Exp $ -.\" Garrett A. Wollman, October 1994 -.\" This file is in the public domain. -.\" -.Dd October 17, 1994 -.Dt LSDEV 8 -.Os -.Sh NAME -.Nm lsdev -.Nd list configured devices -.Sh SYNOPSIS -.Nm lsdev -.Op Fl t Ar type -.Op Fl cv -.Op Ar class Ns Op unit -.Sh DESCRIPTION -The -.Nm lsdev -utility lists devices configured in the current system, in a -machine-dependent manner. The -.Fl t -flag can be used to restrict the listing to a specific -.Ar type -of device; -the types available vary from machine to machine. (Specifying an -invalid type will cause a list of valid types to be printed.) The -.Fl v -flag requests more verbose output. The -.Fl c -flag requests output in a format similar to the input of -.Xr config 8 . -The optional -.Ar class -argument requests information on a particular class of devices (e.g., -.Dq Li wdc -or -.No Do Li ie Dc Ns ). -If no -.Ar unit -is specified, all units of the specified class will be listed. -.Pp -The -.Xr sysctl 3 -mechanism is used to retrieve information from the kernel about which -devices are configured. -.Sh FILES -.Bl -tag -width <machine/devconf.h> -.It Aq sys/devconf.h -defines the structure examined by -.Nm -.It Aq machine/devconf.h -defines the machine-dependent parts of the structure, including the -supported device type names -.El -.Sh SEE ALSO -.\" .Xr chdev 8 -.Xr sysctl 3 -.Sh BUGS -Not all devices have the proper support implemented yet. -.Sh HISTORY -An -.Nm -command appeared in -.Tn FreeBSD -2.0. diff --git a/usr.sbin/lsdev/lsdev.c b/usr.sbin/lsdev/lsdev.c deleted file mode 100644 index b8b0d29..0000000 --- a/usr.sbin/lsdev/lsdev.c +++ /dev/null @@ -1,227 +0,0 @@ -/* - * This file, written by Garrett A. Wollman, is in the public domain. - */ -#include <sys/types.h> -#include <sys/devconf.h> -#include <sys/sysctl.h> - -#include <ctype.h> -#include <err.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "lsdev.h" - -const char *const devtypes[] = DEVTYPENAMES; -int vflag = 0; -const char *whoami; - -static void usage(void); -static void badtype(const char *); -static void badname(const char *); - -static void print_pretty(struct devconf *); -static void hprint_pretty(void); - -int -main(int argc, char **argv) -{ - struct devconf *dc = 0; - size_t size, osize; - int ndevs, i; - int mib[8]; - int c; - int showonlytype = -1; - int showonlydev = 0; - char showonlydevclass[MAXDEVNAME]; - int showonlydevunit = -1; - void (*prtfcn)(struct devconf *) = print_pretty; - void (*hprtfcn)(void) = hprint_pretty; - - whoami = argv[0]; - - while((c = getopt(argc, argv, "t:vc")) != EOF) { - switch(c) { - case 't': - showonlytype = findtype(optarg); - if(showonlytype < 0) - badtype(optarg); - break; - case 'v': - vflag++; - break; - case 'c': - prtfcn = print_config; - hprtfcn = hprint_config; - break; - default: - usage(); - break; - } - } - - if(argc - optind > 1) { - usage(); - } - - if(argv[optind]) { - char *s = &argv[optind][strlen(argv[optind])]; - - if(s - argv[optind] > MAXDEVNAME) - badname(argv[optind]); - s--; /* step over null */ - while(s > argv[optind] && isdigit(*s)) - s--; - s++; - if(*s) { - showonlydevunit = atoi(s); - *s = '\0'; - } else { - showonlydevunit = -1; - } - - strcpy(showonlydevclass, argv[optind]); - showonlydev = 1; - } - - mib[0] = CTL_HW; - mib[1] = HW_DEVCONF; - mib[2] = DEVCONF_NUMBER; - - size = sizeof ndevs; - if(sysctl(mib, 3, &ndevs, &size, 0, 0) < 0) { - err(1, "sysctl(hw.devconf.number)"); - } - osize = 0; - - hprtfcn(); - - for(i = 1; i <= ndevs; i++) { - mib[2] = i; - if(sysctl(mib, 3, 0, &size, 0, 0) < 0) { - /* - * Probably a deleted device; just go on to the next - * one. - */ - continue; - } - if(size > osize) { - dc = realloc(dc, size); - if(!dc) { - err(2, "realloc(%lu)", (unsigned long)size); - } - } - if(sysctl(mib, 3, dc, &size, 0, 0) < 0) { - err(1, "sysctl(hw.devconf.%d)", i); - } - if(!showonlydev && showonlytype < 0) { - prtfcn(dc); - } else if(showonlydev) { - if(!strcmp(showonlydevclass, dc->dc_name) - && (showonlydevunit < 0 || - showonlydevunit == dc->dc_unit)) - prtfcn(dc); - } else if(showonlytype == dc->dc_devtype) { - prtfcn(dc); - } - osize = size; - } - return 0; -} - -static void -usage(void) -{ - fprintf(stderr, - "usage:\n" - "\t%s [-t type] [-v] [name]\n", - whoami); - exit(-1); -} - -int -findtype(const char *name) -{ - int i; - for(i = 0; devtypes[i]; i++) { - if(!strcmp(name, devtypes[i])) - return i; - } - return -1; -} - -static void -badtype(const char *name) -{ - int i; - - fprintf(stderr, - "%s: invalid device type `%s'\n", whoami, name); - fprintf(stderr, - "%s: valid types are: ", whoami); - for(i = 0; devtypes[i]; i++) { - fprintf(stderr, "%s`%s'", i ? ", " : "", devtypes[i]); - } - fputs(".\n", stderr); - exit(-1); -} - -static void -badname(const char *name) -{ - errx(3, "invalid device name `%s'", name); -} - -static void -hprint_pretty(void) -{ - printf("%-10.10s ", "Device"); - if(vflag) { - printf("%-2.2s %-10.10s ", "St", "Parent"); - } else { - printf("%-15.15s ", "State"); - } - - printf("%s\n", "Description"); - - printf("%-10.10s ", "----------"); - if(vflag) { - printf("%-2.2s %-10.10s ", "--", "----------"); - } else { - printf("%-15.15s ", "---------------"); - } - - printf("%s\n", "--------------------------------------------------"); -} - -static const char *const states[] = { "??", "NC", "I", "B" }; -static const char *const longstates[] = { - "Unknown", "Unconfigured", "Idle", "Busy" -}; - -static void -print_pretty(struct devconf *dc) -{ - char buf[MAXDEVNAME * 2]; - - snprintf(buf, sizeof buf, "%s%d", dc->dc_name, dc->dc_unit); - - if(vflag) { - printf("%-10.10s %2.2s ", buf, states[dc->dc_state]); - - if(dc->dc_punit >= 0) { - snprintf(buf, sizeof buf, "%s%d", dc->dc_pname, - dc->dc_punit); - } else { - buf[0] = '-'; - buf[1] = '\0'; - } - printf("%-10.10s ", buf); - } else { - printf("%-10.10s %-15.15s ", buf, longstates[dc->dc_state]); - } - - printf("%s\n", dc->dc_descr); -} - diff --git a/usr.sbin/lsdev/lsdev.h b/usr.sbin/lsdev/lsdev.h deleted file mode 100644 index b377295..0000000 --- a/usr.sbin/lsdev/lsdev.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * This file, written by Garrett A. Wollman, is in the public domain. - */ -/* - * Declarations for lsdev(8). - */ - -extern const char *const devtypes[]; /* device type array */ -extern int vflag; - -int findtype(const char *); /* get device type by name */ -void hprint_config(void); /* machine-specific header printer */ -struct devconf; -void print_config(struct devconf *); /* machine-specific print routine */ |