diff options
author | phk <phk@FreeBSD.org> | 1999-12-08 09:33:00 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1999-12-08 09:33:00 +0000 |
commit | 551bfa2f51cfd055117aec7f1a0f17294cfbc260 (patch) | |
tree | 50da86bbbf154ce5c4d4932b562730a10096f3ab /sys/i386 | |
parent | 224ba89395ce157c152e89a1113bab7205c0dcf9 (diff) | |
download | FreeBSD-src-551bfa2f51cfd055117aec7f1a0f17294cfbc260.zip FreeBSD-src-551bfa2f51cfd055117aec7f1a0f17294cfbc260.tar.gz |
Remove BAD144 support, it has already been disabled for some time.
Diffstat (limited to 'sys/i386')
-rw-r--r-- | sys/i386/boot/biosboot/boot.c | 2 | ||||
-rw-r--r-- | sys/i386/boot/biosboot/disk.c | 116 | ||||
-rw-r--r-- | sys/i386/boot/dosboot/disk.c | 113 | ||||
-rw-r--r-- | sys/i386/boot/dosboot/dkbad.h | 100 | ||||
-rw-r--r-- | sys/i386/isa/wd.c | 100 |
5 files changed, 10 insertions, 421 deletions
diff --git a/sys/i386/boot/biosboot/boot.c b/sys/i386/boot/biosboot/boot.c index a83c9fd..bbd7497 100644 --- a/sys/i386/boot/biosboot/boot.c +++ b/sys/i386/boot/biosboot/boot.c @@ -325,7 +325,7 @@ loadprog(void) * because no str*() functions are available. The file has to be * copied to &disklabel for userconfig. It can't be loaded there * directly because the label is used late in readfile() in some - * unusual cases, e.g., for bad144 handling. + * unusual cases. */ s = name; t = kernel_config_namebuf; diff --git a/sys/i386/boot/biosboot/disk.c b/sys/i386/boot/biosboot/disk.c index 62fdde4..d280e11 100644 --- a/sys/i386/boot/biosboot/disk.c +++ b/sys/i386/boot/biosboot/disk.c @@ -38,9 +38,6 @@ */ #include "boot.h" -#ifdef DO_BAD144 -#include <sys/dkbad.h> -#endif DO_BAD144 #include <sys/disklabel.h> #include <sys/diskslice.h> @@ -51,10 +48,6 @@ #define SPT(di) ((di)&0xff) #define HEADS(di) ((((di)>>8)&0xff)+1) -#ifdef DO_BAD144 -static struct dkbad dkb; -static int do_bad144; -#endif DO_BAD144 static int bsize; static int spt, spc; @@ -75,7 +68,6 @@ static int ra_dev; static int ra_end; static int ra_first; -static int badsect(int sector); static char *Bread(int dosdev, int sector); int @@ -139,54 +131,6 @@ devopen(void) return 1; } -#ifdef DO_BAD144 - do_bad144 = 0; - if (dl->d_flags & D_BADSECT) { - /* this disk uses bad144 */ - int i; - int dkbbnum; - struct dkbad *dkbptr; - - /* find the first readable bad sector table */ - /* some of this code is copied from ufs/ufs_disksubr.c */ - /* including the bugs :-( */ - /* read a bad sector table */ - -#define BAD144_PART 2 /* XXX scattered magic numbers */ -#define BSD_PART 0 /* XXX should be 2 but bad144.c uses 0 */ - if (dl->d_partitions[BSD_PART].p_offset != 0) - dkbbnum = dl->d_partitions[BAD144_PART].p_offset - + dl->d_partitions[BAD144_PART].p_size; - else - dkbbnum = dl->d_secperunit; - dkbbnum -= dl->d_nsectors; - - if (dl->d_secsize > DEV_BSIZE) - dkbbnum *= dl->d_secsize / DEV_BSIZE; - else - dkbbnum /= DEV_BSIZE / dl->d_secsize; - i = 0; - do_bad144 = 0; - do { - /* XXX: what if the "DOS sector" < 512 bytes ??? */ - p = Bread(dosdev_copy, dkbbnum + i); - dkbptr = (struct dkbad *) p; -/* XXX why is this not in <sys/dkbad.h> ??? */ -#define DKBAD_MAGIC 0x4321 - if (dkbptr->bt_mbz == 0 && - dkbptr->bt_flag == DKBAD_MAGIC) { - dkb = *dkbptr; /* structure copy */ - do_bad144 = 1; - break; - } - i += 2; - } while (i < 10 && (unsigned)i < dl->d_nsectors); - if (!do_bad144) - printf("Bad bad sector table\n"); - else - printf("Using bad sector table at %d\n", dkbbnum+i); - } -#endif /* DO_BAD144 */ } #endif /* RAWBOOT */ return 0; @@ -206,7 +150,7 @@ devread(char *iodest, int sector, int cnt) for (offset = 0; offset < cnt; offset += BPS) { dosdev_copy = dosdev; - p = Bread(dosdev_copy, badsect(sector++)); + p = Bread(dosdev_copy, sector++); bcopy(p, iodest+offset, BPS); } } @@ -246,61 +190,3 @@ Bread(int dosdev, int sector) } return (ra_buf + (sector - ra_first) * BPS); } - -static int -badsect(int sector) -{ -#if defined(DO_BAD144) && !defined(RAWBOOT) - int i; - if (do_bad144) { - u_short cyl; - u_short head; - u_short sec; - int newsec; - struct disklabel *dl = &disklabel; - - /* XXX */ - /* from wd.c */ - /* bt_cyl = cylinder number in sorted order */ - /* bt_trksec is actually (head << 8) + sec */ - - /* only remap sectors in the partition */ - if (sector < boff || sector >= boff + bsize) { - goto no_remap; - } - - cyl = (sector-boff) / dl->d_secpercyl; - head = ((sector-boff) % dl->d_secpercyl) / dl->d_nsectors; - sec = (sector-boff) % dl->d_nsectors; - sec = (head<<8) + sec; - - /* now, look in the table for a possible bad sector */ - for (i=0; i<126; i++) { - if (dkb.bt_bad[i].bt_cyl == cyl) { - /* found same cylinder */ - if (dkb.bt_bad[i].bt_trksec == sec) { - /* FOUND! */ - break; - } - } else if (dkb.bt_bad[i].bt_cyl > cyl) { - i = 126; - break; - } - } - if (i == 126) { - /* didn't find bad sector */ - goto no_remap; - } - /* otherwise find replacement sector */ - if (dl->d_partitions[BSD_PART].p_offset != 0) - newsec = dl->d_partitions[BAD144_PART].p_offset - + dl->d_partitions[BAD144_PART].p_size; - else - newsec = dl->d_secperunit; - newsec -= dl->d_nsectors + i + 1; - return newsec; - } - no_remap: -#endif - return sector; -} diff --git a/sys/i386/boot/dosboot/disk.c b/sys/i386/boot/dosboot/disk.c index 3f93ab8..7601fc3 100644 --- a/sys/i386/boot/dosboot/disk.c +++ b/sys/i386/boot/dosboot/disk.c @@ -32,9 +32,6 @@ #define bcopy(a,b,c) memcpy(b,a,c)
#include "boot.h"
-#ifdef DO_BAD144
-#include "dkbad.h"
-#endif
#include "disklabe.h"
#include "diskslic.h"
@@ -48,11 +45,6 @@ static char i_buf[BPS];
#define I_ADDR ((void *) i_buf) /* XXX where all reads go */
-#ifdef DO_BAD144
-struct dkbad dkb;
-int do_bad144;
-long bsize;
-#endif
static int spt, spc;
@@ -66,7 +58,6 @@ extern int biosread(int dev, int track, int head, int sector, int cnt, unsigned struct disklabel disklabel;
static void Bread(int dosdev, long sector);
-static long badsect(int dosdev, long sector);
unsigned long get_diskinfo(int drive)
{
@@ -152,55 +143,6 @@ int devopen(void) }
boff = dl->d_partitions[part].p_offset;
-#ifdef DO_BAD144
- bsize = dl->d_partitions[part].p_size;
- do_bad144 = 0;
- if (dl->d_flags & D_BADSECT) {
- /* this disk uses bad144 */
- int i;
- long dkbbnum;
- struct dkbad *dkbptr;
-
- /* find the first readable bad sector table */
- /* some of this code is copied from ufs/ufs_disksubr.c */
- /* including the bugs :-( */
- /* read a bad sector table */
-
-#define BAD144_PART 2 /* XXX scattered magic numbers */
-#define BSD_PART 0 /* XXX should be 2 but bad144.c uses 0 */
- if (dl->d_partitions[BSD_PART].p_offset != 0)
- dkbbnum = dl->d_partitions[BAD144_PART].p_offset
- + dl->d_partitions[BAD144_PART].p_size;
- else
- dkbbnum = dl->d_secperunit;
- dkbbnum -= dl->d_nsectors;
-
- if (dl->d_secsize > DEV_BSIZE)
- dkbbnum *= dl->d_secsize / DEV_BSIZE;
- else
- dkbbnum /= DEV_BSIZE / dl->d_secsize;
- i = 0;
- do_bad144 = 0;
- do {
- /* XXX: what if the "DOS sector" < 512 bytes ??? */
- Bread(dosdev, dkbbnum + i);
- dkbptr = (struct dkbad *) I_ADDR;
-/* XXX why is this not in <sys/dkbad.h> ??? */
-#define DKBAD_MAGIC 0x4321
- if (dkbptr->bt_mbz == 0 &&
- dkbptr->bt_flag == DKBAD_MAGIC) {
- dkb = *dkbptr; /* structure copy */
- do_bad144 = 1;
- break;
- }
- i += 2;
- } while (i < 10 && (u_long) i < dl->d_nsectors);
- if (!do_bad144)
- printf("Bad badsect table\n");
- else
- printf("Using bad144 bad sector at %ld\n", dkbbnum+i);
- }
-#endif
}
return 0;
}
@@ -211,7 +153,7 @@ void devread(void) int dosdev = (int) inode.i_dev;
for (offset = 0; offset < cnt; offset += BPS)
{
- Bread(dosdev, badsect(dosdev, sector++));
+ Bread(dosdev, sector++);
bcopy(I_ADDR, iodest+offset, BPS);
}
}
@@ -250,56 +192,3 @@ static void Bread(int dosdev, long sector) }
bcopy(ra_buf + (sector - ra_first) * BPS, I_ADDR, BPS);
}
-
-static long badsect(int dosdev, long sector)
-{
-#ifdef DO_BAD144
- int i;
-
- if (do_bad144) {
- u_short cyl;
- u_short head;
- u_short sec;
- long newsec;
- struct disklabel *dl = &disklabel;
-
- /* XXX */
- /* from wd.c */
- /* bt_cyl = cylinder number in sorted order */
- /* bt_trksec is actually (head << 8) + sec */
-
- /* only remap sectors in the partition */
- if (sector < boff || sector >= boff + bsize) {
- goto no_remap;
- }
-
- cyl = (u_short) (sector / dl->d_secpercyl);
- head = (u_short) ((sector % dl->d_secpercyl) / dl->d_nsectors);
- sec = (u_short) (sector % dl->d_nsectors);
- sec = (head<<8) + sec;
-
- /* now, look in the table for a possible bad sector */
- for (i=0; i<126; i++) {
- if (dkb.bt_bad[i].bt_cyl == cyl) {
- /* found same cylinder */
- if (dkb.bt_bad[i].bt_trksec == sec) {
- /* FOUND! */
- break;
- }
- } else if (dkb.bt_bad[i].bt_cyl > cyl) {
- i = 126;
- break;
- }
- }
- if (i == 126) {
- /* didn't find bad sector */
- goto no_remap;
- }
- /* otherwise find replacement sector */
- newsec = dl->d_secperunit - dl->d_nsectors - i -1;
- return newsec;
- }
- no_remap:
-#endif
- return sector;
-}
diff --git a/sys/i386/boot/dosboot/dkbad.h b/sys/i386/boot/dosboot/dkbad.h deleted file mode 100644 index 1aea5de..0000000 --- a/sys/i386/boot/dosboot/dkbad.h +++ /dev/null @@ -1,100 +0,0 @@ -/*-
- * Copyright (c) 1982, 1986, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)dkbad.h 8.1 (Berkeley) 6/2/93
- * $FreeBSD$
- */
-
-#ifndef _SYS_DKBAD_H_
-#define _SYS_DKBAD_H_
-
-/*
- * Definitions needed to perform bad sector revectoring ala DEC STD 144.
- *
- * The bad sector information is located in the first 5 even numbered
- * sectors of the last track of the disk pack. There are five identical
- * copies of the information, described by the dkbad structure.
- *
- * Replacement sectors are allocated starting with the first sector before
- * the bad sector information and working backwards towards the beginning of
- * the disk. A maximum of 126 bad sectors are supported. The position of
- * the bad sector in the bad sector table determines which replacement sector
- * it corresponds to.
- *
- * The bad sector information and replacement sectors are conventionally
- * only accessible through the 'c' file system partition of the disk. If
- * that partition is used for a file system, the user is responsible for
- * making sure that it does not overlap the bad sector information or any
- * replacement sectors.
- */
-
-#define DKBAD_MAGIC 0x4321 /* normal value for bt_flag */
-#define DKBAD_MAXBAD 126 /* maximum bad sectors supported */
-#define DKBAD_NOCYL 0xffff /* cylinder to mark end of disk table */
-#define DKBAD_NOTRKSEC 0xffff /* track/sector to mark end */
-
-struct dkbad {
- long bt_csn; /* cartridge serial number */
- u_short bt_mbz; /* unused; should be 0 */
- u_short bt_flag; /* -1 => alignment cartridge */
- struct bt_bad {
- u_short bt_cyl; /* cylinder number of bad sector */
- u_short bt_trksec; /* track and sector number */
- } bt_bad[DKBAD_MAXBAD];
-};
-
-#define ECC 0
-#define SSE 1
-#define BSE 2
-#define CONT 3
-
-#ifdef KERNEL
-#include <sys/conf.h>
-
-#define DKBAD_NOSECT (-1) /* sector to mark end of core table */
-
-struct dkbad_intern {
- daddr_t bi_maxspare; /* last spare sector */
- u_int bi_nbad; /* actual dimension of bi_badsect[] */
- long bi_bad[DKBAD_MAXBAD + 1]; /* actually usually less */
-};
-
-struct disklabel;
-
-struct dkbad_intern *internbad144 __P((struct dkbad *btp,
- struct disklabel *lp));
-char *readbad144 __P((dev_t dev, d_strategy_t *strat,
- struct disklabel *lp, struct dkbad *btp));
-daddr_t transbad144 __P((struct dkbad_intern *bip, daddr_t blkno));
-#endif
-
-#endif /* !_SYS_DKBAD_H_ */
diff --git a/sys/i386/isa/wd.c b/sys/i386/isa/wd.c index f5b27fb..870145b 100644 --- a/sys/i386/isa/wd.c +++ b/sys/i386/isa/wd.c @@ -41,17 +41,14 @@ * o Bump error count after timeout. * o Satisfy ATA timing in all cases. * o Finish merging berry/sos timeout code (bump error count...). - * o Merge/fix TIH/NetBSD bad144 code. * o Don't use polling except for initialization. Need to * reorganize the state machine. Then "extra" interrupts * shouldn't happen (except maybe one for initialization). - * o Fix disklabel, boot and driver inconsistencies with - * bad144 in standard versions. * o Support extended DOS partitions. * o Support swapping to DOS partitions. - * o Handle bad sectors, clustering, disklabelling, DOS - * partitions and swapping driver-independently. Use - * i386/dkbad.c for bad sectors. Swapping will need new + * o Handle clustering, disklabelling, DOS + * partitions and swapping driver-independently. + * Swapping will need new * driver entries for polled reinit and polled write). */ @@ -68,7 +65,6 @@ #include "opt_ide_delay.h" #include <sys/param.h> -#include <sys/dkbad.h> #include <sys/systm.h> #include <sys/kernel.h> #include <sys/conf.h> @@ -159,7 +155,6 @@ struct disk { #define DKFL_LABELLING 0x00080 /* readdisklabel() in progress */ #define DKFL_32BIT 0x00100 /* use 32-bit i/o mode */ #define DKFL_MULTI 0x00200 /* use multi-i/o mode */ -#define DKFL_BADSCAN 0x00400 /* report all errors */ #define DKFL_USEDMA 0x00800 /* use DMA for data transfers */ #define DKFL_DMA 0x01000 /* using DMA on this transfer-- DKFL_SINGLE * overrides this @@ -582,35 +577,6 @@ wdstrategy(register struct buf *bp) if (dscheck(bp, du->dk_slices) <= 0) goto done; - /* - * Check for *any* block on this transfer being on the bad block list - * if it is, then flag the block as a transfer that requires - * bad block handling. Also, used as a hint for low level disksort - * clustering code to keep from coalescing a bad transfer into - * a normal transfer. Single block transfers for a large number of - * blocks associated with a cluster I/O are undesirable. - * - * XXX the old disksort() doesn't look at B_BAD. Coalescing _is_ - * desirable. We should split the results at bad blocks just - * like we should split them at MAXTRANSFER boundaries. - */ - if (dsgetbad(bp->b_dev, du->dk_slices) != NULL) { - long *badsect = dsgetbad(bp->b_dev, du->dk_slices)->bi_bad; - int i; - int nsecs = howmany(bp->b_bcount, DEV_BSIZE); - /* XXX pblkno is too physical. */ - daddr_t nspblkno = bp->b_pblkno - - du->dk_slices->dss_slices[dkslice(bp->b_dev)].ds_offset; - int blkend = nspblkno + nsecs; - - for (i = 0; badsect[i] != -1 && badsect[i] < blkend; i++) { - if (badsect[i] >= nspblkno) { - bp->b_flags |= B_BAD; - break; - } - } - } - /* queue transfer on drive, activate drive and controller if idle */ s = splbio(); @@ -756,16 +722,6 @@ wdstart(int ctrlr) du->dk_flags |= DKFL_SINGLE; } - if (du->dk_flags & DKFL_SINGLE - && dsgetbad(bp->b_dev, du->dk_slices) != NULL) { - /* XXX */ - u_long ds_offset = - du->dk_slices->dss_slices[dkslice(bp->b_dev)].ds_offset; - - blknum = transbad144(dsgetbad(bp->b_dev, du->dk_slices), - blknum - ds_offset) + ds_offset; - } - wdtab[ctrlr].b_active = 1; /* mark controller active */ /* if starting a multisector transfer, or doing single transfers */ @@ -1049,10 +1005,7 @@ oops: goto outt; } - if (du->dk_flags & DKFL_BADSCAN) { - bp->b_error = EIO; - bp->b_flags |= B_ERROR; - } else if (du->dk_status & WDCS_ERR) { + if (du->dk_status & WDCS_ERR) { if (++wdtab[unit].b_errcnt < RETRIES) { wdtab[unit].b_active = 0; } else { @@ -1192,8 +1145,6 @@ wdopen(dev_t dev, int flags, int fmt, struct proc *p) if (wdtab[du->dk_ctrlr_cmd640].b_active == 2) wdtab[du->dk_ctrlr_cmd640].b_active = 0; - du->dk_flags &= ~DKFL_BADSCAN; - /* spin waiting for anybody else reading the disk label */ while (du->dk_flags & DKFL_LABELLING) tsleep((caddr_t)&du->dk_flags, PZERO - 1, "wdopen", 1); @@ -1263,9 +1214,6 @@ wdopen(dev_t dev, int flags, int fmt, struct proc *p) &du->dk_dd); /* XXX check value returned by wdwsetctlr(). */ wdwsetctlr(du); - if (msg == NULL && du->dk_dd.d_flags & D_BADSECT) - msg = readbad144(dkmodpart(dev, RAW_PART), - &du->dk_dd, &du->dk_bad); du->dk_flags &= ~DKFL_LABELLING; if (msg != NULL) { log(LOG_WARNING, "wd%d: cannot find label (%s)\n", @@ -1661,8 +1609,7 @@ again: } /* * Fake minimal drive geometry for reading the MBR. - * readdisklabel() may enlarge it to read the label and the - * bad sector table. + * readdisklabel() may enlarge it to read the label. */ du->dk_dd.d_secsize = DEV_BSIZE; du->dk_dd.d_nsectors = 17; @@ -1854,16 +1801,7 @@ wdioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p) error = dsioctl(dev, cmd, addr, flags, &du->dk_slices); if (error != ENOIOCTL) return (error); - switch (cmd) { - case DIOCSBADSCAN: - if (*(int *)addr) - du->dk_flags |= DKFL_BADSCAN; - else - du->dk_flags &= ~DKFL_BADSCAN; - return (0); - default: - return (ENOTTY); - } + return (ENOTTY); } int @@ -1889,7 +1827,7 @@ wddump(dev_t dev) long num; /* number of sectors to write */ int lunit, part; long blkoff, blknum; - long blkchk, blkcnt, blknext; + long blkcnt, blknext; u_long ds_offset; u_long nblocks; static int wddoingadump = 0; @@ -1969,30 +1907,6 @@ wddump(dev_t dev) * sector is bad, then reduce reduce the transfer to * avoid any bad sectors. */ - 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; - if (blknew != blkchk) { - /* Found bad block. */ - blkcnt = blkchk - blknum; - if (blkcnt > 0) { - blknext = blknum + blkcnt; - goto out; - } - blkcnt = 1; - blknext = blknum + blkcnt; -#if 1 || defined(WDDEBUG) - printf("bad block %ld -> %ld\n", - (long)blknum, (long)blknew); -#endif - break; - } - } - } -out: /* Compute disk address. */ cylin = blknum / secpercyl; |