fdc.c (f71d35e4022cb9949a2afd8fdefe913c9a810361) | fdc.c (d2fb48929a4984996e65d084adcaf39f1820fb24) |
---|---|
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.99 1997/03/24 11:23:43 bde Exp $ | 46 * $Id: fd.c,v 1.100 1997/07/20 14:09:54 bde Exp $ |
47 * 48 */ 49 50#include "ft.h" 51#if NFT < 1 52#undef NFDC 53#endif 54#include "fd.h" | 47 * 48 */ 49 50#include "ft.h" 51#if NFT < 1 52#undef NFDC 53#endif 54#include "fd.h" |
55#include "opt_fdc.h" |
|
55 56#if NFDC > 0 57 58#include <sys/param.h> 59#include <sys/systm.h> 60#include <sys/kernel.h> 61#include <sys/conf.h> 62#include <sys/fcntl.h> --- 165 unchanged lines hidden (view full) --- 228#define RECALCOMPLETE 5 229#define STARTRECAL 6 230#define RESETCTLR 7 231#define SEEKWAIT 8 232#define RECALWAIT 9 233#define MOTORWAIT 10 234#define IOTIMEDOUT 11 235 | 56 57#if NFDC > 0 58 59#include <sys/param.h> 60#include <sys/systm.h> 61#include <sys/kernel.h> 62#include <sys/conf.h> 63#include <sys/fcntl.h> --- 165 unchanged lines hidden (view full) --- 229#define RECALCOMPLETE 5 230#define STARTRECAL 6 231#define RESETCTLR 7 232#define SEEKWAIT 8 233#define RECALWAIT 9 234#define MOTORWAIT 10 235#define IOTIMEDOUT 11 236 |
236#ifdef DEBUG | 237#ifdef FDC_DEBUG |
237static char const * const fdstates[] = 238{ 239"DEVIDLE", 240"FINDWORK", 241"DOSEEK", 242"SEEKCOMPLETE", 243"IOCOMPLETE", 244"RECALCOMPLETE", --- 4 unchanged lines hidden (view full) --- 249"MOTORWAIT", 250"IOTIMEDOUT" 251}; 252 253/* CAUTION: fd_debug causes huge amounts of logging output */ 254static int volatile fd_debug = 0; 255#define TRACE0(arg) if(fd_debug) printf(arg) 256#define TRACE1(arg1, arg2) if(fd_debug) printf(arg1, arg2) | 238static char const * const fdstates[] = 239{ 240"DEVIDLE", 241"FINDWORK", 242"DOSEEK", 243"SEEKCOMPLETE", 244"IOCOMPLETE", 245"RECALCOMPLETE", --- 4 unchanged lines hidden (view full) --- 250"MOTORWAIT", 251"IOTIMEDOUT" 252}; 253 254/* CAUTION: fd_debug causes huge amounts of logging output */ 255static int volatile fd_debug = 0; 256#define TRACE0(arg) if(fd_debug) printf(arg) 257#define TRACE1(arg1, arg2) if(fd_debug) printf(arg1, arg2) |
257#else /* DEBUG */ | 258#else /* FDC_DEBUG */ |
258#define TRACE0(arg) 259#define TRACE1(arg1, arg2) | 259#define TRACE0(arg) 260#define TRACE1(arg1, arg2) |
260#endif /* DEBUG */ | 261#endif /* FDC_DEBUG */ |
261 262/* autoconfig structure */ 263 264struct isa_driver fdcdriver = { 265 fdprobe, fdattach, "fdc", 266}; 267 268static d_open_t Fdopen; /* NOTE, not fdopen */ --- 267 unchanged lines hidden (view full) --- 536 537 /* select it */ 538 set_motor(fdcu, fdsu, TURNON); 539 DELAY(1000000); /* 1 sec */ 540 541 if (ic_type == 0 && 542 fd_cmd(fdcu, 1, NE7CMD_VERSION, 1, &ic_type) == 0) 543 { | 262 263/* autoconfig structure */ 264 265struct isa_driver fdcdriver = { 266 fdprobe, fdattach, "fdc", 267}; 268 269static d_open_t Fdopen; /* NOTE, not fdopen */ --- 267 unchanged lines hidden (view full) --- 537 538 /* select it */ 539 set_motor(fdcu, fdsu, TURNON); 540 DELAY(1000000); /* 1 sec */ 541 542 if (ic_type == 0 && 543 fd_cmd(fdcu, 1, NE7CMD_VERSION, 1, &ic_type) == 0) 544 { |
545#ifdef FDC_PRINT_BOGUS_CHIPTYPE |
|
544 printf("fdc%d: ", fdcu); | 546 printf("fdc%d: ", fdcu); |
547#endif |
|
545 ic_type = (u_char)ic_type; 546 switch( ic_type ) { 547 case 0x80: | 548 ic_type = (u_char)ic_type; 549 switch( ic_type ) { 550 case 0x80: |
551#ifdef FDC_PRINT_BOGUS_CHIPTYPE |
|
548 printf("NEC 765\n"); | 552 printf("NEC 765\n"); |
553#endif |
|
549 fdc->fdct = FDC_NE765; 550 break; 551 case 0x81: | 554 fdc->fdct = FDC_NE765; 555 break; 556 case 0x81: |
557#ifdef FDC_PRINT_BOGUS_CHIPTYPE |
|
552 printf("Intel 82077\n"); | 558 printf("Intel 82077\n"); |
559#endif |
|
553 fdc->fdct = FDC_I82077; 554 break; 555 case 0x90: | 560 fdc->fdct = FDC_I82077; 561 break; 562 case 0x90: |
563#ifdef FDC_PRINT_BOGUS_CHIPTYPE |
|
556 printf("NEC 72065B\n"); | 564 printf("NEC 72065B\n"); |
565#endif |
|
557 fdc->fdct = FDC_NE72065; 558 break; 559 default: | 566 fdc->fdct = FDC_NE72065; 567 break; 568 default: |
569#ifdef FDC_PRINT_BOGUS_CHIPTYPE |
|
560 printf("unknown IC type %02x\n", ic_type); | 570 printf("unknown IC type %02x\n", ic_type); |
571#endif |
|
561 fdc->fdct = FDC_UNKNOWN; 562 break; 563 } 564 } 565 if ((fd_cmd(fdcu, 2, NE7CMD_SENSED, fdsu, 1, &st3) == 0) && 566 (st3 & NE7_ST3_T0)) { 567 /* if at track 0, first seek inwards */ 568 /* seek some steps: */ --- 279 unchanged lines hidden (view full) --- 848 int baseport = fdc_data[fdcu].baseport; 849 int i, j = 100000; 850 while ((i = inb(baseport+FDSTS) & (NE7_DIO|NE7_RQM)) 851 != (NE7_DIO|NE7_RQM) && j-- > 0) 852 if (i == NE7_RQM) 853 return fdc_err(fdcu, "ready for output in input\n"); 854 if (j <= 0) 855 return fdc_err(fdcu, bootverbose? "input ready timeout\n": 0); | 572 fdc->fdct = FDC_UNKNOWN; 573 break; 574 } 575 } 576 if ((fd_cmd(fdcu, 2, NE7CMD_SENSED, fdsu, 1, &st3) == 0) && 577 (st3 & NE7_ST3_T0)) { 578 /* if at track 0, first seek inwards */ 579 /* seek some steps: */ --- 279 unchanged lines hidden (view full) --- 859 int baseport = fdc_data[fdcu].baseport; 860 int i, j = 100000; 861 while ((i = inb(baseport+FDSTS) & (NE7_DIO|NE7_RQM)) 862 != (NE7_DIO|NE7_RQM) && j-- > 0) 863 if (i == NE7_RQM) 864 return fdc_err(fdcu, "ready for output in input\n"); 865 if (j <= 0) 866 return fdc_err(fdcu, bootverbose? "input ready timeout\n": 0); |
856#ifdef DEBUG | 867#ifdef FDC_DEBUG |
857 i = inb(baseport+FDDATA); 858 TRACE1("[FDDATA->0x%x]", (unsigned char)i); 859 return(i); | 868 i = inb(baseport+FDDATA); 869 TRACE1("[FDDATA->0x%x]", (unsigned char)i); 870 return(i); |
860#else | 871#else /* !FDC_DEBUG */ |
861 return inb(baseport+FDDATA); | 872 return inb(baseport+FDDATA); |
862#endif | 873#endif /* FDC_DEBUG */ |
863} 864 865/* 866 * fd_in: Like in_fdc, but allows you to see if it worked. 867 */ 868static int 869fd_in(fdcu_t fdcu, int *ptr) 870{ 871 int baseport = fdc_data[fdcu].baseport; 872 int i, j = 100000; 873 while ((i = inb(baseport+FDSTS) & (NE7_DIO|NE7_RQM)) 874 != (NE7_DIO|NE7_RQM) && j-- > 0) 875 if (i == NE7_RQM) 876 return fdc_err(fdcu, "ready for output in input\n"); 877 if (j <= 0) 878 return fdc_err(fdcu, bootverbose? "input ready timeout\n": 0); | 874} 875 876/* 877 * fd_in: Like in_fdc, but allows you to see if it worked. 878 */ 879static int 880fd_in(fdcu_t fdcu, int *ptr) 881{ 882 int baseport = fdc_data[fdcu].baseport; 883 int i, j = 100000; 884 while ((i = inb(baseport+FDSTS) & (NE7_DIO|NE7_RQM)) 885 != (NE7_DIO|NE7_RQM) && j-- > 0) 886 if (i == NE7_RQM) 887 return fdc_err(fdcu, "ready for output in input\n"); 888 if (j <= 0) 889 return fdc_err(fdcu, bootverbose? "input ready timeout\n": 0); |
879#ifdef DEBUG | 890#ifdef FDC_DEBUG |
880 i = inb(baseport+FDDATA); 881 TRACE1("[FDDATA->0x%x]", (unsigned char)i); 882 *ptr = i; 883 return 0; | 891 i = inb(baseport+FDDATA); 892 TRACE1("[FDDATA->0x%x]", (unsigned char)i); 893 *ptr = i; 894 return 0; |
884#else | 895#else /* !FDC_DEBUG */ |
885 i = inb(baseport+FDDATA); 886 if (ptr) 887 *ptr = i; 888 return 0; | 896 i = inb(baseport+FDDATA); 897 if (ptr) 898 *ptr = i; 899 return 0; |
889#endif | 900#endif /* FDC_DEBUG */ |
890} 891 892int 893out_fdc(fdcu_t fdcu, int x) 894{ 895 int baseport = fdc_data[fdcu].baseport; 896 int i; 897 --- 997 unchanged lines hidden --- | 901} 902 903int 904out_fdc(fdcu_t fdcu, int x) 905{ 906 int baseport = fdc_data[fdcu].baseport; 907 int i; 908 --- 997 unchanged lines hidden --- |