From 9dddf4b3142fc2e2ae683e1cb7c0f2b503ef96ed Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Thu, 27 Dec 1990 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1990-12-27 --- gnot/clock.c | 3 +- gnot/fns.h | 1 + port/proc.c | 6 + port/queue.c | 80 +++++++++++++ port/sysproc.c | 3 +- ss/boot.c | 4 + ss/boot.h | 298 ++++++++++++++++++++++++++---------------------- ss/clock.c | 31 ++++- ss/faultsparc.c | 10 +- ss/fns.h | 5 + ss/io.h | 2 + ss/l.s | 27 +++-- ss/main.c | 6 + ss/mem.h | 4 +- ss/mmu.c | 40 +++++-- ss/trap.c | 15 ++- 16 files changed, 355 insertions(+), 180 deletions(-) create mode 100644 port/queue.c diff --git a/gnot/clock.c b/gnot/clock.c index 2b5e3eb278b648026d1b7e85a0651dc25c00cecd..7a4445a7f5c4575982f55b981d96fc7c568dea11 100644 --- a/gnot/clock.c +++ b/gnot/clock.c @@ -35,7 +35,8 @@ clock(Ureg *ur) kbdclock(); mouseclock(); if((ur->sr&SPL(7)) == 0 && p && p->state==Running){ - sched(); + if(anyready()) + sched(); if(u->nnote && (ur->sr&SUPER)==0) notify(ur); } diff --git a/gnot/fns.h b/gnot/fns.h index 82252e8ef7b280627c59f3303ee6c210ac0e2cf6..f44afe16793bd001aceab7c19708206a4a2ab7a1 100644 --- a/gnot/fns.h +++ b/gnot/fns.h @@ -1,6 +1,7 @@ Alarm *alarm(int, void (*)(Alarm*), void*); void alarminit(void); Block *allocb(ulong); +int anyready(void); void append(List**, List*); void cancel(Alarm*); int canlock(Lock*); diff --git a/port/proc.c b/port/proc.c index f7b85af863da605b260ce9f3e04747df4aca8b1b..cca7c15b9d4798aa4fce9c536dccbdb37054e472 100644 --- a/port/proc.c +++ b/port/proc.c @@ -105,6 +105,12 @@ sched(void) gotolabel(&p->sched); } +int +anyready(void) +{ + return runq.head != 0; +} + void ready(Proc *p) { diff --git a/port/queue.c b/port/queue.c new file mode 100644 index 0000000000000000000000000000000000000000..a4806fabed034f5f817fcacf1334e2ea9c820a30 --- /dev/null +++ b/port/queue.c @@ -0,0 +1,80 @@ +#include "u.h" +#include "lib.h" +#include "mem.h" +#include "dat.h" +#include "fns.h" +#include "io.h" +#include "errno.h" + +void +initq(IOQ *q) +{ + q->in = q->out = q->buf; + q->puts = puts; + q->putc = putc; +} + +int +putc(IOQ *q, int c) +{ + uchar *nextin; + if(q->in >= &q->buf[sizeof(q->buf)-1]) + nextin = q->buf; + else + nextin = q->in+1; + if(nextin == q->out) + return -1; + *q->in = c; + q->in = nextin; + return 0; +} + +int +getc(IOQ *q) +{ + int c; + + if(q->in == q->out) + return -1; + c = *q->out++; + if(q->out == q->buf+sizeof(q->buf)) + q->out = q->buf; + return c; +} + +void +puts(IOQ *q, char *s, int n) +{ + int m; + + while(n){ + if(q->out > q->in) + m = q->out - q->in - 1; + else + m = &q->buf[NQ] - q->in; + if(m > n) + m = n; + memcpy(q->in, s, m); + n -= m; + q->in += m; + if(q->in >= &q->buf[NQ]) + q->in = q->buf; + } +} + +int +cangetc(void *arg) +{ + IOQ *q = (IOQ *)arg; + int n = q->in - q->out; + if (n < 0) + n += sizeof(q->buf); + return n; +} + +int +canputc(void *arg) +{ + IOQ *q = (IOQ *)arg; + return sizeof(q->buf)-cangetc(q)-1; +} diff --git a/port/sysproc.c b/port/sysproc.c index a81f6aa41b1f9ed96591b1750dc74d159e2e595c..c4df258d7d77b4ee109aa616fb94e894292c78ec 100644 --- a/port/sysproc.c +++ b/port/sysproc.c @@ -126,6 +126,7 @@ sysfork(ulong *arg) p->parent = u->p; p->parentpid = u->p->pid; p->pgrp = u->p->pgrp; + p->bssend = u->p->bssend; incref(p->pgrp); u->p->nchild++; pid = p->pid; @@ -495,13 +496,11 @@ sysbrk_(ulong *arg) Seg *s; addr = arg[0]; -#ifdef WHYROB if(addr < u->p->bssend){ pprint("addr below bss\n"); pexit("Suicide", 0); error(Esegaddr); } -#endif WHYROB if(addr <= ((u->p->bssend+(BY2PG-1))&~(BY2PG-1))) /* still in DSEG */ goto Return; if(segaddr(&u->p->seg[BSEG], u->p->seg[BSEG].minva, arg[0]) == 0){ diff --git a/ss/boot.c b/ss/boot.c index be2c0a6237c9cb76a32a6c8608accd848a81c25f..6076f0b4f34567e2822ee8bae3b9780daf953a0e 100644 --- a/ss/boot.c +++ b/ss/boot.c @@ -24,7 +24,11 @@ main(int argc, char *argv[]) write(1, "hello from boot\n", 16); bind("#c", "/dev", MREPL); binit(0, 0); +if(fork()==0) bitblt(&screen, Pt(100, 100), &screen, Rect(100, 100, 300, 200), 0xF); +else +bitblt(&screen, Pt(500, 500), &screen, Rect(100, 100, 300, 200), 0xF); + fd = open("#e/bootline", OREAD); if(fd >= 0){ diff --git a/ss/boot.h b/ss/boot.h index 562ae23f57caf264196fe00b05810d0c76daf043..957ed0a239e0929b0fa710bd3f2cba4d01634a6b 100644 --- a/ss/boot.h +++ b/ss/boot.h @@ -1,6 +1,6 @@ ulong bootcode[]={ 0x0000002ab, - 0x000007b70, + 0x000007bc0, 0x000000750, 0x000002168, 0x000000000, @@ -18,7 +18,7 @@ ulong bootcode[]={ 0x040000007, 0x001000000, 0x0ce206004, - 0x040000a3c, + 0x040000a51, 0x001000000, 0x010bffffd, 0x001000000, @@ -27,19 +27,19 @@ ulong bootcode[]={ 0x09000b216, 0x0d0206004, 0x0c0206008, - 0x040001642, + 0x040001657, 0x001000000, 0x09200b21e, 0x0d2206004, 0x090002001, 0x0d0206008, - 0x04000163c, + 0x040001651, 0x001000000, 0x09200b226, 0x0d2206004, 0x090002001, 0x0d0206008, - 0x040001636, + 0x04000164b, 0x001000000, 0x092002001, 0x0d2206004, @@ -47,41 +47,49 @@ ulong bootcode[]={ 0x0d0206008, 0x092002010, 0x0d220600c, - 0x040001640, + 0x040001655, 0x001000000, 0x09000b23f, 0x0d0206004, 0x09200b242, 0x0d2206008, 0x0c020600c, - 0x0400015fd, + 0x040001612, 0x001000000, 0x096100000, 0x0c0206004, 0x0c0206008, - 0x0400003cc, + 0x0400003e1, 0x001000000, + 0x040001629, + 0x001000000, + 0x0a200212c, + 0x0a00020c8, + 0x09a00200f, + 0x0980021f4, 0x096002064, - 0x09000b022, - 0x0d0206004, + 0x080a1c000, + 0x0128002f6, + 0x001000000, + 0x09200b022, + 0x0d2206004, 0x0d6206008, 0x0d620600c, - 0x09200b022, - 0x0d2206010, + 0x09000b022, + 0x0d0206010, 0x0d6206014, 0x0d6206018, - 0x09000212c, - 0x0d020601c, - 0x0920020c8, - 0x0d2206020, - 0x09000200f, - 0x0d0206024, - 0x040000596, + 0x0e220601c, + 0x090100010, + 0x0e0206020, + 0x09210000d, + 0x0da206024, + 0x0400005a3, 0x001000000, 0x09000b247, 0x0d0206004, 0x0c0206008, - 0x04000160c, + 0x040001619, 0x001000000, 0x092100007, 0x096100007, @@ -94,16 +102,16 @@ ulong bootcode[]={ 0x0d0206008, 0x092002040, 0x0d220600c, - 0x040001605, + 0x040001612, 0x001000000, 0x0d0006140, 0x0d0206004, - 0x0400015d7, + 0x0400015e4, 0x001000000, 0x09000b253, 0x0d0206004, 0x0c0206008, - 0x0400015f6, + 0x040001603, 0x001000000, 0x092100007, 0x096100007, @@ -116,21 +124,21 @@ ulong bootcode[]={ 0x0d0206008, 0x092002001, 0x0d220600c, - 0x0400015ef, + 0x0400015fc, 0x001000000, 0x0d0006140, 0x0d0206004, - 0x0400015c1, + 0x0400015ce, 0x001000000, 0x09000b261, 0x0d0206004, 0x0c0206008, - 0x0400015e0, + 0x0400015ed, 0x001000000, 0x09800b046, 0x096100007, 0x080a1c000, - 0x0068002ac, + 0x0068002a8, 0x001000000, 0x0d6206140, 0x0d6206004, @@ -138,29 +146,27 @@ ulong bootcode[]={ 0x0d8206008, 0x092002040, 0x0d220600c, - 0x0400015d9, + 0x0400015e6, 0x001000000, 0x0d0006140, 0x0d0206004, - 0x0400015ab, + 0x0400015b8, 0x001000000, 0x096002002, 0x0d048b002, 0x0912a2018, 0x0913a2018, - 0x0921a2041, - 0x080a24000, - 0x002800279, + 0x080a22041, + 0x002800276, 0x001000000, - 0x0921a2061, - 0x080a24000, - 0x002800256, + 0x080a22061, + 0x002800254, 0x001000000, 0x09000b2d6, 0x0d0206004, 0x09410000b, 0x0d6206008, - 0x0400015bd, + 0x0400015cc, 0x001000000, 0x0ce206144, 0x0d0006144, @@ -169,41 +175,39 @@ ulong bootcode[]={ 0x001000000, 0x09200b2dd, 0x0d2206004, - 0x0400002ab, + 0x0400002ba, 0x001000000, 0x0d0006144, 0x0d0206004, 0x09200b2ec, 0x0d2206008, - 0x040000288, + 0x040000297, 0x001000000, 0x0d0006144, 0x0d0206004, 0x09200b2f7, 0x0d2206008, - 0x040000282, + 0x040000291, 0x001000000, - 0x04000159a, + 0x0400015a9, 0x001000000, 0x090100007, - 0x09221ffff, - 0x080a24000, - 0x00280000a, + 0x080a1ffff, + 0x002800009, 0x001000000, - 0x09219c000, - 0x080a24000, + 0x080a1c000, 0x002800229, 0x001000000, 0x0d2006144, 0x0d2206004, - 0x040001575, + 0x040001586, 0x001000000, 0x0c0206130, 0x09000b30d, 0x0d0206004, 0x094002002, 0x0d4206008, - 0x040001592, + 0x0400015a3, 0x001000000, 0x096100007, 0x090100007, @@ -213,13 +217,13 @@ ulong bootcode[]={ 0x001000000, 0x09200b317, 0x0d2206004, - 0x04000027f, + 0x040000290, 0x001000000, 0x09200b329, 0x0d2206004, 0x094002002, 0x0d4206008, - 0x040001582, + 0x040001593, 0x001000000, 0x096100007, 0x092100007, @@ -229,7 +233,7 @@ ulong bootcode[]={ 0x001000000, 0x09000b332, 0x0d0206004, - 0x04000026f, + 0x040000280, 0x001000000, 0x092006030, 0x0d2206004, @@ -237,11 +241,11 @@ ulong bootcode[]={ 0x0d0206008, 0x09200b046, 0x0d220600c, - 0x0400012f6, + 0x040001307, 0x001000000, 0x092006030, 0x0d2206004, - 0x04000135d, + 0x04000136e, 0x001000000, 0x096100007, 0x0d0006144, @@ -251,7 +255,7 @@ ulong bootcode[]={ 0x090100007, 0x0ce20613c, 0x0ce20600c, - 0x040001574, + 0x040001585, 0x001000000, 0x092100007, 0x0d400613c, @@ -262,15 +266,15 @@ ulong bootcode[]={ 0x0d2206004, 0x09000b046, 0x0d0206008, - 0x04000126d, + 0x04000127e, 0x001000000, 0x0d2006144, 0x0d2206004, - 0x04000152f, + 0x040001540, 0x001000000, 0x09000b384, 0x0d0206004, - 0x040001265, + 0x040001276, 0x001000000, 0x092002032, 0x01d000006, @@ -285,7 +289,7 @@ ulong bootcode[]={ 0x0d0206004, 0x094006030, 0x0d4206008, - 0x040001592, + 0x0400015a3, 0x001000000, 0x096100007, 0x0d2006140, @@ -295,7 +299,7 @@ ulong bootcode[]={ 0x092100007, 0x0ce20613c, 0x0ce20600c, - 0x040001548, + 0x040001559, 0x001000000, 0x0d400613c, 0x080a1c00a, @@ -303,7 +307,7 @@ ulong bootcode[]={ 0x001000000, 0x09000b38b, 0x0d0206004, - 0x040000225, + 0x040000236, 0x001000000, 0x0d0006140, 0x0d0206004, @@ -311,7 +315,7 @@ ulong bootcode[]={ 0x0d4206008, 0x090002100, 0x0d020600c, - 0x04000152c, + 0x04000153d, 0x001000000, 0x096100007, 0x080a1e002, @@ -328,7 +332,7 @@ ulong bootcode[]={ 0x001000000, 0x09200b395, 0x0d2206004, - 0x04000020c, + 0x04000021d, 0x001000000, 0x0d600613c, 0x092006030, @@ -338,7 +342,7 @@ ulong bootcode[]={ 0x0d4206008, 0x09210000b, 0x0d620600c, - 0x040001914, + 0x040001925, 0x001000000, 0x090100007, 0x080a1c000, @@ -364,11 +368,11 @@ ulong bootcode[]={ 0x0932a6018, 0x0933a6018, 0x0d2206018, - 0x040001207, + 0x040001218, 0x001000000, 0x09000b3c1, 0x0d0206004, - 0x0400001e4, + 0x0400001f5, 0x001000000, 0x01d000006, 0x09c038002, @@ -378,11 +382,11 @@ ulong bootcode[]={ 0x001000000, 0x09000b3cc, 0x0d0206004, - 0x0400001da, + 0x0400001eb, 0x001000000, 0x09200b3d5, 0x0d2206004, - 0x0400011f5, + 0x040001206, 0x001000000, 0x090002034, 0x01d000006, @@ -397,7 +401,7 @@ ulong bootcode[]={ 0x0d2206004, 0x094006030, 0x0d4206008, - 0x040001522, + 0x040001533, 0x001000000, 0x096100007, 0x0d0006140, @@ -407,7 +411,7 @@ ulong bootcode[]={ 0x090100007, 0x0ce20613c, 0x0ce20600c, - 0x0400014d8, + 0x0400014e9, 0x001000000, 0x092100007, 0x0d400613c, @@ -416,7 +420,7 @@ ulong bootcode[]={ 0x001000000, 0x09000b3e0, 0x0d0206004, - 0x0400001b4, + 0x0400001c5, 0x001000000, 0x0d0006140, 0x0d0206004, @@ -424,7 +428,7 @@ ulong bootcode[]={ 0x0d4206008, 0x090002100, 0x0d020600c, - 0x0400014bb, + 0x0400014cc, 0x001000000, 0x096100007, 0x090100007, @@ -434,7 +438,7 @@ ulong bootcode[]={ 0x001000000, 0x09200b3ee, 0x0d2206004, - 0x0400001a2, + 0x0400001b3, 0x001000000, 0x0d600613c, 0x092006030, @@ -444,7 +448,7 @@ ulong bootcode[]={ 0x0d4206008, 0x09210000b, 0x0d620600c, - 0x0400018aa, + 0x0400018bb, 0x001000000, 0x090100007, 0x080a1c000, @@ -452,7 +456,7 @@ ulong bootcode[]={ 0x001000000, 0x09000b3fb, 0x0d0206004, - 0x040000190, + 0x0400001a1, 0x001000000, 0x01d000006, 0x09c038002, @@ -466,13 +470,13 @@ ulong bootcode[]={ 0x09203a038, 0x092026008, 0x0d2206008, - 0x0400011a1, + 0x0400011b2, 0x001000000, 0x01d00002e, 0x09003a038, 0x090022008, 0x0d0206004, - 0x04000017c, + 0x04000018d, 0x001000000, 0x01d000006, 0x09c038002, @@ -482,11 +486,11 @@ ulong bootcode[]={ 0x001000000, 0x09000b414, 0x0d0206004, - 0x040000172, + 0x040000183, 0x001000000, 0x09200b421, 0x0d2206004, - 0x04000118d, + 0x04000119e, 0x001000000, 0x090006030, 0x0d0206004, @@ -494,7 +498,7 @@ ulong bootcode[]={ 0x0d2206008, 0x09000b42f, 0x0d020600c, - 0x0400011f5, + 0x040001206, 0x001000000, 0x090006030, 0x0d0206004, @@ -502,7 +506,7 @@ ulong bootcode[]={ 0x0d4206008, 0x0900021b6, 0x0d020600c, - 0x040001449, + 0x04000145a, 0x001000000, 0x096100007, 0x090100007, @@ -512,7 +516,7 @@ ulong bootcode[]={ 0x001000000, 0x09200b436, 0x0d2206004, - 0x040000154, + 0x040000165, 0x001000000, 0x090006030, 0x0d0206004, @@ -520,16 +524,16 @@ ulong bootcode[]={ 0x0d2206008, 0x0d0006140, 0x0d020600c, - 0x0400011db, + 0x0400011ec, 0x001000000, 0x092006030, 0x0d2206004, - 0x040001242, + 0x040001253, 0x001000000, 0x0ce206024, 0x094006030, 0x0d4206004, - 0x04000123d, + 0x04000124e, 0x001000000, 0x0ce206020, 0x0d4006134, @@ -538,7 +542,7 @@ ulong bootcode[]={ 0x0d2206008, 0x0d4006020, 0x0d420600c, - 0x040001455, + 0x040001466, 0x001000000, 0x090100007, 0x0d2006024, @@ -547,11 +551,11 @@ ulong bootcode[]={ 0x001000000, 0x09000b440, 0x0d0206004, - 0x040000131, + 0x040000142, 0x001000000, 0x0d2006134, 0x0d2206004, - 0x040001412, + 0x040001423, 0x001000000, 0x090006030, 0x0d0206004, @@ -559,7 +563,7 @@ ulong bootcode[]={ 0x0d2206008, 0x09000b44c, 0x0d020600c, - 0x0400011b4, + 0x0400011c5, 0x001000000, 0x09000b453, 0x0d0206004, @@ -567,7 +571,7 @@ ulong bootcode[]={ 0x0d4206008, 0x0900021b6, 0x0d020600c, - 0x040001408, + 0x040001419, 0x001000000, 0x096100007, 0x090100007, @@ -577,7 +581,7 @@ ulong bootcode[]={ 0x001000000, 0x09200b45b, 0x0d2206004, - 0x040000113, + 0x040000124, 0x001000000, 0x090006030, 0x0d0206004, @@ -585,16 +589,16 @@ ulong bootcode[]={ 0x0d2206008, 0x0d0006140, 0x0d020600c, - 0x04000119a, + 0x0400011ab, 0x001000000, 0x092006030, 0x0d2206004, - 0x040001201, + 0x040001212, 0x001000000, 0x0ce206024, 0x094006030, 0x0d4206004, - 0x0400011fc, + 0x04000120d, 0x001000000, 0x0ce206020, 0x0d4006134, @@ -603,7 +607,7 @@ ulong bootcode[]={ 0x0d2206008, 0x0d4006020, 0x0d420600c, - 0x040001414, + 0x040001425, 0x001000000, 0x090100007, 0x0d2006024, @@ -612,22 +616,22 @@ ulong bootcode[]={ 0x001000000, 0x09000b465, 0x0d0206004, - 0x0400000f0, + 0x040000101, 0x001000000, 0x0d2006134, 0x0d2206004, - 0x0400013d1, + 0x0400013e2, 0x001000000, 0x09000b46b, 0x0d0206004, - 0x040001107, + 0x040001118, 0x001000000, 0x09000b474, 0x0d0206004, 0x09400b476, 0x0d4206008, 0x0c020600c, - 0x0400013c0, + 0x0400013d1, 0x001000000, 0x092100007, 0x080a1c000, @@ -635,7 +639,7 @@ ulong bootcode[]={ 0x001000000, 0x09000b478, 0x0d0206004, - 0x0400000d9, + 0x0400000ea, 0x001000000, 0x0d0006140, 0x0d0206004, @@ -647,7 +651,7 @@ ulong bootcode[]={ 0x0d4206010, 0x09000b480, 0x0d0206014, - 0x0400013d0, + 0x0400013e1, 0x001000000, 0x092100007, 0x080a1c000, @@ -655,17 +659,17 @@ ulong bootcode[]={ 0x001000000, 0x09200b481, 0x0d2206004, - 0x0400000c5, + 0x0400000d6, 0x001000000, 0x09000b487, 0x0d0206004, - 0x0400010e0, + 0x0400010f1, 0x001000000, 0x09000b102, 0x0d0206004, 0x094002020, 0x0d4206008, - 0x040001164, + 0x040001175, 0x001000000, 0x096100000, 0x080a1c000, @@ -678,11 +682,11 @@ ulong bootcode[]={ 0x09000b4a1, 0x0d020600c, 0x0d6206010, - 0x040000e22, + 0x040000e33, 0x001000000, 0x09200b4b5, 0x0d2206004, - 0x0400000aa, + 0x0400000bb, 0x001000000, 0x0d0006000, 0x082006148, @@ -693,11 +697,11 @@ ulong bootcode[]={ 0x09000b4b0, 0x0d0206008, 0x0c020600c, - 0x040000e13, + 0x040000e24, 0x001000000, 0x09200b4b5, 0x0d2206004, - 0x04000009b, + 0x0400000ac, 0x001000000, 0x0d0006000, 0x082006148, @@ -715,7 +719,7 @@ ulong bootcode[]={ 0x0d4206008, 0x090002100, 0x0d020600c, - 0x040001398, + 0x0400013a9, 0x001000000, 0x096100007, 0x010bffe73, @@ -726,19 +730,19 @@ ulong bootcode[]={ 0x001000000, 0x09200b34e, 0x0d2206004, - 0x04000007e, + 0x04000008f, 0x001000000, 0x09000b356, 0x0d0206004, - 0x040001099, + 0x0400010aa, 0x001000000, 0x0d2006140, 0x0d2206004, - 0x04000135b, + 0x04000136c, 0x001000000, 0x0d0006144, 0x0d0206004, - 0x040001357, + 0x040001368, 0x001000000, 0x0d0006130, 0x090022001, @@ -748,7 +752,7 @@ ulong bootcode[]={ 0x01d00003a, 0x09003a260, 0x0d0206004, - 0x04000137d, + 0x04000138e, 0x001000000, 0x010bffffb, 0x001000000, @@ -756,7 +760,7 @@ ulong bootcode[]={ 0x0d2206004, 0x09410000b, 0x0d6206008, - 0x040001369, + 0x04000137a, 0x001000000, 0x096100007, 0x092100007, @@ -766,28 +770,28 @@ ulong bootcode[]={ 0x001000000, 0x09000b2b0, 0x0d0206004, - 0x040000056, + 0x040000067, 0x001000000, 0x0d6006144, 0x09210000b, 0x0d6206004, 0x09000b2c4, 0x0d0206008, - 0x040000032, + 0x040000043, 0x001000000, 0x0d2006144, 0x0d2206004, 0x09000b2cb, 0x0d0206008, - 0x04000002c, + 0x04000003d, 0x001000000, - 0x010bffd9e, + 0x010bffda0, 0x001000000, 0x09000b273, 0x0d0206004, 0x09410000b, 0x0d6206008, - 0x04000134a, + 0x04000135b, 0x001000000, 0x096100007, 0x090100007, @@ -797,31 +801,48 @@ ulong bootcode[]={ 0x001000000, 0x09200b27f, 0x0d2206004, - 0x040000037, + 0x040000048, 0x001000000, 0x0d6006144, 0x09010000b, 0x0d6206004, 0x09200b293, 0x0d2206008, - 0x040000013, + 0x040000024, 0x001000000, 0x0d0006144, 0x0d0206004, 0x09200b299, 0x0d2206008, - 0x04000000d, + 0x04000001e, 0x001000000, - 0x010bffd7f, + 0x010bffd81, 0x001000000, 0x09210000c, 0x0d8206004, 0x09000b26f, 0x0d0206008, - 0x0400010f8, + 0x040001109, 0x001000000, 0x096002002, - 0x010bffd5c, + 0x010bffd60, + 0x001000000, + 0x09000b022, + 0x0d0206004, + 0x0d8206008, + 0x0d820600c, + 0x09200b022, + 0x0d2206010, + 0x0d6206014, + 0x0d6206018, + 0x0e220601c, + 0x092100010, + 0x0e0206020, + 0x09010000d, + 0x0da206024, + 0x0400002af, + 0x001000000, + 0x010bffd0c, 0x001000000, 0x082206014, 0x0de206000, @@ -1204,15 +1225,15 @@ ulong bootcode[]={ 0x0c020b03a, 0x092002050, 0x0d2206004, - 0x01d000007, - 0x09003a3b8, + 0x01d000008, + 0x09003a00c, 0x0d0206008, 0x040000683, 0x001000000, 0x092002052, 0x0d2206004, 0x01d000007, - 0x09003a334, + 0x09003a388, 0x0d0206008, 0x04000067c, 0x001000000, @@ -1293,7 +1314,7 @@ ulong bootcode[]={ 0x04000112f, 0x001000000, 0x01d000007, - 0x09203a270, + 0x09203a2c4, 0x0d2206004, 0x040000503, 0x001000000, @@ -1439,7 +1460,7 @@ ulong bootcode[]={ 0x040000c50, 0x001000000, 0x01d000007, - 0x09203a270, + 0x09203a2c4, 0x0d2206004, 0x040000471, 0x001000000, @@ -7908,7 +7929,6 @@ ulong bootcode[]={ 0x001000000, 0x000000000, 0x000000000, - 0x000000000, 0x06e6f6e2d, 0x07a65726f, 0x020657869, @@ -8274,13 +8294,13 @@ ulong bootcode[]={ 0x065207265, 0x061640000, 0x000000000, - 0x000004808, - 0x00000492c, - 0x00000411c, - 0x000004a44, - 0x000004858, - 0x0000048a4, - 0x0000048ec, + 0x00000485c, + 0x000004980, + 0x000004170, + 0x000004a98, + 0x0000048ac, + 0x0000048f8, + 0x000004940, 0x000000000, 0x000000000, 0x000000000, @@ -8375,8 +8395,8 @@ ulong bootcode[]={ 0x00a000000, 0x000000000, 0x000000000, - 0x000082e0, + 0x00008330, 0x0, - 0x000082e0, + 0x00008330, 0x0, }; diff --git a/ss/clock.c b/ss/clock.c index d2e1b3745a9a27231f2b7367e28fcb051df3f340..3b50adbe9b9583ac8df4f11d9d15a90506bd8ffb 100644 --- a/ss/clock.c +++ b/ss/clock.c @@ -18,12 +18,34 @@ delay(int ms) ; } +typedef struct Ctr Ctr; +struct Ctr +{ + ulong ctr0; + ulong lim0; + ulong ctr1; + ulong lim1; +}; +Ctr *ctr; + +void +clockinit(void) +{ + KMap *k; + + k = kmappa(CLOCK, PTENOCACHE|PTEIO); + ctr = (Ctr*)k->va; + ctr->lim1 = (CLOCKFREQ/HZ)<<10; +} + void clock(Ureg *ur) { Proc *p; + ulong i; - SYNCREG[1] = 0x5F; /* clear interrupt */ + i = ctr->lim1; /* clear interrupt */ + USED(i); m->ticks++; p = m->proc; if(p){ @@ -34,9 +56,10 @@ clock(Ureg *ur) checkalarms(); kbdclock(); mouseclock(); - if((ur->psr&SPL(7)) == 0 && p && p->state==Running){ - sched(); - if(u->nnote && (ur->psr&PSRSUPER)==0) + if((ur->psr&SPL(0xF))==0 && p && p->state==Running){ + if(anyready()) + sched(); + if(u->nnote && (ur->psr&PSRPSUPER)==0) notify(ur); } } diff --git a/ss/faultsparc.c b/ss/faultsparc.c index a4458680018550e83fb71713086fb157a71f9edc..cb19132a93d9cabd8707b60b6e3a5defd07b18e1 100644 --- a/ss/faultsparc.c +++ b/ss/faultsparc.c @@ -14,16 +14,16 @@ faultsparc(Ureg *ur) int user, read, insyscall; ulong tbr; - tbr = ur->tbr&0xFFF; + tbr = (ur->tbr&0xFFF)>>4; addr = ur->pc; /* assume instr. exception */ - if(tbr == (9<<4)) /* data access exception */ + if(tbr == 9) /* data access exception */ addr = getw2(SEVAR); - else if(tbr != (1<<4)){ /* should be instruction access exception */ + else if(tbr != 1){ /* should be instruction access exception */ trap(ur); - panic("trap returns"); + return; } spllo(); -print("fault: %s pc=0x%lux addr %lux\n", excname(ur->tbr), ur->pc, addr); +print("fault: %s pc=0x%lux addr %lux\n", excname(tbr), ur->pc, addr); if(u == 0){ dumpregs(ur); panic("fault u==0 pc=%lux", ur->pc); diff --git a/ss/fns.h b/ss/fns.h index f0fc7f17429fac01048f364ee8b523583501335d..b743fd0207eedd7e8e1bb58ea8fdda9f80d14267 100644 --- a/ss/fns.h +++ b/ss/fns.h @@ -1,6 +1,7 @@ Alarm *alarm(int, void (*)(Alarm*), void*); void alarminit(void); Block *allocb(ulong); +int anyready(void); void append(List**, List*); void cacheinit(void); void cancel(Alarm*); @@ -12,6 +13,7 @@ void chandevinit(void); void checkalarms(void); #define clearmmucache() void clock(Ureg*); +void clockinit(void); Chan *clone(Chan*, Chan*); void close(Chan*); void closemount(Mount*); @@ -94,6 +96,7 @@ void kbdrepeat(int); void kbdclock(void); void kmapinit(void); KMap *kmap(Page*); +KMap *kmappa(ulong, ulong); int kprint(char*, ...); void kproc(char*, void(*)(void*), void*); void kunmap(KMap*); @@ -151,6 +154,8 @@ void putstr(char*); void putstrn(char*, long); void puttbr(ulong); void putw2(ulong, ulong); +void putw4(ulong, ulong); +void putwC(ulong, ulong); void putwD(ulong, ulong); void putwE(ulong, ulong); ulong pwait(Waitmsg*); diff --git a/ss/io.h b/ss/io.h index b4b94a0151f76cdc209b17ece303249411c96880..0cd810056de4308f97df90ffff23327a7c41258f 100644 --- a/ss/io.h +++ b/ss/io.h @@ -3,6 +3,8 @@ typedef struct Duart Duart; #define SYNCREG ((char*)0x40400000) #define DISPLAYRAM 0x1E800000 #define EPROM 0xF6000000 +#define CLOCK 0xF3000000 +#define CLOCKFREQ 1000000 /* one microsecond increments */ #define DUARTREG ((Duart*)0x40100000) #define PORT ((uchar *)0x40300000) diff --git a/ss/l.s b/ss/l.s index 6a254ffc49f1c7e5b7739e8c7d47f1ede130d7e4..2416165c6a0abaa1ed15fe0737f6298fe3c8e0c7 100644 --- a/ss/l.s +++ b/ss/l.s @@ -1,6 +1,6 @@ #include "mem.h" -#define SYSPSR (PSREF|SPL(0xF)|PSRSUPER) +#define SYSPSR (PSREF|SPL(0x0)|PSRSUPER) TEXT start(SB), $-4 @@ -319,11 +319,11 @@ TEXT setlabel(SB), $0 TEXT gotolabel(SB), $0 - MOVW r+4(FP), R7 MOVW b+0(FP), R8 MOVW (R8), R1 MOVW 4(R8), R15 MOVW R15, 0(R1) + MOVW $1, R7 RETURN TEXT putcxsegm(SB), $0 @@ -368,32 +368,39 @@ TEXT putw2(SB), $0 MOVW R8, (R7, 2) RETURN -TEXT putwE(SB), $0 +TEXT putw4(SB), $0 MOVW 0(FP), R7 MOVW 4(FP), R8 - MOVW R8, (R7, 0xE) + MOVW R8, (R7, 4) RETURN -TEXT putsegm(SB), $0 +TEXT putwC(SB), $0 MOVW 0(FP), R7 MOVW 4(FP), R8 - MOVW R8, (R7, 3) + MOVW R8, (R7, 0xC) RETURN -TEXT putpmeg(SB), $0 +TEXT putwD(SB), $0 MOVW 0(FP), R7 MOVW 4(FP), R8 - MOVW R8, (R7, 4) + MOVW R8, (R7, 0xD) + RETURN + +TEXT putwE(SB), $0 + + MOVW 0(FP), R7 + MOVW 4(FP), R8 + MOVW R8, (R7, 0xE) RETURN -TEXT putwd(SB), $0 +TEXT putsegm(SB), $0 MOVW 0(FP), R7 MOVW 4(FP), R8 - MOVW R8, (R7, 0xD) + MOVW R8, (R7, 3) RETURN GLOBL mach0+0(SB), $MACHSIZE diff --git a/ss/main.c b/ss/main.c index 2eeb6289c67b399b997c7db8c4c9d68635e5771a..fb010c9d24b0fa92e90b9f5ce140c7ac18ba21c9 100644 --- a/ss/main.c +++ b/ss/main.c @@ -78,6 +78,12 @@ main(void) /* filsysinit(); /**/ pageinit(); userinit(); +{KMap *k; +k = kmappa(0xF5000000, PTENOCACHE|PTEIO); +print("interrupt %ux\n", *(uchar*)k->va); +kunmap(k); +} + clockinit(); schedinit(); } diff --git a/ss/mem.h b/ss/mem.h index eac374ea9fc35b37951a46513bbe0c9b0fd4d461..aa4ab46200447a2290e0ecb52b107f77ddc4cd2b 100644 --- a/ss/mem.h +++ b/ss/mem.h @@ -18,7 +18,7 @@ /* * Time */ -#define HZ (60) /* clock frequency */ +#define HZ 20 /* clock frequency */ #define MS2HZ (1000/HZ) /* millisec per clock tick */ #define TK2SEC(t) ((t)/HZ) /* ticks to seconds */ #define TK2MS(t) ((((ulong)(t))*1000)/HZ) /* ticks to milliseconds */ @@ -54,7 +54,7 @@ * MMU */ -#define VAMASK 0x1FFFFFFF +#define VAMASK 0x3FFFFFFF #define NPMEG (1<<12) #define BY2SEGM (1<<18) #define PG2SEGM (1<<6) diff --git a/ss/mmu.c b/ss/mmu.c index e80ab5d1c47306b5c4ce7c560250518bda6aeb59..4ab62600e8d7ff4f1bf580128366c7c591d1eeef 100644 --- a/ss/mmu.c +++ b/ss/mmu.c @@ -40,6 +40,11 @@ mapstack(Proc *p) /* don't set m->pidhere[*tp] because we're only writing U entry */ tlbphys = PPN(p->upage->pa)|PTEVALID|PTEWRITE|PTEKERNEL|PTEMAINMEM; putcontext(tp-1); + /* + * putw4(USERADDR, tlbphys) might be good enough but + * there is that fuss in pexit/pwait() copying between + * u areas and that might surprise any cache entries + */ putpmeg(USERADDR, tlbphys); u = (User*)USERADDR; } @@ -64,6 +69,7 @@ newpid(Proc *p) m->pidproc[i] = p; m->lastpid = i; print("new context %d\n", i); + putcontext(i-1); /* * kludge: each context is allowed 2 pmegs, one for text and one for stack */ @@ -128,11 +134,10 @@ mmuinit(void) /* * Invalidate user addresses */ -/* - for(l=UZERO; lnext; unlock(&kmapalloc); - k->pa = pg->pa; + k->pa = pa; /* * Cache is virtual and a pain to deal with. * Must avoid having the same entry in the cache twice, so * must use NOCACHE or else extreme cleverness elsewhere. */ - putpmeg(k->va, PPN(k->pa)|PTEVALID|PTEKERNEL|PTEWRITE|PTENOCACHE|flag); + putpmeg(k->va, PPN(pa)|PTEVALID|PTEKERNEL|PTEWRITE|PTENOCACHE|flag); return k; } KMap* kmap(Page *pg) { - return kmap1(pg, PTEMAINMEM); + return kmappa(pg->pa, PTEMAINMEM); } void diff --git a/ss/trap.c b/ss/trap.c index c73e5240d85bb90c73f2f25bdd07a1ad625170a9..cae3416e014acd3cd042fc50d55ba54c2e027238 100644 --- a/ss/trap.c +++ b/ss/trap.c @@ -35,8 +35,6 @@ excname(ulong tbr) { static char buf[32]; /* BUG: not reentrant! */ - tbr &= 0xFFF; - tbr >>= 4; if(tbr < sizeof trapname/sizeof(char*)) return trapname[tbr]; if(tbr == 36) @@ -57,19 +55,26 @@ trap(Ureg *ur) { int user; char buf[64]; + ulong tbr; + + tbr = (ur->tbr&0xFFF)>>4; + if(tbr == 30){ /* interrupt 14: counter 1 */ + clock(ur); + return; + } user = !(ur->psr&PSRPSUPER); /* if(u) u->p->pc = ur->pc; /* BUG */ if(user){ - print("user trap: %s pc=0x%lux\n", excname(ur->tbr), ur->pc); + print("user trap: %s pc=0x%lux\n", excname(tbr), ur->pc); dumpregs(ur); for(;;); - sprint(buf, "sys: trap: pc=0x%lux %s", ur->pc, excname(ur->tbr)); + sprint(buf, "sys: trap: pc=0x%lux %s", ur->pc, excname(tbr)); postnote(u->p, 1, buf, NDebug); }else{ - print("kernel trap: %s pc=0x%lux\n", excname(ur->tbr), ur->pc); + print("kernel trap: %s pc=0x%lux\n", excname(tbr), ur->pc); dumpregs(ur); for(;;); exit();