From 2d32370b89cc5590ea216bf512f2a3112726dcab Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Sun, 28 Feb 1999 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1999-02-28 --- carrera/clock.c | 6 +++--- carrera/devrtc.c | 11 ----------- pc/clock.c | 13 ------------- pc/i8253.c | 6 +++--- port/devcons.c | 31 ++++++++++++++++++++++++++++++- port/devsd.c | 16 ++++++++-------- 6 files changed, 44 insertions(+), 39 deletions(-) diff --git a/carrera/clock.c b/carrera/clock.c index 7f7af44aa2688b6c2d678fb951254bd21a15b3e8..4267646dc81f85087ac71d573cf3ec9c8cff0672 100644 --- a/carrera/clock.c +++ b/carrera/clock.c @@ -124,10 +124,10 @@ clock(Ureg *ur) } } -uvlong +vlong fastticks(uvlong *hz) { if(hz) - *hz = HZ; - return m->ticks; + *hz = HZ*100; + return (vlong)m->ticks*100; } diff --git a/carrera/devrtc.c b/carrera/devrtc.c index 811b8e01020492392c2612cd1e3ac99cec7c030d..c54acb6aea5b3c8e48bad722f0bbf2277472145f 100644 --- a/carrera/devrtc.c +++ b/carrera/devrtc.c @@ -176,7 +176,6 @@ _rtctime(void) long rtctime(void) { -#ifdef notdef int i; long t, ot; @@ -193,9 +192,6 @@ rtctime(void) iunlock(&rtclock); return t; -#else - return boottime+TK2SEC(MACHP(0)->ticks); -#endif /* notdef */ } static long @@ -264,8 +260,6 @@ rtcwrite(Chan *c, void *buf, long n, vlong off) rtc.year = PUTBCD(rtc.year); } -/* disgusting hack because RTC doesn't work and m->ticks drifts */ -if(boottime == 0){ ilock(&rtclock); /* set clock values */ x = (*(uchar*)Rtcindex)&~0x7f; @@ -282,11 +276,6 @@ if(boottime == 0){ *(uchar*)Rtcindex = x|Year; *(uchar*)Rtcdata = rtc.year; iunlock(&rtclock); -}else{ - splhi(); - MACHP(0)->ticks = HZ*(secs - boottime); /* inverse of SEC2TK() */ - spllo(); -} return n; case Qnvram: diff --git a/pc/clock.c b/pc/clock.c index a036d7efd41ee324490a55f963cca8e2a0347869..b4e3a5cd7e7b5caff2f99d77d548f33c04848b8a 100644 --- a/pc/clock.c +++ b/pc/clock.c @@ -95,16 +95,3 @@ microdelay(int microsecs) microsecs = 1; aamloop(microsecs); } - -ulong -TK2MS(ulong ticks) -{ - uvlong t, hz; - - t = ticks; - hz = HZ; - t *= 1000L; - t = t/hz; - ticks = t; - return ticks; -} diff --git a/pc/i8253.c b/pc/i8253.c index 0e35c9934c99ebdeab0a3e5d2896c42b2c5de8fd..f3b9ca2f39d6bfe227fc7984d280405391e81b91 100644 --- a/pc/i8253.c +++ b/pc/i8253.c @@ -131,12 +131,12 @@ i8253enable(void) /* * return time elapsed since clock start in - * 10ths of nanoseconds + * 100 times hz */ uvlong i8253read(uvlong *hz) { if(hz) - *hz = HZ; - return m->ticks; + *hz = HZ*100; + return m->ticks*100; } diff --git a/port/devcons.c b/port/devcons.c index d9364b3f9fe3f106eb08717dc20e3672dedffc23..4bc6304822b5e54404b03c99d62871066894fec5 100644 --- a/port/devcons.c +++ b/port/devcons.c @@ -394,12 +394,41 @@ static Dirtab consdir[]={ "user", {Quser}, NAMELEN, 0666, }; +uvlong billion = 1000000000ULL; +uvlong bilbil = 1000000000ULL*1000000000ULL; + +// +// this routine is a hack till we get 64 bit ops faster +// int readvlnum(ulong off, char *buf, ulong n, uvlong val, int size) { char tmp[64]; + char num[64]; + ulong y; + int i; - snprint(tmp, sizeof(tmp), "%*.0ulld", size-1, val); + i = 0; + if(val > bilbil){ + y = val/bilbil; + i += sprint(num+i, "%lud", y); + val -= y*bilbil; + y = val/billion; + i += sprint(num+i, "%9.9lud", y); + val -= y*billion; + y = val; + sprint(num+i, "%9.9lud", y); + } else if(val > billion){ + y = val/billion; + i += sprint(num+i, "%lud", y); + val -= y*billion; + y = val; + sprint(num+i, "%9.9lud", y); + } else { + y = val; + sprint(num+i, "%lud", y); + } + snprint(tmp, sizeof(tmp), "%*s", size-1, num); tmp[size-1] = ' '; if(off >= size) return 0; diff --git a/port/devsd.c b/port/devsd.c index 65543ae2597e73997f0eb54b74775aeaca359329..d83d77cf4acfe730852a5bb1fba75cbbdf28ea5e 100644 --- a/port/devsd.c +++ b/port/devsd.c @@ -132,12 +132,12 @@ sdinit(void) type = scratch[0] & 0x1F; /* - * Read-capacity is mandatory for TypeDA, TypeMO and TypeCD. - * It may return 'not ready' if TypeDA is not spun up, - * TypeMO or TypeCD are not loaded or just plain slow getting - * their act together after a reset. - * If 'not ready' comes back, try starting a TypeDA and punt - * the get capacity until the drive is attached. + * Read-capacity is mandatory for TypeDA, TypeMO and + * TypeCD. It may return 'not ready' if TypeDA is not + * spun up, TypeMO or TypeCD are not loaded or just + * plain slow getting their act together after a reset. + * If 'not ready' comes back, try starting a TypeDA and + * punt the get capacity until the drive is attached. */ if(scsicap(d->t, d->lun, &d->size, &d->bsize) != STok) { nbytes = 0xFF; @@ -150,9 +150,9 @@ sdinit(void) case 0x02: break; case 0x06: - if(scratch[12] == 0x28 && scratch[13] == 0) + if(scratch[12] == 0x28 && !scratch[13]) break; - if(scratch[12] == 0x29 && scratch[13] == 0) + if(scratch[12] == 0x29 && !scratch[13]) break; /*FALLTHROUGH*/ default: