1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-16 10:20:30 +00:00

- Supported 1.23MB FD again.

- Supported all formats that IBM-PC's driver (isa/fd.c) supports.
- Changed the device minor numbers. They sync in IBM-PC's driver.
This commit is contained in:
Yoshihiro Takahashi 1999-09-23 14:21:14 +00:00
parent 96648c2dc8
commit a1e145f227
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=51613
2 changed files with 138 additions and 118 deletions

View File

@ -84,15 +84,14 @@
#include <pc98/pc98/pc98.h> #include <pc98/pc98/pc98.h>
#include <pc98/pc98/pc98_machdep.h> #include <pc98/pc98/pc98_machdep.h>
#include <pc98/pc98/epsonio.h> #include <pc98/pc98/epsonio.h>
#include <i386/isa/isa_dma.h>
#include <pc98/pc98/fdreg.h> #include <pc98/pc98/fdreg.h>
#include <isa/fdc.h>
#else #else
#include <i386/isa/isa.h> #include <isa/isareg.h>
#include <i386/isa/isa_dma.h> #include <isa/fdreg.h>
#include <i386/isa/fdreg.h> #include <isa/fdc.h>
#include <isa/rtc.h> #include <isa/rtc.h>
#endif #endif
#include <isa/fdc.h>
#ifdef FDC_YE #ifdef FDC_YE
#undef FDC_YE #undef FDC_YE
@ -118,7 +117,7 @@
#define FDC_ERRMAX 100 /* do not log more */ #define FDC_ERRMAX 100 /* do not log more */
#ifdef PC98 #ifdef PC98
#define NUMTYPES 5 #define NUMTYPES 12
#define NUMDENS NUMTYPES #define NUMDENS NUMTYPES
#else #else
#define NUMTYPES 14 #define NUMTYPES 14
@ -128,17 +127,6 @@
/* These defines (-1) must match index for fd_types */ /* These defines (-1) must match index for fd_types */
#define F_TAPE_TYPE 0x020 /* bit for fd_types to indicate tape */ #define F_TAPE_TYPE 0x020 /* bit for fd_types to indicate tape */
#define NO_TYPE 0 /* must match NO_TYPE in ft.c */ #define NO_TYPE 0 /* must match NO_TYPE in ft.c */
#ifdef PC98
#define FDT_NONE 0 /* none present */
#define FDT_12M 1 /* 1M/640K FDD */
#define FDT_144M 2 /* 1.44M/1M/640K FDD */
#define FD_1200 1
#define FD_1232 2
#define FD_720 3
#define FD_640 4
#define FD_1440 5
#else
#define FD_1720 1 #define FD_1720 1
#define FD_1480 2 #define FD_1480 2
#define FD_1440 3 #define FD_1440 3
@ -148,6 +136,16 @@
#define FD_720 7 #define FD_720 7
#define FD_360 8 #define FD_360 8
#ifdef PC98
#define FD_640 9
#define FD_1232 10
#define FD_1280 11
#define FD_1476 12
#define FDT_NONE 0 /* none present */
#define FDT_12M 1 /* 1M/640K FDD */
#define FDT_144M 2 /* 1.44M/1M/640K FDD */
#else
#define FD_1480in5_25 9 #define FD_1480in5_25 9
#define FD_1440in5_25 10 #define FD_1440in5_25 10
#define FD_820in5_25 11 #define FD_820in5_25 11
@ -160,11 +158,22 @@
static struct fd_type fd_types[NUMTYPES] = static struct fd_type fd_types[NUMTYPES] =
{ {
#ifdef PC98 #ifdef PC98
{ 15,2,0xFF,0x1B,80,2400,1,0,2,0x54,1 }, /* 1.2 meg HD floppy */ { 21,2,0xFF,0x04,82,3444,1,2,2,0x0C,2 }, /* 1.72M in 3mode */
{ 8,3,0xFF,0x35,77,1232,1,0,2,0x74,1 }, /* 1.2 meg HD floppy 1024/sec */ { 18,2,0xFF,0x1B,82,2952,1,2,2,0x54,1 }, /* 1.48M in 3mode */
{ 9,2,0xFF,0x20,80,1440,1,1,2,0x50,1 }, /* 720k floppy in 1.2meg drive */ { 18,2,0xFF,0x1B,80,2880,1,2,2,0x54,1 }, /* 1.44M in 3mode */
{ 8,2,0xFF,0x2A,80,1280,1,1,2,0x50,1 }, /* 640k floppy in 1.2meg drive */ { 15,2,0xFF,0x1B,80,2400,1,0,2,0x54,1 }, /* 1.2M */
{ 18,2,0xFF,0x1B,80,2880,1,2,2,0x54,1 }, /* 1.44 meg HD 3.5in floppy */ { 10,2,0xFF,0x10,82,1640,1,1,2,0x30,1 }, /* 820K */
{ 10,2,0xFF,0x10,80,1600,1,1,2,0x30,1 }, /* 800K */
{ 9,2,0xFF,0x20,80,1440,1,1,2,0x50,1 }, /* 720K */
{ 9,2,0xFF,0x20,40, 720,2,1,2,0x50,1 }, /* 360K */
{ 8,2,0xFF,0x2A,80,1280,1,1,2,0x50,1 }, /* 640K */
{ 8,3,0xFF,0x35,77,1232,1,0,2,0x74,1 }, /* 1.23M 1024/sec */
{ 8,3,0xFF,0x35,80,1280,1,0,2,0x74,1 }, /* 1.28M 1024/sec */
{ 9,3,0xFF,0x35,82,1476,1,0,2,0x47,1 }, /* 1.48M 1024/sec 9sec */
#if 0
{ 10,3,0xFF,0x1B,82,1640,1,2,2,0x54,1 }, /* 1.64M in 3mode - Reserve */
#endif
#else #else
{ 21,2,0xFF,0x04,82,3444,1,FDC_500KBPS,2,0x0C,2 }, /* 1.72M in HD 3.5in */ { 21,2,0xFF,0x04,82,3444,1,FDC_500KBPS,2,0x0C,2 }, /* 1.72M in HD 3.5in */
{ 18,2,0xFF,0x1B,82,2952,1,FDC_500KBPS,2,0x6C,1 }, /* 1.48M in HD 3.5in */ { 18,2,0xFF,0x1B,82,2952,1,FDC_500KBPS,2,0x6C,1 }, /* 1.48M in HD 3.5in */
@ -184,6 +193,17 @@ static struct fd_type fd_types[NUMTYPES] =
#endif #endif
}; };
#ifdef PC98 /* XXX Should be used PC/AT also */
#ifdef DEVFS
static int fd_typesizes[NUMDENS] = {
1720, 1480, 1440, 1200, 820, 800, 720, 360,
#ifdef PC98
640, 1232, 1280, 1476,
#endif
};
#endif /* DEVFS */
#endif
#ifdef PC98 #ifdef PC98
#define DRVS_PER_CTLR 4 /* 4 floppies */ #define DRVS_PER_CTLR 4 /* 4 floppies */
#else #else
@ -217,10 +237,6 @@ struct fd_data {
struct callout_handle toffhandle; struct callout_handle toffhandle;
struct callout_handle tohandle; struct callout_handle tohandle;
struct devstat device_stats; struct devstat device_stats;
#ifdef DEVFS
void *bdevs[1 + NUMDENS + MAXPARTITIONS];
void *cdevs[1 + NUMDENS + MAXPARTITIONS];
#endif
#ifdef PC98 #ifdef PC98
int pc98_trans; int pc98_trans;
#endif #endif
@ -939,8 +955,8 @@ fdc_print_child(device_t me, device_t child)
retval += bus_print_child_header(me, child); retval += bus_print_child_header(me, child);
retval += printf(" on %s drive %d\n", device_get_nameunit(me), retval += printf(" on %s drive %d\n", device_get_nameunit(me),
*(int *)device_get_ivars(child)); *(int *)device_get_ivars(child));
return (retval); return (retval);
} }
@ -1099,25 +1115,31 @@ fd_probe(device_t dev)
#ifdef PC98 #ifdef PC98
switch (fdt) { switch (fdt) {
case FDT_144M:
/* Check 3mode I/F */
fd->pc98_trans = 0;
outb(0x4be, (fd->fdu << 5) | 0x10);
if (!(inb(0x4be) & 0x01)) {
device_set_desc(dev, "1.44M FDD");
fd->type = FD_1440;
break;
}
printf("Warning: can't control 3mode I/F, "
"fallback to 2mode.\n"
"fd%d: ", fd->fdu);
/* FALLTHROUGH */
case FDT_12M: case FDT_12M:
#ifdef EPSON_NRDISK #ifdef EPSON_NRDISK
if (fdu == nrdu) { if (fd->fdu == nrdu) {
device_set_desc(dev, "EPSON RAM DRIVE"); device_set_desc(dev, "EPSON RAM DRIVE");
nrd_LED_off(); nrd_LED_off();
} else } else
device_set_desc(dev, "1M/640M FDD");
#else
device_set_desc(dev, "1M/640M FDD");
#endif #endif
device_set_desc(dev, "1M/640K FDD");
fd->type = FD_1200; fd->type = FD_1200;
fd->pc98_trans = 0; fd->pc98_trans = 0;
break; break;
case FDT_144M:
device_set_desc(dev, "1.44M FDD");
fd->type = FD_1200;
fd->pc98_trans = 0;
outb(0x4be, (fd->fdu << 5) | 0x10);
break;
default: default:
return (ENXIO); return (ENXIO);
} }
@ -1177,19 +1199,7 @@ fd_attach(device_t dev)
* data driven. * data driven.
*/ */
#ifdef PC98 #ifdef PC98
switch (fd->type) { /* XXX any types are OK for PC-98 */
case FDT_12M:
if (i != FD_1200 && i != FD_1232
&& i != FD_720 && i != FD_640)
continue;
break;
case FDT_144M:
if (i != FD_1200 && i != FD_1232
&& i != FD_720 && i != FD_640
&& i != FD_1440)
continue;
break;
}
#else #else
switch (fd->type) { switch (fd->type) {
case FD_360: case FD_360:
@ -1215,10 +1225,7 @@ fd_attach(device_t dev)
} }
#endif #endif
#ifdef PC98 #ifdef PC98
if (i == FD_1232) typesize = fd_typesizes[i - 1];
typesize = fd_types[i - 1].size;
else
typesize = fd_types[i - 1].size / 2;
#else #else
typesize = fd_types[i - 1].size / 2; typesize = fd_types[i - 1].size / 2;
/* /*
@ -1631,12 +1638,16 @@ Fdopen(dev_t dev, int flags, int mode, struct proc *p)
if (type > NUMDENS) if (type > NUMDENS)
return (ENXIO); return (ENXIO);
#ifdef PC98 #ifdef PC98
if (type == 0)
type = FD_1200; /* XXX backward compatibility */
else
; /* XXX any types are OK for PC-98 */
if (pc98_fd_check_ready(fdu) == -1) if (pc98_fd_check_ready(fdu) == -1)
return(EIO); return(EIO);
#endif #else
if (type == 0) if (type == 0)
type = fd->type; type = fd->type;
#ifndef PC98
else { else {
/* /*
* For each type of basic drive, make sure we are trying * For each type of basic drive, make sure we are trying
@ -1989,8 +2000,7 @@ fdstate(fdc_p fdc)
pc98_trans_prev = pc98_trans; pc98_trans_prev = pc98_trans;
} }
if (pc98_trans != fd->pc98_trans) { if (pc98_trans != fd->pc98_trans) {
if (pc98_trans != 1 && if (fd->type == FD_1440) {
(PC98_SYSTEM_PARAMETER(0x5ae) >> fdu) & 0x01) {
outb(0x4be, (fdu << 5) | 0x10 | (pc98_trans >> 1)); outb(0x4be, (fdu << 5) | 0x10 | (pc98_trans >> 1));
outb(0x5f, 0); outb(0x5f, 0);
outb(0x5f, 0); outb(0x5f, 0);

View File

@ -84,15 +84,14 @@
#include <pc98/pc98/pc98.h> #include <pc98/pc98/pc98.h>
#include <pc98/pc98/pc98_machdep.h> #include <pc98/pc98/pc98_machdep.h>
#include <pc98/pc98/epsonio.h> #include <pc98/pc98/epsonio.h>
#include <i386/isa/isa_dma.h>
#include <pc98/pc98/fdreg.h> #include <pc98/pc98/fdreg.h>
#include <isa/fdc.h>
#else #else
#include <i386/isa/isa.h> #include <isa/isareg.h>
#include <i386/isa/isa_dma.h> #include <isa/fdreg.h>
#include <i386/isa/fdreg.h> #include <isa/fdc.h>
#include <isa/rtc.h> #include <isa/rtc.h>
#endif #endif
#include <isa/fdc.h>
#ifdef FDC_YE #ifdef FDC_YE
#undef FDC_YE #undef FDC_YE
@ -118,7 +117,7 @@
#define FDC_ERRMAX 100 /* do not log more */ #define FDC_ERRMAX 100 /* do not log more */
#ifdef PC98 #ifdef PC98
#define NUMTYPES 5 #define NUMTYPES 12
#define NUMDENS NUMTYPES #define NUMDENS NUMTYPES
#else #else
#define NUMTYPES 14 #define NUMTYPES 14
@ -128,17 +127,6 @@
/* These defines (-1) must match index for fd_types */ /* These defines (-1) must match index for fd_types */
#define F_TAPE_TYPE 0x020 /* bit for fd_types to indicate tape */ #define F_TAPE_TYPE 0x020 /* bit for fd_types to indicate tape */
#define NO_TYPE 0 /* must match NO_TYPE in ft.c */ #define NO_TYPE 0 /* must match NO_TYPE in ft.c */
#ifdef PC98
#define FDT_NONE 0 /* none present */
#define FDT_12M 1 /* 1M/640K FDD */
#define FDT_144M 2 /* 1.44M/1M/640K FDD */
#define FD_1200 1
#define FD_1232 2
#define FD_720 3
#define FD_640 4
#define FD_1440 5
#else
#define FD_1720 1 #define FD_1720 1
#define FD_1480 2 #define FD_1480 2
#define FD_1440 3 #define FD_1440 3
@ -148,6 +136,16 @@
#define FD_720 7 #define FD_720 7
#define FD_360 8 #define FD_360 8
#ifdef PC98
#define FD_640 9
#define FD_1232 10
#define FD_1280 11
#define FD_1476 12
#define FDT_NONE 0 /* none present */
#define FDT_12M 1 /* 1M/640K FDD */
#define FDT_144M 2 /* 1.44M/1M/640K FDD */
#else
#define FD_1480in5_25 9 #define FD_1480in5_25 9
#define FD_1440in5_25 10 #define FD_1440in5_25 10
#define FD_820in5_25 11 #define FD_820in5_25 11
@ -160,11 +158,22 @@
static struct fd_type fd_types[NUMTYPES] = static struct fd_type fd_types[NUMTYPES] =
{ {
#ifdef PC98 #ifdef PC98
{ 15,2,0xFF,0x1B,80,2400,1,0,2,0x54,1 }, /* 1.2 meg HD floppy */ { 21,2,0xFF,0x04,82,3444,1,2,2,0x0C,2 }, /* 1.72M in 3mode */
{ 8,3,0xFF,0x35,77,1232,1,0,2,0x74,1 }, /* 1.2 meg HD floppy 1024/sec */ { 18,2,0xFF,0x1B,82,2952,1,2,2,0x54,1 }, /* 1.48M in 3mode */
{ 9,2,0xFF,0x20,80,1440,1,1,2,0x50,1 }, /* 720k floppy in 1.2meg drive */ { 18,2,0xFF,0x1B,80,2880,1,2,2,0x54,1 }, /* 1.44M in 3mode */
{ 8,2,0xFF,0x2A,80,1280,1,1,2,0x50,1 }, /* 640k floppy in 1.2meg drive */ { 15,2,0xFF,0x1B,80,2400,1,0,2,0x54,1 }, /* 1.2M */
{ 18,2,0xFF,0x1B,80,2880,1,2,2,0x54,1 }, /* 1.44 meg HD 3.5in floppy */ { 10,2,0xFF,0x10,82,1640,1,1,2,0x30,1 }, /* 820K */
{ 10,2,0xFF,0x10,80,1600,1,1,2,0x30,1 }, /* 800K */
{ 9,2,0xFF,0x20,80,1440,1,1,2,0x50,1 }, /* 720K */
{ 9,2,0xFF,0x20,40, 720,2,1,2,0x50,1 }, /* 360K */
{ 8,2,0xFF,0x2A,80,1280,1,1,2,0x50,1 }, /* 640K */
{ 8,3,0xFF,0x35,77,1232,1,0,2,0x74,1 }, /* 1.23M 1024/sec */
{ 8,3,0xFF,0x35,80,1280,1,0,2,0x74,1 }, /* 1.28M 1024/sec */
{ 9,3,0xFF,0x35,82,1476,1,0,2,0x47,1 }, /* 1.48M 1024/sec 9sec */
#if 0
{ 10,3,0xFF,0x1B,82,1640,1,2,2,0x54,1 }, /* 1.64M in 3mode - Reserve */
#endif
#else #else
{ 21,2,0xFF,0x04,82,3444,1,FDC_500KBPS,2,0x0C,2 }, /* 1.72M in HD 3.5in */ { 21,2,0xFF,0x04,82,3444,1,FDC_500KBPS,2,0x0C,2 }, /* 1.72M in HD 3.5in */
{ 18,2,0xFF,0x1B,82,2952,1,FDC_500KBPS,2,0x6C,1 }, /* 1.48M in HD 3.5in */ { 18,2,0xFF,0x1B,82,2952,1,FDC_500KBPS,2,0x6C,1 }, /* 1.48M in HD 3.5in */
@ -184,6 +193,17 @@ static struct fd_type fd_types[NUMTYPES] =
#endif #endif
}; };
#ifdef PC98 /* XXX Should be used PC/AT also */
#ifdef DEVFS
static int fd_typesizes[NUMDENS] = {
1720, 1480, 1440, 1200, 820, 800, 720, 360,
#ifdef PC98
640, 1232, 1280, 1476,
#endif
};
#endif /* DEVFS */
#endif
#ifdef PC98 #ifdef PC98
#define DRVS_PER_CTLR 4 /* 4 floppies */ #define DRVS_PER_CTLR 4 /* 4 floppies */
#else #else
@ -217,10 +237,6 @@ struct fd_data {
struct callout_handle toffhandle; struct callout_handle toffhandle;
struct callout_handle tohandle; struct callout_handle tohandle;
struct devstat device_stats; struct devstat device_stats;
#ifdef DEVFS
void *bdevs[1 + NUMDENS + MAXPARTITIONS];
void *cdevs[1 + NUMDENS + MAXPARTITIONS];
#endif
#ifdef PC98 #ifdef PC98
int pc98_trans; int pc98_trans;
#endif #endif
@ -939,8 +955,8 @@ fdc_print_child(device_t me, device_t child)
retval += bus_print_child_header(me, child); retval += bus_print_child_header(me, child);
retval += printf(" on %s drive %d\n", device_get_nameunit(me), retval += printf(" on %s drive %d\n", device_get_nameunit(me),
*(int *)device_get_ivars(child)); *(int *)device_get_ivars(child));
return (retval); return (retval);
} }
@ -1099,25 +1115,31 @@ fd_probe(device_t dev)
#ifdef PC98 #ifdef PC98
switch (fdt) { switch (fdt) {
case FDT_144M:
/* Check 3mode I/F */
fd->pc98_trans = 0;
outb(0x4be, (fd->fdu << 5) | 0x10);
if (!(inb(0x4be) & 0x01)) {
device_set_desc(dev, "1.44M FDD");
fd->type = FD_1440;
break;
}
printf("Warning: can't control 3mode I/F, "
"fallback to 2mode.\n"
"fd%d: ", fd->fdu);
/* FALLTHROUGH */
case FDT_12M: case FDT_12M:
#ifdef EPSON_NRDISK #ifdef EPSON_NRDISK
if (fdu == nrdu) { if (fd->fdu == nrdu) {
device_set_desc(dev, "EPSON RAM DRIVE"); device_set_desc(dev, "EPSON RAM DRIVE");
nrd_LED_off(); nrd_LED_off();
} else } else
device_set_desc(dev, "1M/640M FDD");
#else
device_set_desc(dev, "1M/640M FDD");
#endif #endif
device_set_desc(dev, "1M/640K FDD");
fd->type = FD_1200; fd->type = FD_1200;
fd->pc98_trans = 0; fd->pc98_trans = 0;
break; break;
case FDT_144M:
device_set_desc(dev, "1.44M FDD");
fd->type = FD_1200;
fd->pc98_trans = 0;
outb(0x4be, (fd->fdu << 5) | 0x10);
break;
default: default:
return (ENXIO); return (ENXIO);
} }
@ -1177,19 +1199,7 @@ fd_attach(device_t dev)
* data driven. * data driven.
*/ */
#ifdef PC98 #ifdef PC98
switch (fd->type) { /* XXX any types are OK for PC-98 */
case FDT_12M:
if (i != FD_1200 && i != FD_1232
&& i != FD_720 && i != FD_640)
continue;
break;
case FDT_144M:
if (i != FD_1200 && i != FD_1232
&& i != FD_720 && i != FD_640
&& i != FD_1440)
continue;
break;
}
#else #else
switch (fd->type) { switch (fd->type) {
case FD_360: case FD_360:
@ -1215,10 +1225,7 @@ fd_attach(device_t dev)
} }
#endif #endif
#ifdef PC98 #ifdef PC98
if (i == FD_1232) typesize = fd_typesizes[i - 1];
typesize = fd_types[i - 1].size;
else
typesize = fd_types[i - 1].size / 2;
#else #else
typesize = fd_types[i - 1].size / 2; typesize = fd_types[i - 1].size / 2;
/* /*
@ -1631,12 +1638,16 @@ Fdopen(dev_t dev, int flags, int mode, struct proc *p)
if (type > NUMDENS) if (type > NUMDENS)
return (ENXIO); return (ENXIO);
#ifdef PC98 #ifdef PC98
if (type == 0)
type = FD_1200; /* XXX backward compatibility */
else
; /* XXX any types are OK for PC-98 */
if (pc98_fd_check_ready(fdu) == -1) if (pc98_fd_check_ready(fdu) == -1)
return(EIO); return(EIO);
#endif #else
if (type == 0) if (type == 0)
type = fd->type; type = fd->type;
#ifndef PC98
else { else {
/* /*
* For each type of basic drive, make sure we are trying * For each type of basic drive, make sure we are trying
@ -1989,8 +2000,7 @@ fdstate(fdc_p fdc)
pc98_trans_prev = pc98_trans; pc98_trans_prev = pc98_trans;
} }
if (pc98_trans != fd->pc98_trans) { if (pc98_trans != fd->pc98_trans) {
if (pc98_trans != 1 && if (fd->type == FD_1440) {
(PC98_SYSTEM_PARAMETER(0x5ae) >> fdu) & 0x01) {
outb(0x4be, (fdu << 5) | 0x10 | (pc98_trans >> 1)); outb(0x4be, (fdu << 5) | 0x10 | (pc98_trans >> 1));
outb(0x5f, 0); outb(0x5f, 0);
outb(0x5f, 0); outb(0x5f, 0);