fdc.c (3755) | fdc.c (3816) |
---|---|
1/*- 2 * Copyright (c) 1990 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Don Ahn. 7 * 8 * Portions Copyright (c) 1993, 1994 by --- 26 unchanged lines hidden (view full) --- 35 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 36 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 37 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 38 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 39 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 40 * SUCH DAMAGE. 41 * 42 * from: @(#)fd.c 7.4 (Berkeley) 5/25/91 | 1/*- 2 * Copyright (c) 1990 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Don Ahn. 7 * 8 * Portions Copyright (c) 1993, 1994 by --- 26 unchanged lines hidden (view full) --- 35 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 36 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 37 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 38 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 39 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 40 * SUCH DAMAGE. 41 * 42 * from: @(#)fd.c 7.4 (Berkeley) 5/25/91 |
43 * $Id: fd.c,v 1.35 1994/10/19 01:58:56 wollman Exp $ | 43 * $Id: fd.c,v 1.36 1994/10/21 16:58:50 joerg Exp $ |
44 * 45 */ 46 47#include "ft.h" 48#if NFT < 1 49#undef NFDC 50#endif 51#include "fd.h" --- 28 unchanged lines hidden (view full) --- 80 81static int fd_goaway(struct kern_devconf *, int); 82static int fdc_goaway(struct kern_devconf *, int); 83static int fd_externalize(struct proc *, struct kern_devconf *, void *, size_t); 84 85/* 86 * Templates for the kern_devconf structures used when we attach. 87 */ | 44 * 45 */ 46 47#include "ft.h" 48#if NFT < 1 49#undef NFDC 50#endif 51#include "fd.h" --- 28 unchanged lines hidden (view full) --- 80 81static int fd_goaway(struct kern_devconf *, int); 82static int fdc_goaway(struct kern_devconf *, int); 83static int fd_externalize(struct proc *, struct kern_devconf *, void *, size_t); 84 85/* 86 * Templates for the kern_devconf structures used when we attach. 87 */ |
88static struct kern_devconf kdc_fd_template = { | 88static struct kern_devconf kdc_fd[NFD] = { { |
89 0, 0, 0, /* filled in by kern_devconf.c */ | 89 0, 0, 0, /* filled in by kern_devconf.c */ |
90 "fd", 0, { "fdc0", MDDT_DISK, 0 }, 91 fd_externalize, 0, fd_goaway, DISK_EXTERNALLEN 92}; | 90 "fd", 0, { MDDT_DISK, 0 }, 91 fd_externalize, 0, fd_goaway, DISK_EXTERNALLEN, 92 0, /* parent */ 93 0, /* parentdata */ 94 DC_UNKNOWN, /* state */ 95 "floppy disk" 96} }; |
93 | 97 |
94static struct kern_devconf kdc_fdc_template = { | 98struct kern_devconf kdc_fdc[NFDC] = { { |
95 0, 0, 0, /* filled in by kern_devconf.c */ | 99 0, 0, 0, /* filled in by kern_devconf.c */ |
96 "fdc", 0, { "isa0", MDDT_ISA, 0 }, 97 isa_generic_externalize, 0, fdc_goaway, ISA_EXTERNALLEN 98}; | 100 "fdc", 0, { MDDT_ISA, 0, "bio" }, 101 isa_generic_externalize, 0, fdc_goaway, ISA_EXTERNALLEN, 102 0, /* parent */ 103 0, /* parentdata */ 104 DC_UNKNOWN, /* state */ 105 "floppy disk/tape controller" 106} }; |
99 100static inline void 101fd_registerdev(int ctlr, int unit) 102{ | 107 108static inline void 109fd_registerdev(int ctlr, int unit) 110{ |
103 struct kern_devconf *kdc; | 111 if(unit != 0) 112 kdc_fd[unit] = kdc_fd[0]; |
104 | 113 |
105 MALLOC(kdc, struct kern_devconf *, sizeof *kdc, M_TEMP, M_NOWAIT); 106 if(!kdc) return; 107 *kdc = kdc_fd_template; 108 kdc->kdc_unit = unit; 109 sprintf(kdc->kdc_md.mddc_parent, "fdc%d", ctlr); 110 dev_attach(kdc); | 114 kdc_fd[unit].kdc_unit = unit; 115 kdc_fd[unit].kdc_parent = &kdc_fdc[ctlr]; 116 kdc_fd[unit].kdc_parentdata = 0; 117 dev_attach(&kdc_fd[unit]); |
111} 112 | 118} 119 |
120static inline void 121fdc_registerdev(struct isa_device *dvp) 122{ 123 int unit = dvp->id_unit; 124 125 if(unit != 0) 126 kdc_fdc[unit] = kdc_fdc[0]; 127 128 kdc_fdc[unit].kdc_unit = unit; 129 kdc_fdc[unit].kdc_parent = &kdc_isa0; 130 kdc_fdc[unit].kdc_parentdata = dvp; 131 dev_attach(&kdc_fdc[unit]); 132} 133 |
|
113static int 114fdc_goaway(struct kern_devconf *kdc, int force) 115{ 116 if(force) { 117 dev_detach(kdc); | 134static int 135fdc_goaway(struct kern_devconf *kdc, int force) 136{ 137 if(force) { 138 dev_detach(kdc); |
118 FREE(kdc, M_TEMP); | |
119 return 0; 120 } else { 121 return EBUSY; /* XXX fix */ 122 } 123} 124 125static int 126fd_goaway(struct kern_devconf *kdc, int force) 127{ 128 dev_detach(kdc); | 139 return 0; 140 } else { 141 return EBUSY; /* XXX fix */ 142 } 143} 144 145static int 146fd_goaway(struct kern_devconf *kdc, int force) 147{ 148 dev_detach(kdc); |
129 FREE(kdc, M_TEMP); | |
130 return 0; 131} 132 133#define RAW_PART 2 134#define b_cylin b_resid 135 136/* misuse a flag to identify format operation */ 137#define B_FORMAT B_XXX --- 229 unchanged lines hidden (view full) --- 367{ 368 unsigned fdt; 369 fdu_t fdu; 370 fdcu_t fdcu = dev->id_unit; 371 fdc_p fdc = fdc_data + fdcu; 372 fd_p fd; 373 int fdsu, st0, i; 374 struct isa_device *fdup; | 149 return 0; 150} 151 152#define RAW_PART 2 153#define b_cylin b_resid 154 155/* misuse a flag to identify format operation */ 156#define B_FORMAT B_XXX --- 229 unchanged lines hidden (view full) --- 386{ 387 unsigned fdt; 388 fdu_t fdu; 389 fdcu_t fdcu = dev->id_unit; 390 fdc_p fdc = fdc_data + fdcu; 391 fd_p fd; 392 int fdsu, st0, i; 393 struct isa_device *fdup; |
375 struct kern_devconf *kdc; | |
376 | 394 |
377 MALLOC(kdc, struct kern_devconf *, sizeof *kdc, M_TEMP, M_NOWAIT); 378 if(!kdc) 379 return 0; 380 *kdc = kdc_fdc_template; 381 kdc->kdc_unit = fdcu; 382 kdc->kdc_isa = dev; 383 dev_attach(kdc); | 395 fdc_registerdev(dev); |
384 385 fdc->fdcu = fdcu; 386 fdc->flags |= FDC_ATTACHED; 387 fdc->dmachan = dev->id_drq; 388 fdc->state = DEVIDLE; 389 /* reset controller, turn motor off, clear fdout mirror reg */ 390 outb(fdc->baseport + FDOUT, ((fdc->fdout = 0))); 391 printf("fdc%d:", fdcu); --- 1209 unchanged lines hidden --- | 396 397 fdc->fdcu = fdcu; 398 fdc->flags |= FDC_ATTACHED; 399 fdc->dmachan = dev->id_drq; 400 fdc->state = DEVIDLE; 401 /* reset controller, turn motor off, clear fdout mirror reg */ 402 outb(fdc->baseport + FDOUT, ((fdc->fdout = 0))); 403 printf("fdc%d:", fdcu); --- 1209 unchanged lines hidden --- |