fdc.c (12691) | fdc.c (12724) |
---|---|
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 * Copyright (c) 1993, 1994 by --- 29 unchanged lines hidden (view full) --- 38 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 39 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 40 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 41 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 42 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 43 * SUCH DAMAGE. 44 * 45 * 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 * Copyright (c) 1993, 1994 by --- 29 unchanged lines hidden (view full) --- 38 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 39 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 40 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 41 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 42 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 43 * SUCH DAMAGE. 44 * 45 * from: @(#)fd.c 7.4 (Berkeley) 5/25/91 |
46 * $Id: fd.c,v 1.74 1995/12/08 23:20:26 phk Exp $ | 46 * $Id: fd.c,v 1.75 1995/12/09 09:10:12 julian Exp $ |
47 * 48 */ 49 50#include "ft.h" 51#if NFT < 1 52#undef NFDC 53#endif 54#include "fd.h" --- 140 unchanged lines hidden (view full) --- 195#define FD_1480in5_25 9 196#define FD_1440in5_25 10 197#define FD_820in5_25 11 198#define FD_800in5_25 12 199#define FD_720in5_25 13 200#define FD_360in5_25 14 201 202 | 47 * 48 */ 49 50#include "ft.h" 51#if NFT < 1 52#undef NFDC 53#endif 54#include "fd.h" --- 140 unchanged lines hidden (view full) --- 195#define FD_1480in5_25 9 196#define FD_1440in5_25 10 197#define FD_820in5_25 11 198#define FD_800in5_25 12 199#define FD_720in5_25 13 200#define FD_360in5_25 14 201 202 |
203struct fd_type fd_types[NUMTYPES] = | 203static struct fd_type fd_types[NUMTYPES] = |
204{ 205{ 21,2,0xFF,0x04,82,3444,1,FDC_500KBPS,2,0x0C,2 }, /* 1.72M in HD 3.5in */ 206{ 18,2,0xFF,0x1B,82,2952,1,FDC_500KBPS,2,0x6C,1 }, /* 1.48M in HD 3.5in */ 207{ 18,2,0xFF,0x1B,80,2880,1,FDC_500KBPS,2,0x6C,1 }, /* 1.44M in HD 3.5in */ 208{ 15,2,0xFF,0x1B,80,2400,1,FDC_500KBPS,2,0x54,1 }, /* 1.2M in HD 5.25/3.5 */ 209{ 10,2,0xFF,0x10,82,1640,1,FDC_250KBPS,2,0x2E,1 }, /* 820K in HD 3.5in */ 210{ 10,2,0xFF,0x10,80,1600,1,FDC_250KBPS,2,0x2E,1 }, /* 800K in HD 3.5in */ 211{ 9,2,0xFF,0x20,80,1440,1,FDC_250KBPS,2,0x50,1 }, /* 720K in HD 3.5in */ --- 13 unchanged lines hidden (view full) --- 225* Per controller structure. * 226\***********************************************************************/ 227struct fdc_data fdc_data[NFDC]; 228 229/***********************************************************************\ 230* Per drive structure. * 231* N per controller (DRVS_PER_CTLR) * 232\***********************************************************************/ | 204{ 205{ 21,2,0xFF,0x04,82,3444,1,FDC_500KBPS,2,0x0C,2 }, /* 1.72M in HD 3.5in */ 206{ 18,2,0xFF,0x1B,82,2952,1,FDC_500KBPS,2,0x6C,1 }, /* 1.48M in HD 3.5in */ 207{ 18,2,0xFF,0x1B,80,2880,1,FDC_500KBPS,2,0x6C,1 }, /* 1.44M in HD 3.5in */ 208{ 15,2,0xFF,0x1B,80,2400,1,FDC_500KBPS,2,0x54,1 }, /* 1.2M in HD 5.25/3.5 */ 209{ 10,2,0xFF,0x10,82,1640,1,FDC_250KBPS,2,0x2E,1 }, /* 820K in HD 3.5in */ 210{ 10,2,0xFF,0x10,80,1600,1,FDC_250KBPS,2,0x2E,1 }, /* 800K in HD 3.5in */ 211{ 9,2,0xFF,0x20,80,1440,1,FDC_250KBPS,2,0x50,1 }, /* 720K in HD 3.5in */ --- 13 unchanged lines hidden (view full) --- 225* Per controller structure. * 226\***********************************************************************/ 227struct fdc_data fdc_data[NFDC]; 228 229/***********************************************************************\ 230* Per drive structure. * 231* N per controller (DRVS_PER_CTLR) * 232\***********************************************************************/ |
233struct fd_data { | 233static struct fd_data { |
234 struct fdc_data *fdc; /* pointer to controller structure */ 235 int fdsu; /* this units number on this controller */ 236 int type; /* Drive type (FD_1440...) */ 237 struct fd_type *ft; /* pointer to the type descriptor */ 238 int flags; 239#define FD_OPEN 0x01 /* it's open */ 240#define FD_ACTIVE 0x02 /* it's active */ 241#define FD_MOTOR 0x04 /* motor should be on */ --- 113 unchanged lines hidden (view full) --- 355 nxdump, zerosize, 0, "fd", &fd_cdevsw, -1 }; 356 357static struct cdevsw fd_cdevsw = 358 { Fdopen, fdclose, rawread, rawwrite, /*9*/ 359 fdioctl, nostop, nullreset, nodevtotty, 360 seltrue, nommap, fdstrategy, "fd", 361 &fd_bdevsw, -1 }; 362 | 234 struct fdc_data *fdc; /* pointer to controller structure */ 235 int fdsu; /* this units number on this controller */ 236 int type; /* Drive type (FD_1440...) */ 237 struct fd_type *ft; /* pointer to the type descriptor */ 238 int flags; 239#define FD_OPEN 0x01 /* it's open */ 240#define FD_ACTIVE 0x02 /* it's active */ 241#define FD_MOTOR 0x04 /* motor should be on */ --- 113 unchanged lines hidden (view full) --- 355 nxdump, zerosize, 0, "fd", &fd_cdevsw, -1 }; 356 357static struct cdevsw fd_cdevsw = 358 { Fdopen, fdclose, rawread, rawwrite, /*9*/ 359 fdioctl, nostop, nullreset, nodevtotty, 360 seltrue, nommap, fdstrategy, "fd", 361 &fd_bdevsw, -1 }; 362 |
363struct isa_device *fdcdevs[NFDC]; | 363static struct isa_device *fdcdevs[NFDC]; |
364 365/* 366 * Provide hw.devconf information. 367 */ 368static int 369fd_externalize(struct kern_devconf *kdc, struct sysctl_req *req) 370{ 371 return disk_externalize(fd_data[kdc->kdc_unit].fdsu, req); --- 16 unchanged lines hidden (view full) --- 388 389/* 390 * fd_cmd: Send a command to the chip. Takes a varargs with this structure: 391 * Unit number, 392 * # of output bytes, output bytes as ints ..., 393 * # of input bytes, input bytes as ints ... 394 */ 395 | 364 365/* 366 * Provide hw.devconf information. 367 */ 368static int 369fd_externalize(struct kern_devconf *kdc, struct sysctl_req *req) 370{ 371 return disk_externalize(fd_data[kdc->kdc_unit].fdsu, req); --- 16 unchanged lines hidden (view full) --- 388 389/* 390 * fd_cmd: Send a command to the chip. Takes a varargs with this structure: 391 * Unit number, 392 * # of output bytes, output bytes as ints ..., 393 * # of input bytes, input bytes as ints ... 394 */ 395 |
396int | 396static int |
397fd_cmd(fdcu_t fdcu, int n_out, ...) 398{ 399 u_char cmd; 400 int n_in; 401 int n; 402 va_list ap; 403 404 va_start(ap, n_out); --- 23 unchanged lines hidden (view full) --- 428 cmd, n + 1, n_in); 429 return fdc_err(fdcu, msg); 430 } 431 } 432 433 return 0; 434} 435 | 397fd_cmd(fdcu_t fdcu, int n_out, ...) 398{ 399 u_char cmd; 400 int n_in; 401 int n; 402 va_list ap; 403 404 va_start(ap, n_out); --- 23 unchanged lines hidden (view full) --- 428 cmd, n + 1, n_in); 429 return fdc_err(fdcu, msg); 430 } 431 } 432 433 return 0; 434} 435 |
436int | 436static int |
437fd_sense_drive_status(fdc_p fdc, int *st3p) 438{ 439 int st3; 440 441 if (fd_cmd(fdc->fdcu, 2, NE7CMD_SENSED, fdc->fdu, 1, &st3)) 442 { 443 return fdc_err(fdc->fdcu, "Sense Drive Status failed\n"); 444 } 445 if (st3p) 446 *st3p = st3; 447 448 return 0; 449} 450 | 437fd_sense_drive_status(fdc_p fdc, int *st3p) 438{ 439 int st3; 440 441 if (fd_cmd(fdc->fdcu, 2, NE7CMD_SENSED, fdc->fdu, 1, &st3)) 442 { 443 return fdc_err(fdc->fdcu, "Sense Drive Status failed\n"); 444 } 445 if (st3p) 446 *st3p = st3; 447 448 return 0; 449} 450 |
451int | 451static int |
452fd_sense_int(fdc_p fdc, int *st0p, int *cylp) 453{ 454 int st0, cyl; 455 456 int ret = fd_cmd(fdc->fdcu, 1, NE7CMD_SENSEI, 1, &st0); 457 458 if (ret) 459 { --- 20 unchanged lines hidden (view full) --- 480 481 if (cylp) 482 *cylp = cyl; 483 484 return 0; 485} 486 487 | 452fd_sense_int(fdc_p fdc, int *st0p, int *cylp) 453{ 454 int st0, cyl; 455 456 int ret = fd_cmd(fdc->fdcu, 1, NE7CMD_SENSEI, 1, &st0); 457 458 if (ret) 459 { --- 20 unchanged lines hidden (view full) --- 480 481 if (cylp) 482 *cylp = cyl; 483 484 return 0; 485} 486 487 |
488int | 488static int |
489fd_read_status(fdc_p fdc, int fdsu) 490{ 491 int i, ret; 492 493 for (i = 0; i < 7; i++) 494 { 495 /* 496 * XXX types are poorly chosen. Only bytes can by read --- 1449 unchanged lines hidden --- | 489fd_read_status(fdc_p fdc, int fdsu) 490{ 491 int i, ret; 492 493 for (i = 0; i < 7; i++) 494 { 495 /* 496 * XXX types are poorly chosen. Only bytes can by read --- 1449 unchanged lines hidden --- |