From 2f86936a077e531bc6fed8688d33030ae28ea45a Mon Sep 17 00:00:00 2001 From: Garrett Wollman Date: Sun, 23 Oct 1994 21:28:03 +0000 Subject: Finished device configuration database work for all ISA devices (except `ze') and all SCSI devices (except that it's not done quite the way I want). New information added includes: - A text description of the device - A ``state''---unknown, unconfigured, idle, or busy - A generic parent device (with support in the m.i. code) - An interrupt mask type field (which will hopefully go away) so that . ``doconfig'' can be written This requires a new version of the `lsdev' program as well (next commit). --- sys/dev/fdc/fdc.c | 68 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 28 deletions(-) (limited to 'sys/dev/fdc') diff --git a/sys/dev/fdc/fdc.c b/sys/dev/fdc/fdc.c index edbb90348aa5..a000acf89420 100644 --- a/sys/dev/fdc/fdc.c +++ b/sys/dev/fdc/fdc.c @@ -40,7 +40,7 @@ * SUCH DAMAGE. * * from: @(#)fd.c 7.4 (Berkeley) 5/25/91 - * $Id: fd.c,v 1.35 1994/10/19 01:58:56 wollman Exp $ + * $Id: fd.c,v 1.36 1994/10/21 16:58:50 joerg Exp $ * */ @@ -85,29 +85,50 @@ static int fd_externalize(struct proc *, struct kern_devconf *, void *, size_t); /* * Templates for the kern_devconf structures used when we attach. */ -static struct kern_devconf kdc_fd_template = { +static struct kern_devconf kdc_fd[NFD] = { { 0, 0, 0, /* filled in by kern_devconf.c */ - "fd", 0, { "fdc0", MDDT_DISK, 0 }, - fd_externalize, 0, fd_goaway, DISK_EXTERNALLEN -}; - -static struct kern_devconf kdc_fdc_template = { + "fd", 0, { MDDT_DISK, 0 }, + fd_externalize, 0, fd_goaway, DISK_EXTERNALLEN, + 0, /* parent */ + 0, /* parentdata */ + DC_UNKNOWN, /* state */ + "floppy disk" +} }; + +struct kern_devconf kdc_fdc[NFDC] = { { 0, 0, 0, /* filled in by kern_devconf.c */ - "fdc", 0, { "isa0", MDDT_ISA, 0 }, - isa_generic_externalize, 0, fdc_goaway, ISA_EXTERNALLEN -}; + "fdc", 0, { MDDT_ISA, 0, "bio" }, + isa_generic_externalize, 0, fdc_goaway, ISA_EXTERNALLEN, + 0, /* parent */ + 0, /* parentdata */ + DC_UNKNOWN, /* state */ + "floppy disk/tape controller" +} }; static inline void fd_registerdev(int ctlr, int unit) { - struct kern_devconf *kdc; - - MALLOC(kdc, struct kern_devconf *, sizeof *kdc, M_TEMP, M_NOWAIT); - if(!kdc) return; - *kdc = kdc_fd_template; - kdc->kdc_unit = unit; - sprintf(kdc->kdc_md.mddc_parent, "fdc%d", ctlr); - dev_attach(kdc); + if(unit != 0) + kdc_fd[unit] = kdc_fd[0]; + + kdc_fd[unit].kdc_unit = unit; + kdc_fd[unit].kdc_parent = &kdc_fdc[ctlr]; + kdc_fd[unit].kdc_parentdata = 0; + dev_attach(&kdc_fd[unit]); +} + +static inline void +fdc_registerdev(struct isa_device *dvp) +{ + int unit = dvp->id_unit; + + if(unit != 0) + kdc_fdc[unit] = kdc_fdc[0]; + + kdc_fdc[unit].kdc_unit = unit; + kdc_fdc[unit].kdc_parent = &kdc_isa0; + kdc_fdc[unit].kdc_parentdata = dvp; + dev_attach(&kdc_fdc[unit]); } static int @@ -115,7 +136,6 @@ fdc_goaway(struct kern_devconf *kdc, int force) { if(force) { dev_detach(kdc); - FREE(kdc, M_TEMP); return 0; } else { return EBUSY; /* XXX fix */ @@ -126,7 +146,6 @@ static int fd_goaway(struct kern_devconf *kdc, int force) { dev_detach(kdc); - FREE(kdc, M_TEMP); return 0; } @@ -372,15 +391,8 @@ fdattach(dev) fd_p fd; int fdsu, st0, i; struct isa_device *fdup; - struct kern_devconf *kdc; - MALLOC(kdc, struct kern_devconf *, sizeof *kdc, M_TEMP, M_NOWAIT); - if(!kdc) - return 0; - *kdc = kdc_fdc_template; - kdc->kdc_unit = fdcu; - kdc->kdc_isa = dev; - dev_attach(kdc); + fdc_registerdev(dev); fdc->fdcu = fdcu; fdc->flags |= FDC_ATTACHED; -- cgit v1.3