#include "all.h" #include "io.h" #include "mem.h" ulong meminit(void) { long x, i, *l; x = 0x12345678; for(i=4; i<128; i+=4){ l = (long*)(KSEG1|(i*1024L*1024L)); /* if(probe(l, sizeof(long))) break; /**/ *l = x; wbflush(); *(ulong*)KSEG1 = *(ulong*)KSEG1; /* clear latches */ if(*l != x) break; x += 0x3141526; } return i*1024*1024; } void vecinit(void) { ulong *p, *q; int size; p = (ulong*)EXCEPTION; q = (ulong*)vector80; for(size=0; size<4; size++) *p++ = *q++; p = (ulong*)UTLBMISS; q = (ulong*)vector80; for(size=0; size<4; size++) *p++ = *q++; } /* * should be called splhi * so there is no confusion * about cpu number */ void lights(int n, int on) { int l; l = m->lights; if(on) l |= (1<lights = l; *LED = ~l; } void nlights(int x) { int i; for(i = 0; i < 8; i++) { lights(i, x&1); x = x>>1; } } void delay(int ms) { int i, j; for(i=0; ictl = CTR(2)|SET16|MODE2; t->cnt2 = TIME2&0xFF; t->cnt2 = (TIME2>>8)&0xFF; t->ctl = CTR(1)|SET16|MODE2; t->cnt1 = TIME1&0xFF; t->cnt1 = (TIME1>>8)&0xFF; t->ctl = CTR(0)|SET16|MODE2; t->cnt0 = TIME0; t->cnt0 = (TIME0>>8)&0xFF; i = *CLRTIM0; USED(i); i = *CLRTIM1; USED(i); m->ticks = 0; f.duart = -1; } void clockreload(ulong n) { int i; if (n & INTR2) { i = *CLRTIM0; USED(i); } if (n & INTR4) { i = *CLRTIM1; USED(i); } } typedef struct Beef Beef; struct Beef { long deadbeef; long sum; long cpuid; long virid; long erno; void (*launch)(void); void (*rend)(void); long junk1[4]; long isize; long dsize; long nonbss; long junk2[18]; }; void launch(int n) { Beef *p; long i, s; ulong *ptr; p = (Beef*) 0xb0000500 + n; p->launch = newstart; p->sum = 0; s = 0; ptr = (ulong*)p; for (i = 0; i < sizeof(Beef)/sizeof(ulong); i++) s += *ptr++; p->sum = -(s+1); for(i=0; i<5000; i++) { if(p->launch == 0) break; delay(1); } } int nbits(ulong x) { int n; for(n=0; x; x>>=1) if(x & 1) n++; return n; } void launchinit(void) { int i; probeflag = 0; for(i=1; imachno; unlock(&active); clockinit(); schedinit(); } void userinit(void (*f)(void), void *arg, char *text) { User *p; p = newproc(); /* * Kernel Stack */ p->sched.pc = (ulong)init0; p->sched.sp = (ulong)p->stack + sizeof(p->stack); p->start = f; p->text = text; p->arg = arg; dofilter(&p->time); ready(p); }