| plan 9 kernel history: overview | file list | diff list |
2001/1023/alphapc/clock.c (diff list | history)
| 2001/1023/sys/src/9/alphapc/clock.c:1,104 – 2002/0410/sys/src/9/alphapc/clock.c:1,109 (short | long | prev | next) | ||
| 1999/0415 | #include "u.h" #include "../port/lib.h" #include "mem.h" #include "dat.h" #include "fns.h" #include "io.h" | |
| 1999/0429 | #include "axp.h" | |
| 1999/0415 | #include "ureg.h" void | |
| 1999/0429 | clockinit(void) | |
| 1999/0415 | { | |
| 1999/0429 | } | |
| 1999/0415 | ||
| 1999/0429 | uvlong cycletimer(void) { ulong pcc; | |
| 1999/0430 | vlong delta; | |
| 1999/0429 | pcc = rpcc(nil) & 0xFFFFFFFF; if(m->cpuhz == 0){ /* * pcclast is needed to detect wraparound of * the cycle timer which is only 32-bits. * m->cpuhz is set from the info passed from * the firmware. * This could be in clockinit if can * guarantee no wraparound between then and now. * * All the clock stuff needs work. */ m->cpuhz = hwrpb->cfreq; m->pcclast = pcc; } | |
| 1999/0430 | delta = pcc - m->pcclast; if(delta < 0) delta += 0x100000000LL; | |
| 1999/0429 | m->pcclast = pcc; | |
| 1999/0430 | m->fastclock += delta; | |
| 1999/0429 | return MACHP(0)->fastclock; | |
| 1999/0415 | } | |
| 1999/0429 |
| |
| 2002/0410 | uvlong | |
| 1999/0429 | fastticks(uvlong* hz) | |
| 1999/0415 | { | |
| 1999/0429 | uvlong ticks; int x; | |
| 1999/0415 | ||
| 1999/0429 | x = splhi(); ticks = cycletimer(); splx(x); if(hz) *hz = m->cpuhz; | |
| 2002/0410 | return ticks; | |
| 1999/0415 | } void | |
| 2002/0410 | timerset(uvlong) { } void | |
| 1999/0429 | microdelay(int us) | |
| 1999/0415 | { | |
| 1999/0429 | uvlong eot; | |
| 1999/0415 | ||
| 1999/0501 | eot = fastticks(nil) + (m->cpuhz/1000000)*us; while(fastticks(nil) < eot) | |
| 1999/0429 | ; } | |
| 1999/0415 | ||
| 1999/0429 | void | |
| 2001/0727 | delay(int millisecs) | |
| 1999/0429 | { | |
| 2001/0727 | microdelay(millisecs*1000); | |
| 1999/0415 | } void | |
| 2001/0727 | clock(Ureg *ureg) | |
| 1999/0415 | { static int count; | |
| 1999/0430 | cycletimer(); | |
| 2001/0727 | ||
| 1999/0415 | /* HZ == 100, timer == 1024Hz. error < 1ms */ count += 100; if (count < 1024) return; count -= 1024; | |
| 2001/0727 |
| |
| 2002/0410 | timerintr(ureg, 0); | |
| 1999/0415 | } | |
| 2001/1023 | ulong TK2MS(ulong ticks) { uvlong t, hz; t = ticks; hz = HZ; t *= 1000L; t = t/hz; ticks = t; return ticks; } | |