Save another 80 bytes, and clean up the code a little.

This commit is contained in:
mycroft 1995-01-18 02:54:23 +00:00
parent ae56aa82ca
commit d5eea96416
3 changed files with 33 additions and 38 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: boot.c,v 1.24 1995/01/16 02:21:15 mycroft Exp $ */
/* $NetBSD: boot.c,v 1.25 1995/01/18 02:54:23 mycroft Exp $ */
/*
* Ported to boot 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
@ -76,14 +76,15 @@ int drive;
int loadflags, currname = 0;
char *t;
printf("\n>> NetBSD BOOT @ 0x%x: %d/%d k [%s]\n",
printf("\n"
">> NetBSD BOOT @ 0x%x: %d/%d k [%s]\n"
"use hd(1,a)/netbsd to boot sd0 when wd0 is also installed\n",
ouraddr,
argv[7] = memsize(0),
argv[8] = memsize(1),
version);
printf("use hd(1,a)/netbsd to boot sd0 when wd0 is also installed\n");
gateA20();
loadstart:
loadstart:
/***************************************************************\
* As a default set it to the first partition of the first *
* floppy or hard drive *
@ -214,7 +215,7 @@ loadprog(howto)
addr += i;
}
printf("]");
putchar(']');
/********************************************************/
/* and that many bytes of (debug symbols?) */
@ -306,6 +307,6 @@ getbootdev(howto)
}
}
} else
printf("\n");
putchar('\n');
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: disk.c,v 1.8 1994/10/27 04:14:37 cgd Exp $ */
/* $NetBSD: disk.c,v 1.9 1995/01/18 02:54:24 mycroft Exp $ */
/*
* Ported to boot 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
@ -114,8 +114,6 @@ devopen()
dkbbnum = dl->d_secperunit - 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 {
@ -170,7 +168,7 @@ Bread(dosdev, sector)
if (dosdev != ra_dev || sector < ra_first || sector >= ra_end) {
int cyl, head, sec, nsec;
cyl = sector/spc;
cyl = sector / spc;
head = (sector % spc) / spt;
sec = sector % spt;
nsec = spt - sec;
@ -181,7 +179,7 @@ Bread(dosdev, sector)
nsec = 1;
twiddle();
while (biosread(dosdev, cyl, head, sec, nsec, ra_buf) != 0) {
printf("Error: C:%d H:%d S:%d\n", cyl, head, sec);
printf("Error: C:%d H:%d S:%d\n", cyl, head, sec);
twiddle();
}
}
@ -198,9 +196,7 @@ badsect(dosdev, sector)
int i;
#ifdef DO_BAD144
if (do_bad144) {
u_short cyl;
u_short head;
u_short sec;
u_short cyl, head, sec;
int newsec;
struct disklabel *dl = &disklabel;
@ -216,25 +212,20 @@ badsect(dosdev, sector)
cyl = sector / dl->d_secpercyl;
head = (sector % dl->d_secpercyl) / dl->d_nsectors;
sec = sector % dl->d_nsectors;
sec = (head<<8) + sec;
sec += head << 8;
/* 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 same sector */
break;
}
if (dkb.bt_bad[i].bt_cyl == cyl &&
dkb.bt_bad[i].bt_trksec == sec) {
/* found same sector */
goto remap;
} else if (dkb.bt_bad[i].bt_cyl > cyl) {
i = 126;
break;
goto no_remap;
}
}
if (i == 126) {
/* didn't find bad sector */
goto no_remap;
}
goto no_remap;
remap:
/* otherwise find replacement sector */
newsec = dl->d_secperunit - dl->d_nsectors - i -1;
return newsec;

View File

@ -1,4 +1,4 @@
/* $NetBSD: io.c,v 1.13 1995/01/18 01:54:25 mycroft Exp $ */
/* $NetBSD: io.c,v 1.14 1995/01/18 02:54:26 mycroft Exp $ */
/*
* Ported to boot 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
@ -81,31 +81,33 @@ printf(format, data)
}
c = *format++;
if (c == 'd') {
int num = *dataptr++;
int num = *dataptr++, dig;
char buf[10], *ptr = buf;
if (num < 0) {
num = -num;
putchar('-');
}
do
*ptr++ = '0' + num % 10;
while (num /= 10);
do {
dig = num % 10;
*ptr++ = '0' + dig;
} while (num /= 10);
do
putchar(*--ptr);
while (ptr != buf);
} else if (c == 'x') {
unsigned int num = (unsigned int)*dataptr++, dig;
char buf[8], *ptr = buf;
do
*ptr++ = (dig = (num & 0xf)) > 9?
'a' + dig - 10 :
'0' + dig;
while (num >>= 4);
do {
dig = num & 0xf;
*ptr++ = dig > 9 ?
'a' + dig - 10 :
'0' + dig;
} while (num >>= 4);
do
putchar(*--ptr);
while (ptr != buf);
} else if (c == 'c') {
putchar((*dataptr++) & 0xff);
putchar((char)*dataptr++);
} else if (c == 's') {
char *ptr = (char *)*dataptr++;
while (c = *ptr++)
@ -115,6 +117,7 @@ printf(format, data)
}
putchar(c)
int c;
{
if (c == '\n')
putc('\r');