M gnot/errno.h => gnot/errno.h +1 -1
@@ 1,5 1,5 @@
enum{
- Enevermind, /* never mind */
+ Enoerror, /* no error */
Enofd, /* no free file descriptors */
Ebadfd, /* fd out of range or not open */
Ebadusefd, /* inappropriate use of fd */
A pc/cga.c => pc/cga.c +58 -0
@@ 0,0 1,58 @@
+#include "u.h"
+#include "lib.h"
+#include "mem.h"
+#include "dat.h"
+#include "fns.h"
+
+#define WIDTH 160
+#define HEIGHT 24
+#define SCREEN ((char *)(0xB8000|KZERO))
+int pos;
+
+void
+screeninit(void)
+{
+ memset(SCREEN+pos, 0, WIDTH*HEIGHT-pos);
+}
+
+void
+screenputc(int c)
+{
+ int i;
+ static int color;
+
+ if(c == '\n'){
+ pos = pos/WIDTH;
+ pos = (pos+1)*WIDTH;
+ } else if(c == '\t'){
+ i = 8 - ((pos/2)&7);
+ while(i-->0)
+ screenputc(' ');
+ } else if(c == '\b'){
+ if(pos >= 2)
+ pos -= 2;
+ screenputc(' ');
+ pos -= 2;
+ } else {
+ SCREEN[pos++] = c;
+ SCREEN[pos++] = 0x1d;
+ }
+ if(pos >= WIDTH*HEIGHT){
+ memmove(SCREEN, &SCREEN[WIDTH], WIDTH*(HEIGHT-1));
+ memset(&SCREEN[WIDTH*(HEIGHT-1)], 0, WIDTH);
+ pos = WIDTH*(HEIGHT-1);
+ }
+}
+
+void
+screenputs(char *s, int n)
+{
+ while(n-- > 0)
+ screenputc(*s++);
+}
+
+int
+screenbits(void)
+{
+ return 4;
+}
M pc/trap.c => pc/trap.c +2 -2
@@ 259,7 259,7 @@ syscall(Ureg *ur)
if(ax == NOTED){
noted(ur, *(ulong*)(sp+BY2WD));
ret = -1;
- } else if(u->nnote){
+ } else if(u->nnote && ax!=FORK){
ur->ax = ret;
notify(ur);
}
@@ 346,7 346,7 @@ noted(Ureg *ur, ulong arg0)
u->notified = 0;
nur->flags = (u->svflags&0xffffff00) | (ur->flags&0xff);
memmove(ur, u->ureg, sizeof(Ureg));
- ur->ax = -1; /* return error from the interrupted call */
+ ur->ax = -1; /* return error from the interrupted syscall */
switch(arg0){
case NCONT:
splhi();
M pc/vga.c => pc/vga.c +29 -7
@@ 9,21 9,43 @@ enum
{
GRX= 0x3CE, /* index to graphics registers */
GR= 0x3CF, /* graphics registers 0-8 */
+ SRX= 0x3C4, /* index to sequence registers */
+ SR= 0x3C5, /* sequence registers 0-7 */
};
+void
+srout(int reg, int val)
+{
+ outb(SRX, reg);
+ outb(SR, val);
+}
+
+void
+grout(int reg, int val)
+{
+ outb(GRX, reg);
+ outb(GR, val);
+}
+
/*
* look at VGA registers
*/
void
vgainit(void)
{
+ uchar *display;
int i;
- uchar x;
- for(i = 0; i < 9; i++){
- outb(GRX, i);
- x = inb(GR);
- print("GR%d == %ux\n", i, x);
- }
- panic("for the hell of it");
+ srout(2, 0x0f); /* enable all 4 color planes */
+ srout(4, 0x08); /* quad mode */
+ grout(5, 0x40); /* pixel bits are sequential */
+ grout(6, 0x01); /* graphics mode - display starts at 0xA0000 */
+
+ for(;;);
+ display = (uchar*)(0xA0000 | KZERO);
+ for(i = 0; i < 128*1024; i++)
+ display[i] = 0x00;
+
+ for(i = 0; i < 4*640; i++)
+ display[i] = 0xff;
}
M port/devproc.c => port/devproc.c +1 -1
@@ 273,7 273,7 @@ procread(Chan *c, void *va, long n, ulong offset)
s->steal++;
qunlock(&s->lk);
if(pagedout(pg)){
- pprint("nonresident page addr %lux (complain to rob)\n", offset);
+ pprint("nonresident page addr %lux (complain to philw)\n", offset);
memset(a, 0, n);
}else{
k = kmap(pg);
M port/portdat.h => port/portdat.h +62 -65
@@ 63,7 63,7 @@ struct Alarm
List;
Lock;
int busy;
- long dt; /* may underflow in clock(); must be signed */
+ long dt; /* may underflow in clock(); must be signed */
void (*f)(void*);
void *arg;
};
@@ 86,20 86,20 @@ struct Alarms
struct Block
{
Block *next;
- uchar *rptr; /* first unconsumed byte */
- uchar *wptr; /* first empty byte */
- uchar *lim; /* 1 past the end of the buffer */
- uchar *base; /* start of the buffer */
+ uchar *rptr; /* first unconsumed byte */
+ uchar *wptr; /* first empty byte */
+ uchar *lim; /* 1 past the end of the buffer */
+ uchar *base; /* start of the buffer */
uchar flags;
uchar type;
};
struct Blist {
Lock;
- Block *first; /* first data block */
- Block *last; /* last data block */
- long len; /* length of list in bytes */
- int nb; /* number of blocks in list */
+ Block *first; /* first data block */
+ Block *last; /* last data block */
+ long len; /* length of list in bytes */
+ int nb; /* number of blocks in list */
};
/*
@@ 107,21 107,21 @@ struct Blist {
*/
enum
{
- Aaccess, /* as in access, stat */
- Atodir, /* as in chdir */
- Aopen, /* for i/o */
- Amount, /* to be mounted upon */
- Acreate, /* file is to be created */
+ Aaccess, /* as in access, stat */
+ Atodir, /* as in chdir */
+ Aopen, /* for i/o */
+ Amount, /* to be mounted upon */
+ Acreate, /* file is to be created */
};
/*
* Chan.flags
*/
-#define COPEN 1 /* for i/o */
-#define CMOUNT 2 /* is result of a mount/bind */
-#define CCREATE 4 /* permits creation if CMOUNT */
-#define CCEXEC 8 /* close on exec */
-#define CFREE 16 /* not in use */
+#define COPEN 1 /* for i/o */
+#define CMOUNT 2 /* is result of a mount/bind */
+#define CCREATE 4 /* permits creation if CMOUNT */
+#define CCEXEC 8 /* close on exec */
+#define CFREE 16 /* not in use */
struct Chan
{
@@ 200,9 200,9 @@ struct Etherpkt {
uchar data[1500];
uchar crc[4];
};
-#define ETHERMINTU 60 /* minimum transmit size */
-#define ETHERMAXTU 1514 /* maximum transmit size */
-#define ETHERHDRSIZE 14 /* size of an ethernet header */
+#define ETHERMINTU 60 /* minimum transmit size */
+#define ETHERMAXTU 1514 /* maximum transmit size */
+#define ETHERHDRSIZE 14 /* size of an ethernet header */
/*
* character based IO (mouse, keyboard, console screen)
@@ 287,12 287,12 @@ struct Page
struct Swapalloc
{
- Lock; /* Free map lock */
- int free; /* Number of currently free swap pages */
- char *swmap; /* Base of swap map in memory */
- char *alloc; /* Round robin allocator */
- char *top; /* Top of swap map */
- Rendez r; /* Pager kproc idle sleep */
+ Lock; /* Free map lock */
+ int free; /* Number of currently free swap pages */
+ char *swmap; /* Base of swap map in memory */
+ char *alloc; /* Round robin allocator */
+ char *top; /* Top of swap map */
+ Rendez r; /* Pager kproc idle sleep */
}swapalloc;
struct Image
@@ 390,17 390,17 @@ struct Palloc
Lock;
ulong addr;
int active;
- Page *page; /* base of Page structures, indexed by phys page number */
- ulong minppn; /* index of first usable page */
- Page *head; /* most recently used */
- Page *tail; /* least recently used */
- ulong freecount; /* how many pages on free list now */
- ulong user; /* how many user pages */
+ Page *page; /* base of Page structures */
+ ulong minppn; /* index of first usable page */
+ Page *head; /* most recently used */
+ Page *tail; /* least recently used */
+ ulong freecount; /* how many pages on free list now */
+ ulong user; /* how many user pages */
Page *hash[PGHSIZE];
Lock hashlock;
- Rendez r; /* Sleep for free mem */
- QLock pwait; /* Queue of procs waiting for memory */
- int wanted; /* Do the wakeup at free */
+ Rendez r; /* Sleep for free mem */
+ QLock pwait; /* Queue of procs waiting for memory */
+ int wanted; /* Do the wakeup at free */
};
enum /* Argument to forkpgrp call */
@@ 523,37 523,37 @@ struct Qinfo
/*
* Queue.flag
*/
-#define QHUNGUP 0x1 /* flag bit meaning the stream has been hung up */
+#define QHUNGUP 0x1 /* flag bit meaning the stream has been hung up */
#define QINUSE 0x2
-#define QHIWAT 0x4 /* queue has gone past the high water mark */
+#define QHIWAT 0x4 /* queue has gone past the high water mark */
#define QDEBUG 0x8
struct Queue {
Blist;
int flag;
- Qinfo *info; /* line discipline definition */
- Queue *other; /* opposite direction, same line discipline */
- Queue *next; /* next queue in the stream */
+ Qinfo *info; /* line discipline definition */
+ Queue *other; /* opposite direction, same line discipline */
+ Queue *next; /* next queue in the stream */
void (*put)(Queue*, Block*);
- QLock rlock; /* mutex for processes sleeping at r */
- Rendez r; /* standard place to wait for flow control */
- Rendez *rp; /* where flow control wakeups go to */
- void *ptr; /* private info for the queue */
+ QLock rlock; /* mutex for processes sleeping at r */
+ Rendez r; /* standard place to wait for flow control */
+ Rendez *rp; /* where flow control wakeups go to */
+ void *ptr; /* private info for the queue */
};
struct Stream {
- QLock; /* structure lock */
- short inuse; /* number of processes in stream */
- short opens; /* number of processes with stream open */
- ushort hread; /* number of reads after hangup */
- ushort type; /* correlation with Chan */
- ushort dev; /* ... */
- ushort id; /* ... */
- QLock rdlock; /* read lock */
- Queue *procq; /* write queue at process end */
- Queue *devq; /* read queue at device end */
- Block *err; /* error message from down stream */
- int forcedelim; /* force a delimiter before the next message */
+ QLock; /* structure lock */
+ short inuse; /* number of processes in stream */
+ short opens; /* number of processes with stream open */
+ ushort hread; /* number of reads after hangup */
+ ushort type; /* correlation with Chan */
+ ushort dev; /* ... */
+ ushort id; /* ... */
+ QLock rdlock; /* read lock */
+ Queue *procq; /* write queue at process end */
+ Queue *devq; /* read queue at device end */
+ Block *err; /* error message from down stream */
+ int forcedelim; /* force a delimiter before the next message */
};
/*
@@ 578,13 578,13 @@ enum {
Sdataqid = Shighqid,
Sctlqid = Sdataqid-1,
Slowqid = Sctlqid,
- Streamhi= (9*1024), /* byte count high water mark */
- Streambhi= 32, /* block count high water mark */
+ Streamhi= (9*1024), /* byte count high water mark */
+ Streambhi= 32, /* block count high water mark */
};
-#define MAXSYSARG 6 /* for mount(fd, mpt, flag, arg, srv, authfd) */
+#define MAXSYSARG 6 /* for mount(fd, mpt, flag, arg, srv, authfd) */
#define PRINTSIZE 256
-#define NUMSIZE 12 /* size of formatted number */
+#define NUMSIZE 12 /* size of formatted number */
extern FPsave initfp;
extern Conf conf;
@@ 600,6 600,3 @@ extern Image swapimage;
#define CHDIR 0x80000000L
#define CHAPPEND 0x40000000L
#define CHEXCL 0x20000000L
-
-
-
M port/segment.c => port/segment.c +8 -2
@@ 196,7 196,10 @@ attachimage(int type, Chan *c, ulong base, ulong len)
lock(&imagealloc);
- /* Search the image cache for remains of the text from a previous incarnation */
+ /*
+ * Search the image cache for remains of the text from a previous
+ * or currently running incarnation
+ */
for(i = ihash(c->qid.path); i; i = i->hash) {
if(c->qid.path == i->qid.path) {
lock(i);
@@ 211,6 214,10 @@ attachimage(int type, Chan *c, ulong base, ulong len)
}
}
+ /*
+ * imagereclaim dumps pages from the free list which are cached by image
+ * structures. This should free some image structures.
+ */
while(!(i = imagealloc.free)) {
unlock(&imagealloc);
imagereclaim();
@@ 241,7 248,6 @@ found:
else
incref(i->s);
- unlock(i);
return i;
}
M port/sysproc.c => port/sysproc.c +3 -0
@@ 264,12 264,14 @@ sysexec(ulong *arg)
fdclose(i, CCEXEC);
/* Text. Shared. Attaches to cache image if possible */
+ /* attachimage returns a locked cache image */
img = attachimage(SG_TEXT|SG_RONLY, tc, UTZERO, (t-UTZERO)>>PGSHIFT);
ts = img->s;
p->seg[TSEG] = ts;
ts->flushme = 1;
ts->fstart = 0;
ts->flen = sizeof(Exec)+text;
+ unlock(img);
/* Data. Shared. */
s = newseg(SG_DATA, t, (d-t)>>PGSHIFT);
@@ 408,6 410,7 @@ syserrstr(ulong *arg)
validaddr(arg[0], ERRLEN, 1);
memmove((char*)arg[0], u->error, ERRLEN);
+ strncpy(u->error, errstrtab[0], ERRLEN);
return 0;
}
M power/errno.h => power/errno.h +1 -1
@@ 1,5 1,5 @@
enum{
- Enevermind, /* never mind */
+ Enoerror, /* no error */
Enofd, /* no free file descriptors */
Ebadfd, /* fd out of range or not open */
Ebadusefd, /* inappropriate use of fd */
M ss/trap.c => ss/trap.c +1 -2
@@ 284,7 284,6 @@ noted(Ureg **urp, ulong arg0)
}
u->notified = 0;
memmove(*urp, u->ureg, sizeof(Ureg));
- (*urp)->r7 = -1; /* return error from the interrupted call */
switch(arg0){
case NCONT:
splhi();
@@ 412,7 411,7 @@ syscall(Ureg *aur)
u->p->insyscall = 0;
if(r7 == NOTED) /* ugly hack */
noted(&aur, *(ulong*)(sp+1*BY2WD)); /* doesn't return */
- if(u->nnote){
+ if(u->nnote && r7!=FORK){
ur->r7 = ret;
notify(ur);
}