From ddeb95826316253063ad17e17808eee3d67763dc Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Fri, 15 Dec 2000 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 2000-12-15 --- bitsy/bitsyreset.s | 8 ++++++++ bitsy/clock.c | 14 +++++++++++++- bitsy/devpenmouse.c | 6 ++++++ bitsy/fns.h | 1 + port/error.h | 1 + port/lib.h | 2 +- port/portdat.h | 2 +- port/tod.c | 12 +++++++----- 8 files changed, 38 insertions(+), 8 deletions(-) create mode 100644 bitsy/bitsyreset.s diff --git a/bitsy/bitsyreset.s b/bitsy/bitsyreset.s new file mode 100644 index 0000000000000000000000000000000000000000..0905c7cc8fe5dcc4d8dd16f275c1902d901d70b7 --- /dev/null +++ b/bitsy/bitsyreset.s @@ -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) diff --git a/bitsy/clock.c b/bitsy/clock.c index b0963f41cc07848226431642d8e88fa140bef127..47a318ad260cffe0bf00a4a9e30a4f376ca020fd 100644 --- a/bitsy/clock.c +++ b/bitsy/clock.c @@ -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 diff --git a/bitsy/devpenmouse.c b/bitsy/devpenmouse.c index b145f8a47ee073fbc0337e58faa06e911bacdd33..a291b5a2b5520c6ee996c3d661febf7ffca170f1 100644 --- a/bitsy/devpenmouse.c +++ b/bitsy/devpenmouse.c @@ -10,6 +10,7 @@ #include #include #include "screen.h" +#include 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); diff --git a/bitsy/fns.h b/bitsy/fns.h index bc6417dfa1fc8aca73daedf45597a5c7682eedb0..970fd086e5cae81dad601f8e7a4d64376d23a076 100644 --- a/bitsy/fns.h +++ b/bitsy/fns.h @@ -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); diff --git a/port/error.h b/port/error.h index 3306d9ad86f91582d51df88f042abea15f935468..4cf4554a762855eb64d483f85da1a58bcc3e6aa9 100644 --- a/port/error.h +++ b/port/error.h @@ -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 */ diff --git a/port/lib.h b/port/lib.h index b376ada795293c2da680ff9ca950a0c483d3c5c5..423330affe2eba58ced07b6366476baceee5875d 100644 --- a/port/lib.h +++ b/port/lib.h @@ -128,7 +128,7 @@ struct Dir ulong mode; long atime; long mtime; - Length; + vlong length; short type; short dev; }; diff --git a/port/portdat.h b/port/portdat.h index ea8c51d10620b846e0edcb0474836808224c5f92..875907b3eae7b9fd6ad4e322f606521ee4aa56da 100644 --- a/port/portdat.h +++ b/port/portdat.h @@ -202,7 +202,7 @@ struct Dirtab { char name[NAMELEN]; Qid qid; - Length; + vlong length; long perm; }; diff --git a/port/tod.c b/port/tod.c index 371e9a086853b0b428f9851e62ca07193945bb27..b7d0d6070ea6f39c62ac061d999a0e6100e9e463 100644 --- a/port/tod.c +++ b/port/tod.c @@ -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