1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-17 15:27:36 +00:00

Remove BAD144 support, it has already been disabled for some time.

This commit is contained in:
Poul-Henning Kamp 1999-12-08 09:33:00 +00:00
parent a3fb836cb5
commit 7d5961670c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=54294
23 changed files with 20 additions and 1091 deletions

View File

@ -35,7 +35,6 @@
* - NetBSD libi386/biosdisk.c
* - FreeBSD biosboot/disk.c
*
* XXX Todo: add bad144 support.
*/
#include <stand.h>

View File

@ -35,7 +35,6 @@
* - NetBSD libi386/biosdisk.c
* - FreeBSD biosboot/disk.c
*
* XXX Todo: add bad144 support.
*/
#include <stand.h>

View File

@ -34,7 +34,6 @@
* - NetBSD libi386/biosdisk.c
* - FreeBSD biosboot/disk.c
*
* XXX Todo: add bad144 support.
*/
#include <stand.h>

View File

@ -346,7 +346,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;

View File

@ -42,9 +42,6 @@
*/
#include "boot.h"
#ifdef DO_BAD144
#include <sys/dkbad.h>
#endif DO_BAD144
#include <sys/disklabel.h>
#include <sys/diskslice.h>
@ -55,11 +52,6 @@
#define SPT(di) ((di)&0xff)
#define HEADS(di) (((di)>>8)&0xff)
#ifdef DO_BAD144
static struct dkbad dkb;
static int do_bad144;
static int bsize;
#endif DO_BAD144
static int spt, spc;
@ -79,7 +71,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
@ -161,54 +152,6 @@ devopen(void)
#endif
#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;
@ -228,7 +171,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);
}
}
@ -270,61 +213,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;
}

View File

@ -34,7 +34,6 @@
* - NetBSD libi386/biosdisk.c
* - FreeBSD biosboot/disk.c
*
* XXX Todo: add bad144 support.
*/
#include <stand.h>

View File

@ -364,7 +364,6 @@ kern/subr_bus.c standard
kern/subr_devstat.c standard
kern/subr_disk.c standard
kern/subr_diskslice.c standard
kern/subr_dkbad.c standard
kern/subr_eventhandler.c standard
kern/subr_log.c standard
kern/subr_module.c standard

View File

@ -61,7 +61,6 @@
#include <sys/syslog.h>
#include <sys/fcntl.h>
#include <sys/vnode.h>
#include <sys/dkbad.h>
#include <sys/queue.h>
#ifdef KERNEL
#include <machine/setjmp.h>

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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_ */

View File

@ -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 @@ wdintr(void *unitnum)
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 @@ wdgetctlr(struct disk *du)
}
/*
* 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;

View File

@ -59,7 +59,6 @@
#endif
#include <sys/disklabel.h>
#include <sys/diskslice.h>
#include <sys/dkbad.h>
#include <sys/fcntl.h>
#include <sys/malloc.h>
#include <sys/stat.h>
@ -84,8 +83,6 @@ static void free_ds_labeldevs __P((struct diskslices *ssp, int slice));
#endif
static void partition_info __P((char *sname, int part, struct partition *pp));
static void slice_info __P((char *sname, struct diskslice *sp));
static void set_ds_bad __P((struct diskslices *ssp, int slice,
struct dkbad_intern *btp));
static void set_ds_label __P((struct diskslices *ssp, int slice,
struct disklabel *lp));
static void set_ds_labeldevs __P((dev_t dev, struct diskslices *ssp));
@ -143,7 +140,6 @@ clone_label(lp)
* if needed, and signal errors or early completion.
*
* XXX TODO:
* o Do bad sector remapping. May need to split buffer.
* o Split buffers that are too big for the device.
* o Check for overflow.
* o Finish cleaning this up.
@ -204,16 +200,6 @@ if (labelsect != 0) Debugger("labelsect != 0 in dscheck()");
pp = &lp->d_partitions[dkpart(bp->b_dev)];
endsecno = pp->p_size;
slicerel_secno = pp->p_offset + secno;
if (sp->ds_bad != NULL && ds_debug) {
daddr_t newsecno;
newsecno = transbad144(sp->ds_bad, slicerel_secno);
if (newsecno != slicerel_secno)
printf(
"dscheck(%s): should map bad sector %ld -> %ld\n",
devtoname(bp->b_dev),
(long)slicerel_secno, (long)newsecno);
}
}
/* overwriting disk label ? */
@ -358,10 +344,6 @@ dsgone(sspp)
for (slice = 0, ssp = *sspp; slice < ssp->dss_nslices; slice++) {
sp = &ssp->dss_slices[slice];
if (sp->ds_bad != NULL) {
free(sp->ds_bad, M_DEVBUF);
set_ds_bad(ssp, slice, (struct dkbad_intern *)NULL);
}
#ifdef DEVFS
if (sp->ds_bdev != NULL)
devfs_remove_dev(sp->ds_bdev);
@ -375,7 +357,7 @@ dsgone(sspp)
}
/*
* For the "write" commands (DIOCSBAD, DIOCSDINFO and DIOCWDINFO), this
* For the "write" commands (DIOCSDINFO and DIOCWDINFO), this
* is subject to the same restriction as dsopen().
*/
int
@ -428,20 +410,6 @@ dsioctl(dev, cmd, data, flags, sspp)
(char *)ssp);
return (0);
case DIOCSBAD:
if ((ssp->dss_oflags & DSO_BAD144) == 0)
return (ENODEV);
if (slice == WHOLE_DISK_SLICE)
return (ENODEV);
if (!(flags & FWRITE))
return (EBADF);
if (lp == NULL)
return (EINVAL);
if (sp->ds_bad != NULL)
free(sp->ds_bad, M_DEVBUF);
set_ds_bad(ssp, slice, internbad144((struct dkbad *)data, lp));
return (0);
case DIOCSDINFO:
if (slice == WHOLE_DISK_SLICE)
return (ENODEV);
@ -699,7 +667,6 @@ dsopen(dev, mode, flags, sspp, lp)
struct diskslices **sspp;
struct disklabel *lp;
{
struct dkbad *btp;
dev_t dev1;
int error;
struct disklabel *lp1;
@ -831,29 +798,9 @@ dsopen(dev, mode, flags, sspp, lp)
continue;
}
if (lp1->d_flags & D_BADSECT) {
if ((flags & DSO_BAD144) == 0) {
log(LOG_ERR,
"%s: bad sector table not supported\n",
sname);
continue;
}
btp = malloc(sizeof *btp, M_DEVBUF, M_WAITOK);
TRACE(("readbad144\n"));
msg = readbad144(dev1, lp1, btp);
if (msg != NULL) {
log(LOG_ERR,
"%s: cannot find bad sector table (%s)\n",
sname, msg);
free(btp, M_DEVBUF);
free(lp1, M_DEVBUF);
continue;
}
set_ds_bad(ssp, slice, internbad144(btp, lp1));
free(btp, M_DEVBUF);
if (sp->ds_bad == NULL) {
free(lp1, M_DEVBUF);
continue;
}
log(LOG_ERR, "%s: bad sector table not supported\n",
sname);
continue;
}
set_ds_label(ssp, slice, lp1);
set_ds_labeldevs(dev1, ssp);
@ -1064,26 +1011,6 @@ slice_info(sname, sp)
sp->ds_offset, sp->ds_offset + sp->ds_size - 1, sp->ds_size);
}
/*
* Most changes to ds_bad, ds_label and ds_wlabel are made using the
* following functions to ensure coherency of the compatibility slice
* with the first BSD slice. The openmask fields are _not_ shared and
* the other fields (ds_offset and ds_size) aren't changed after they
* are initialized.
*/
static void
set_ds_bad(ssp, slice, btp)
struct diskslices *ssp;
int slice;
struct dkbad_intern *btp;
{
ssp->dss_slices[slice].ds_bad = btp;
if (slice == COMPATIBILITY_SLICE)
ssp->dss_slices[ssp->dss_first_bsd_slice].ds_bad = btp;
else if (slice == ssp->dss_first_bsd_slice)
ssp->dss_slices[COMPATIBILITY_SLICE].ds_bad = btp;
}
static void
set_ds_label(ssp, slice, lp)
struct diskslices *ssp;

View File

@ -1,160 +0,0 @@
/*-
* Copyright (c) 1994 Bruce D. Evans.
* All rights reserved.
*
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* William Jolitz.
*
* Copyright (c) 1982, 1986, 1988 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.
*
* from: @(#)wd.c 7.2 (Berkeley) 5/9/91
* from: wd.c,v 1.55 1994/10/22 01:57:12 phk Exp $
* from: @(#)ufs_disksubr.c 7.16 (Berkeley) 5/4/91
* from: ufs_disksubr.c,v 1.8 1994/06/07 01:21:39 phk Exp $
* $FreeBSD$
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/buf.h>
#include <sys/conf.h>
#include <sys/disklabel.h>
#include <sys/dkbad.h>
#include <sys/malloc.h>
/*
* Internalize the bad sector table.
* TODO:
* o Fix types.
* Type long should be daddr_t since we compare with blkno's.
* Sentinel -1 should be ((daddr_t)-1).
* o Can remove explicit test for sentinel if it is a positive
* (unsigned or not) value larger than all possible blkno's.
* o Check that the table is sorted.
* o Use faster searches.
* o Use the internal table in wddump().
* o Don't duplicate so much code.
* o Do all bad block handing in a driver-independent file.
* o Remove limit of 126 spare sectors.
*/
struct dkbad_intern *
internbad144(btp, lp)
struct dkbad *btp;
struct disklabel *lp;
{
struct dkbad_intern *bip;
int i;
bip = malloc(sizeof *bip, M_DEVBUF, M_WAITOK);
/*
* Spare sectors are allocated beginning with the last sector of
* the second last track of the disk (the last track is used for
* the bad sector list).
*/
bip->bi_maxspare = lp->d_secperunit - lp->d_nsectors - 1;
bip->bi_nbad = DKBAD_MAXBAD;
i = 0;
for (; i < DKBAD_MAXBAD && btp->bt_bad[i].bt_cyl != DKBAD_NOCYL; i++)
bip->bi_bad[i] = btp->bt_bad[i].bt_cyl * lp->d_secpercyl
+ (btp->bt_bad[i].bt_trksec >> 8)
* lp->d_nsectors
+ (btp->bt_bad[i].bt_trksec & 0x00ff);
bip->bi_bad[i] = -1;
return (bip);
}
char *
readbad144(dev, lp, bdp)
dev_t dev;
struct disklabel *lp;
struct dkbad *bdp;
{
struct buf *bp;
struct dkbad *db;
int i;
char *msg;
bp = geteblk((int)lp->d_secsize);
i = 0;
do {
/* Read a bad sector table. */
bp->b_dev = dev;
bp->b_blkno = lp->d_secperunit - lp->d_nsectors + i;
if (lp->d_secsize > DEV_BSIZE)
bp->b_blkno *= lp->d_secsize / DEV_BSIZE;
else
bp->b_blkno /= DEV_BSIZE / lp->d_secsize;
bp->b_bcount = lp->d_secsize;
bp->b_flags |= B_READ;
bp->b_flags &= ~B_ERROR;
BUF_STRATEGY(bp, 1);
/* If successful, validate, otherwise try another. */
if (biowait(bp) == 0) {
db = (struct dkbad *)(bp->b_data);
if (db->bt_mbz == 0 && db->bt_flag == DKBAD_MAGIC) {
msg = NULL;
*bdp = *db;
break;
}
msg = "bad sector table corrupted";
} else
msg = "bad sector table I/O error";
} while ((bp->b_flags & B_ERROR) && (i += 2) < 10 &&
i < lp->d_nsectors);
bp->b_flags |= B_INVAL | B_AGE;
brelse(bp);
return (msg);
}
daddr_t
transbad144(bip, blkno)
struct dkbad_intern *bip;
daddr_t blkno;
{
int i;
/*
* List is sorted, so the search can terminate when it is past our
* sector.
*/
for (i = 0; bip->bi_bad[i] != -1 && bip->bi_bad[i] <= blkno; i++)
if (bip->bi_bad[i] == blkno)
/*
* Spare sectors are allocated in decreasing order.
*/
return (bip->bi_maxspare - i);
return (blkno);
}

View File

@ -363,7 +363,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;

View File

@ -42,9 +42,6 @@
*/
#include "boot.h"
#ifdef DO_BAD144
#include <sys/dkbad.h>
#endif DO_BAD144
#include <sys/disklabel.h>
#include <sys/diskslice.h>
@ -55,10 +52,6 @@
#define SPT(di) ((di)&0xff)
#define HEADS(di) (((di)>>8)&0xff)
#ifdef DO_BAD144
static struct dkbad dkb;
static int do_bad144;
#endif DO_BAD144
static int bsize;
static int spt, spc;
@ -79,7 +72,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
@ -161,54 +153,6 @@ devopen(void)
#endif
#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;
@ -228,7 +172,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);
}
}
@ -270,61 +214,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;
}

View File

@ -41,12 +41,9 @@
* 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
@ -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>
@ -679,35 +675,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();
@ -864,16 +831,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 */
@ -1171,10 +1128,7 @@ wdintr(void *unitnum)
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 {
@ -1389,9 +1343,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",
@ -2078,17 +2029,7 @@ wdioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p)
#ifdef PC98
outb(0x432,(du->dk_unit)%2);
#endif
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
@ -2205,29 +2146,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. */

View File

@ -389,9 +389,6 @@ struct dos_partition {
#define DIOCWLABEL _IOW('d', 109, int) /* write en/disable label */
#define DIOCSBAD _IOW('d', 110, struct dkbad) /* set kernel dkbad */
#define DIOCSBADSCAN _IOW('d', 111, int) /* set badscan mode */
#ifdef KERNEL
/*

View File

@ -389,9 +389,6 @@ struct dos_partition {
#define DIOCWLABEL _IOW('d', 109, int) /* write en/disable label */
#define DIOCSBAD _IOW('d', 110, struct dkbad) /* set kernel dkbad */
#define DIOCSBADSCAN _IOW('d', 111, int) /* set badscan mode */
#ifdef KERNEL
/*

View File

@ -389,9 +389,6 @@ struct dos_partition {
#define DIOCWLABEL _IOW('d', 109, int) /* write en/disable label */
#define DIOCSBAD _IOW('d', 110, struct dkbad) /* set kernel dkbad */
#define DIOCSBADSCAN _IOW('d', 111, int) /* set badscan mode */
#ifdef KERNEL
/*

View File

@ -49,7 +49,6 @@ struct diskslice {
int ds_subtype; /* sub slice type */
u_char ds_name[16]; /* slice name */
#endif
struct dkbad_intern *ds_bad; /* bad sector table, if any */
struct disklabel *ds_label; /* BSD label, if any */
void *ds_bdev; /* devfs token for whole slice */
void *ds_cdev; /* devfs token for raw whole slice */
@ -85,9 +84,7 @@ struct diskslices {
/* Flags for dsopen(). */
#define DSO_NOLABELS 1
#define DSO_ONESLICE 2
#define DSO_BAD144 4
#define dsgetbad(dev, ssp) (ssp->dss_slices[dkslice(dev)].ds_bad)
#define dsgetlabel(dev, ssp) (ssp->dss_slices[dkslice(dev)].ds_label)
struct buf;

View File

@ -1,98 +0,0 @@
/*-
* Copyright (c) 1982, 1986, 1993, 1994
* 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.2 (Berkeley) 7/10/94
* $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 {
int32_t bt_csn; /* cartridge serial number */
u_int16_t bt_mbz; /* unused; should be 0 */
u_int16_t bt_flag; /* -1 => alignment cartridge */
struct bt_bad {
u_int16_t bt_cyl; /* cylinder number of bad sector */
u_int16_t bt_trksec; /* track and sector number */
} bt_bad[DKBAD_MAXBAD];
};
#define ECC 0
#define SSE 1
#define BSE 2
#define CONT 3
#ifdef KERNEL
#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 buf;
struct disklabel;
struct dkbad_intern *internbad144 __P((struct dkbad *btp,
struct disklabel *lp));
char *readbad144 __P((dev_t dev, struct disklabel *lp, struct dkbad *btp));
daddr_t transbad144 __P((struct dkbad_intern *bip, daddr_t blkno));
#endif
#endif /* !_SYS_DKBAD_H_ */