mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-12-04 12:28:58 +00:00
Sync with sys/i386/isa/wd.c revision 1.166.
This commit is contained in:
parent
0b9df1bef1
commit
78f718856a
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=35826
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)wd.c 7.2 (Berkeley) 5/9/91
|
||||
* $Id: wd.c,v 1.52 1998/05/04 04:55:36 kato Exp $
|
||||
* $Id: wd.c,v 1.53 1998/05/06 08:25:58 kato Exp $
|
||||
*/
|
||||
|
||||
/* TODO:
|
||||
@ -180,21 +180,21 @@ struct diskgeom {
|
||||
* The structure of a disk drive.
|
||||
*/
|
||||
struct disk {
|
||||
long dk_bc; /* byte count left */
|
||||
u_int dk_bc; /* byte count left */
|
||||
short dk_skip; /* blocks already transferred */
|
||||
int dk_ctrlr; /* physical controller number */
|
||||
#ifdef CMD640
|
||||
int dk_ctrlr_cmd640;/* controller number for CMD640 quirk */
|
||||
#endif
|
||||
int dk_unit; /* physical unit number */
|
||||
int dk_lunit; /* logical unit number */
|
||||
int dk_interface; /* interface (two ctrlrs per interface) */
|
||||
u_int32_t dk_unit; /* physical unit number */
|
||||
u_int32_t dk_lunit; /* logical unit number */
|
||||
u_int32_t dk_interface; /* interface (two ctrlrs per interface) */
|
||||
char dk_state; /* control state */
|
||||
u_char dk_status; /* copy of status reg. */
|
||||
u_char dk_error; /* copy of error reg. */
|
||||
u_char dk_timeout; /* countdown to next timeout */
|
||||
int dk_port; /* i/o port base */
|
||||
int dk_altport; /* altstatus port base */
|
||||
u_int32_t dk_port; /* i/o port base */
|
||||
u_int32_t dk_altport; /* altstatus port base */
|
||||
#ifdef DEVFS
|
||||
#ifdef SLICE
|
||||
struct slice *slice;
|
||||
@ -221,8 +221,8 @@ struct disk {
|
||||
#define DKFL_LBA 0x02000 /* use LBA for data transfers */
|
||||
struct wdparams dk_params; /* ESDI/IDE drive/controller parameters */
|
||||
int dk_dkunit; /* disk stats unit number */
|
||||
int dk_multi; /* multi transfers */
|
||||
int dk_currentiosize; /* current io size */
|
||||
unsigned int dk_multi; /* multi transfers */
|
||||
u_int dk_currentiosize; /* current io size */
|
||||
struct diskgeom dk_dd; /* device configuration data */
|
||||
struct diskslices *dk_slices; /* virtual drives */
|
||||
void *dk_dmacookie; /* handle for DMA services */
|
||||
@ -274,7 +274,9 @@ static void wderror(struct buf *bp, struct disk *du, char *mesg);
|
||||
static void wdflushirq(struct disk *du, int old_ipl);
|
||||
static int wdreset(struct disk *du);
|
||||
static void wdsleep(int ctrlr, char *wmesg);
|
||||
#ifndef SLICE
|
||||
static void wdstrategy1(struct buf *bp);
|
||||
#endif
|
||||
static timeout_t wdtimeout;
|
||||
static int wdunwedge(struct disk *du);
|
||||
static int wdwait(struct disk *du, u_char bits_wanted, int timeout);
|
||||
@ -289,6 +291,7 @@ static sl_h_IO_req_t wdsIOreq; /* IO req downward (to device) */
|
||||
static sl_h_ioctl_t wdsioctl; /* ioctl req downward (to device) */
|
||||
static sl_h_open_t wdsopen; /* downwards travelling open */
|
||||
/*static sl_h_close_t wdsclose; */ /* downwards travelling close */
|
||||
static sl_h_dump_t wddump; /* core dump req downward */
|
||||
static void wds_init(void*);
|
||||
|
||||
static struct slice_handler slicetype = {
|
||||
@ -304,7 +307,8 @@ static struct slice_handler slicetype = {
|
||||
NULL, /* revoke */
|
||||
NULL, /* claim */
|
||||
NULL, /* verify */
|
||||
NULL /* upconfig */
|
||||
NULL, /* upconfig */
|
||||
&wddump
|
||||
};
|
||||
#endif
|
||||
|
||||
@ -513,7 +517,7 @@ wdattach(struct isa_device *dvp)
|
||||
#if defined(DEVFS) && ! defined(SLICE)
|
||||
int mynor;
|
||||
#endif
|
||||
int unit, lunit;
|
||||
u_int unit, lunit;
|
||||
struct isa_device *wdup;
|
||||
struct disk *du;
|
||||
struct wdparams *wp;
|
||||
@ -966,8 +970,8 @@ wdstart(int ctrlr)
|
||||
struct diskgeom *lp; /* XXX sic */
|
||||
long blknum;
|
||||
long secpertrk, secpercyl;
|
||||
int lunit;
|
||||
int count;
|
||||
u_int lunit;
|
||||
u_int count;
|
||||
#ifdef CMD640
|
||||
int ctrlr_atapi;
|
||||
|
||||
@ -1070,7 +1074,7 @@ wdstart(int ctrlr)
|
||||
blknum - ds_offset) + ds_offset;
|
||||
}
|
||||
#else
|
||||
if (du->dk_flags & DKFL_SINGLE) {
|
||||
if (du->dk_flags & DKFL_SINGLE && du->slice->handler_up) {
|
||||
(void) (*du->slice->handler_up->upconf)(du->slice,
|
||||
SLCIOCTRANSBAD, (caddr_t)&blknum, 0, 0);
|
||||
}
|
||||
@ -1435,7 +1439,7 @@ oops:
|
||||
if (((bp->b_flags & (B_READ | B_ERROR)) == B_READ)
|
||||
&& !((du->dk_flags & (DKFL_DMA|DKFL_SINGLE)) == DKFL_DMA)
|
||||
&& wdtab[unit].b_active) {
|
||||
int chk, dummy, multisize;
|
||||
u_int chk, dummy, multisize;
|
||||
multisize = chk = du->dk_currentiosize * DEV_BSIZE;
|
||||
if( du->dk_bc < chk) {
|
||||
chk = du->dk_bc;
|
||||
@ -2197,7 +2201,7 @@ failed:
|
||||
bcopy(tb, wp, sizeof(struct wdparams));
|
||||
|
||||
/* shuffle string byte order */
|
||||
for (i = 0; i < sizeof(wp->wdp_model); i += 2) {
|
||||
for (i = 0; (unsigned)i < sizeof(wp->wdp_model); i += 2) {
|
||||
u_short *p;
|
||||
|
||||
p = (u_short *) (wp->wdp_model + i);
|
||||
@ -2207,12 +2211,13 @@ failed:
|
||||
* Clean up the wdp_model by converting nulls to spaces, and
|
||||
* then removing the trailing spaces.
|
||||
*/
|
||||
for (i=0; i < sizeof(wp->wdp_model); i++) {
|
||||
for (i = 0; (unsigned)i < sizeof(wp->wdp_model); i++) {
|
||||
if (wp->wdp_model[i] == '\0') {
|
||||
wp->wdp_model[i] = ' ';
|
||||
}
|
||||
}
|
||||
for (i=sizeof(wp->wdp_model)-1; i>=0 && wp->wdp_model[i]==' '; i--) {
|
||||
for (i = sizeof(wp->wdp_model) - 1;
|
||||
(i >= 0 && wp->wdp_model[i] == ' '); i--) {
|
||||
wp->wdp_model[i] = '\0';
|
||||
}
|
||||
|
||||
@ -2420,12 +2425,15 @@ wdsize(dev_t dev)
|
||||
#endif
|
||||
return (dssize(dev, &du->dk_slices, wdopen, wdclose));
|
||||
}
|
||||
|
||||
/*
|
||||
* Dump core after a system crash.
|
||||
*/
|
||||
#endif /* !SLICE */
|
||||
|
||||
#ifndef SLICE
|
||||
int
|
||||
wddump(dev_t dev)
|
||||
#else
|
||||
static int
|
||||
wddump(void *private, int32_t start, int32_t num)
|
||||
#endif /* SLICE */
|
||||
{
|
||||
#ifdef PC98
|
||||
/* do nothing */
|
||||
@ -2433,17 +2441,23 @@ wddump(dev_t dev)
|
||||
return(0);
|
||||
#else
|
||||
register struct disk *du;
|
||||
#ifndef SLICE
|
||||
struct disklabel *lp;
|
||||
long num; /* number of sectors to write */
|
||||
int lunit, part;
|
||||
long blkoff, blknum;
|
||||
long blkchk, blkcnt, blknext;
|
||||
long cylin, head, sector;
|
||||
long secpertrk, secpercyl, nblocks;
|
||||
u_long ds_offset;
|
||||
char *addr;
|
||||
u_long nblocks;
|
||||
static int wddoingadump = 0;
|
||||
#else
|
||||
long blknum, blkchk, blkcnt, blknext;
|
||||
#endif /* SLICE */
|
||||
long cylin, head, sector;
|
||||
long secpertrk, secpercyl;
|
||||
char *addr;
|
||||
|
||||
#ifndef SLICE
|
||||
/* Toss any characters present prior to dump. */
|
||||
while (cncheckc() != -1)
|
||||
;
|
||||
@ -2463,6 +2477,7 @@ wddump(dev_t dev)
|
||||
/* Size of memory to dump, in disk sectors. */
|
||||
num = (u_long)Maxmem * PAGE_SIZE / du->dk_dd.d_secsize;
|
||||
|
||||
|
||||
secpertrk = du->dk_dd.d_nsectors;
|
||||
secpercyl = du->dk_dd.d_secpercyl;
|
||||
nblocks = lp->d_partitions[part].p_size;
|
||||
@ -2489,6 +2504,14 @@ wddump(dev_t dev)
|
||||
wdtab[du->dk_ctrlr].b_active = 1;
|
||||
#endif
|
||||
wddoingadump = 1;
|
||||
#else
|
||||
du = private;
|
||||
if (du->dk_state < OPEN)
|
||||
return (ENXIO);
|
||||
|
||||
secpertrk = du->dk_dd.d_nsectors;
|
||||
secpercyl = du->dk_dd.d_secpercyl;
|
||||
#endif /* SLICE */
|
||||
|
||||
/* Recalibrate the drive. */
|
||||
DELAY(5); /* ATA spec XXX NOT */
|
||||
@ -2501,7 +2524,11 @@ wddump(dev_t dev)
|
||||
|
||||
du->dk_flags |= DKFL_SINGLE;
|
||||
addr = (char *) 0;
|
||||
#ifndef SLICE
|
||||
blknum = dumplo + blkoff;
|
||||
#else
|
||||
blknum = start;
|
||||
#endif /* SLICE */
|
||||
while (num > 0) {
|
||||
blkcnt = num;
|
||||
if (blkcnt > MAXTRANSFER)
|
||||
@ -2518,12 +2545,20 @@ wddump(dev_t dev)
|
||||
* sector is bad, then reduce reduce the transfer to
|
||||
* avoid any bad sectors.
|
||||
*/
|
||||
#ifndef SLICE
|
||||
if (du->dk_flags & DKFL_SINGLE
|
||||
&& dsgetbad(dev, du->dk_slices) != NULL) {
|
||||
for (blkchk = blknum; blkchk < blknum + blkcnt; blkchk++) {
|
||||
daddr_t blknew;
|
||||
blknew = transbad144(dsgetbad(dev, du->dk_slices),
|
||||
blkchk - ds_offset) + ds_offset;
|
||||
#else
|
||||
if (du->dk_flags & DKFL_SINGLE && du->slice->handler_up) {
|
||||
for (blkchk = blknum; blkchk < blknum + blkcnt; blkchk++) {
|
||||
daddr_t blknew = blkchk;
|
||||
(void) (*du->slice->handler_up->upconf)(du->slice,
|
||||
SLCIOCTRANSBAD, (caddr_t)&blknew, 0, 0);
|
||||
#endif /* SLICE */
|
||||
if (blknew != blkchk) {
|
||||
/* Found bad block. */
|
||||
blkcnt = blkchk - blknum;
|
||||
@ -2539,7 +2574,7 @@ wddump(dev_t dev)
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
out:
|
||||
|
||||
@ -2628,7 +2663,6 @@ out:
|
||||
return (0);
|
||||
#endif
|
||||
}
|
||||
#endif /* !SLICE */
|
||||
|
||||
static void
|
||||
wderror(struct buf *bp, struct disk *du, char *mesg)
|
||||
@ -2966,7 +3000,6 @@ static int
|
||||
wdsopen(void *private, int flags, int mode, struct proc *p)
|
||||
{
|
||||
register struct disk *du;
|
||||
register unsigned int lunit;
|
||||
int error = 0;
|
||||
|
||||
du = private;
|
||||
@ -3006,10 +3039,10 @@ wdsclose(void *private, int flags, int mode, struct proc *p)
|
||||
static int
|
||||
wdsioctl( void *private, int cmd, caddr_t addr, int flag, struct proc *p)
|
||||
{
|
||||
register struct disk *du;
|
||||
register struct disk *du = private;
|
||||
#ifdef notyet
|
||||
int error;
|
||||
|
||||
du = private;
|
||||
#endif
|
||||
|
||||
wdsleep(du->dk_ctrlr, "wdioct");
|
||||
switch (cmd) {
|
||||
|
Loading…
Reference in New Issue
Block a user