fdc.c (37c841831ff323187d7f749947244f7e278a14ea) | fdc.c (419f39ce0fa833c72140e14574aef903de18cea9) |
---|---|
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 * Libretto PCMCIA floppy support by David Horwitt (dhorwitt@ucsd.edu) --- 152 unchanged lines hidden (view full) --- 161 bus_space_handle_t porth; 162 bus_space_tag_t ctlt; 163 bus_space_handle_t ctlh; 164 void *fdc_intr; 165 struct device *fdc_dev; 166 void (*fdctl_wr)(struct fdc_data *fdc, u_int8_t v); 167}; 168 | 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 * Libretto PCMCIA floppy support by David Horwitt (dhorwitt@ucsd.edu) --- 152 unchanged lines hidden (view full) --- 161 bus_space_handle_t porth; 162 bus_space_tag_t ctlt; 163 bus_space_handle_t ctlh; 164 void *fdc_intr; 165 struct device *fdc_dev; 166 void (*fdctl_wr)(struct fdc_data *fdc, u_int8_t v); 167}; 168 |
169#define BIO_FORMAT BIO_CMD2 | 169#define FDBIO_FORMAT BIO_CMD2 |
170 171typedef int fdu_t; 172typedef int fdcu_t; 173typedef int fdsu_t; 174typedef struct fd_data *fd_p; 175typedef struct fdc_data *fdc_p; 176typedef enum fdc_type fdc_t; 177 --- 53 unchanged lines hidden (view full) --- 231 * Density #0 is used for automatic format detection, the other 232 * densities are available as programmable densities (for assignment 233 * by fdcontrol(8)). 234 * The upper 2 bits of the minor number are reserved for the subunit 235 * (drive #) per controller. 236 */ 237#define NUMDENS 16 238 | 170 171typedef int fdu_t; 172typedef int fdcu_t; 173typedef int fdsu_t; 174typedef struct fd_data *fd_p; 175typedef struct fdc_data *fdc_p; 176typedef enum fdc_type fdc_t; 177 --- 53 unchanged lines hidden (view full) --- 231 * Density #0 is used for automatic format detection, the other 232 * densities are available as programmable densities (for assignment 233 * by fdcontrol(8)). 234 * The upper 2 bits of the minor number are reserved for the subunit 235 * (drive #) per controller. 236 */ 237#define NUMDENS 16 238 |
239#define BIO_RDSECTID BIO_CMD1 | 239#define FDBIO_RDSECTID BIO_CMD1 |
240 241/* 242 * List of native drive densities. Order must match enum fd_drivetype 243 * in <sys/fdcio.h>. Upon attaching the drive, each of the 244 * programmable subdevices is initialized with the native density 245 * definition. 246 */ 247static struct fd_type fd_native_types[] = --- 1426 unchanged lines hidden (view full) --- 1674 (u_long)major(bp->bio_dev), (u_long)minor(bp->bio_dev)); 1675 fdc = fd->fdc; 1676 if (fd->type == FDT_NONE || fd->ft == 0) { 1677 bp->bio_error = ENXIO; 1678 bp->bio_flags |= BIO_ERROR; 1679 goto bad; 1680 } 1681 fdblk = 128 << (fd->ft->secsize); | 240 241/* 242 * List of native drive densities. Order must match enum fd_drivetype 243 * in <sys/fdcio.h>. Upon attaching the drive, each of the 244 * programmable subdevices is initialized with the native density 245 * definition. 246 */ 247static struct fd_type fd_native_types[] = --- 1426 unchanged lines hidden (view full) --- 1674 (u_long)major(bp->bio_dev), (u_long)minor(bp->bio_dev)); 1675 fdc = fd->fdc; 1676 if (fd->type == FDT_NONE || fd->ft == 0) { 1677 bp->bio_error = ENXIO; 1678 bp->bio_flags |= BIO_ERROR; 1679 goto bad; 1680 } 1681 fdblk = 128 << (fd->ft->secsize); |
1682 if (bp->bio_cmd != BIO_FORMAT && bp->bio_cmd != BIO_RDSECTID) { | 1682 if (bp->bio_cmd != FDBIO_FORMAT && bp->bio_cmd != FDBIO_RDSECTID) { |
1683 if (fd->flags & FD_NONBLOCK) { 1684 bp->bio_error = EAGAIN; 1685 bp->bio_flags |= BIO_ERROR; 1686 goto bad; 1687 } 1688 if (bp->bio_blkno < 0) { 1689 printf( 1690 "fd%d: fdstrat: bad request blkno = %lu, bcount = %ld\n", --- 222 unchanged lines hidden (view full) --- 1913 * unit attention bit. 1914 */ 1915 oopts = fd->options; 1916 fd->options |= FDOPT_NOERRLOG | FDOPT_NORETRY; 1917 for (i = 0; i < n; i++, fdtp++) { 1918 fd->ft = fdtp; 1919 1920 id.cyl = id.head = 0; | 1683 if (fd->flags & FD_NONBLOCK) { 1684 bp->bio_error = EAGAIN; 1685 bp->bio_flags |= BIO_ERROR; 1686 goto bad; 1687 } 1688 if (bp->bio_blkno < 0) { 1689 printf( 1690 "fd%d: fdstrat: bad request blkno = %lu, bcount = %ld\n", --- 222 unchanged lines hidden (view full) --- 1913 * unit attention bit. 1914 */ 1915 oopts = fd->options; 1916 fd->options |= FDOPT_NOERRLOG | FDOPT_NORETRY; 1917 for (i = 0; i < n; i++, fdtp++) { 1918 fd->ft = fdtp; 1919 1920 id.cyl = id.head = 0; |
1921 rv = fdmisccmd(dev, BIO_RDSECTID, &id); | 1921 rv = fdmisccmd(dev, FDBIO_RDSECTID, &id); |
1922 if (rv != 0) 1923 continue; 1924 if (id.cyl != 0 || id.head != 0 || 1925 id.secshift != fdtp->secsize) 1926 continue; 1927 id.cyl = 2; 1928 id.head = fd->ft->heads - 1; | 1922 if (rv != 0) 1923 continue; 1924 if (id.cyl != 0 || id.head != 0 || 1925 id.secshift != fdtp->secsize) 1926 continue; 1927 id.cyl = 2; 1928 id.head = fd->ft->heads - 1; |
1929 rv = fdmisccmd(dev, BIO_RDSECTID, &id); | 1929 rv = fdmisccmd(dev, FDBIO_RDSECTID, &id); |
1930 if (id.cyl != 2 || id.head != fdtp->heads - 1 || 1931 id.secshift != fdtp->secsize) 1932 continue; 1933 if (rv == 0) 1934 break; 1935 } 1936 1937 fd->options = oopts; --- 59 unchanged lines hidden (view full) --- 1997 device_printf(fd->dev, "confused fd pointers\n"); 1998 read = bp->bio_cmd == BIO_READ; 1999 mfm = (fd->ft->flags & FL_MFM)? NE7CMD_MFM: 0; 2000 steptrac = (fd->ft->flags & FL_2STEP)? 2: 1; 2001 if (read) 2002 idf = ISADMA_READ; 2003 else 2004 idf = ISADMA_WRITE; | 1930 if (id.cyl != 2 || id.head != fdtp->heads - 1 || 1931 id.secshift != fdtp->secsize) 1932 continue; 1933 if (rv == 0) 1934 break; 1935 } 1936 1937 fd->options = oopts; --- 59 unchanged lines hidden (view full) --- 1997 device_printf(fd->dev, "confused fd pointers\n"); 1998 read = bp->bio_cmd == BIO_READ; 1999 mfm = (fd->ft->flags & FL_MFM)? NE7CMD_MFM: 0; 2000 steptrac = (fd->ft->flags & FL_2STEP)? 2: 1; 2001 if (read) 2002 idf = ISADMA_READ; 2003 else 2004 idf = ISADMA_WRITE; |
2005 format = bp->bio_cmd == BIO_FORMAT; 2006 rdsectid = bp->bio_cmd == BIO_RDSECTID; | 2005 format = bp->bio_cmd == FDBIO_FORMAT; 2006 rdsectid = bp->bio_cmd == FDBIO_RDSECTID; |
2007 if (format) 2008 finfo = (struct fd_formb *)bp->bio_data; 2009 TRACE1("fd%d", fdu); 2010 TRACE1("[%s]", fdstates[fdc->state]); 2011 TRACE1("(0x%x)", fd->flags); 2012 untimeout(fd_turnoff, fd, fd->toffhandle); 2013 fd->toffhandle = timeout(fd_turnoff, fd, 4 * hz); 2014 switch (fdc->state) --- 558 unchanged lines hidden (view full) --- 2573 bp = malloc(sizeof(struct bio), M_TEMP, M_ZERO); 2574 2575 /* 2576 * Set up a bio request for fdstrategy(). bio_blkno is faked 2577 * so that fdstrategy() will seek to the the requested 2578 * cylinder, and use the desired head. 2579 */ 2580 bp->bio_cmd = cmd; | 2007 if (format) 2008 finfo = (struct fd_formb *)bp->bio_data; 2009 TRACE1("fd%d", fdu); 2010 TRACE1("[%s]", fdstates[fdc->state]); 2011 TRACE1("(0x%x)", fd->flags); 2012 untimeout(fd_turnoff, fd, fd->toffhandle); 2013 fd->toffhandle = timeout(fd_turnoff, fd, 4 * hz); 2014 switch (fdc->state) --- 558 unchanged lines hidden (view full) --- 2573 bp = malloc(sizeof(struct bio), M_TEMP, M_ZERO); 2574 2575 /* 2576 * Set up a bio request for fdstrategy(). bio_blkno is faked 2577 * so that fdstrategy() will seek to the the requested 2578 * cylinder, and use the desired head. 2579 */ 2580 bp->bio_cmd = cmd; |
2581 if (cmd == BIO_FORMAT) { | 2581 if (cmd == FDBIO_FORMAT) { |
2582 bp->bio_blkno = 2583 (finfo->cyl * (fd->ft->sectrac * fd->ft->heads) + 2584 finfo->head * fd->ft->sectrac) * 2585 fdblk / DEV_BSIZE; 2586 bp->bio_bcount = sizeof(struct fd_idfield_data) * 2587 finfo->fd_formb_nsecs; | 2582 bp->bio_blkno = 2583 (finfo->cyl * (fd->ft->sectrac * fd->ft->heads) + 2584 finfo->head * fd->ft->sectrac) * 2585 fdblk / DEV_BSIZE; 2586 bp->bio_bcount = sizeof(struct fd_idfield_data) * 2587 finfo->fd_formb_nsecs; |
2588 } else if (cmd == BIO_RDSECTID) { | 2588 } else if (cmd == FDBIO_RDSECTID) { |
2589 bp->bio_blkno = 2590 (idfield->cyl * (fd->ft->sectrac * fd->ft->heads) + 2591 idfield->head * fd->ft->sectrac) * 2592 fdblk / DEV_BSIZE; 2593 bp->bio_bcount = sizeof(struct fdc_readid); 2594 } else 2595 panic("wrong cmd in fdmisccmd()"); 2596 bp->bio_data = data; --- 167 unchanged lines hidden (view full) --- 2764 break; 2765 2766 case FD_FORM: 2767 if ((flag & FWRITE) == 0) 2768 return (EBADF); /* must be opened for writing */ 2769 if (((struct fd_formb *)addr)->format_version != 2770 FD_FORMAT_VERSION) 2771 return (EINVAL); /* wrong version of formatting prog */ | 2589 bp->bio_blkno = 2590 (idfield->cyl * (fd->ft->sectrac * fd->ft->heads) + 2591 idfield->head * fd->ft->sectrac) * 2592 fdblk / DEV_BSIZE; 2593 bp->bio_bcount = sizeof(struct fdc_readid); 2594 } else 2595 panic("wrong cmd in fdmisccmd()"); 2596 bp->bio_data = data; --- 167 unchanged lines hidden (view full) --- 2764 break; 2765 2766 case FD_FORM: 2767 if ((flag & FWRITE) == 0) 2768 return (EBADF); /* must be opened for writing */ 2769 if (((struct fd_formb *)addr)->format_version != 2770 FD_FORMAT_VERSION) 2771 return (EINVAL); /* wrong version of formatting prog */ |
2772 error = fdmisccmd(dev, BIO_FORMAT, addr); | 2772 error = fdmisccmd(dev, FDBIO_FORMAT, addr); |
2773 break; 2774 2775 case FD_GTYPE: /* get drive type */ 2776 *(struct fd_type *)addr = *fd->ft; 2777 break; 2778 2779 case FD_STYPE: /* set drive type */ 2780 /* this is considered harmful; only allow for superuser */ --- 32 unchanged lines hidden (view full) --- 2813 return (EINVAL); 2814 memcpy(fsp->status, fd->fdc->status, 7 * sizeof(u_int)); 2815 break; 2816 2817 case FD_READID: 2818 rid = (struct fdc_readid *)addr; 2819 if (rid->cyl > MAX_CYLINDER || rid->head > MAX_HEAD) 2820 return (EINVAL); | 2773 break; 2774 2775 case FD_GTYPE: /* get drive type */ 2776 *(struct fd_type *)addr = *fd->ft; 2777 break; 2778 2779 case FD_STYPE: /* set drive type */ 2780 /* this is considered harmful; only allow for superuser */ --- 32 unchanged lines hidden (view full) --- 2813 return (EINVAL); 2814 memcpy(fsp->status, fd->fdc->status, 7 * sizeof(u_int)); 2815 break; 2816 2817 case FD_READID: 2818 rid = (struct fdc_readid *)addr; 2819 if (rid->cyl > MAX_CYLINDER || rid->head > MAX_HEAD) 2820 return (EINVAL); |
2821 error = fdmisccmd(dev, BIO_RDSECTID, addr); | 2821 error = fdmisccmd(dev, FDBIO_RDSECTID, addr); |
2822 break; 2823 2824 default: 2825 error = ENOTTY; 2826 break; 2827 } 2828 return (error); 2829} | 2822 break; 2823 2824 default: 2825 error = ENOTTY; 2826 break; 2827 } 2828 return (error); 2829} |