M pc/devhard.c => pc/devhard.c +1 -0
@@ 259,6 259,7 @@ hardattach(char *spec)
print(" cyl=%d h=%d sec=%d\n",
dp->id.lcyls, dp->id.lheads, dp->id.ls2t);
}
+ case 0x427a: /* for now: a list of those that work */
dp->cyl = dp->id.lcyls;
dp->heads = dp->id.lheads;
dp->sectors = dp->id.ls2t;
M pc/vga.c => pc/vga.c +20 -17
@@ 100,14 100,14 @@ VGAmode mode12 =
VGAmode mode6a =
{
/* general */
- 0xe3, 0x00, /* 0x70, 0x04, these are read-only */
+ 0x2f, 0x00, /* 0x70, 0x04, these are read-only */
/* sequence */
0x03, 0x01, 0x0f, 0x00, 0x06,
/* crt */
- 0x7f, 0x63, 0x64, 0x02, 0x6a, 0x1d, 0x77, 0xf0,
- 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60,
- 0x5d, 0x8f, 0x57, 0x32, 0x00, 0x5b, 0x74, 0xc3,
- 0xff,
+ 0x7a, 0x63, 0x65, 0x9d, 0x67, 0x92, 0x39, 0x1f,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x33, 0x82, 0x2b, 0x32, 0x0f, 0x33, 0x36, 0xe7,
+ 0xff,
/* graphics */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f,
0xff,
@@ 208,7 208,6 @@ setmode(VGAmode *v)
arout(i, v->attribute[i]);
}
-#ifdef VGATROUBLE
void
getmode(VGAmode *v) {
int i;
@@ 236,27 235,27 @@ getmode(VGAmode *v) {
void
printmode(VGAmode *v) {
int i;
- print("general registers: %02x %02x\n",
+ print("g %2.2x %2x\n",
v->general[0], v->general[1]);
- print("sequence registers: ");
+ print("s ");
for(i = 0; i < sizeof(v->sequencer); i++) {
- print(" %02x", v->sequencer[i]);
+ print(" %2.2x", v->sequencer[i]);
}
- print("\nCRT registers: ");
+ print("\nc ");
for(i = 0; i < sizeof(v->crt); i++) {
- print(" %02x", v->crt[i]);
+ print(" %2.2x", v->crt[i]);
}
- print("\nGraphics registers: ");
+ print("\ng ");
for(i = 0; i < sizeof(v->graphics); i++) {
- print(" %02x", v->graphics[i]);
+ print(" %2.2x", v->graphics[i]);
}
- print("\nAttribute registers: ");
+ print("\na ");
for(i = 0; i < sizeof(v->attribute); i++) {
- print(" %02x", v->attribute[i]);
+ print(" %2.2x", v->attribute[i]);
}
print("\n");
}
@@ 302,9 301,10 @@ screeninit(void)
int i, j, k;
int c;
ulong *l;
- VGAmode v;
+ VGAmode testmode;
- setmode(&mode12);
+ setmode(&mode6a);
+ getmode(&testmode);
/*
* swizzle the font longs.
@@ 320,6 320,9 @@ screeninit(void)
out.pos.x = MINX;
out.pos.y = 0;
out.bwid = defont0.info[' '].width;
+delay(50000);
+ setmode(&mode12);
+ printmode(&testmode);
}
void
M port/devbit.c => port/devbit.c +4 -2
@@ 1244,8 1244,10 @@ bitalloc(Rectangle rect, int ld)
if(bit.free == 0)
error(Enobitmap);
ws = 1<<(5-ld); /* pixels per word */
- if(rect.min.x >= 0)
- l = (rect.max.x+ws-1)/ws - rect.min.x/ws;
+ if(rect.min.x >= 0) {
+ l = (rect.max.x+ws-1)/ws;
+ l -= rect.min.x/ws;
+ }
else{ /* make positive before divide */
t = (-rect.min.x)+ws-1;
t = (t/ws)*ws;
M port/devscc.c => port/devscc.c +0 -1
@@ 451,7 451,6 @@ sccspecial(int port, IOQ *oq, IOQ *iq, int baud)
}
}
-static int sccputc(IOQ *, int);
static void sccstopen(Queue*, Stream*);
static void sccstclose(Queue*);
static void sccoput(Queue*, Block*);
M port/proc.c => port/proc.c +6 -0
@@ 297,6 297,7 @@ void
sleep(Rendez *r, int (*f)(void*), void *arg)
{
Proc *p;
+ int s;
p = u->p;
sleep1(r, f, arg);
@@ 304,10 305,12 @@ sleep(Rendez *r, int (*f)(void*), void *arg)
sched(); /* notepending may go true while asleep */
if(p->notepending){
p->notepending = 0;
+ s = splhi();
lock(r);
if(r->p == p)
r->p = 0;
unlock(r);
+ splx(s);
error(Eintr);
}
}
@@ 317,6 320,7 @@ tsleep(Rendez *r, int (*f)(void*), void *arg, int ms)
{
Alarm *a;
Proc *p;
+ int s;
p = u->p;
sleep1(r, f, arg);
@@ 327,10 331,12 @@ tsleep(Rendez *r, int (*f)(void*), void *arg, int ms)
}
if(p->notepending){
p->notepending = 0;
+ s = splhi();
lock(r);
if(r->p == p)
r->p = 0;
unlock(r);
+ splx(s);
error(Eintr);
}
}
M power/devduart.c => power/devduart.c +33 -62
@@ 137,10 137,7 @@ struct Duartport
/* stream interface */
Queue *wq; /* write queue */
Rendez r; /* kproc waiting for input */
- Alarm *a; /* alarm for waking the kernel process */
- int delay; /* between character input and waking kproc */
int kstarted; /* kproc started */
- uchar delim[256/8]; /* characters that act as delimiters */
};
Duartport duartport[Maxport]; /* max possible */
@@ 207,7 204,7 @@ duartenable0(void)
void
duartbaud(Duartport *dp, int b)
{
- int x = 0;
+ int x;
switch(b){
case 38400:
@@ 235,9 232,10 @@ duartbaud(Duartport *dp, int b)
return;
}
if(x & 0x0100)
- dp->duart->ipc_acr = duartacr |= 0x80;
+ duartacr |= 0x80;
else
- dp->duart->ipc_acr = duartacr &= ~0x80;
+ duartacr &= ~0x80;
+ dp->duart->ipc_acr = duartacr;
dp->duart->sr_csr = x;
}
@@ 257,11 255,13 @@ duartbreak(Duartport *dp, int val)
duart = dp->duart;
if (val){
- duart->is_imr = duartimr &= ~IM_XRDYB;
+ duartimr &= ~IM_XRDYB;
+ duart->is_imr = duartimr;
duart->cmnd = STRT_BRK|ENB_TX;
} else {
duart->cmnd = STOP_BRK|ENB_TX;
- duart->is_imr = duartimr |= IM_XRDYB;
+ duartimr |= IM_XRDYB;
+ duart->is_imr = duartimr;
}
}
@@ 273,10 273,10 @@ duartslave0(Duartport *dp)
{
switch(dp->op){
case Ddtr:
- duartbaud(dp, dp->val);
+ duartdtr(dp, dp->val);
break;
case Dbaud:
- duartdtr(dp, dp->val);
+ duartbaud(dp, dp->val);
break;
case Dbreak:
duartbreak(dp, dp->val);
@@ 298,16 298,24 @@ duartslave0(Duartport *dp)
void
duartslave(void)
{
+ IOQ *cq;
Duartport *dp;
dp = &duartport[2*m->machno];
+ cq = dp->iq;
+ if(dp->wq && cangetc(cq))
+ wakeup(&cq->r);
if(dp->op != Dnone)
duartslave0(dp);
dp++;
+ cq = dp->iq;
+ if(dp->wq && cangetc(cq))
+ wakeup(&cq->r);
if(dp->op != Dnone)
duartslave0(dp);
}
+void
duartrintr(Duartport *dp)
{
Duart *duart;
@@ 324,13 332,11 @@ duartrintr(Duartport *dp)
cq = dp->iq;
if(cq->putc)
(*cq->putc)(cq, ch);
- else {
+ else
putc(cq, ch);
- if(dp->delim[ch/8] & (1<<(ch&7)) )
- wakeup(&cq->r);
- }
}
+void
duartxintr(Duartport *dp)
{
Duart *duart;
@@ 490,7 496,6 @@ duartspecial(int port, IOQ *oq, IOQ *iq, int baud)
duartbaud(dp, baud);
}
-static void duarttimer(Alarm*);
static int duartputc(IOQ *, int);
static void duartstopen(Queue*, Stream*);
static void duartstclose(Queue*);
@@ 505,36 510,12 @@ Qinfo duartinfo =
"duart"
};
-/*
- * wakeup the helper process to do input
- */
-static void
-duarttimer(Alarm *a)
-{
- Duartport *dp = a->arg;
-
- cancel(a);
- dp->a = 0;
- wakeup(&dp->iq->r);
-}
-
static int
-duartputc(IOQ *cq, int ch)
+opdone(void *x)
{
- Duartport *dp = cq->ptr; int r;
-
- r = putc(cq, ch);
+ Duartport *dp = x;
- /*
- * pass upstream within dp->delay milliseconds
- */
- if(dp->a==0){
- if(dp->delay == 0)
- wakeup(&cq->r);
- else
- dp->a = alarm(dp->delay, duarttimer, dp);
- }
- return r;
+ return dp->op == Dnone;
}
static void
@@ 549,18 530,17 @@ duartstopen(Queue *q, Stream *s)
dp->wq = WR(q);
WR(q)->ptr = dp;
RD(q)->ptr = dp;
- dp->delay = 64;
- dp->iq->putc = duartputc;
qunlock(dp);
- /* start with all characters as delimiters */
- memset(dp->delim, 1, sizeof(dp->delim));
-
if(dp->kstarted == 0){
dp->kstarted = 1;
sprint(name, "duart%d", s->id);
kproc(name, duartkproc, dp);
}
+
+ /* enable the port */
+ dp->op = Dena;
+ sleep(&dp->opr, opdone, dp);
}
static void
@@ 576,13 556,6 @@ duartstclose(Queue *q)
qunlock(dp);
}
-static int
-opdone(void *x)
-{
- Duartport *dp = x;
-
- return dp->op == Dnone;
-}
static void
duartoput(Queue *q, Block *bp)
{
@@ 631,11 604,6 @@ duartoput(Queue *q, Block *bp)
case 'r':
/* can't control? */
break;
- case 'W':
- case 'w':
- if(n>=0 && n<1000)
- dp->delay = n;
- break;
}
qunlock(dp);
}else while((m = BLEN(bp)) > 0){
@@ 699,8 667,10 @@ duartreset(void)
for(i = 0; i < nduartport; i++){
sprint(duartdir[2*i].name, "eia%d", i);
sprint(duartdir[2*i+1].name, "eia%dctl", i);
- duartdir[2*i].length = duartdir[2*i+1].length = 0;
- duartdir[2*i].perm = duartdir[2*i+1].perm = 0666;
+ duartdir[2*i].length = 0;
+ duartdir[2*i+1].length = 0;
+ duartdir[2*i].perm = 0666;
+ duartdir[2*i+1].perm = 0666;
duartdir[2*i].qid.path = STREAMQID(i, Sdataqid);
duartdir[2*i+1].qid.path = STREAMQID(i, Sctlqid);
}
@@ 746,7 716,7 @@ duartstat(Chan *c, char *dp)
{
switch(STREAMTYPE(c->qid.path)){
case Sdataqid:
- streamstat(c, dp, "eia0");
+ streamstat(c, dp, duartdir[2*STREAMID(c->qid.path)].name);
break;
default:
devstat(c, dp, duartdir, 2*nduartport, devgen);
@@ 815,6 785,7 @@ duartread(Chan *c, void *buf, long n, ulong offset)
}
error(Egreg);
+ return 0; /* not reached */
}
long