svn commit: r272129 - in head/sys: conf dev/fdc modules/fdc pc98/cbus
John Baldwin
jhb at FreeBSD.org
Thu Sep 25 20:40:25 UTC 2014
Author: jhb
Date: Thu Sep 25 20:40:24 2014
New Revision: 272129
URL: http://svnweb.freebsd.org/changeset/base/272129
Log:
Merge the PC98 fdc(4) driver into the MI driver. While here, replace
the magic numbers used with NE7CMD_SPECIFY with invocations of the
NE7_SPEC_x() macros.
Approved by: nyan
Added:
head/sys/dev/fdc/fdc_cbus.c
- copied, changed from r272118, head/sys/pc98/cbus/fdc_cbus.c
Deleted:
head/sys/pc98/cbus/fdc.c
head/sys/pc98/cbus/fdc_cbus.c
head/sys/pc98/cbus/fdcreg.h
head/sys/pc98/cbus/fdcvar.h
Modified:
head/sys/conf/files.pc98
head/sys/dev/fdc/fdc.c
head/sys/dev/fdc/fdcvar.h
head/sys/modules/fdc/Makefile
Modified: head/sys/conf/files.pc98
==============================================================================
--- head/sys/conf/files.pc98 Thu Sep 25 20:34:13 2014 (r272128)
+++ head/sys/conf/files.pc98 Thu Sep 25 20:40:24 2014 (r272129)
@@ -98,6 +98,8 @@ dev/ct/ct_isa.c optional ct isa
dev/ed/if_ed_cbus.c optional ed isa
dev/ed/if_ed_wd80x3.c optional ed isa
dev/fb/fb.c optional fb | gdc
+dev/fdc/fdc.c optional fdc
+dev/fdc/fdc_cbus.c optional fdc isa
dev/fe/if_fe_cbus.c optional fe isa
dev/hwpmc/hwpmc_amd.c optional hwpmc
dev/hwpmc/hwpmc_intel.c optional hwpmc
@@ -217,8 +219,6 @@ libkern/udivdi3.c standard
libkern/umoddi3.c standard
pc98/apm/apm_bioscall.S optional apm
pc98/cbus/cbus_dma.c optional isa
-pc98/cbus/fdc.c optional fdc
-pc98/cbus/fdc_cbus.c optional fdc isa
pc98/cbus/gdc.c optional gdc
pc98/cbus/nmi.c standard
pc98/cbus/olpt.c optional olpt
Modified: head/sys/dev/fdc/fdc.c
==============================================================================
--- head/sys/dev/fdc/fdc.c Thu Sep 25 20:34:13 2014 (r272128)
+++ head/sys/dev/fdc/fdc.c Thu Sep 25 20:40:24 2014 (r272129)
@@ -82,9 +82,13 @@ __FBSDID("$FreeBSD$");
#include <machine/stdarg.h>
#include <isa/isavar.h>
+#ifdef PC98
+#include <pc98/pc98/pc98_machdep.h>
+#else
#include <isa/isareg.h>
-#include <dev/fdc/fdcvar.h>
#include <isa/rtc.h>
+#endif
+#include <dev/fdc/fdcvar.h>
#include <dev/ic/nec765.h>
@@ -136,33 +140,56 @@ __FBSDID("$FreeBSD$");
*/
static struct fd_type fd_searchlist_360k[] = {
+#ifndef PC98
{ FDF_5_360 },
+#endif
{ 0 }
};
static struct fd_type fd_searchlist_12m[] = {
+#ifdef PC98
+ { FDF_5_1200 | FL_AUTO },
+ { FDF_5_720 | FL_AUTO },
+ { FDF_5_360 | FL_AUTO },
+ { FDF_5_640 | FL_AUTO },
+ { FDF_5_1230 | FL_AUTO },
+#else
{ FDF_5_1200 | FL_AUTO },
{ FDF_5_360 | FL_2STEP | FL_AUTO},
+#endif
{ 0 }
};
static struct fd_type fd_searchlist_720k[] = {
+#ifndef PC98
{ FDF_3_720 },
+#endif
{ 0 }
};
static struct fd_type fd_searchlist_144m[] = {
+#ifdef PC98
{ FDF_3_1440 | FL_AUTO},
+ { FDF_3_1200 | FL_AUTO},
{ FDF_3_720 | FL_AUTO},
+ { FDF_3_360 | FL_AUTO},
+ { FDF_3_640 | FL_AUTO},
+ { FDF_3_1230 | FL_AUTO},
+#else
+ { FDF_3_1440 | FL_AUTO},
+ { FDF_3_720 | FL_AUTO},
+#endif
{ 0 }
};
static struct fd_type fd_searchlist_288m[] = {
+#ifndef PC98
{ FDF_3_1440 | FL_AUTO },
#if 0
{ FDF_3_2880 | FL_AUTO }, /* XXX: probably doesn't work */
#endif
{ FDF_3_720 | FL_AUTO},
+#endif
{ 0 }
};
@@ -183,6 +210,26 @@ static struct fd_type *fd_native_types[]
* Internals start here
*/
+#ifdef PC98
+/* registers */
+#define FDSTS 0 /* NEC 765 Main Status Register (R) */
+#define FDDATA 1 /* NEC 765 Data Register (R/W) */
+#define FDCTL 2 /* FD Control Register */
+#define FDC_RST 0x80 /* FDC RESET */
+#define FDC_RDY 0x40 /* force READY */
+#define FDC_DD 0x20 /* FDD Mode Exchange 0:1M 1:640K */
+#define FDC_DMAE 0x10 /* enable floppy DMA */
+#define FDC_MTON 0x08 /* MOTOR ON (when EMTON=1)*/
+#define FDC_TMSK 0x04 /* TIMER MASK */
+#define FDC_TTRG 0x01 /* TIMER TRIGER */
+
+#define FDP 3
+#define FDP_EMTON 0x04 /* enable MTON */
+#define FDP_FDDEXC 0x02 /* FDD Mode Exchange 1:1M 0:640K */
+#define FDP_PORTEXC 0x01 /* PORT Exchane 1:1M 0:640K */
+
+#define FDEM 4
+#else
/* registers */
#define FDOUT 2 /* Digital Output Register (W) */
#define FDO_FDSEL 0x03 /* floppy device select */
@@ -197,6 +244,7 @@ static struct fd_type *fd_native_types[]
#define FDDSR 4 /* Data Rate Select Register (W) */
#define FDDATA 5 /* NEC 765 Data Register (R/W) */
#define FDCTL 7 /* Control Register (W) */
+#endif /* PC98 */
/*
* The YE-DATA PC Card floppies use PIO to read in the data rather
@@ -219,9 +267,11 @@ static struct fd_type *fd_native_types[]
#define FDBCDR 0 /* And 1 */
#define FD_YE_DATAPORT 6 /* Drive Data port */
+#ifndef PC98
#define FDI_DCHG 0x80 /* diskette has been changed */
/* requires drive and motor being selected */
/* is cleared by any step pulse to drive */
+#endif
/*
* We have three private BIO commands.
@@ -258,6 +308,9 @@ struct fd_data {
struct g_provider *fd_provider;
device_t dev;
struct bio_queue_head fd_bq;
+#ifdef PC98
+ int pc98_trans;
+#endif
};
#define FD_NOT_VALID -2
@@ -281,11 +334,19 @@ static int retries = 10;
SYSCTL_INT(_debug_fdc, OID_AUTO, retries, CTLFLAG_RW, &retries, 0,
"Number of retries to attempt");
-static int spec1 = 0xaf;
+#ifdef PC98
+static int spec1 = NE7_SPEC_1(4, 240);
+#else
+static int spec1 = NE7_SPEC_1(6, 240);
+#endif
SYSCTL_INT(_debug_fdc, OID_AUTO, spec1, CTLFLAG_RW, &spec1, 0,
"Specification byte one (step-rate + head unload)");
-static int spec2 = 0x10;
+#ifdef PC98
+static int spec2 = NE7_SPEC_2(2, 0);
+#else
+static int spec2 = NE7_SPEC_2(16, 0);
+#endif
SYSCTL_INT(_debug_fdc, OID_AUTO, spec2, CTLFLAG_RW, &spec2, 0,
"Specification byte two (head load time + no-dma)");
@@ -335,12 +396,14 @@ fdctl_wr(struct fdc_data *fdc, u_int8_t
fdregwr(fdc, FDCTL, v);
}
+#ifndef PC98
static void
fdout_wr(struct fdc_data *fdc, u_int8_t v)
{
fdregwr(fdc, FDOUT, v);
}
+#endif
static u_int8_t
fdsts_rd(struct fdc_data *fdc)
@@ -349,12 +412,14 @@ fdsts_rd(struct fdc_data *fdc)
return fdregrd(fdc, FDSTS);
}
+#ifndef PC98
static void
fddsr_wr(struct fdc_data *fdc, u_int8_t v)
{
fdregwr(fdc, FDDSR, v);
}
+#endif
static void
fddata_wr(struct fdc_data *fdc, u_int8_t v)
@@ -370,12 +435,14 @@ fddata_rd(struct fdc_data *fdc)
return fdregrd(fdc, FDDATA);
}
+#ifndef PC98
static u_int8_t
fdin_rd(struct fdc_data *fdc)
{
return fdregrd(fdc, FDCTL);
}
+#endif
/*
* Magic pseudo-DMA initialization for YE FDC. Sets count and
@@ -502,11 +569,90 @@ fdc_cmd(struct fdc_data *fdc, int n_out,
return (0);
}
+#ifdef PC98
+static void fd_motor(struct fd_data *fd, int turnon);
+
+static int pc98_trans = 0; /* 0 : HD , 1 : DD , 2 : 1.44 */
+static int pc98_trans_prev = -1;
+
+static void
+set_density(struct fdc_data *fdc)
+{
+ /* always motor on */
+ fdregwr(fdc, FDP, (pc98_trans != 1 ? FDP_FDDEXC : 0) | FDP_PORTEXC);
+ DELAY(100);
+ fdctl_wr(fdc, FDC_RST | FDC_DMAE);
+ /* in the case of note W, always inhibit 100ms timer */
+}
+
+static int
+pc98_fd_check_ready(struct fd_data *fd)
+{
+ struct fdc_data *fdc = fd->fdc;
+ int retry = 0, status;
+ int fdu = device_get_unit(fd->dev);
+
+ while (retry++ < 30000) {
+ fd_motor(fd, 1);
+ fdc_out(fdc, NE7CMD_SENSED); /* Sense Drive Status */
+ DELAY(100);
+ fdc_out(fdc, fdu); /* Drive number */
+ DELAY(100);
+ if ((fdc_in(fdc, &status) == 0) && (status & NE7_ST3_RD)) {
+ fdctl_wr(fdc, FDC_DMAE | FDC_MTON);
+ DELAY(10);
+ return (0);
+ }
+ }
+ return (-1);
+}
+
+static void
+pc98_fd_check_type(struct fd_data *fd, int unit)
+{
+ struct fdc_data *fdc;
+
+ if (fd->type != FDT_NONE || unit < 0 || unit > 3)
+ return;
+
+ fdc = fd->fdc;
+
+ /* Look up what the BIOS thinks we have. */
+ if (!((PC98_SYSTEM_PARAMETER(0x55c) >> unit) & 0x01)) {
+ fd->type = FDT_NONE;
+ return;
+ }
+ if ((PC98_SYSTEM_PARAMETER(0x5ae) >> unit) & 0x01) {
+ /* Check 3mode I/F */
+ fd->pc98_trans = 0;
+ fdregwr(fdc, FDEM, (unit << 5) | 0x10);
+ if (!(fdregrd(fdc, FDEM) & 0x01)) {
+ fd->type = FDT_144M;
+ return;
+ }
+ device_printf(fd->dev,
+ "Warning: can't control 3mode I/F, fallback to 2mode.\n");
+ }
+
+ fd->type = FDT_12M;
+}
+#endif /* PC98 */
+
static void
fdc_reset(struct fdc_data *fdc)
{
int i, r[10];
+#ifdef PC98
+ set_density(fdc);
+ if (pc98_machine_type & M_EPSON_PC98)
+ fdctl_wr(fdc, FDC_RST | FDC_RDY | FDC_DD | FDC_MTON);
+ else
+ fdctl_wr(fdc, FDC_RST | FDC_RDY | FDC_DMAE | FDC_MTON);
+ DELAY(200);
+ fdctl_wr(fdc, FDC_DMAE | FDC_MTON);
+ DELAY(10);
+#else
if (fdc->fdct == FDC_ENHANCED) {
/* Try a software reset, default precomp, and 500 kb/s */
fddsr_wr(fdc, I8207X_DSR_SR);
@@ -519,6 +665,7 @@ fdc_reset(struct fdc_data *fdc)
}
DELAY(100);
fdout_wr(fdc, fdc->fdout);
+#endif
/* XXX after a reset, silently believe the FDC will accept commands */
if (fdc_cmd(fdc, 3, NE7CMD_SPECIFY, spec1, spec2, 0))
@@ -612,6 +759,7 @@ fdc_read_status(struct fdc_data *fdc)
return ret;
}
+#ifndef PC98
/*
* Select this drive
*/
@@ -649,6 +797,7 @@ fd_turnon(void *arg)
if (once)
wakeup(&fd->fdc->head);
}
+#endif
static void
fd_motor(struct fd_data *fd, int turnon)
@@ -659,6 +808,11 @@ fd_motor(struct fd_data *fd, int turnon)
/*
mtx_assert(&fdc->fdc_mtx, MA_OWNED);
*/
+#ifdef PC98
+ fdregwr(fdc, FDP, (pc98_trans != 1 ? FDP_FDDEXC : 0) | FDP_PORTEXC);
+ DELAY(10);
+ fdctl_wr(fdc, FDC_DMAE | FDC_MTON);
+#else
if (turnon) {
fd->flags |= FD_MOTORWAIT;
fdc->fdout |= (FDO_MOEN0 << fd->fdsu);
@@ -669,6 +823,7 @@ fd_motor(struct fd_data *fd, int turnon)
fdc->fdout &= ~(FDO_MOEN0 << fd->fdsu);
}
fdout_wr(fdc, fdc->fdout);
+#endif
}
static void
@@ -836,15 +991,41 @@ fdc_worker(struct fdc_data *fdc)
}
/* Select drive, setup params */
+#ifdef PC98
+ pc98_trans = fd->ft->trans;
+ if (pc98_trans_prev != pc98_trans) {
+ int i;
+
+ set_density(fdc);
+ for (i = 0; i < 10; i++) {
+ outb(0x5f, 0);
+ outb(0x5f, 0);
+ }
+ pc98_trans_prev = pc98_trans;
+ }
+ if (pc98_trans != fd->pc98_trans) {
+ if (fd->type == FDT_144M) {
+ fdregwr(fdc, FDEM,
+ (device_get_unit(fd->dev) << 5) | 0x10 |
+ (pc98_trans >> 1));
+ outb(0x5f, 0);
+ outb(0x5f, 0);
+ }
+ fd->pc98_trans = pc98_trans;
+ }
+#else
fd_select(fd);
if (fdc->fdct == FDC_ENHANCED)
fddsr_wr(fdc, fd->ft->trans);
else
fdctl_wr(fdc, fd->ft->trans);
+#endif
if (bp->bio_cmd & BIO_PROBE) {
if ((!(device_get_flags(fd->dev) & FD_NO_CHLINE) &&
+#ifndef PC98
!(fdin_rd(fdc) & FDI_DCHG) &&
+#endif
!(fd->flags & FD_EMPTY)) ||
fd_probe_disk(fd, &need_recal) == 0)
return (fdc_biodone(fdc, 0));
@@ -857,6 +1038,7 @@ fdc_worker(struct fdc_data *fdc)
if (fd->flags & FD_EMPTY)
return (fdc_biodone(fdc, ENXIO));
+#ifndef PC98
/* Check if we lost our media */
if (fdin_rd(fdc) & FDI_DCHG) {
if (debugflags & 0x40)
@@ -874,9 +1056,10 @@ fdc_worker(struct fdc_data *fdc)
g_topology_unlock();
return (fdc_biodone(fdc, ENXIO));
}
+#endif
/* Check if the floppy is write-protected */
- if(bp->bio_cmd & (BIO_FMT | BIO_WRITE)) {
+ if (bp->bio_cmd & (BIO_FMT | BIO_WRITE)) {
retry_line = __LINE__;
if(fdc_sense_drive(fdc, &st3) != 0)
return (1);
@@ -907,6 +1090,9 @@ fdc_worker(struct fdc_data *fdc)
if ((need_recal & (1 << fd->fdsu)) ||
(cylinder == 0 && fd->track != 0) ||
fdc->retry > 2) {
+#ifdef PC98
+ pc98_fd_check_ready(fd);
+#endif
retry_line = __LINE__;
if (fdc_cmd(fdc, 2, NE7CMD_RECAL, fd->fdsu, 0))
return (1);
@@ -928,6 +1114,9 @@ fdc_worker(struct fdc_data *fdc)
* SEEK to where we want to be
*/
if (cylinder != fd->track) {
+#ifdef PC98
+ pc98_fd_check_ready(fd);
+#endif
retry_line = __LINE__;
if (fdc_cmd(fdc, 3, NE7CMD_SEEK, fd->fdsu, descyl, 0))
return (1);
@@ -1230,6 +1419,7 @@ fd_probe_disk(struct fd_data *fd, int *r
if (fdc_sense_int(fdc, &st0, &cyl) == FD_NOT_VALID)
goto done; /* XXX */
*recal |= (1 << fd->fdsu);
+#ifndef PC98
if (fdin_rd(fdc) & FDI_DCHG) {
if (debugflags & 0x40)
printf("Empty in probe\n");
@@ -1237,6 +1427,9 @@ fd_probe_disk(struct fd_data *fd, int *r
fd->flags |= FD_EMPTY;
mtx_unlock(&fdc->fdc_mtx);
} else {
+#else
+ {
+#endif
if (fdc_sense_drive(fdc, &st3) != 0)
goto done;
if (debugflags & 0x40)
@@ -1372,7 +1565,12 @@ fdautoselect(struct fd_data *fd)
} else {
if (debugflags & 0x40) {
device_printf(fd->dev,
- "autoselected %d KB medium\n", fd->ft->size / 2);
+ "autoselected %d KB medium\n",
+#ifdef PC98
+ (128 << (fd->ft->secsize)) * fd->ft->size / 1024);
+#else
+ fd->ft->size / 2);
+#endif
fdprinttype(fd->ft);
}
return (0);
@@ -1425,6 +1623,10 @@ fd_access(struct g_provider *pp, int r,
busy = 0;
if (pp->acr == 0 && pp->acw == 0 && pp->ace == 0) {
+#ifdef PC98
+ if (pc98_fd_check_ready(fd) == -1)
+ return (ENXIO);
+#endif
if (fdmisccmd(fd, BIO_PROBE, NULL))
return (ENXIO);
if (fd->flags & FD_EMPTY)
@@ -1494,6 +1696,10 @@ fd_ioctl(struct g_provider *pp, u_long c
fd = pp->geom->softc;
+#ifdef PC98
+ pc98_fd_check_ready(fd);
+#endif
+
switch (cmd) {
case FD_GTYPE: /* get drive type */
*(struct fd_type *)data = *fd->ft;
@@ -1661,6 +1867,12 @@ fdc_initial_reset(device_t dev, struct f
{
int ic_type, part_id;
+#ifdef PC98
+ /* See if it can handle a command. */
+ if (fdc_cmd(fdc, 3, NE7CMD_SPECIFY, NE7_SPEC_1(4, 240),
+ NE7_SPEC_2(2, 0), 0))
+ return (ENXIO);
+#else
/*
* A status value of 0xff is very unlikely, but not theoretically
* impossible, but it is far more likely to indicate an empty bus.
@@ -1686,8 +1898,10 @@ fdc_initial_reset(device_t dev, struct f
return (ENXIO);
/* Then, see if it can handle a command. */
- if (fdc_cmd(fdc, 3, NE7CMD_SPECIFY, 0xaf, 0x1e, 0))
+ if (fdc_cmd(fdc, 3, NE7CMD_SPECIFY, NE7_SPEC_1(6, 240),
+ NE7_SPEC_2(31, 0), 0))
return (ENXIO);
+#endif
/*
* Try to identify the chip.
@@ -1749,7 +1963,11 @@ fdc_detach(device_t dev)
mtx_unlock(&fdc->fdc_mtx);
/* reset controller, turn motor off */
+#ifdef PC98
+ fdc_reset(fdc);
+#else
fdout_wr(fdc, 0);
+#endif
if (!(fdc->flags & FDC_NODMA))
isa_dma_release(fdc->dmachan);
@@ -1823,7 +2041,11 @@ fdc_attach(device_t dev)
mtx_init(&fdc->fdc_mtx, "fdc lock", NULL, MTX_DEF);
/* reset controller, turn motor off, clear fdout mirror reg */
+#ifdef PC98
+ fdc_reset(fdc);
+#else
fdout_wr(fdc, fdc->fdout = 0);
+#endif
bioq_init(&fdc->head);
kproc_create(fdc_thread, fdc, &fdc->fdc_thread, 0, 0,
@@ -1877,8 +2099,11 @@ fdc_print_child(device_t me, device_t ch
static int
fd_probe(device_t dev)
{
- int i, unit;
+ int unit;
+#ifndef PC98
+ int i;
u_int st0, st3;
+#endif
struct fd_data *fd;
struct fdc_data *fdc;
int fdsu;
@@ -1905,7 +2130,9 @@ fd_probe(device_t dev)
fd->type = type;
}
-#if (defined(__i386__) && !defined(PC98)) || defined(__amd64__)
+#ifdef PC98
+ pc98_fd_check_type(fd, unit);
+#elif defined(__i386__) || defined(__amd64__)
if (fd->type == FDT_NONE && (unit == 0 || unit == 1)) {
/* Look up what the BIOS thinks we have. */
if (unit == 0)
@@ -1920,6 +2147,7 @@ fd_probe(device_t dev)
if (fd->type == FDT_NONE)
return (ENXIO);
+#ifndef PC98
/*
mtx_lock(&fdc->fdc_mtx);
*/
@@ -1972,10 +2200,19 @@ fd_probe(device_t dev)
if ((flags & FD_NO_PROBE) == 0 &&
(st0 & NE7_ST0_EC) != 0) /* no track 0 -> no drive present */
return (ENXIO);
+#endif /* PC98 */
done:
switch (fd->type) {
+#ifdef PC98
+ case FDT_144M:
+ device_set_desc(dev, "1.44M FDD");
+ break;
+ case FDT_12M:
+ device_set_desc(dev, "1M/640K FDD");
+ break;
+#else
case FDT_12M:
device_set_desc(dev, "1200-KB 5.25\" drive");
break;
@@ -1991,6 +2228,7 @@ done:
case FDT_720K:
device_set_desc(dev, "720-KB 3.5\" drive");
break;
+#endif
default:
return (ENXIO);
}
@@ -1998,6 +2236,9 @@ done:
fd->fdc = fdc;
fd->fdsu = fdsu;
fd->options = 0;
+#ifdef PC98
+ fd->pc98_trans = 0;
+#endif
callout_init_mtx(&fd->toffhandle, &fd->fdc->fdc_mtx, 0);
/* initialize densities for subdevices */
Copied and modified: head/sys/dev/fdc/fdc_cbus.c (from r272118, head/sys/pc98/cbus/fdc_cbus.c)
==============================================================================
--- head/sys/pc98/cbus/fdc_cbus.c Thu Sep 25 17:47:26 2014 (r272118, copy source)
+++ head/sys/dev/fdc/fdc_cbus.c Thu Sep 25 20:40:24 2014 (r272129)
@@ -33,15 +33,16 @@ __FBSDID("$FreeBSD$");
#include <sys/bio.h>
#include <sys/bus.h>
#include <sys/kernel.h>
+#include <sys/lock.h>
#include <sys/module.h>
+#include <sys/mutex.h>
#include <sys/rman.h>
#include <sys/systm.h>
#include <machine/bus.h>
#include <pc98/cbus/cbus.h>
-#include <pc98/cbus/fdcreg.h>
-#include <pc98/cbus/fdcvar.h>
+#include <dev/fdc/fdcvar.h>
#include <isa/isavar.h>
@@ -50,62 +51,70 @@ static bus_addr_t fdc_iat[] = {0, 2, 4};
static int
fdc_cbus_alloc_resources(device_t dev, struct fdc_data *fdc)
{
- int rid;
+ struct resource *res;
+ int i, rid;
fdc->fdc_dev = dev;
- fdc->rid_ioport = 0;
- fdc->rid_irq = 0;
- fdc->rid_drq = 0;
- fdc->res_irq = 0;
- fdc->res_drq = 0;
-
- fdc->res_ioport = isa_alloc_resourcev(dev, SYS_RES_IOPORT,
- &fdc->rid_ioport, fdc_iat,
- 3, RF_ACTIVE);
- if (fdc->res_ioport == 0) {
+ rid = 0;
+ res = isa_alloc_resourcev(dev, SYS_RES_IOPORT, &rid, fdc_iat, 3,
+ RF_ACTIVE);
+ if (res == NULL) {
device_printf(dev, "cannot reserve I/O port range\n");
- return ENXIO;
+ return (ENXIO);
}
- isa_load_resourcev(fdc->res_ioport, fdc_iat, 3);
- fdc->portt = rman_get_bustag(fdc->res_ioport);
- fdc->porth = rman_get_bushandle(fdc->res_ioport);
-
+ isa_load_resourcev(res, fdc_iat, 3);
+ for (i = 0; i < 3; i++) {
+ fdc->resio[i] = res;
+ fdc->ridio[i] = rid;
+ fdc->ioff[i] = i;
+ fdc->ioh[i] = rman_get_bushandle(res);
+ }
+ fdc->iot = rman_get_bustag(res);
+
rid = 3;
bus_set_resource(dev, SYS_RES_IOPORT, rid, IO_FDPORT, 1);
- fdc->res_fdsio = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid,
- RF_ACTIVE);
- if (fdc->res_fdsio == 0)
- return ENXIO;
- fdc->sc_fdsiot = rman_get_bustag(fdc->res_fdsio);
- fdc->sc_fdsioh = rman_get_bushandle(fdc->res_fdsio);
+ res = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, RF_ACTIVE);
+ if (res == NULL) {
+ device_printf(dev, "cannot reserve I/O port range\n");
+ return (ENXIO);
+ }
+ fdc->resio[3] = res;
+ fdc->ridio[3] = rid;
+ fdc->ioff[3] = 0;
+ fdc->ioh[3] = rman_get_bushandle(res);
+ /* XXX: Reuses fdc->iot */
rid = 4;
bus_set_resource(dev, SYS_RES_IOPORT, rid, 0x4be, 1);
- fdc->res_fdemsio = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid,
- RF_ACTIVE);
- if (fdc->res_fdemsio == 0)
- return ENXIO;
- fdc->sc_fdemsiot = rman_get_bustag(fdc->res_fdemsio);
- fdc->sc_fdemsioh = rman_get_bushandle(fdc->res_fdemsio);
+ res = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, RF_ACTIVE);
+ if (res == NULL) {
+ device_printf(dev, "cannot reserve I/O port range\n");
+ return (ENXIO);
+ }
+ fdc->resio[4] = res;
+ fdc->ridio[4] = rid;
+ fdc->ioff[4] = 0;
+ fdc->ioh[4] = rman_get_bushandle(res);
+ /* XXX: Reuses fdc->iot */
fdc->res_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &fdc->rid_irq,
- RF_ACTIVE);
- if (fdc->res_irq == 0) {
+ RF_ACTIVE);
+ if (fdc->res_irq == NULL) {
device_printf(dev, "cannot reserve interrupt line\n");
- return ENXIO;
+ return (ENXIO);
}
if ((fdc->flags & FDC_NODMA) == 0) {
fdc->res_drq = bus_alloc_resource_any(dev, SYS_RES_DRQ,
- &fdc->rid_drq, RF_ACTIVE);
- if (fdc->res_drq == 0) {
+ &fdc->rid_drq, RF_ACTIVE);
+ if (fdc->res_drq == NULL) {
device_printf(dev, "cannot reserve DMA request line\n");
- return ENXIO;
+ return (ENXIO);
}
fdc->dmachan = rman_get_start(fdc->res_drq);
}
- return 0;
+ return (0);
}
static int
@@ -122,8 +131,8 @@ fdc_cbus_probe(device_t dev)
/* Attempt to allocate our resources for the duration of the probe */
error = fdc_cbus_alloc_resources(dev, fdc);
- if (!error)
- error = fdc_initial_reset(fdc);
+ if (error == 0)
+ error = fdc_initial_reset(dev, fdc);
fdc_release_resources(fdc);
return (error);
@@ -136,15 +145,14 @@ fdc_cbus_attach(device_t dev)
int error;
fdc = device_get_softc(dev);
-
- if ((error = fdc_cbus_alloc_resources(dev, fdc)) != 0 ||
- (error = fdc_attach(dev)) != 0 ||
- (error = fdc_hints_probe(dev)) != 0) {
+ error = fdc_cbus_alloc_resources(dev, fdc);
+ if (error == 0)
+ error = fdc_attach(dev);
+ if (error == 0)
+ error = fdc_hints_probe(dev);
+ if (error)
fdc_release_resources(fdc);
- return (error);
- }
-
- return (0);
+ return (error);
}
static device_method_t fdc_methods[] = {
Modified: head/sys/dev/fdc/fdcvar.h
==============================================================================
--- head/sys/dev/fdc/fdcvar.h Thu Sep 25 20:34:13 2014 (r272128)
+++ head/sys/dev/fdc/fdcvar.h Thu Sep 25 20:40:24 2014 (r272129)
@@ -49,7 +49,9 @@ struct fdc_data {
#define FDC_KTHREAD_ALIVE 0x2000 /* worker thread is alive */
struct fd_data *fd; /* The active drive */
int retry;
+#ifndef PC98
int fdout; /* mirror of the w/o digital output reg */
+#endif
u_int status[7]; /* copy of the registers */
enum fdc_type fdct; /* chip version of FDC */
int fdc_errs; /* number of logged errors */
Modified: head/sys/modules/fdc/Makefile
==============================================================================
--- head/sys/modules/fdc/Makefile Thu Sep 25 20:34:13 2014 (r272128)
+++ head/sys/modules/fdc/Makefile Thu Sep 25 20:40:24 2014 (r272129)
@@ -2,11 +2,10 @@
KMOD= fdc
+.PATH: ${.CURDIR}/../../dev/fdc
.if ${MACHINE} == "pc98"
-.PATH: ${.CURDIR}/../../pc98/cbus
SRCS= fdc.c fdc_cbus.c
.else
-.PATH: ${.CURDIR}/../../dev/fdc
SRCS= fdc.c fdc_isa.c fdc_pccard.c
.if ${MACHINE} == "i386" || ${MACHINE} == "amd64"
SRCS+= opt_acpi.h acpi_if.h fdc_acpi.c
More information about the svn-src-head
mailing list