Moved instantiation of `poff' to sys.c. It is no longer used in disk.c.
Saved a few bytes by copying `dosdev' and/or `name' to local variables. This optimization (for dosdev) was done in one place before but this was lost in the devread() cleanup. This optimization (for dosdev) can almost be done by bogusly declaring dosdev as const, but gcc still often space-pessimizes code like the following: extern const int dosdev; ... foo(dosdev); bar(dosdev); gcc often doesn't bother to copy dosdev to a temporary local because the local would have to be preserved in memory across the call to foo(). OTOH, for extern int dosdev; ... auto int dosdev_copy = dosdev; ... foo(dosdev_copy); bar(dosdev_copy); the copy must be made because foo() might alter dosdev.
This commit is contained in:
parent
1d7af3ef48
commit
2a41569eab
@ -24,7 +24,7 @@
|
||||
* the rights to redistribute these changes.
|
||||
*
|
||||
* from: Mach, Revision 2.2 92/04/04 11:35:49 rpd
|
||||
* $Id: disk.c,v 1.18 1996/09/10 21:18:39 phk Exp $
|
||||
* $Id: disk.c,v 1.19 1996/09/11 19:23:10 phk Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -61,7 +61,7 @@ int spt, spc;
|
||||
|
||||
struct fs *fs;
|
||||
struct inode inode;
|
||||
int dosdev, unit, slice, part, maj, boff, poff;
|
||||
int dosdev, unit, slice, part, maj, boff;
|
||||
|
||||
/*#define EMBEDDED_DISKLABEL 1*/
|
||||
|
||||
@ -82,13 +82,14 @@ devopen(void)
|
||||
struct dos_partition *dptr;
|
||||
struct disklabel *dl;
|
||||
char *p;
|
||||
int i, sector = 0, di;
|
||||
int i, sector = 0, di, dosdev_copy;
|
||||
|
||||
di = get_diskinfo(dosdev);
|
||||
dosdev_copy = dosdev;
|
||||
di = get_diskinfo(dosdev_copy);
|
||||
spt = SPT(di);
|
||||
|
||||
/* Hack for 2.88MB floppy drives. */
|
||||
if (!(dosdev & 0x80) && spt == 36)
|
||||
if (!(dosdev_copy & 0x80) && spt == 36)
|
||||
spt = 18;
|
||||
|
||||
spc = spt * HEADS(di);
|
||||
@ -98,7 +99,7 @@ devopen(void)
|
||||
#ifdef EMBEDDED_DISKLABEL
|
||||
dl = &disklabel;
|
||||
#else EMBEDDED_DISKLABEL
|
||||
p = Bread(dosdev, 0);
|
||||
p = Bread(dosdev_copy, 0);
|
||||
dptr = (struct dos_partition *)(p+DOSPARTOFF);
|
||||
slice = WHOLE_DISK_SLICE;
|
||||
for (i = 0; i < NDOSPART; i++, dptr++)
|
||||
@ -107,7 +108,7 @@ devopen(void)
|
||||
sector = dptr->dp_start;
|
||||
break;
|
||||
}
|
||||
p = Bread(dosdev, sector + LABELSECTOR);
|
||||
p = Bread(dosdev_copy, sector + LABELSECTOR);
|
||||
dl=((struct disklabel *)p);
|
||||
disklabel = *dl; /* structure copy (maybe useful later)*/
|
||||
#endif EMBEDDED_DISKLABEL
|
||||
@ -162,7 +163,7 @@ devopen(void)
|
||||
do_bad144 = 0;
|
||||
do {
|
||||
/* XXX: what if the "DOS sector" < 512 bytes ??? */
|
||||
p = Bread(dosdev, dkbbnum + i);
|
||||
p = Bread(dosdev_copy, dkbbnum + i);
|
||||
dkbptr = (struct dkbad *) p;
|
||||
/* XXX why is this not in <sys/dkbad.h> ??? */
|
||||
#define DKBAD_MAGIC 0x4321
|
||||
@ -194,10 +195,12 @@ devread(char *iodest, int sector, int cnt)
|
||||
{
|
||||
int offset;
|
||||
char *p;
|
||||
int dosdev_copy;
|
||||
|
||||
for (offset = 0; offset < cnt; offset += BPS)
|
||||
{
|
||||
p = Bread(dosdev, badsect(dosdev, sector++));
|
||||
dosdev_copy = dosdev;
|
||||
p = Bread(dosdev_copy, badsect(dosdev_copy, sector++));
|
||||
bcopy(p, iodest+offset, BPS);
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and its
|
||||
* documentation is hereby granted, provided that both the copyright
|
||||
e* notice and this permission notice appear in all copies of the
|
||||
* notice and this permission notice appear in all copies of the
|
||||
* software, derivative works or modified versions, and any portions
|
||||
* thereof, and that both notices appear in supporting documentation.
|
||||
*
|
||||
@ -24,7 +24,7 @@ e* notice and this permission notice appear in all copies of the
|
||||
* the rights to redistribute these changes.
|
||||
*
|
||||
* from: Mach, Revision 2.2 92/04/04 11:36:34 rpd
|
||||
* $Id: sys.c,v 1.13 1996/09/10 21:18:40 phk Exp $
|
||||
* $Id: sys.c,v 1.14 1996/09/11 19:23:11 phk Exp $
|
||||
*/
|
||||
|
||||
#include "boot.h"
|
||||
@ -47,6 +47,8 @@ char buf[BUFSIZE], fsbuf[BUFSIZE], iobuf[BUFSIZE];
|
||||
char mapbuf[MAPBUFSIZE];
|
||||
int mapblock;
|
||||
|
||||
int poff;
|
||||
|
||||
#ifdef RAWBOOT
|
||||
#define STARTBYTE 8192 /* Where on the media the kernel starts */
|
||||
#endif
|
||||
@ -191,8 +193,8 @@ block_map(int file_block)
|
||||
int
|
||||
openrd(void)
|
||||
{
|
||||
char **devp, *cp = name;
|
||||
int biosdrive, ret;
|
||||
char **devp, *name0 = name, *cp = name0;
|
||||
int biosdrive, dosdev_copy, ret;
|
||||
|
||||
/*******************************************************\
|
||||
* If bracket given look for preceding device name *
|
||||
@ -201,7 +203,7 @@ openrd(void)
|
||||
cp++;
|
||||
if (!*cp)
|
||||
{
|
||||
cp = name;
|
||||
cp = name0;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -210,16 +212,16 @@ openrd(void)
|
||||
* by a colon).
|
||||
*/
|
||||
biosdrivedigit = '\0';
|
||||
if (*(name + 1) == ':' && *name >= '0' && *name <= '9') {
|
||||
biosdrivedigit = *name;
|
||||
name += 2;
|
||||
if (*(name0 + 1) == ':' && *name0 >= '0' && *name0 <= '9') {
|
||||
biosdrivedigit = *name0;
|
||||
name0 += 2;
|
||||
}
|
||||
|
||||
if (cp++ != name)
|
||||
if (cp++ != name0)
|
||||
{
|
||||
for (devp = devs; *devp; devp++)
|
||||
if (name[0] == (*devp)[0] &&
|
||||
name[1] == (*devp)[1])
|
||||
if (name0[0] == (*devp)[0] &&
|
||||
name0[1] == (*devp)[1])
|
||||
break;
|
||||
if (!*devp)
|
||||
{
|
||||
@ -262,17 +264,18 @@ openrd(void)
|
||||
{
|
||||
case 0:
|
||||
case 4:
|
||||
dosdev = biosdrive | 0x80;
|
||||
dosdev_copy = biosdrive | 0x80;
|
||||
break;
|
||||
case 2:
|
||||
dosdev = biosdrive;
|
||||
dosdev_copy = biosdrive;
|
||||
break;
|
||||
default:
|
||||
printf("Unknown device\n");
|
||||
return 1;
|
||||
}
|
||||
printf("dosdev = %x, biosdrive = %d, unit = %d, maj = %d\n",
|
||||
dosdev, biosdrive, unit, maj);
|
||||
dosdev = dosdev_copy;
|
||||
printf("dosdev= %x, biosdrive = %d, unit = %d, maj = %d\n",
|
||||
dosdev_copy, biosdrive, unit, maj);
|
||||
|
||||
/***********************************************\
|
||||
* Now we know the disk unit and part, *
|
||||
|
Loading…
Reference in New Issue
Block a user