M pc/clock.c => pc/clock.c +13 -0
@@ 95,3 95,16 @@ 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;
+}
M pc/fns.h => pc/fns.h +1 -0
@@ 110,6 110,7 @@ void vectortable(void);
void wrmsr(int, vlong);
void wbflush(void);
int xchgw(ushort*, int);
+ulong TK2MS(ulong); /* ticks to milliseconds */
#define waserror() (up->nerrlab++, setlabel(&up->errlab[up->nerrlab-1]))
#define getcallerpc(x) (((ulong*)(&x))[-1])
M pc/mem.h => pc/mem.h +1 -2
@@ 24,8 24,7 @@
#define HZ (100) /* clock frequency */
#define MS2HZ (1000/HZ) /* millisec per clock tick */
#define TK2SEC(t) ((t)/HZ) /* ticks to seconds */
-#define TK2MS(t) ((t)*MS2HZ) /* ticks to milliseconds */
-#define MS2TK(t) ((t)/MS2HZ) /* milliseconds to ticks */
+#define MS2TK(t) (((t)*HZ)/1000) /* milliseconds to ticks */
/*
* Fundamental addresses
M port/devcons.c => port/devcons.c +2 -2
@@ 604,7 604,7 @@ consread(Chan *c, void *buf, long n, vlong off)
return readnum((ulong)offset, buf, n, up->parentpid, NUMSIZE);
case Qtime:
- return readnum((ulong)offset, buf, n, rtctime(), 12);
+ return readnum((ulong)offset, buf, n, boottime+TK2SEC(MACHP(0)->ticks), 12);
case Qclock:
k = offset;
@@ 777,7 777,7 @@ conswrite(Chan *c, void *va, long n, vlong off)
break;
case Qtime:
- if(n<=0 || (boottime != 0 && !iseve())) /* write once file */
+ if(n<=0 || !iseve())
return 0;
if(n >= sizeof cbuf)
n = sizeof cbuf - 1;