M mtx/clock.c => mtx/clock.c +25 -9
@@ 8,19 8,36 @@
static ulong clkreload;
-// the following can be 4 or 16 depending on the clock multiplier
-// see 15.3.3 in 860 manual
-enum {
- Timebase = 16, /* system clock cycles per time base cycle */
-};
+void
+delayloopinit(void)
+{
+ ulong v;
+ uvlong x;
+
+ m->loopconst = 5000;
+ v = getdec();
+ delay(1000);
+ v -= getdec();
+
+ x = m->loopconst;
+ x *= m->dechz;
+ x /= v;
+ m->loopconst = x;
+}
void
clockinit(void)
{
-// delayloopinit();
+ /* XXX the hardcoding of these values is WRONG */
+ m->cpuhz = 300000000;
+ m->bushz = 66666666;
+
+ m->dechz = m->bushz/4; /* true for all 604e */
+ m->tbhz = m->dechz; /* conjecture; manual says bugger all */
+
+ delayloopinit();
-// clkreload = (m->clockgen/Timebase)/HZ-1;
- clkreload = (300000000/Timebase)/HZ-1;
+ clkreload = m->dechz/HZ-1; /* decremented at 1/4 bus clock speed */
putdec(clkreload);
}
@@ 44,7 61,6 @@ clockintr(Ureg *ureg)
}
portclock(ureg);
-if((m->ticks%HZ) == 0) print("tick! %d\n", m->ticks/HZ);
}
void
M mtx/dat.h => mtx/dat.h +5 -1
@@ 136,7 136,11 @@ struct Mach
ulong fairness; /* for runproc */
- ulong cpuhz; /* hwrpb->cfreq */
+ ulong cpuhz;
+ ulong bushz;
+ ulong dechz;
+ ulong tbhz;
+
ulong pcclast;
uvlong fastclock;
vlong intrts; /* time stamp of last interrupt */
M mtx/main.c => mtx/main.c +8 -9
@@ 34,8 34,6 @@ main(void)
links();
chandevreset();
pageinit();
-spllo();
-for(;;);
swapinit();
userinit();
schedinit();
@@ 53,8 51,8 @@ machinit(void)
* be enough for a while. Cpuidentify will
* calculate the real value later.
*/
- m->loopconst = 100000;
-m->loopconst = 5000;
+// m->loopconst = 100000;
+m->loopconst = 5000; /* dog slow, the cache must be off */
active.machs = 1;
active.exiting = 0;
@@ 101,8 99,6 @@ init0(void)
// char **p, *q, name[KNAMELEN];
// int n;
-print("init0\n");
-
up->nerrlab = 0;
spllo();
@@ 141,6 137,7 @@ print("init0\n");
poperror();
}
kproc("alarm", alarmkproc, 0);
+for(;;);
touser((void*)(USTKTOP-8));
}
@@ 160,8 157,10 @@ userinit(void)
p->rgrp = newrgrp();
p->procmode = 0640;
- strcpy(p->text, "*init*");
- strcpy(p->user, eve);
+ kstrdup(&eve, "");
+ kstrdup(&p->text, "*init*");
+ kstrdup(&p->user, eve);
+
p->fpstate = FPinit;
/*
@@ 171,7 170,7 @@ userinit(void)
* 4 bytes for gotolabel's return PC
*/
p->sched.pc = (ulong)init0;
- p->sched.sp = (ulong)p->kstack+KSTACK-(1+MAXSYSARG)*BY2WD;
+ p->sched.sp = (ulong)p->kstack+KSTACK-(sizeof(Sargs)+BY2WD);
/*
* User Stack
M mtx/mmu.c => mtx/mmu.c +0 -6
@@ 8,9 8,6 @@
void
mmuinit(void)
{
- int i;
-
- print("mmuinit\n");
}
void
@@ 18,7 15,6 @@ flushmmu(void)
{
int x;
-if(0)print("flushmmu(%ld)\n", up->pid);
x = splhi();
up->newtlb = 1;
mmuswitch(up);
@@ 33,7 29,6 @@ mmuswitch(Proc *p)
{
int tp;
-if(0)print("mmuswitch()\n");
if(p->newtlb) {
memset(p->pidonmach, 0, sizeof p->pidonmach);
p->newtlb = 0;
@@ 45,7 40,6 @@ if(0)print("mmuswitch()\n");
void
mmurelease(Proc* p)
{
-if(0)print("mmurelease(%ld)\n", p->pid);
memset(p->pidonmach, 0, sizeof p->pidonmach);
}