## diffname mpc/clock.c 1999/0121 ## diff -e /dev/null /n/emeliedump/1999/0121/sys/src/brazil/mpc/clock.c 0a #include "u.h" #include "../port/lib.h" #include "mem.h" #include "dat.h" #include "fns.h" #include "io.h" #include "ureg.h" typedef struct Clock0link Clock0link; typedef struct Clock0link { void (*clock)(void); Clock0link* link; } Clock0link; static Clock0link *clock0link; static Lock clock0lock; ulong clkrelinq; void (*kproftick)(ulong); /* set by devkprof.c when active */ long clkvv; ulong clkhigh; void addclock0link(void (*clock)(void)) { Clock0link *lp; if((lp = malloc(sizeof(Clock0link))) == 0){ print("addclock0link: too many links\n"); return; } ilock(&clock0lock); lp->clock = clock; lp->link = clock0link; clock0link = lp; iunlock(&clock0lock); } void delay(int l) { ulong i, j; j = m->delayloop; while(l-- > 0) for(i=0; i < j; i++) ; } void microdelay(int l) { ulong i; l *= m->delayloop; l /= 1000; if(l <= 0) l = 1; for(i = 0; i < l; i++) ; } enum { Timebase = 4, /* system clock cycles per time base cycle */ }; static ulong clkreload; void clockinit(void) { long x, est; est = m->cpuhz/1000; /* initial estimate */ m->delayloop = est; do { x = gettbl(); delay(10); x = gettbl() - x; } while(x < 0); /* * fix count */ m->delayloop = (m->delayloop*10*est)/(x*Timebase); if(m->delayloop == 0) m->delayloop = 1; clkreload = (m->clockgen/Timebase)/HZ-1; putdec(clkreload); } void clockintr(Ureg *ur) { Clock0link *lp; long v; v = (clkvv = -getdec()); if(v > clkreload) clkhigh++; if(v > clkreload/2){ if(v > clkreload) m->ticks += v/clkreload; v = 0; } putdec(clkreload-v); m->ticks++; if(m->ticks%MS2TK(1000) == 0) m->bcsr[4] ^= DisableLamp; if(up) up->pc = ur->pc; checkalarms(); if(m->machno == 0) { if(kproftick != nil) (*kproftick)(ur->pc); lock(&clock0lock); for(lp = clock0link; lp; lp = lp->link) lp->clock(); unlock(&clock0lock); } if(up && up->state == Running){ // if(up->type == Interp && tready()) // ur->cr |= 1<<(31-31); if(nrdy > 0) sched(); } } void clockcheck(void) { /* called by ../port/taslock.c: reset watchdog here, if it's enabled */ } void clkprint(void) { print("clkr=%ld clkvv=%ld clkhigh=%lud\n", clkreload, clkvv, clkhigh); print("\n"); } uvlong fastticks(uvlong *hz) { if(hz) *hz = HZ; return m->ticks; } . ## diffname mpc/clock.c 1999/0122 ## diff -e /n/emeliedump/1999/0121/sys/src/brazil/mpc/clock.c /n/emeliedump/1999/0122/sys/src/brazil/mpc/clock.c 109,110c // if(m->ticks%MS2TK(1000) == 0) // m->bcsr[4] ^= DisableLamp; . ## diffname mpc/clock.c 1999/0123 ## diff -e /n/emeliedump/1999/0122/sys/src/brazil/mpc/clock.c /n/emeliedump/1999/0123/sys/src/brazil/mpc/clock.c 131,136d 110c // *(uchar*)(NIMMEM+0x2200) = (m->ticks/MS2TK(1000))&2; . 107a // keep alive for watchdog m->iomem->swsr = 0x556c; m->iomem->swsr = 0xaa39; . 73c est = m->clockgen/1000; /* initial estimate */ . ## diffname mpc/clock.c 1999/0127 ## diff -e /n/emeliedump/1999/0123/sys/src/brazil/mpc/clock.c /n/emeliedump/1999/0127/sys/src/brazil/mpc/clock.c 113,114c if(m->ticks%MS2TK(1000) == 0) *(uchar*)(NIMMEM+0x2200) = (m->ticks/MS2TK(1000))&2; . ## diffname mpc/clock.c 1999/0317 ## diff -e /n/emeliedump/1999/0127/sys/src/brazil/mpc/clock.c /n/emeliedump/1999/0317/sys/src/brazil/mpc/clock.c 144c vlong . ## diffname mpc/clock.c 1999/0415 ## diff -e /n/emeliedump/1999/0317/sys/src/brazil/mpc/clock.c /n/emeliedump/1999/0415/sys/src/brazil/mpc/clock.c 113,114d 84c m->delayloop = (m->delayloop*est/Timebase)/(x); . 77c delay(1); . 73c est = m->cpuhz/1000; /* initial estimate */ . 63c Timebase = 16, /* system clock cycles per time base cycle */ . 61a // the following can be 4 or 16 depending on the clock multiplier // see 15.3.3 in 860 manual . ## diffname mpc/clock.c 1999/0608 ## diff -e /n/emeliedump/1999/0415/sys/src/brazil/mpc/clock.c /n/emeliedump/1999/0608/sys/src/brazil/mpc/clock.c 129,134c if(up == 0 || up->state != Running) return; // user profiling clock // if(ur->status & KUSER) { // (*(ulong*)(USTKTOP-BY2WD)) += TK2MS(1); // segclock(ur->pc); // } if(anyready()) sched(); . 121,122d 118a . 116,117c accounttime(); if(kproftimer != nil) kproftimer(ur->pc); . 114a if(m->proc) m->proc->pc = ur->pc; . ## diffname mpc/clock.c 1999/0930 ## diff -e /n/emeliedump/1999/0608/sys/src/brazil/mpc/clock.c /n/emeliedump/1999/0930/sys/src/brazil/mpc/clock.c 88a } void clockinit(void) { delayloopinit(); . 71c delayloopinit(void) . ## diffname mpc/clock.c 2000/0516 ## diff -e /n/emeliedump/1999/0930/sys/src/brazil/mpc/clock.c /n/emeliedump/2000/0516/sys/src/9/mpc/clock.c 134a } if(m->flushmmu){ if(up) flushmmu(); m->flushmmu = 0; . 120a if((m->iomem->pddat & SIBIT(15)) == 0) { print("button pressed\n"); delay(200); reset(); } . 69a #ifdef XXX ulong millisec(void) { ulong tbu, tbl, x; vlong t; do { tbu = gettbu(); tbl = gettbl(); } while (gettbu() != tbu); t = (((vlong)tbu)<<32) + tbl; t <<= 4; t /= m->oscclk * 1000; x = t; if((long)(ledtime-x) < 0) powerdownled(); return (ulong)t; } #endif ulong millisec(void) { ulong tbl, x; tbl = gettbl(); x = tbl/((m->oscclk * 1000)/16); return x; } . ## diffname mpc/clock.c 2000/0527 ## diff -e /n/emeliedump/2000/0516/sys/src/9/mpc/clock.c /n/emeliedump/2000/0527/sys/src/9/mpc/clock.c 54a l += 500; . ## diffname mpc/clock.c 2001/0527 # deleted ## diff -e /n/emeliedump/2000/0527/sys/src/9/mpc/clock.c /n/emeliedump/2001/0527/sys/src/9/mpc/clock.c 1,212d