From c6e4dea4c4067c28da2aba05376b1f02060affdb Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Mon, 8 Apr 2002 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 2002-04-08 --- bitsy/clock.c | 34 +++++++++++++++------------------- bitsy/fns.h | 2 +- bitsy/power.c | 8 ++++---- 3 files changed, 20 insertions(+), 24 deletions(-) diff --git a/bitsy/clock.c b/bitsy/clock.c index 00a15c8f0f922cf6c5ff8c32b334726cdb367a2e..c1419f9e819c90404411669cd46affc62a62e3c1 100644 --- a/bitsy/clock.c +++ b/bitsy/clock.c @@ -20,6 +20,7 @@ OSTimer *timerregs = (OSTimer*)OSTIMERREGS; static int clockinited; static void clockintr(Ureg*, void*); +static uvlong when; /* scheduled time of next interrupt */ enum { @@ -34,7 +35,7 @@ clockpower(int on) if (on){ timerregs->ossr |= 1<<0; timerregs->oier = 1<<0; - timerregs->osmr[0] = timerregs->oscr + ClockFreq/HZ; + timerregs->osmr[0] = timerregs->oscr + Minfreq; } clockinited = on; } @@ -65,7 +66,8 @@ clockinit(void) (id>>16)&0xff, (id>>4)&0xfff, id&0xf); /* post interrupt 1/HZ secs from now */ - timerregs->osmr[0] = timerregs->oscr + ClockFreq/HZ; + when = timerregs->oscr + Minfreq; + timerregs->osmr[0] = when; timersinit(); @@ -95,35 +97,29 @@ fastticks(uvlong *hz) void timerset(uvlong v) { - ulong when, tics; /* Must be unsigned! */ + ulong next, tics; /* Must be unsigned! */ static int count; - if (v == 0LL) - when = timerregs->oscr + Minfreq; - else { - when = v; + next = v; - /* post next interrupt: calculate # of tics from now */ - tics = when - timerregs->oscr - Maxfreq; - if (tics > Minfreq){ - iprint("%lud %lud %lud %d\n", when, tics, timerregs->oscr, Minfreq); - when = timerregs->oscr + Maxfreq; - } + /* post next interrupt: calculate # of tics from now */ + tics = next - timerregs->oscr - Maxfreq; + if (tics > Minfreq){ + iprint("%lud %lud %lud %d\n", next, tics, timerregs->oscr, Minfreq); + next = timerregs->oscr + Maxfreq; } - timerregs->osmr[0] = when; + timerregs->osmr[0] = next; } static void clockintr(Ureg *ureg, void*) { - static ulong count; - /* reset previous interrupt */ timerregs->ossr |= 1<<0; + when += Minfreq; + timerregs->osmr[0] = when; /* insurance */ - timerset(timerintr(ureg, nil)); - if ((count++ % 100) == 0) - iprint("%lud ", timerregs->osmr[0] - timerregs->oscr); + timerintr(ureg, when); } void diff --git a/bitsy/fns.h b/bitsy/fns.h index b40908edeff47ad51b066bda4389dc43fd72c970..65fbff23b59866e7541b9003b5c2505e7281f42f 100644 --- a/bitsy/fns.h +++ b/bitsy/fns.h @@ -103,7 +103,7 @@ uchar* tarlookup(uchar*, char*, int*); void timersinit(void); void timeradd(Timer*); void timerdel(Timer*); -uvlong timerintr(Ureg *, void*); +void timerintr(Ureg *, uvlong); void timerset(uvlong); void touser(void*); void trapdump(char *tag); diff --git a/bitsy/power.c b/bitsy/power.c index 981fba6231fa33a444331eb09131082effb4d3b9..6d8cac5823bb8fe010f1cae93148e162ccfe8caf 100644 --- a/bitsy/power.c +++ b/bitsy/power.c @@ -173,7 +173,7 @@ deepsleep(void) { screenpower(0); µcpower(0); iprint("entering suspend mode, sp = 0x%lux, pc = 0x%lux, psw = 0x%ux\n", &xsp, xlink, power_pl); - dumpitall(); +// dumpitall(); delay(1000); uartpower(0); rs232power(0); @@ -206,7 +206,7 @@ deepsleep(void) { delay(100); xlink = getcallerpc(&xlink); iprint("\nresuming execution, sp = 0x%lux, pc = 0x%lux, psw = 0x%ux\n", &xsp, xlink, splhi()); - dumpitall(); +// dumpitall(); delay(1000); // irpower(1); // audiopower(1); @@ -232,11 +232,11 @@ powerkproc(void*) xlink = getcallerpc(&xlink); - iprint("call deepsleep, pc = 0x%lux, sp = 0x%lux\n", xlink, &xlink); +// iprint("call deepsleep, pc = 0x%lux, sp = 0x%lux\n", xlink, &xlink); deepsleep(); xlink1 = getcallerpc(&xlink1); - iprint("deepsleep returned, pc = 0x%lux, sp = 0x%lux\n", xlink1, &xlink); +// iprint("deepsleep returned, pc = 0x%lux, sp = 0x%lux\n", xlink1, &xlink); delay(2000);