A bitsy/bitsyreset.s => bitsy/bitsyreset.s +8 -0
@@ 0,0 1,8 @@
+#include "mem.h"
+
+reset:
+ mov $INTREGS+4, r0 // turn off interrupts
+ mov $0, (r0)
+
+ mov $POWERREGS+14, r0 // set clock speed to 191.7MHz
+ mov $9, (r0)
M bitsy/clock.c => bitsy/clock.c +13 -1
@@ 47,12 47,24 @@ clockinit(void)
clockinited = 1;
}
+/* turn 32 bit counter into a 64 bit one. since todfix calls
+ * us at least once a second and we overflow once every 1165
+ * seconds, we won't miss an overflow.
+ */
vlong
fastticks(uvlong *hz)
{
+ static vlong high;
+ static ulong last;
+ ulong x;
+
if(hz != nil)
*hz = ClockFreq;
- return timerregs->oscr;
+ x = timerregs->oscr;
+ if(x < last)
+ high += 1LL<<32;
+ last = x;
+ return high+x;
}
static void
M bitsy/devpenmouse.c => bitsy/devpenmouse.c +6 -0
@@ 10,6 10,7 @@
#include <memdraw.h>
#include <cursor.h>
#include "screen.h"
+#include <ctype.h>
typedef struct Mouseinfo Mouseinfo;
typedef struct Mousestate Mousestate;
@@ 361,6 362,11 @@ penmousewrite(Chan *c, void *va, long n, vlong)
calibration.transx = 0;
calibration.transy = 0;
} else if (nf == 5) {
+ if ((!isdigit(*field[1]) && *field[1] != '-')
+ || (!isdigit(*field[2]) && *field[2] != '-')
+ || (!isdigit(*field[3]) && *field[3] != '-')
+ || (!isdigit(*field[4]) && *field[4] != '-'))
+ error(Ectlsyntax);
calibration.scalex = strtol(field[1], nil, 0);
calibration.scaley = strtol(field[2], nil, 0);
calibration.transx = strtol(field[3], nil, 0);
M bitsy/fns.h => bitsy/fns.h +1 -0
@@ 38,6 38,7 @@ void intrenable(int, int, void (*)(Ureg*, void*), void*, char*);
int iprint(char*, ...);
void irpower(int);
void lcdpower(int);
+void links(void);
void* mapmem(ulong, int, int);
void mappedIvecEnable(void);
void mappedIvecDisable(void);
M port/error.h => port/error.h +1 -0
@@ 43,3 43,4 @@ extern char Egreg[]; /* xterm: Error 50, errno 1: Too big */
extern char Ebadspec[]; /* bad attach specifier */
extern char Enoreg[]; /* process has no saved registers */
extern char Enoattach[]; /* mount/attach disallowed */
+extern char Ectlsyntax[]; /* bad syntax in control file messages */
M port/lib.h => port/lib.h +1 -1
@@ 128,7 128,7 @@ struct Dir
ulong mode;
long atime;
long mtime;
- Length;
+ vlong length;
short type;
short dev;
};
M port/portdat.h => port/portdat.h +1 -1
@@ 202,7 202,7 @@ struct Dirtab
{
char name[NAMELEN];
Qid qid;
- Length;
+ vlong length;
long perm;
};
M port/tod.c => port/tod.c +7 -5
@@ 16,7 16,7 @@
// 'f' is the clock frequency
// 'ticks' are clock ticks
//
-// to avoid too much calculation in gettod(), we calculate
+// to avoid too much calculation in todget(), we calculate
//
// mult = (1000000000<<31)/f
//
@@ 37,7 37,7 @@ struct {
vlong hz; // frequency of fast clock
vlong last; // last reading of fast clock
vlong off; // offset from epoch to last
- vlong lasttime; // last return value from gettod
+ vlong lasttime; // last return value from todget
vlong delta; // add 'delta' each slow clock tick from sstart to send
ulong sstart; // ...
ulong send; // ...
@@ 46,7 46,9 @@ struct {
void
todinit(void)
{
- fastticks((uvlong*)&tod.hz);
+ ilock(&tod);
+ tod.last = fastticks((uvlong*)&tod.hz);
+ iunlock(&tod);
todsetfreq(tod.hz);
addclock0link(todfix);
}
@@ 155,8 157,8 @@ todfix(void)
ilock(&tod);
// convert to epoch
- diff = ticks - tod.last;
- x = (diff * tod.multiplier) >> 31;
+ x = diff * tod.multiplier;
+ x = x >> 31;
x = x + tod.off;
// protect against overflows