@@ 53,7 53,7 @@ enum
*/
struct Ident
{
- ushort magic; /* must be 0x0A5A */
+ ushort magic; /* drive type magic */
ushort lcyls; /* logical number of cylinders */
ushort rcyl; /* number of removable cylinders */
ushort lheads; /* logical number of heads */
@@ 221,6 221,7 @@ Chan*
hardattach(char *spec)
{
Drive *dp;
+ static int drivecomment=1;
for(dp = hard; dp < &hard[conf.nhard]; dp++){
if(!waserror()){
@@ 239,9 240,20 @@ hardattach(char *spec)
dp->heads = dp->id.lheads;
dp->sectors = dp->id.ls2t - 1;
break;
- default:
- print("unknown hard disk type\n");
- error(Egreg);
+ default: /* others: we hope this works */
+ if (drivecomment) {
+ print("unknown hard disk type, magic=%04x\n",
+ dp->id.magic);
+ print(" lcyls=%d lheads=%d sectors=%d\n",
+ dp->id.lcyls, dp->id.lheads, dp->id.ls2t);
+ print(" ncyls=%d nheads=%d dlcyls=%d dlheads=%d\n",
+ dp->id.ncyls, dp->id.nheads, dp->id.dlcyls,
+ dp->id.dlheads);
+ }
+ dp->cyl = dp->id.lcyls;
+ dp->heads = dp->id.lheads;
+ dp->sectors = dp->id.ls2t;
+ break;
}
dp->bytes = 512;
dp->cap = dp->bytes * dp->cyl * dp->heads * dp->sectors;
@@ 251,7 263,7 @@ hardattach(char *spec)
} else
dp->online = 0;
}
-
+ drivecomment=0; /* only the first time */
return devattach('w', spec);
}
@@ 713,7 725,8 @@ hardintr(Ureg *ur)
wakeup(&cp->r);
break;
default:
- print("weird disk interrupt\n");
+ print("weird disk interrupt, cmd=%02x\n",
+ cp->cmd);
break;
}
}
@@ 59,7 59,7 @@ enum
typedef struct VGAmode VGAmode;
struct VGAmode
{
- uchar general[4];
+ uchar general[2];
uchar sequencer[5];
uchar crt[0x19];
uchar graphics[9];
@@ 73,7 73,7 @@ struct VGAmode
VGAmode mode12 =
{
/* general */
- 0xe3, 0x00, 0x70, 0x04,
+ 0xe3, 0x00, /* 0x70, 0x04, these are read-only */
/* sequence */
0x03, 0x01, 0x0f, 0x00, 0x06,
/* crt */
@@ 96,7 96,7 @@ VGAmode mode12 =
VGAmode mode12 =
{
/* general */
- 0xe7, 0x00, 0x70, 0x04,
+ 0xe7, 0x00, /* 0x70, 0x04, these are read-only */
/* sequence */
0x03, 0x01, 0x0f, 0x00, 0x06,
/* crt */
@@ 109,7 109,7 @@ VGAmode mode12 =
0xff,
/* attribute */
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0d, 0x0f,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x3f,
0x01, 0x10, 0x0f, 0x00, 0x00,
};
#endif
@@ 119,7 119,6 @@ VGAmode mode12 =
void
genout(int reg, int val)
{
-delay(TESTDELAY);
if(reg == 0)
outb(EMISCW, val);
else if (reg == 1)
@@ 131,7 130,6 @@ srout(int reg, int val)
/*
* needed or the screen goes blank on an ultra VGA card
*/
- delay(TESTDELAY);
outb(SRX, reg);
outb(SR, val);
}
@@ 147,15 145,21 @@ arout(int reg, int val)
/*
* if this print is missing, we are left with a blank white screen.
*/
- print("arout %d %2x\n", reg, val);
inb(0x3DA);
- outb(ARW, reg | 0x20);
- outb(ARW, val);
+ if (reg <= 0xf) {
+ outb(ARW, reg | 0x0);
+ outb(ARW, val);
+ inb(0x3DA);
+ outb(ARW, reg | 0x20);
+ } else {
+ outb(ARW, reg | 0x20);
+ outb(ARW, val);
+ }
}
+
void
crout(int reg, int val)
{
- delay(TESTDELAY); /* needed for 16bit VGA path on Ultra SVGA */
outb(CRX, reg);
outb(CR, val);
}
@@ 203,6 207,44 @@ setmode(VGAmode *v)
arout(i, v->attribute[i]);
}
+#ifdef VGATROUBLE
+void
+dumpmodes(VGAmode *v)
+{
+ int i;
+
+ print("general registers: %02x %02x %02x %02x\n",
+ inb(0x3cc), inb(0x3ca), inb(0x3c2), inb(0x3da));
+
+ print("sequence registers: ");
+ for(i = 0; i < sizeof(v->sequencer); i++) {
+ outb(SRX, i);
+ print(" %02x", inb(SR));
+ }
+
+ print("\nCRT registers: ");
+ for(i = 0; i < sizeof(v->crt); i++) {
+ outb(CRX, i);
+ print(" %02x", inb(CR));
+ }
+
+ print("\nGraphics registers: ");
+ for(i = 0; i < sizeof(v->graphics); i++) {
+ outb(GRX, i);
+ print(" %02x", inb(GR));
+ }
+
+ print("\nAttribute registers: ");
+ for(i = 0; i < sizeof(v->attribute); i++) {
+ inb(0x3DA);
+ outb(ARW, i | 0x20);
+ print(" %02x", inb(ARR));
+ }
+
+ print("\nPEL Mask Register = %02x\n\n", inb(0x3c6)&0xff);
+}
+#endif
+
void
screeninit(void)
{
@@ 226,7 268,6 @@ screeninit(void)
out.pos.x = MINX;
out.pos.y = 0;
out.bwid = defont0.info[' '].width;
-print("PEL Mask Register = %02x\n", inb(0x3c6)&0xff);
}
void
@@ 330,8 330,12 @@ procread(Chan *c, void *va, long n, ulong offset)
return 0;
if(offset+n > STATSIZE)
n = STATSIZE - offset;
+
+/* Assertion for deref of psstate which causes faults */
if((p->state < Dead) || (p->state > Rendezvous))
- panic("p->state=#%lux, p->psstate=#%lux\n", p->state, p->psstate);
+ panic("p->state=#%lux, p->psstate=#%lux\n", p->state, p->psstate);
+
+
j = sprint(statbuf, "%-27s %-27s %-11s ",
p->text, p->user, p->psstate ? p->psstate : statename[p->state]);
for(i=0; i<6; i++){
@@ 608,7 612,7 @@ procctlmemio(Proc *p, ulong offset, int n, void *va, int read)
Page *pg;
KMap *k;
Segment *s;
- ulong soff;
+ ulong soff, l;
char *a = va, *b;
for(;;) {
@@ 640,7 644,11 @@ procctlmemio(Proc *p, ulong offset, int n, void *va, int read)
pg = pte->pages[(soff&(PTEMAPMEM-1))/BY2PG];
if(pagedout(pg))
panic("procctlmemio1");
-
+
+ l = BY2PG - (offset&(BY2PG-1));
+ if(n > l)
+ n = l;
+
k = kmap(pg);
b = (char*)VA(k);
if(read == 1)