M gnot/fns.h => gnot/fns.h +1 -0
@@ 47,6 47,7 @@ void spldone(void);
int splduart(void);
int tas(char*);
void touser(void*);
+#define screenupdate(a)
#define waserror() (u->nerrlab++, setlabel(&u->errlab[u->nerrlab-1]))
#define kmapperm(x) kmap(x)
#define getcallerpc(x) (*(ulong*)(x))
M pc/devether.c => pc/devether.c +2 -2
@@ 353,14 353,14 @@ etherup(EtherCtlr *cp, void *data, int len)
qunlock(tp);
continue;
}
- if(waserror() == 0){
+ if(!waserror()){
bp = allocb(len);
memmove(bp->rptr, p, len);
bp->wptr += len;
bp->flags |= S_DELIM;
PUTNEXT(tp->q, bp);
+ poperror();
}
- poperror();
qunlock(tp);
}
}
M pc/devincon.c => pc/devincon.c +3 -27
@@ 184,45 184,28 @@ Dirtab incondir[]={
#define NINCON (sizeof incondir/sizeof incondir[0])
static void
-Xdelay(int n)
-{
- while(--n >= 0) ;
-}
-#define SDLY 1000
-
-/*#define Xdelay(n)*/
-
-static void
reset(int dev) /* hardware reset */
{
outb(dev+Qpcr, Finitbar);
- Xdelay(10000);
outb(dev+Qpcr, 0);
- Xdelay(10000);
outb(dev+Qpcr, Finitbar);
}
static void
wrctl(int dev, int data) /* write control character */
{
- Xdelay(SDLY);
outb(dev+Qpcr, Finitbar); /* no interrupts, please */
outb(dev+Qdlr, data);
- Xdelay(SDLY);
outb(dev+Qpcr, Finitbar|Fstrobe);
- Xdelay(SDLY);
outb(dev+Qpcr, Finitbar|Fie);
}
static void
wrdata(int dev, int data) /* write data character */
{
- Xdelay(SDLY);
outb(dev+Qpcr, Finitbar|Fsi);
outb(dev+Qdlr, data);
- Xdelay(SDLY);
outb(dev+Qpcr, Finitbar|Fsi|Fstrobe);
- Xdelay(SDLY);
outb(dev+Qpcr, Finitbar|Fsi|Fie);
}
@@ 231,9 214,7 @@ wrcmd(int dev, int data) /* write command */
{
outb(dev+Qpcr, Finitbar|Faf);
outb(dev+Qdlr, data);
- Xdelay(SDLY);
outb(dev+Qpcr, Finitbar|Faf|Fstrobe);
- Xdelay(SDLY);
outb(dev+Qpcr, Finitbar|Faf|Fie);
}
@@ 267,9 248,7 @@ static void
iwrcmd(int dev, int data) /* write command at interrupt level */
{
outb(dev+Qdlr, data);
- Xdelay(SDLY);
outb(dev+Qpcr, Finitbar|Faf|Fstrobe);
- Xdelay(SDLY);
outb(dev+Qpcr, Finitbar|Faf);
}
@@ 326,9 305,7 @@ static void
irdnop(int dev, int pcr) /* read nop (mux reset) */
{
outb(dev+Qdlr, 0x03);
- Xdelay(SDLY);
outb(dev+Qpcr, Finitbar|Faf|Fsi|Fstrobe);
- Xdelay(SDLY);
outb(dev+Qpcr, pcr);
}
@@ 753,8 730,7 @@ inconoput(Queue *q, Block *bp)
int dev;
Incon *ip;
ulong end;
- int chan;
- int ctl;
+ int status, chan, ctl;
int n, size;
ip = (Incon *)q->ptr;
@@ 819,10 795,10 @@ inconoput(Queue *q, Block *bp)
/*
* spin till there is room
*/
- for(n=0, end = NOW+1000; (ctl=rdstatus(ip)) & TX_FULL; n++){
+ for(n=0, end = NOW+1000; (status=rdstatus(ip)) & TX_FULL; n++){
nop(); /* make sure we don't optimize too much */
if(NOW > end){
- print("incon output stuck 0 %.2ux\n", ctl);
+ print("incon output stuck 0 %.2ux\n", status);
freemsg(q, bp);
qunlock(&ip->xmit);
return;
M pc/devrtc.c => pc/devrtc.c +0 -1
@@ 60,7 60,6 @@ rtcreset(void)
void
rtcinit(void)
{
- print("nvrm(0x2b) == 0x%lux\n", nvramread(0x2b));
}
Chan*
M pc/ether509.c => pc/ether509.c +5 -4
@@ 295,7 295,6 @@ receive(EtherCtlr *cp)
* without updating the ring.
*/
if(status & RxError){
- print("error #%ux, #%ux\n", status, getdiag(hw));
switch(status & RxErrMask){
case RxErrOverrun: /* Overrrun */
@@ 392,7 391,7 @@ interrupt(EtherCtlr *cp)
{
EtherHw *hw = cp->hw;
ushort status;
- uchar txstatus;
+ uchar txstatus, x;
status = ins(hw->addr+Status);
@@ 411,8 410,10 @@ interrupt(EtherCtlr *cp)
*/
txstatus = 0;
while(ins(hw->addr+Status) & TxComplete){
- txstatus |= inb(hw->addr+TxStatus);
- outb(hw->addr+TxStatus, 0);
+ x = inb(hw->addr+TxStatus);
+ if(x)
+ outb(hw->addr+TxStatus, 0);
+ txstatus |= x;
}
if(txstatus & (TxJabber|TxUnderrun))
COMMAND(hw, TxReset, 0);
M pc/fns.h => pc/fns.h +1 -0
@@ 70,6 70,7 @@ void uartclock(void);
void uartintr0(Ureg*);
void uartspecial(int, IOQ*, IOQ*, int);
void vgainit(void);
+#define screenupdate(a)
#define waserror() (u->nerrlab++, setlabel(&u->errlab[u->nerrlab-1]))
#define kmapperm(x) kmap(x)
#define getcallerpc(x) (*(ulong*)(x))
M pc/kbd.c => pc/kbd.c +71 -27
@@ 106,6 106,7 @@ KIOQ kbdq;
static int mousebuttons;
static int keybuttons;
+static uchar ccc;
/*
* predeclared
@@ 114,6 115,14 @@ static void kbdintr(Ureg*);
enum
{
+ /* controller command byte */
+ Cscs1= (1<<6), /* scan code set 1 */
+ Cmousedis= (1<<5), /* mouse disable */
+ Ckbddis= (1<<4), /* kbd disable */
+ Csf= (1<<2), /* system flag */
+ Cmouseint= (1<<1), /* mouse interrupt enable */
+ Ckbdint= (1<<0), /* kbd interrupt enable */
+
/* what kind of mouse */
Mouseother= 0,
Mouseserial= 1,
@@ 121,6 130,8 @@ enum
};
static int mousetype;
+static int mymouseputc(IOQ*, int);
+
/*
* wait for output no longer busy
*/
@@ 129,9 140,11 @@ outready(void)
{
int tries;
- for(tries = 0; (inb(Status) & Outbusy); tries++)
- if(tries > 10000)
+ for(tries = 0; (inb(Status) & Outbusy); tries++){
+ if(tries > 500)
return -1;
+ delay(2);
+ }
return 0;
}
@@ 143,9 156,11 @@ inready(void)
{
int tries;
- for(tries = 0; !(inb(Status) & Inready); tries++)
- if(tries > 1000)
+ for(tries = 0; !(inb(Status) & Inready); tries++){
+ if(tries > 500)
return -1;
+ delay(2);
+ }
return 0;
}
@@ 159,21 174,26 @@ mousecmd(int cmd)
int tries;
c = 0;
+ tries = 0;
do{
- for(tries=0; tries < 100; tries++){
- if(outready() < 0)
- return -1;
- outb(Cmd, 0xD4);
- if(outready() < 0)
- return -1;
- outb(Data, cmd);
- if(inready() < 0)
- return -1;
- c = inb(Data);
- }
+ if(tries++ > 5)
+ break;
+ if(outready() < 0)
+ continue;
+ outb(Cmd, 0xD4);
+ if(outready() < 0)
+ continue;
+ outb(Data, cmd);
+ if(outready() < 0)
+ continue;
+ if(inready() < 0)
+ continue;
+ c = inb(Data);
} while(c == 0xFE);
- if(c != 0xFA)
+ if(c != 0xFA){
+ print("mouse returns %2.2ux to the %2.2ux command\n", c, cmd);
return -1;
+ }
return 0;
}
@@ 183,6 203,7 @@ mousecmd(int cmd)
void
i8042a20(void)
{
+ outready();
outb(Cmd, 0xD1);
outready();
outb(Data, 0xDF);
@@ 223,11 244,24 @@ kbdinit(void)
if(c & Inready)
inb(Data);
+ /* get current controller command byte */
+ outb(Cmd, 0x20);
+ if(inready() < 0){
+ print("kbdinit: can't read ccc\n");
+ ccc = 0;
+ } else
+ ccc = inb(Data);
+
/* enable kbd xfers and interrupts */
+ ccc &= ~Ckbddis;
+ ccc |= Csf | Ckbdint | Cscs1;
+ if(outready() < 0)
+ print("kbd init failed\n");
outb(Cmd, 0x60);
if(outready() < 0)
print("kbd init failed\n");
- outb(Data, 0x65);
+ outb(Data, ccc);
+ outready();
}
/*
@@ 236,7 270,7 @@ kbdinit(void)
void
mouseserial(int port)
{
- if(mousetype)
+ if(mousetype == Mouseserial)
return;
/* set up /dev/eia0 as the mouse */
@@ 250,24 284,32 @@ mouseserial(int port)
void
mouseps2(void)
{
- if(mousetype)
- return;
+ int x;
bigcursor();
setvec(Mousevec, kbdintr);
/* enable kbd/mouse xfers and interrupts */
+ x = splhi();
+ ccc &= ~Cmousedis;
+ ccc |= Cmouseint;
+ if(outready() < 0)
+ print("mouse init failed\n");
outb(Cmd, 0x60);
if(outready() < 0)
- print("kbd init failed\n");
- outb(Data, 0x47);
+ print("mouse init failed\n");
+ outb(Data, ccc);
if(outready() < 0)
- print("kbd init failed\n");
+ print("mouse init failed\n");
outb(Cmd, 0xA8);
+ if(outready() < 0)
+ print("mouse init failed\n");
/* make mouse streaming, enabled */
mousecmd(0xEA);
mousecmd(0xF4);
+ splx(x);
+
mousetype = MousePS2;
}
@@ 314,8 356,8 @@ static int shift;
*
* shift & left button is the same as middle button
*/
-static void
-mymouseputc(int c)
+static int
+mymouseputc(IOQ *q, int c)
{
static short msg[3];
static int nb;
@@ 323,11 365,12 @@ mymouseputc(int c)
static lastdx, lastdy;
extern Mouseinfo mouse;
+ USED(q); /* not */
/*
* check byte 0 for consistency
*/
if(nb==0 && (c&0xc8)!=0x08)
- return;
+ return 0;
msg[nb] = c;
if(++nb == 3){
@@ 345,6 388,7 @@ mymouseputc(int c)
spllo(); /* mouse tracking kills uart0 */
mouseclock();
}
+ return 0;
}
/*
@@ 404,7 448,7 @@ kbdintr0(void)
* if it's the mouse...
*/
if(s & Minready){
- mymouseputc(c);
+ mymouseputc(&mouseq, c);
return 0;
}
M pc/screen.h => pc/screen.h +0 -1
@@ 30,5 30,4 @@ extern void mouseupdate(int);
#define hwscreenwrite(a, b)
-#define screenupdate(z)
int islcd;
M pc/vga.c => pc/vga.c +5 -5
@@ 49,18 49,18 @@ struct VGAmode
};
/*
- * 640x480 display, 16 bit color.
+ * 640x480 display, 16 bit color.
*/
VGAmode mode12 =
{
/* general */
- 0xe3, 0x00,
+ 0xe7, 0x00,
/* sequence */
0x03, 0x01, 0x0f, 0x00, 0x06,
/* crt */
- 0x63, 0x4f, 0x58, 0x81, 0x59, 0x81, 0x0b, 0x3e,
+ 0x65, 0x4f, 0x50, 0x88, 0x55, 0x9a, 0x09, 0x3e,
0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xea, 0x2c, 0xdf, 0x28, 0x00, 0xea, 0xeb, 0xe3,
+ 0xe8, 0x8b, 0xdf, 0x28, 0x00, 0xe7, 0x04, 0xe3,
0xff,
/* graphics */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f,
@@ 68,7 68,7 @@ VGAmode mode12 =
/* attribute */
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x3f,
- 0x01, 0x00, 0x0f, 0x00, 0x00,
+ 0x01, 0x10, 0x0f, 0x00, 0x00,
};
M port/devbit.c => port/devbit.c +27 -3
@@ 107,6 107,7 @@ extern islcd;
Mouseinfo mouse;
Cursorinfo cursor;
+Rendez lcdmouse;
Cursor arrow =
{
@@ 161,6 162,8 @@ void cursoron(int);
void cursoroff(int);
int mousechanged(void*);
+static Rectangle mbb = {10000, 10000, -10000, -10000};
+
enum{
Qdir,
Qbitblt,
@@ 245,6 248,26 @@ bitdebug(void)
print("%d subfonts\n", l);
}
+/*
+ * need a process to do scsi transactions to update mouse on LCD
+ */
+void
+lcdmousep(void *a)
+{
+ USED(a);
+ for(;;){
+ sleep(&lcdmouse, return0, 0);
+ qlock(&bit);
+ if(waserror()){
+ qunlock(&bit);
+ continue;
+ }
+ screenupdate(mbb);
+ qunlock(&bit);
+ poperror();
+ }
+}
+
void
bitreset(void)
{
@@ 304,6 327,8 @@ bitinit(void)
cursorback.width = ((16 << gscreen.ldepth) + 31) >> 5;
}
cursoron(1);
+ if(islcd)
+ kproc("lcdmouse", lcdmousep, 0);
}
Chan*
@@ 747,8 772,6 @@ bitread(Chan *c, void *va, long n, ulong offset)
return n;
}
-static Rectangle mbb = {10000, 10000, -10000, -10000};
-
static void
mbbrect(Rectangle r)
{
@@ 814,7 837,6 @@ bitwrite(Chan *c, void *va, long n, ulong offset)
BSubfont *f, *tf, **fp;
GFont *ff, **ffp;
GCacheinfo *gc;
- extern void screenupdate(Rectangle);
if(!conf.monitor)
error(Egreg);
@@ 1989,6 2011,8 @@ mouseupdate(int dolock)
cursoroff(0);
mouse.xy = Pt(x, y);
cursoron(0);
+ if(islcd)
+ wakeup(&lcdmouse);
mouse.dx = 0;
mouse.dy = 0;
mouse.clock = 0;
M power/fns.h => power/fns.h +1 -0
@@ 71,6 71,7 @@ void vector0(void);
void vector80(void);
void vmereset(void);
void wbflush(void);
+#define screenupdate(a)
#define waserror() setlabel(&u->errlab[u->nerrlab++])
#define kmapperm(x) kmap(x)
#define KADDR(a) ((void*)((ulong)(a)|KZERO))
M ss/fns.h => ss/fns.h +1 -0
@@ 66,6 66,7 @@ ulong tas(ulong*);
void touser(ulong);
void trap(Ureg*);
void trapinit(void);
+#define screenupdate(a)
#define wbflush() /* mips compatibility */
#define waserror() (u->nerrlab++, setlabel(&u->errlab[u->nerrlab-1]))
#define getcallerpc(x) _getcallerpc()