Catchup with the future.

This commit is contained in:
leo 1996-02-09 20:52:04 +00:00
parent 01b73223a6
commit 89bbb8b2fb
3 changed files with 70 additions and 49 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ahdilbl.h,v 1.1 1996/01/16 15:15:06 leo Exp $ */
/* $NetBSD: ahdilbl.h,v 1.2 1996/02/09 20:52:04 leo Exp $ */
/*
* Copyright (c) 1995 Leo Weppelman.
@ -44,9 +44,9 @@
*/
#define BBMINSIZE 8192 /* minimum size of boot block */
#define LABELSECTOR 0 /* `natural' start of boot block */
#define LABELOFFSET 512 /* offset of disk label in bytes,
#define LABELOFFSET 516 /* offset of disk label in bytes,
relative to start of boot block */
#define LABELMAXSIZE 1024 /* maximum size of disk label */
#define LABELMAXSIZE 1020 /* maximum size of disk label */
#define MAXPARTITIONS 16 /* max. # of NetBSD partitions */
#define RAW_PART 2 /* xx?c is raw partition */
@ -55,14 +55,18 @@
#define MAXAUXROOTS 29 /* max. # of auxilary root sectors */
struct bootblock {
u_int8_t bb_xxboot[LABELOFFSET]; /* first-stage boot loader */
u_int8_t bb_dlabel[LABELMAXSIZE];/* disk pack label */
u_int8_t bb_xxboot[LABELOFFSET - sizeof(u_int32_t)];
/* first-stage boot loader */
u_int32_t bb_magic; /* boot block magic number */
#define NBDAMAGIC 0x4e424441
#define AHDIMAGIC 0x41484449
u_int8_t bb_label[LABELMAXSIZE]; /* disk pack label */
u_int8_t bb_bootxx[BBMINSIZE - (LABELOFFSET + LABELMAXSIZE)];
/* second-stage boot loader*/
};
#define BBGETLABEL(bb, dl) *(dl) = *((struct disklabel *)(bb)->bb_dlabel)
#define BBSETLABEL(bb, dl) *((struct disklabel *)(bb)->bb_dlabel) = *(dl)
#define BBGETLABEL(bb, dl) *(dl) = *((struct disklabel *)(bb)->bb_label)
#define BBSETLABEL(bb, dl) *((struct disklabel *)(bb)->bb_label) = *(dl)
/***** from src/sys/arch/atari/include/ahdilabel.h *************************/

View File

@ -1,4 +1,4 @@
/* $NetBSD: diskio.c,v 1.2 1996/01/16 15:15:16 leo Exp $ */
/* $NetBSD: diskio.c,v 1.3 1996/02/09 20:52:05 leo Exp $ */
/*
* Copyright (c) 1995 Waldi Ravens.
@ -105,7 +105,7 @@ disk_read(dd, start, count)
return(buffer);
if (e == -32 || (e == -1 && XHGetVersion() == -1)) {
if (!ahdi_compatible())
fatal(-1, "AHDI 3.0 compatible harddisk driver required");
fatal(-1, "AHDI 3.0 compatible harddisk driver required");
bdev = BIOSDEV(dd->major, dd->minor);
if (bdev && !bios_read(buffer, start, count, bdev))
return(buffer);
@ -128,7 +128,7 @@ disk_write(dd, start, count, buffer)
e = XHReadWrite(dd->major, dd->minor, 1, start, count, buffer);
if (e == -32 || (e == -1 && XHGetVersion() == -1)) {
if (!ahdi_compatible())
fatal(-1, "AHDI 3.0 compatible harddisk driver required");
fatal(-1, "AHDI 3.0 compatible harddisk driver required");
bdev = BIOSDEV(dd->major, dd->minor);
if (bdev)
e = bios_write(buffer, start, count, bdev);
@ -167,9 +167,9 @@ setmami(dd, name)
bus = IDE;
if (*++p < '0' || *p > '1') {
if (*p)
error(-1, "%s: invalid IDE target `%c'", name, *p);
error(-1, "%s: invalid IDE target `%c'", name, *p);
else
error(-1, "%s: missing IDE target", name);
error(-1, "%s: missing IDE target", name);
return(-1);
}
target = *p++ - '0';
@ -189,7 +189,8 @@ setmami(dd, name)
}
if (*++p < '0' || *p > '7') {
if (*p)
error(-1, "%s: invalid %s target `%c'", name, b, *p);
error(-1, "%s: invalid %s target `%c'", name,
b, *p);
else
error(-1, "%s: missing %s target", name, b);
return(-1);
@ -198,7 +199,8 @@ setmami(dd, name)
if (*p < '0' || *p > '7') {
if (*p) {
error(-1, "%s: invalid %s lun `%c'", name, b, *p);
error(-1, "%s: invalid %s lun `%c'", name,
b, *p);
return(-1);
}
lun = 0;
@ -264,23 +266,24 @@ setsizes(dd)
disk_t *dd;
{
if (XHGetVersion() != -1) {
char *p, prod[1024];
char *p, prod[1024];
if (XHInqTarget2(dd->major, dd->minor, &dd->bsize, NULL, prod, sizeof(prod))) {
if (XHInqTarget(dd->major, dd->minor, &dd->bsize, NULL, prod)) {
error(-1, "%s: device not configured", dd->sname);
return(-1);
}
if (XHInqTarget2(dd->major, dd->minor, &dd->bsize, NULL, prod,
sizeof(prod))) {
if (XHInqTarget(dd->major, dd->minor, &dd->bsize, NULL, prod)) {
error(-1, "%s: device not configured", dd->sname);
return(-1);
}
p = strrchr(prod, '\0');
while (isspace(*--p))
*p = '\0';
dd->product = strbd(prod, NULL);
if (!XHGetCapacity(dd->major, dd->minor, &dd->msize, &dd->bsize))
return(0);
}
p = strrchr(prod, '\0');
while (isspace(*--p))
*p = '\0';
dd->product = strbd(prod, NULL);
if (!XHGetCapacity(dd->major, dd->minor, &dd->msize, &dd->bsize))
return(0);
} else {
dd->product = strbd("unknown", NULL);
dd->bsize = AHDI_BSIZE; /* XXX */
dd->product = strbd("unknown", NULL);
dd->bsize = AHDI_BSIZE; /* XXX */
}
/* Trial&error search for last sector on medium */

View File

@ -1,4 +1,4 @@
/* $NetBSD: disklbl.c,v 1.2 1996/01/20 13:54:46 leo Exp $ */
/* $NetBSD: disklbl.c,v 1.3 1996/02/09 20:52:06 leo Exp $ */
/*
* Copyright (c) 1995 Waldi Ravens.
@ -50,7 +50,8 @@ readdisklabel(dd)
{
int e;
printf("Device : %s (%s) [%s]\n", dd->sname, dd->fname, dd->product);
printf("Device : %s (%s) [%s]\n", dd->sname, dd->fname,
dd->product);
printf("Medium size: %lu sectors\n", (u_long)dd->msize);
printf("Sector size: %lu bytes\n\n", (u_long)dd->bsize);
@ -96,15 +97,22 @@ bsd_label(dd, offset)
nsec = (BBMINSIZE + (dd->bsize - 1)) / dd->bsize;
bblk = disk_read(dd, offset, nsec);
if (bblk) {
u_short *end, *p;
u_int *end, *p;
end = (u_short *)&bblk[BBMINSIZE - sizeof(struct disklabel)];
rv = 1;
for (p = (u_short *)bblk; p < end; ++p) {
struct disklabel *dl = (struct disklabel *)p;
if (dl->d_magic == DISKMAGIC && dl->d_magic2 == DISKMAGIC
&& dl->d_npartitions <= MAXPARTITIONS && !dkcksum(dl)) {
dd->lblofs = (u_char *)p - bblk;
end = (u_int *)&bblk[BBMINSIZE - sizeof(struct disklabel)];
rv = 1;
for (p = (u_int *)bblk; p < end; ++p) {
struct disklabel *dl = (struct disklabel *)&p[1];
if ( ( (p[0] == NBDAMAGIC && offset == 0)
|| (p[0] == AHDIMAGIC && offset != 0)
|| (u_char *)dl - bblk == 7168
)
&& dl->d_npartitions <= MAXPARTITIONS
&& dl->d_magic2 == DISKMAGIC
&& dl->d_magic == DISKMAGIC
&& dkcksum(dl) == 0
) {
dd->lblofs = (u_char *)dl - bblk;
dd->bblock = offset;
rv = 0;
break;
@ -257,23 +265,28 @@ ahdi_display(dd)
for (j = 0; j < dd->nroots; ++j) {
u_int aux = dd->roots[j];
if (aux >= p1->start && aux <= p1->end) {
printf("FATAL: auxilary root at %u\n", aux); rv = 1;
printf("FATAL: auxilary root at %u\n", aux);
rv = 1;
}
}
for (j = i; j--;) {
part_t *p2 = &dd->parts[j];
if (p1->start >= p2->start && p1->start <= p2->end) {
printf("FATAL: clash with %u/%u\n", p2->rsec, p2->rent); rv = 1;
}
if (p2->start >= p1->start && p2->start <= p1->end) {
printf("FATAL: clash with %u/%u\n", p2->rsec, p2->rent); rv = 1;
}
part_t *p2 = &dd->parts[j];
if (p1->start >= p2->start && p1->start <= p2->end) {
printf("FATAL: clash with %u/%u\n", p2->rsec, p2->rent);
rv = 1;
}
if (p2->start >= p1->start && p2->start <= p1->end) {
printf("FATAL: clash with %u/%u\n", p2->rsec, p2->rent);
rv = 1;
}
}
if (p1->start >= dd->bslst && p1->start <= dd->bslend) {
printf("FATAL: partition overlaps with bad sector list\n"); rv = 1;
printf("FATAL: partition overlaps with bad sector list\n");
rv = 1;
}
if (dd->bslst >= p1->start && dd->bslst <= p1->end) {
printf("FATAL: partition overlaps with bad sector list\n"); rv = 1;
printf("FATAL: partition overlaps with bad sector list\n");
rv = 1;
}
}
@ -320,7 +333,8 @@ ahdi_getparts(dd, rsec, esec)
u_int i = ++dd->nroots;
dd->roots = xrealloc(dd->roots, i * sizeof *dd->roots);
dd->roots[--i] = offs;
rv = ahdi_getparts(dd, offs, esec == AHDI_BBLOCK ? offs : esec);
rv = ahdi_getparts(dd, offs,
esec == AHDI_BBLOCK ? offs : esec);
if (rv)
goto done;
} else {