~kris/9p

9hist

1da40af099035b1ca81c1970f78eccde1aef81ed — David du Colombier 33 years ago 6d9091a
Plan 9 from Bell Labs 1992-10-02
5 files changed, 29 insertions(+), 29 deletions(-)

M pc/devfloppy.c
M pc/devhard.c
M pc/main.c
M port/fault.c
M ss/main.c
M pc/devfloppy.c => pc/devfloppy.c +12 -10
@@ 72,6 72,7 @@ struct Type
	int	tracks;		/* tracks/disk */
	int	gpl;		/* intersector gap length for read/write */	
	int	fgpl;		/* intersector gap length for format */
	int	ring;		/* ring of compatible floppy types */

	/*
	 *  these depend on previous entries and are set filled in


@@ 83,12 84,12 @@ struct Type
};
Type floppytype[] =
{
	{ "MF2HD",	512,	18,	2,	1,	80,	0x1B,	0x54, },
	{ "MF1DD",	512,	9,	2,	1,	80,	0x1B,	0x54, },
	{ "MF4HD",	1024,	18,	2,	1,	80,	0x1B,	0x54, },
	{ "F2HD",	512,	15,	2,	1,	80,	0x2A,	0x50, },
	{ "F2DD",	512,	8,	2,	2,	40,	0x2A,	0x50, },
	{ "F1DD",	512,	8,	1,	2,	40,	0x2A,	0x50, },
[0]	{ "MF2HD",	512,	18,	2,	1,	80,	0x1B,	0x54,	1, },
[1]	{ "MF1DD",	512,	9,	2,	1,	80,	0x1B,	0x54,	2, },
[2]	{ "MF4HD",	1024,	18,	2,	1,	80,	0x1B,	0x54,	0, },
[3]	{ "F2HD",	512,	15,	2,	1,	80,	0x2A,	0x50,	4, },
[4]	{ "F2DD",	512,	8,	2,	2,	40,	0x2A,	0x50,	5, },
[5]	{ "F1DD",	512,	8,	1,	2,	40,	0x2A,	0x50,	3, },
};
#define NTYPES (sizeof(floppytype)/sizeof(Type))



@@ 323,7 324,7 @@ islegal(Chan *c, long n, Drive *dp)
}

/*
 *  check if the floppy has been replaced under foot
 *  check if the floppy has been replaced under foot.  cause a read error if it has.
 *
 *  a seek and a read clears the condition.  this was determined experimentally,
 *  there has to be a better way.


@@ 337,9 338,9 @@ changed(Chan *c, Drive *dp)
		dp->vers++;
		dp->ccyl = -1;
		if(dp->cyl)
			floppyxfer(dp, Fread, dp->cache, 0, dp->t->tsize);
			floppythrice(dp, Fread, dp->cache, 0, dp->t->tsize);
		else
			floppyxfer(dp, Fread, dp->cache, dp->t->heads*dp->t->tsize, dp->t->tsize);
			floppythrice(dp, Fread, dp->cache, dp->t->heads*dp->t->tsize, dp->t->tsize);
	}
	old = c->qid.vers;
	c->qid.vers = dp->vers;


@@ 759,7 760,8 @@ floppyseek(Drive *dp, long off)
}

/*
 *  since floppies are so flakey, try 3 times before giving up
 *  since floppies are so flakey, automaticly retry failed attempts.
 *  every 3 tries switch to a different density
 */
static long
floppythrice(Drive *dp, int cmd, void *a, long off, long n)

M pc/devhard.c => pc/devhard.c +12 -16
@@ 6,6 6,8 @@
#include	"io.h"
#include	"../port/error.h"

#include	"devtab.h"

#define DPRINT if(1)print

typedef	struct Drive		Drive;


@@ 271,7 273,7 @@ hardwstat(Chan *c, char *dp)
}

long
hardread(Chan *c, void *a, long n)
hardread(Chan *c, void *a, long n, ulong offset)
{
	Drive *dp;
	long rv, i;


@@ 285,19 287,16 @@ hardread(Chan *c, void *a, long n)

	buf = smalloc(Maxxfer);
	if(waserror()){
		print("hard read error\n");
		free(buf);
		nexterror();
	}

if(a&KZERO)print("rd k 0x%lux d 0x%lux\n", a, n);

	dp = &hard[DRIVE(c->qid.path)];
	pp = &dp->p[PART(c->qid.path)];

	skip = c->offset % dp->bytes;
	skip = offset % dp->bytes;
	for(rv = 0; rv < n; rv += i){
		i = hardxfer(dp, pp, Cread, c->offset+rv-skip, n-rv+skip, buf);
		i = hardxfer(dp, pp, Cread, offset+rv-skip, n-rv+skip, buf);
		if(i == 0)
			break;
		i -= skip;


@@ 314,7 313,7 @@ if(a&KZERO)print("rd k 0x%lux d 0x%lux\n", a, n);
}

long
hardwrite(Chan *c, void *a, long n)
hardwrite(Chan *c, void *a, long n, ulong offset)
{
	Drive *dp;
	long rv, i, partial;


@@ 329,27 328,24 @@ hardwrite(Chan *c, void *a, long n)
	pp = &dp->p[PART(c->qid.path)];
	buf = smalloc(Maxxfer);
	if(waserror()){
		print("hard write error\n");
		free(buf);
		nexterror();
	}

if(a&KZERO)print("wr k 0x%lux d 0x%lux\n", a, n);

	/*
	 *  if not starting on a sector boundary,
	 *  read in the first sector before writing
	 *  it out.
	 */
	partial = c->offset % dp->bytes;
	partial = offset % dp->bytes;
	if(partial){
		hardxfer(dp, pp, Cread, c->offset-partial, dp->bytes, buf);
		hardxfer(dp, pp, Cread, offset-partial, dp->bytes, buf);
		if(partial+n > dp->bytes)
			rv = dp->bytes - partial;
		else
			rv = n;
		memmove(buf+partial, aa, rv);
		hardxfer(dp, pp, Cwrite, c->offset-partial, dp->bytes, buf);
		hardxfer(dp, pp, Cwrite, offset-partial, dp->bytes, buf);
	} else
		rv = 0;



@@ 363,7 359,7 @@ if(a&KZERO)print("wr k 0x%lux d 0x%lux\n", a, n);
		if(i > Maxxfer)
			i = Maxxfer;
		memmove(buf, aa+rv, i);
		i = hardxfer(dp, pp, Cwrite, c->offset+rv, i, buf);
		i = hardxfer(dp, pp, Cwrite, offset+rv, i, buf);
		if(i == 0)
			break;
	}


@@ 374,9 370,9 @@ if(a&KZERO)print("wr k 0x%lux d 0x%lux\n", a, n);
	 *  it out.
	 */
	if(partial){
		hardxfer(dp, pp, Cread, c->offset+rv, dp->bytes, buf);
		hardxfer(dp, pp, Cread, offset+rv, dp->bytes, buf);
		memmove(buf, aa+rv, partial);
		hardxfer(dp, pp, Cwrite, c->offset+rv, dp->bytes, buf);
		hardxfer(dp, pp, Cwrite, offset+rv, dp->bytes, buf);
		rv += partial;
	}


M pc/main.c => pc/main.c +5 -1
@@ 227,6 227,7 @@ void
confinit(void)
{
	long x, i, j, *l;
	int pcnt;
	ulong ktop;

	/*


@@ 265,7 266,10 @@ confinit(void)
	conf.base1 = 1*MB;
	conf.npage1 = ((i-1)*MB - conf.base1)/BY2PG;
	conf.npage = conf.npage0 + conf.npage1;
	conf.upages = (conf.npage*60)/100;

	pcnt = screenbits()-1;		/* Calculate % of memory for page pool */
	pcnt = 70 - (pcnt*10);
	conf.upages = (conf.npage*pcnt)/100;

	ktop = PGROUND((ulong)end);
	ktop = PADDR(ktop);

M port/fault.c => port/fault.c +0 -1
@@ 247,7 247,6 @@ pio(Segment *s, ulong addr, ulong soff, Page **p)
void
faulterror(char *s)
{
	print("faulterror %s\n", s);
	if(u->nerrlab) {
		postnote(u->p, 1, s, NDebug);
		error(s);

M ss/main.c => ss/main.c +0 -1
@@ 300,7 300,6 @@ confinit(void)
	 * keyboard, too.
	 */
	switch(idprom[1]){
	case 0x52:	/* IPC */
	case 0x54:	/* SLC */
		conf.monitor = 1;
		fbslot = 3;