~kris/9p

9hist

288caae5f82539a2bf664b1aee489b9efd874e7e — David du Colombier 33 years ago f4322fa
Plan 9 from Bell Labs 1993-02-26
M gnot/clock.c => gnot/clock.c +1 -1
@@ 42,8 42,8 @@ clock(Ureg *ur)
	MACHP(0)->load = (MACHP(0)->load*19+nrun)/20;
	checkalarms();
	kbdclock();
	mouseclock();
	duartclock();
	mouseclock();
	kproftimer(ur->pc);
	if((ur->sr&SPL(7)) == 0 && p && p->state==Running){
		if(anyready()){

M gnot/devduart.c => gnot/devduart.c +1 -1
@@ 427,7 427,7 @@ duartintr(Ureg *ur)
	 * Is it 5?
	 */
	if(cause & IM_IPC)
		mousebuttons((~duart[0].ipc_acr) & 7);
		mousetrack((~duart[0].ipc_acr) & 7, 0, 0);
}



M gnot/l.s => gnot/l.s +0 -1
@@ 305,7 305,6 @@ TEXT	syncintr(SB), $0		/* level 6 */
	BSR	clock(SB)
	/* fall through */
retintr:
	BSR	mousetry(SB)
	ADDL	$4, A7
	MOVL	((8+8)*BY2WD)(A7), A0
	MOVL	A0, USP

M gnot/screen.c => gnot/screen.c +0 -20
@@ 158,26 158,6 @@ hwcursmove(int x, int y)
	return 0;
}

void
mouseclock(void)	/* called spl6 */
{
	++mouse.clock;
}

void
mousetry(Ureg *ur)
{
	int s;

	if(mouse.clock && mouse.track && (ur->sr&SPL(7)) == 0 && canlock(&cursor)){
		s = spl1();
		mouseupdate(0);
		splx(s);
		unlock(&cursor);
		wakeup(&mouse.r);
	}
}

/* only 1 flavor mouse */
void
mousectl(char *x)

M gnot/screen.h => gnot/screen.h +0 -30
@@ 1,33 1,3 @@
typedef struct Mouseinfo	Mouseinfo;
typedef struct Cursorinfo	Cursorinfo;

struct Mouseinfo{
	/*
	 * First three fields are known in some l.s's
	 */
	int	dx;		/* interrupt-time delta */
	int	dy;
	int	track;		/* update cursor on screen */
	Mouse;
	ulong	counter;	/* increments every update */
	ulong	lastcounter;	/* value when /dev/mouse read */
	Rendez	r;
	int	newbuttons;	/* interrupt time access only */
	int	clock;		/* check mouse.track on RTE */
};

struct Cursorinfo{
	Cursor;
	Lock;
	int	visible;	/* on screen */
	int	disable;	/* from being used */
	Rectangle r;		/* location */
};


extern Mouseinfo	mouse;
extern Cursorinfo	cursor;

extern void		mouseupdate(int);

#define	hwscreenwrite(a, b)

M gnot/segment.h => gnot/segment.h +1 -10
@@ 2,16 2,7 @@
 * Attach segment types
 */

typedef struct Physseg Physseg;
struct Physseg
{
	ulong	attr;			/* Segment attributes */
	char	*name;			/* Attach name */
	ulong	pa;			/* Physical address */
	ulong	size;			/* Maximum segment size in pages */
	Page	*(*pgalloc)(Segment*, ulong);	/* Allocation if we need it */
	void	(*pgfree)(Page*);
}physseg[] = {
Physseg physseg[] = {
	{ SG_SHARED,	"lock",		0,	SEGMAXSIZE,	0, 	0 },
	{ SG_SHARED,	"shared",	0,	SEGMAXSIZE,	0, 	0 },
	{ SG_BSS,	"memory",	0,	SEGMAXSIZE,	0,	0 },

M pc/clock.c => pc/clock.c +1 -0
@@ 89,6 89,7 @@ clock(Ureg *ur)

	checkalarms();
	uartclock();
	mouseclock();

	/*
	 *  process time accounting

M pc/devvga.c => pc/devvga.c +0 -7
@@ 931,13 931,6 @@ hwcursmove(int x, int y)
	return 0;
}

void
mouseclock(void)
{
	spllo();	/* so we don't cause lost chars on the uart */
	mouseupdate(1);
}

/*
 *  a fatter than usual cursor for the safari
 */

M pc/kbd.c => pc/kbd.c +5 -41
@@ 10,8 10,6 @@
#include	<gnot.h>
#include	"screen.h"

extern Mouseinfo mouse;

enum {
	Data=		0x60,	/* data port */



@@ 332,6 330,7 @@ ps2mouseputc(IOQ *q, int c)
	static short msg[3];
	static int nb;
	static uchar b[] = {0, 1, 4, 5, 2, 3, 6, 7, 0, 1, 2, 5, 2, 3, 6, 7 };
	int buttons, dx, dy;

	USED(q);		/* not */
	/* 


@@ 348,11 347,10 @@ ps2mouseputc(IOQ *q, int c)
		if(msg[0] & 0x20)
			msg[2] |= 0xFF00;

		mouse.newbuttons = b[(msg[0]&7) | (shift ? 8 : 0)] | keybuttons;
		mouse.dx = msg[1];
		mouse.dy = -msg[2];
		mouse.track = 1;
		mouseclock();
		buttons = b[(msg[0]&7) | (shift ? 8 : 0)] | keybuttons;
		dx = msg[1];
		dy = -msg[2];
		mousetrack(buttons, dx, dy);
	}
	return 0;
}


@@ 415,22 413,6 @@ mousectl(char *arg)
}

/*
 *  Ctrl key used as middle button pressed
 */
static void
mbon(int val)
{
	keybuttons |= val;
	mousebuttons(keybuttons);
}
static void
mboff(int val)
{
	keybuttons &= ~val;
	mousebuttons(keybuttons);
}

/*
 *  keyboard interrupt
 */
int


@@ 508,15 490,6 @@ kbdintr0(void)
		case Ctrl:
			ctl = 0;
			break;
		case KF|1:
			mboff(Rbutton);
			break;
		case KF|2:
			mboff(Mbutton);
			break;
		case KF|3:
			mboff(Lbutton);
			break;
		}
		return 0;
	}


@@ 578,15 551,6 @@ kbdintr0(void)
		case Ctrl:
			ctl = 1;
			return 0;
		case KF|1:
			mbon(Rbutton);
			return 0;
		case KF|2:
			mbon(Mbutton);
			return 0;
		case KF|3:
			mbon(Lbutton);
			return 0;
		}
	}
	kbdputc(&kbdq, c);

M pc/screen.h => pc/screen.h +0 -30
@@ 1,33 1,3 @@
typedef struct Mouseinfo	Mouseinfo;
typedef struct Cursorinfo	Cursorinfo;

struct Mouseinfo{
	/*
	 * First three fields are known in some l.s's
	 */
	int	dx;		/* interrupt-time delta */
	int	dy;
	int	track;		/* update cursor on screen */
	Mouse;
	ulong	counter;	/* increments every update */
	ulong	lastcounter;	/* value when /dev/mouse read */
	Rendez	r;
	int	newbuttons;	/* interrupt time access only */
	int	clock;		/* check mouse.track on RTE */
};

struct Cursorinfo{
	Cursor;
	Lock;
	int	visible;	/* on screen */
	int	disable;	/* from being used */
	Rectangle r;		/* location */
};


extern Mouseinfo	mouse;
extern Cursorinfo	cursor;

extern void		mouseupdate(int);

#define	hwscreenwrite(a, b)

M port/devbit.c => port/devbit.c +66 -50
@@ 104,6 104,31 @@ void	bitstring(GBitmap*, Point, GFont*, uchar*, long, Fcode);
void	bitloadchar(GFont*, int, GSubfont*, int);
extern	GBitmap	gscreen;

typedef struct Mouseinfo	Mouseinfo;
typedef struct Cursorinfo	Cursorinfo;

struct Mouseinfo{
	/*
	 * First three fields are known in some l.s's
	 */
	int	dx;
	int	dy;
	int	track;		/* l.s has updated dx & dy */
	Mouse;
	int	redraw;		/* update cursor on screen */
	ulong	counter;	/* increments every update */
	ulong	lastcounter;	/* value when /dev/mouse read */
	Rendez	r;
};

struct Cursorinfo{
	Cursor;
	Lock;
	int	visible;	/* on screen */
	int	disable;	/* from being used */
	Rectangle r;		/* location */
};

Mouseinfo	mouse;
Cursorinfo	cursor;
int		mouseshifted;


@@ 1578,7 1603,7 @@ bitwrite(Chan *c, void *va, long n, ulong offset)
			pt1.y = BGLONG(p+5);
			if(ptinrect(pt1, gscreen.r)){
				mouse.xy = pt1;
				mouse.track = 1;
				mouse.redraw = 1;
				mouseclock();
			}
			m -= 9;


@@ 2027,61 2052,51 @@ cursoroff(int dolock)
		unlock(&cursor);
}

/*
 *  called by the clock routine to redraw the cursor
 */
void
mousedelta(int b, int dx, int dy)	/* called at higher priority */
{
	mouse.dx += dx;
	mouse.dy += dy;
	mouse.newbuttons = b;
	mouse.track = 1;
}

void
mousebuttons(int b)	/* called at higher priority */
mouseclock(void)
{
	/*
	 * It is possible if you click very fast and get bad luck
	 * you could miss a button click (down up).  Doesn't seem
	 * likely or important enough to worry about.
	 */
	mouse.newbuttons = b;
	mouse.track = 1;		/* aggressive but o.k. */
	mouseclock();
	if(mouse.track){
		mousetrack(mouse.buttons, mouse.dx, mouse.dy);
		mouse.track = 0;
		mouse.dx = 0;
		mouse.dy = 0;
	}
	if(mouse.redraw && canlock(&cursor)){
		mouse.redraw = 0;
		cursoroff(0);
		cursoron(0);
		mousescreenupdate();
		unlock(&cursor);
	}
}

/*
 *  called at interrupt level to update the structure and
 *  awaken any waiting procs.
 */
void
mouseupdate(int dolock)
mousetrack(int b, int dx, int dy)
{
	int x, y;

	if(!mouse.track || (dolock && !canlock(&cursor)))
		return;

	x = mouse.xy.x + mouse.dx;
	x = mouse.xy.x + dx;
	if(x < gscreen.r.min.x)
		x = gscreen.r.min.x;
	if(x >= gscreen.r.max.x)
		x = gscreen.r.max.x;
	y = mouse.xy.y + mouse.dy;
	y = mouse.xy.y + dy;
	if(y < gscreen.r.min.y)
		y = gscreen.r.min.y;
	if(y >= gscreen.r.max.y)
		y = gscreen.r.max.y;
	cursoroff(0);
	mouse.xy = Pt(x, y);
	cursoron(0);
	mousescreenupdate();
	mouse.dx = 0;
	mouse.dy = 0;
	mouse.clock = 0;
	mouse.track = 0;
	mouse.buttons = mouse.newbuttons;
	mouse.counter++;

	if(dolock){
		unlock(&cursor);
		wakeup(&mouse.r);
	}
	mouse.xy = Pt(x, y);
	mouse.buttons = b;
	mouse.redraw = 1;
	wakeup(&mouse.r);
}

/*


@@ 2102,6 2117,7 @@ m3mouseputc(IOQ *q, int c)
	static int middle;
	static uchar b[] = { 0, 4, 1, 5, 0, 2, 1, 5 };
	short x;
	int dx, dy, newbuttons;

	USED(q);
	/* 


@@ 2111,20 2127,20 @@ m3mouseputc(IOQ *q, int c)
		if((c&0x40) == 0){
			/* an extra byte gets sent for the middle button */
			middle = (c&0x20) ? 2 : 0;
			mousebuttons((mouse.buttons & ~2) | middle);
			newbuttons = (mouse.buttons & ~2) | middle;
			mousetrack(newbuttons, 0, 0);
			return 0;
		}
	}
	msg[nb] = c;
	if(++nb == 3){
		nb = 0;
		mouse.newbuttons = middle | b[(msg[0]>>4)&3 | (mouseshifted ? 4 : 0)];
		newbuttons = middle | b[(msg[0]>>4)&3 | (mouseshifted ? 4 : 0)];
		x = (msg[0]&0x3)<<14;
		mouse.dx = (x>>8) | msg[1];
		dx = (x>>8) | msg[1];
		x = (msg[0]&0xc)<<12;
		mouse.dy = (x>>8) | msg[2];
		mouse.track = 1;
		mouseclock();
		dy = (x>>8) | msg[2];
		mousetrack(newbuttons, dx, dy);
	}
	return 0;
}


@@ 2140,6 2156,7 @@ mouseputc(IOQ *q, int c)
	static short msg[5];
	static int nb;
	static uchar b[] = {0, 4, 2, 6, 1, 5, 3, 7, 0, 2, 2, 6, 1, 5, 3, 7};
	int dx, dy, newbuttons;

	USED(q);
	if((c&0xF0) == 0x80)


@@ 2148,11 2165,10 @@ mouseputc(IOQ *q, int c)
	if(c & 0x80)
		msg[nb] |= ~0xFF;	/* sign extend */
	if(++nb == 5){
		mouse.newbuttons = b[((msg[0]&7)^7) | (mouseshifted ? 8 : 0)];
		mouse.dx = msg[1]+msg[3];
		mouse.dy = -(msg[2]+msg[4]);
		mouse.track = 1;
		mouseclock();
		newbuttons = b[((msg[0]&7)^7) | (mouseshifted ? 8 : 0)];
		dx = msg[1]+msg[3];
		dy = -(msg[2]+msg[4]);
		mousetrack(newbuttons, dx, dy);
		nb = 0;
	}
	return 0;

M port/devscc.c => port/devscc.c +34 -1
@@ 63,7 63,9 @@ enum

	/* wr 11 */
	TRxCOutBR=	2,
	TxClockTRxC=	1<<3,
	TxClockBR=	2<<3,
	RxClockTRxC=	1<<5,
	RxClockBR=	2<<5,
	TRxCOI=		1<<2,



@@ 233,6 235,24 @@ sccbits(SCC *sp, int n)
}

/*
 *  set/clear external clock mode; the indigo uses the CTS pin,
 *  so we disable external interrupts.
 */
void
sccextclk(SCC *sp, int n)
{
	if(n){
		sp->sticky[1] &= ~ExtIntEna;
		sp->sticky[11] = TxClockTRxC | RxClockTRxC;
	}else{
		sp->sticky[1] |= ExtIntEna;
		sp->sticky[11] = TxClockBR | RxClockBR | TRxCOutBR;
	}
	sccwrreg(sp, 1, 0);
	sccwrreg(sp, 11, 0);
}

/*
 *  toggle DTR
 */
void


@@ 486,6 506,13 @@ sccspecial(int port, IOQ *oq, IOQ *iq, int baud)
{
	SCC *sp = scc[port];

	/* let output drain */
	if(sp->oq){
		while(cangetc(sp->oq))
			sleep(&sp->oq->r, cangetc, sp->oq);
		tsleep(&sp->oq->r, cangetc, sp->oq, 50);
	}

	sp->special = 1;
	sp->oq = oq;
	sp->iq = iq;


@@ 585,7 612,9 @@ sccoput(Queue *q, Block *bp)
		nexterror();
	}
	if(bp->type == M_CTL){
		while (cangetc(cq))	/* let output drain */
		if(*bp->rptr == '!')	/* do it now! */
			++bp->rptr;
		else while(cangetc(cq))	/* else let output drain */
			sleep(&cq->r, cangetc, cq);
		n = strtoul((char *)(bp->rptr+1), 0, 0);
		switch(*bp->rptr){


@@ 596,6 625,10 @@ sccoput(Queue *q, Block *bp)
			else
				sccsetbaud(sp, n);
			break;
		case 'C':
		case 'c':
			sccextclk(sp, n);
			break;
		case 'D':
		case 'd':
			sccdtr(sp, n);

M port/portfns.h => port/portfns.h +2 -2
@@ 119,9 119,9 @@ void		mmurelease(Proc*);
void		mntdump(void);
int		mount(Chan*, Chan*, int);
void		mountfree(Mount*);
void		mousebuttons(int);
void		mousectl(char*);
void		mouseclock(void);
void		mousectl(char*);
void		mousetrack(int, int, int);
int		mouseputc(IOQ*, int);
void		mousescreenupdate(void);
int		msize(void*);

M port/stlapd.c => port/stlapd.c +7 -3
@@ 120,6 120,7 @@ char *lapderrors[] = {
};

Lapd	*lapd;
Lapd	*lapdN;

/*
 *  predeclared


@@ 164,7 165,10 @@ lapderror(Lapd *lp, int code)
static void
lapdreset(void)
{
	lapd = xalloc(conf.nlapd*sizeof(Lapd));
	int nlapd = 3; /* formerly conf.nlapd */

	lapd = xalloc(nlapd*sizeof(Lapd));
	lapdN = lapd + nlapd;
}

static void


@@ 174,13 178,13 @@ lapdopen(Queue *q, Stream *s)
	char name[32];

	USED(s);
	for(lp=lapd; lp<&lapd[conf.nlapd]; lp++){
	for(lp=lapd; lp<lapdN; lp++){
		qlock(lp);
		if(lp->state == 0)
			break;
		qunlock(lp);
	}
	if(lp>=&lapd[conf.nlapd])
	if(lp>=lapdN)
		error(Enoifc);

	/*q->flag |= QDEBUG;

M ss/screen.c => ss/screen.c +0 -6
@@ 526,12 526,6 @@ hwcursmove(int x, int y)
	return 0;
}

void
mouseclock(void)	/* called splhi */
{
	mouseupdate(1);
}

/* replicate (from top) value in v (n bits) until it fills a ulong */
static ulong
rep(ulong v, int n)

M ss/screen.h => ss/screen.h +0 -30
@@ 1,33 1,3 @@
typedef struct Mouseinfo	Mouseinfo;
typedef struct Cursorinfo	Cursorinfo;

struct Mouseinfo{
	/*
	 * First three fields are known in some l.s's
	 */
	int	dx;		/* interrupt-time delta */
	int	dy;
	int	track;		/* update cursor on screen */
	Mouse;
	ulong	counter;	/* increments every update */
	ulong	lastcounter;	/* value when /dev/mouse read */
	Rendez	r;
	int	newbuttons;	/* interrupt time access only */
	int	clock;		/* check mouse.track on RTE */
};

struct Cursorinfo{
	Cursor;
	Lock;
	int	visible;	/* on screen */
	int	disable;	/* from being used */
	Rectangle r;		/* location */
};


extern Mouseinfo	mouse;
extern Cursorinfo	cursor;

extern void		mouseupdate(int);

#define	hwscreenwrite(a, b)