From 32b8c41432ac7fc909f0b95e71b9c635bd73b433 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Wed, 19 Dec 2001 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 2001-12-19 --- mtx/clock.c | 34 +++++++++++++++++++++++++--------- mtx/dat.h | 6 +++++- mtx/main.c | 17 ++++++++--------- mtx/mmu.c | 6 ------ 4 files changed, 38 insertions(+), 25 deletions(-) diff --git a/mtx/clock.c b/mtx/clock.c index 729b00d4900bc0daea97be60e28ce4d76afe83bc..f025ef06f10ec38beab7de2656470753d2dfd2d1 100644 --- a/mtx/clock.c +++ b/mtx/clock.c @@ -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 diff --git a/mtx/dat.h b/mtx/dat.h index 589793e42b75dd2e46e96ba8cb9d342908fd7c2d..98c9cff39574d9cd55e8bf622744d6ebd8a531a2 100644 --- a/mtx/dat.h +++ b/mtx/dat.h @@ -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 */ diff --git a/mtx/main.c b/mtx/main.c index b7e6b8a466252e24a72d1040810458cbe8db10b8..a5dfa5238508a94cf0f557c7e29ed28e19c32b98 100644 --- a/mtx/main.c +++ b/mtx/main.c @@ -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 diff --git a/mtx/mmu.c b/mtx/mmu.c index 626a9813a4ffc459332d790407b942bb1ffa2bb1..3b339645344b97589e53317d4c15ffe857142553 100644 --- a/mtx/mmu.c +++ b/mtx/mmu.c @@ -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); }