#include "u.h"
+#include "tos.h"
#include "../port/lib.h"
#include "mem.h"
#include "dat.h"
#include "fns.h"
#include "io.h"
-#include "tos.h"
#include "ureg.h"
-#include "init.h"
#include "pool.h"
-#include "reboot.h"
+#include "rebootcode.i"
Mach *m;
-
-/*
- * Where configuration info is left for the loaded programme.
- * This will turn into a structure as more is done by the boot loader
- * (e.g. why parse the .ini file twice?).
- * There are 3584 bytes available at CONFADDR.
- */
-#define BOOTLINE ((char*)CONFADDR)
-#define BOOTLINELEN 64
-#define BOOTARGS ((char*)(CONFADDR+BOOTLINELEN))
-#define BOOTARGSLEN (4096-0x200-BOOTLINELEN)
-#define MAXCONF 64
-
-char bootdisk[KNAMELEN];
Conf conf;
-char *confname[MAXCONF];
-char *confval[MAXCONF];
-int nconf;
-uchar *sp; /* user stack of init proc */
-int delaylink;
-static void
-options(void)
-{
- long i, n;
- char *cp, *line[MAXCONF], *p, *q;
- ulong *m, l;
- extern ulong *multiboot;
-
- if(multiboot != nil){
- cp = BOOTARGS;
- *cp = 0;
- if((*multiboot & 8) != 0 && multiboot[5] > 0){
- m = KADDR(multiboot[6]);
- l = m[1] - m[0];
- m = KADDR(m[0]);
- if(l >= BOOTARGSLEN)
- l = BOOTARGSLEN - 1;
- memmove(cp, m, l);
- cp[l] = 0;
- }
- }
-
- /*
- * parse configuration args from dos file plan9.ini
- */
- cp = BOOTARGS; /* where b.com leaves its config */
- cp[BOOTARGSLEN-1] = 0;
-
- /*
- * Strip out '\r', change '\t' -> ' '.
- */
- p = cp;
- for(q = cp; *q; q++){
- if(*q == '\r')
- continue;
- if(*q == '\t')
- *q = ' ';
- *p++ = *q;
- }
- *p = 0;
-
- n = getfields(cp, line, MAXCONF, 1, "\n");
- for(i = 0; i < n; i++){
- if(*line[i] == '#')
- continue;
- cp = strchr(line[i], '=');
- if(cp == nil)
- continue;
- *cp++ = '\0';
- confname[nconf] = line[i];
- confval[nconf] = cp;
- nconf++;
- }
-}
+int delaylink;
+int idle_spin;
-extern void mmuinit0(void);
extern void (*i8237alloc)(void);
+extern void bootscreeninit(void);
+extern void multibootdebug(void);
void
main(void)
{
mach0init();
- options();
+ bootargsinit();
ioinit();
i8250console();
quotefmtinstall();
screeninit();
print("\nPlan 9\n");
-
+
trapinit0();
- mmuinit0();
-
- kbdinit();
i8253init();
cpuidentify();
+ meminit0();
+ archinit();
meminit();
+ ramdiskinit();
confinit();
- archinit();
xinit();
+ bootscreeninit();
if(i8237alloc != nil)
i8237alloc();
trapinit();
arch->intrinit();
timersinit();
mathinit();
- kbdenable();
if(arch->clockenable)
arch->clockenable();
procinit0();
pcimatch(0, 0, 0);
}else
links();
- conf.monitor = 1;
chandevreset();
pageinit();
- swapinit();
userinit();
- active.thunderbirdsarego = 1;
schedinit();
}
machinit();
- active.machs = 1;
+ active.machs[0] = 1;
active.exiting = 0;
}
void
init0(void)
{
- int i;
- char buf[2*KNAMELEN];
-
- up->nerrlab = 0;
-
- spllo();
-
- /*
- * These are o.k. because rootinit is null.
- * Then early kproc's will have a root and dot.
- */
- up->slash = namec("#/", Atodir, 0, 0);
- pathclose(up->slash->path);
- up->slash->path = newpath("/");
- up->dot = cclone(up->slash);
+ char buf[2*KNAMELEN], **sp;
chandevinit();
ksetenv("service", "cpu", 0);
else
ksetenv("service", "terminal", 0);
- for(i = 0; i < nconf; i++){
- if(confname[i][0] != '*')
- ksetenv(confname[i], confval[i], 0);
- ksetenv(confname[i], confval[i], 1);
- }
+ setconfenv();
poperror();
}
kproc("alarm", alarmkproc, 0);
- touser(sp);
-}
-
-void
-userinit(void)
-{
- void *v;
- Proc *p;
- Segment *s;
- Page *pg;
-
- p = newproc();
- p->pgrp = newpgrp();
- p->egrp = smalloc(sizeof(Egrp));
- p->egrp->ref = 1;
- p->fgrp = dupfgrp(nil);
- p->rgrp = newrgrp();
- p->procmode = 0640;
-
- kstrdup(&eve, "");
- kstrdup(&p->text, "*init*");
- kstrdup(&p->user, eve);
-
- procsetup(p);
-
- /*
- * Kernel Stack
- *
- * N.B. make sure there's enough space for syscall to check
- * for valid args and
- * 4 bytes for gotolabel's return PC
- */
- p->sched.pc = (ulong)init0;
- p->sched.sp = (ulong)p->kstack+KSTACK-(sizeof(Sargs)+BY2WD);
-
- /*
- * User Stack
- *
- * N.B. cannot call newpage() with clear=1, because pc kmap
- * requires up != nil. use tmpmap instead.
- */
- s = newseg(SG_STACK, USTKTOP-USTKSIZE, USTKSIZE/BY2PG);
- p->seg[SSEG] = s;
- pg = newpage(0, 0, USTKTOP-BY2PG);
- v = tmpmap(pg);
- memset(v, 0, BY2PG);
- segpage(s, pg);
- bootargs(v);
- tmpunmap(v);
-
- /*
- * Text
- */
- s = newseg(SG_TEXT, UTZERO, 1);
- s->flushme++;
- p->seg[TSEG] = s;
- pg = newpage(0, 0, UTZERO);
- memset(pg->cachectl, PG_TXTFLUSH, sizeof(pg->cachectl));
- segpage(s, pg);
- v = tmpmap(pg);
- memset(v, 0, BY2PG);
- memmove(v, initcode, sizeof initcode);
- tmpunmap(v);
-
- ready(p);
-}
-
-uchar *
-pusharg(char *p)
-{
- int n;
-
- n = strlen(p)+1;
- sp -= n;
- memmove(sp, p, n);
- return sp;
-}
-
-void
-bootargs(void *base)
-{
- int i, ac;
- uchar *av[32];
- uchar **lsp;
- char *cp = BOOTLINE;
- char buf[64];
-
- sp = (uchar*)base + BY2PG - sizeof(Tos);
-
- ac = 0;
- av[ac++] = pusharg("boot");
-
- /* when boot is changed to only use rc, this code can go away */
- cp[BOOTLINELEN-1] = 0;
- buf[0] = 0;
- if(strncmp(cp, "fd", 2) == 0){
- sprint(buf, "local!#f/fd%lddisk", strtol(cp+2, 0, 0));
- av[ac++] = pusharg(buf);
- } else if(strncmp(cp, "sd", 2) == 0){
- sprint(buf, "local!#S/sd%c%c/fs", *(cp+2), *(cp+3));
- av[ac++] = pusharg(buf);
- } else if(strncmp(cp, "ether", 5) == 0)
- av[ac++] = pusharg("-n");
-
- /* 4 byte word align stack */
- sp = (uchar*)((ulong)sp & ~3);
-
- /* build argc, argv on stack */
- sp -= (ac+1)*sizeof(sp);
- lsp = (uchar**)sp;
- for(i = 0; i < ac; i++)
- lsp[i] = av[i] + ((USTKTOP - BY2PG) - (ulong)base);
- lsp[i] = 0;
- sp += (USTKTOP - BY2PG) - (ulong)base;
- sp -= BY2WD;
-}
-
-char*
-getconf(char *name)
-{
- int i;
-
- for(i = 0; i < nconf; i++)
- if(cistrcmp(confname[i], name) == 0)
- return confval[i];
- return 0;
-}
-
-static void
-writeconf(void)
-{
- char *p, *q;
- int n;
-
- p = getconfenv();
-
- if(waserror()) {
- free(p);
- nexterror();
- }
- /* convert to name=value\n format */
- for(q=p; *q; q++) {
- q += strlen(q);
- *q = '=';
- q += strlen(q);
- *q = '\n';
- }
- n = q - p + 1;
- if(n >= BOOTARGSLEN)
- error("kernel configuration too large");
- memset(BOOTLINE, 0, BOOTLINELEN);
- memmove(BOOTARGS, p, n);
- poperror();
- free(p);
+ sp = (char**)(USTKTOP - sizeof(Tos) - 8 - sizeof(sp[0])*4);
+ sp[3] = sp[2] = nil;
+ strcpy(sp[1] = (char*)&sp[4], "boot");
+ sp[0] = nil;
+ touser(sp);
}
void
int i, userpcnt;
ulong kpages;
+ if(p = getconf("service")){
+ if(strcmp(p, "cpu") == 0)
+ cpuserver = 1;
+ else if(strcmp(p,"terminal") == 0)
+ cpuserver = 0;
+ }
+
if(p = getconf("*kernelpercent"))
userpcnt = 100 - strtol(p, 0, 0);
else
if(userpcnt < 10)
userpcnt = 70;
kpages = conf.npage - (conf.npage*userpcnt)/100;
+ conf.nimage = conf.nproc;
/*
* Hack for the big boys. Only good while physmem < 4GB.
* The patch of nimage is a band-aid, scanning the whole
* page list in imagereclaim just takes too long.
*/
+ if(getconf("*imagemaxmb") == 0)
if(kpages > (64*MB + conf.npage*sizeof(Page))/BY2PG){
kpages = (64*MB + conf.npage*sizeof(Page))/BY2PG;
- conf.nimage = 2000;
kpages += (conf.nproc*KSTACK)/BY2PG;
}
} else {
/*
* Guess how much is taken by the large permanent
- * datastructures. Mntcache and Mntrpc are not accounted for
- * (probably ~300KB).
+ * datastructures. Mntcache and Mntrpc are not accounted for.
*/
kpages *= BY2PG;
kpages -= conf.upages*sizeof(Page)
* the dynamic allocation will balance the load properly,
* hopefully. be careful with 32-bit overflow.
*/
- imagmem->maxsize = mainmem->maxsize;
+ imagmem->maxsize = kpages - (kpages/10);
if(p = getconf("*imagemaxmb")){
imagmem->maxsize = strtol(p, nil, 0)*MB;
if(imagmem->maxsize > mainmem->maxsize)
}
}
+/*
+ * we keep FPsave structure in SSE format emulating FXSAVE / FXRSTOR
+ * instructions for legacy x87 fpu.
+ */
+void
+fpx87save(FPsave *fps)
+{
+ ushort tag;
+
+ fpx87save0(fps);
+
+ /*
+ * convert x87 tag word to fxsave tag byte:
+ * 00, 01, 10 -> 1, 11 -> 0
+ */
+ tag = ~fps->tag;
+ tag = (tag | (tag >> 1)) & 0x5555;
+ tag = (tag | (tag >> 1)) & 0x3333;
+ tag = (tag | (tag >> 2)) & 0x0F0F;
+ tag = (tag | (tag >> 4)) & 0x00FF;
+
+ /* NOP fps->fcw = fps->control; */
+ fps->fsw = fps->status;
+ fps->ftw = tag;
+ fps->fop = fps->opcode;
+ fps->fpuip = fps->pc;
+ fps->cs = fps->selector;
+ fps->fpudp = fps->operand;
+ fps->ds = fps->oselector;
+
+#define MOVA(d,s) \
+ *((ushort*)(d+8)) = *((ushort*)(s+8)), \
+ *((ulong*)(d+4)) = *((ulong*)(s+4)), \
+ *((ulong*)(d)) = *((ulong*)(s))
+
+ MOVA(fps->xregs+0x70, fps->regs+70);
+ MOVA(fps->xregs+0x60, fps->regs+60);
+ MOVA(fps->xregs+0x50, fps->regs+50);
+ MOVA(fps->xregs+0x40, fps->regs+40);
+ MOVA(fps->xregs+0x30, fps->regs+30);
+ MOVA(fps->xregs+0x20, fps->regs+20);
+ MOVA(fps->xregs+0x10, fps->regs+10);
+ MOVA(fps->xregs+0x00, fps->regs+00);
+
+#undef MOVA
+
+#define CLR6(d) \
+ *((ulong*)(d)) = 0, \
+ *((ushort*)(d+4)) = 0
+
+ CLR6(fps->xregs+0x70+10);
+ CLR6(fps->xregs+0x60+10);
+ CLR6(fps->xregs+0x50+10);
+ CLR6(fps->xregs+0x40+10);
+ CLR6(fps->xregs+0x30+10);
+ CLR6(fps->xregs+0x20+10);
+ CLR6(fps->xregs+0x10+10);
+ CLR6(fps->xregs+0x00+10);
+
+#undef CLR6
+
+ fps->rsrvd1 = fps->rsrvd2 = fps->mxcsr = fps->mxcsr_mask = 0;
+}
+
+void
+fpx87restore(FPsave *fps)
+{
+ ushort msk, tos, tag, *reg;
+
+ /* convert fxsave tag byte to x87 tag word */
+ tag = 0;
+ tos = 7 - ((fps->fsw >> 11) & 7);
+ for(msk = 0x80; msk != 0; tos--, msk >>= 1){
+ tag <<= 2;
+ if((fps->ftw & msk) != 0){
+ reg = (ushort*)&fps->xregs[(tos & 7) << 4];
+ switch(reg[4] & 0x7fff){
+ case 0x0000:
+ if((reg[0] | reg[1] | reg[2] | reg[3]) == 0){
+ tag |= 1; /* 01 zero */
+ break;
+ }
+ /* no break */
+ case 0x7fff:
+ tag |= 2; /* 10 special */
+ break;
+ default:
+ if((reg[3] & 0x8000) == 0)
+ break; /* 00 valid */
+ tag |= 2; /* 10 special */
+ break;
+ }
+ }else{
+ tag |= 3; /* 11 empty */
+ }
+ }
+
+#define MOVA(d,s) \
+ *((ulong*)(d)) = *((ulong*)(s)), \
+ *((ulong*)(d+4)) = *((ulong*)(s+4)), \
+ *((ushort*)(d+8)) = *((ushort*)(s+8))
+
+ MOVA(fps->regs+00, fps->xregs+0x00);
+ MOVA(fps->regs+10, fps->xregs+0x10);
+ MOVA(fps->regs+20, fps->xregs+0x20);
+ MOVA(fps->regs+30, fps->xregs+0x30);
+ MOVA(fps->regs+40, fps->xregs+0x40);
+ MOVA(fps->regs+50, fps->xregs+0x50);
+ MOVA(fps->regs+60, fps->xregs+0x60);
+ MOVA(fps->regs+70, fps->xregs+0x70);
+
+#undef MOVA
+
+ fps->oselector = fps->ds;
+ fps->operand = fps->fpudp;
+ fps->opcode = fps->fop & 0x7ff;
+ fps->selector = fps->cs;
+ fps->pc = fps->fpuip;
+ fps->tag = tag;
+ fps->status = fps->fsw;
+ /* NOP fps->control = fps->fcw; */
+
+ fps->r1 = fps->r2 = fps->r3 = fps->r4 = 0;
+
+ fpx87restore0(fps);
+}
+
static char* mathmsg[] =
{
nil, /* handled below */
};
static void
-mathnote(void)
+mathnote(ulong status, ulong pc)
{
- int i;
- ulong status;
char *msg, note[ERRMAX];
-
- status = up->fpsave.status;
+ int i;
/*
* Some attention should probably be paid here to the
msg = "invalid operation";
}
snprint(note, sizeof note, "sys: fp: %s fppc=0x%lux status=0x%lux",
- msg, up->fpsave.pc, status);
+ msg, pc, status);
postnote(up, 1, note, NDebug);
}
* math coprocessor error
*/
static void
-matherror(Ureg *ur, void*)
+matherror(Ureg*, void*)
{
/*
* a write cycle to port 0xF0 clears the interrupt latch attached
* to the error# line from the 387
*/
- if(!(m->cpuiddx & 0x01))
+ if(!(m->cpuiddx & Fpuonchip))
outb(0xF0, 0xFF);
/*
- * save floating point state to check out error
+ * get floating point state to check out error
*/
- fpenv(&up->fpsave);
- mathnote();
+ fpsave(up->fpsave);
+ up->fpstate = FPinactive;
+ mathnote(up->fpsave->fsw, up->fpsave->fpuip);
+}
- if((ur->pc & 0xf0000000) == KZERO)
- panic("fp: status %ux fppc=0x%lux pc=0x%lux",
- up->fpsave.status, up->fpsave.pc, ur->pc);
+/*
+ * SIMD error
+ */
+static void
+simderror(Ureg *ureg, void*)
+{
+ fpsave(up->fpsave);
+ up->fpstate = FPinactive;
+ mathnote(up->fpsave->mxcsr & 0x3f, ureg->pc);
}
/*
static void
mathemu(Ureg *ureg, void*)
{
+ ulong status, control;
+
if(up->fpstate & FPillegal){
/* someone did floating point in a note handler */
postnote(up, 1, "sys: floating point in note handler", NDebug);
switch(up->fpstate){
case FPinit:
fpinit();
+ if(fpsave == fpssesave)
+ ldmxcsr(0x1f80); /* no simd exceptions on 386 */
+ while(up->fpsave == nil)
+ up->fpsave = mallocalign(sizeof(FPsave), FPalign, 0, 0);
up->fpstate = FPactive;
break;
case FPinactive:
* More attention should probably be paid here to the
* exception masks and error summary.
*/
- if((up->fpsave.status & ~up->fpsave.control) & 0x07F){
- mathnote();
+ status = up->fpsave->fsw;
+ control = up->fpsave->fcw;
+ if((status & ~control) & 0x07F){
+ mathnote(status, up->fpsave->fpuip);
break;
}
- fprestore(&up->fpsave);
+ fprestore(up->fpsave);
up->fpstate = FPactive;
break;
case FPactive:
mathinit(void)
{
trapenable(VectorCERR, matherror, 0, "matherror");
- if(X86FAMILY(m->cpuidax) == 3)
+ if(m->cpuidfamily == 3)
intrenable(IrqIRQ13, matherror, 0, BUSUNKNOWN, "matherror");
trapenable(VectorCNA, mathemu, 0, "mathemu");
trapenable(VectorCSO, mathover, 0, "mathover");
+ trapenable(VectorSIMD, simderror, 0, "simderror");
}
/*
p->fpstate = FPinit;
fpoff();
- cycles(&p->kentry);
- p->pcycles = -p->kentry;
-
memset(p->gdt, 0, sizeof(p->gdt));
- p->ldt = nil;
p->nldt = 0;
+
+ /* clear debug registers */
+ memset(p->dr, 0, sizeof(p->dr));
+ if(m->dr7 != 0){
+ m->dr7 = 0;
+ putdr7(0);
+ }
+
+ cycles(&p->kentry);
+ p->pcycles = -p->kentry;
}
void
procfork(Proc *p)
{
+ int s;
+
p->kentry = up->kentry;
p->pcycles = -p->kentry;
memmove(p->ldt, up->ldt, sizeof(Segdesc) * up->nldt);
p->nldt = up->nldt;
}
+
+ /* save floating point state */
+ s = splhi();
+ switch(up->fpstate & ~FPillegal){
+ case FPactive:
+ fpsave(up->fpsave);
+ up->fpstate = FPinactive;
+ case FPinactive:
+ while(p->fpsave == nil)
+ p->fpsave = mallocalign(sizeof(FPsave), FPalign, 0, 0);
+ memmove(p->fpsave, up->fpsave, sizeof(FPsave));
+ p->fpstate = FPinactive;
+ }
+ splx(s);
}
void
procrestore(Proc *p)
{
uvlong t;
+
+ if(p->dr[7] != 0){
+ m->dr7 = p->dr[7];
+ putdr(p->dr);
+ }
+
+ if(p->vmx != nil)
+ vmxprocrestore(p);
if(p->kp)
return;
procsave(Proc *p)
{
uvlong t;
-
+
cycles(&t);
p->kentry -= t;
p->pcycles += t;
+ /* we could just always putdr7(0) but accessing DR7 might be slow in a VM */
+ if(m->dr7 != 0){
+ m->dr7 = 0;
+ putdr7(0);
+ }
+ if(p->state == Moribund)
+ p->dr[7] = 0;
+
if(p->fpstate == FPactive){
if(p->state == Moribund)
fpclear();
* until the process runs again and generates an
* emulation fault to activate the FPU.
*/
- fpsave(&p->fpsave);
+ fpsave(p->fpsave);
}
p->fpstate = FPinactive;
}
}
static void
-shutdown(int ispanic)
+rebootjump(uintptr entry, uintptr code, ulong size)
{
- int ms, once;
-
- lock(&active);
- if(ispanic)
- active.ispanic = ispanic;
- else if(m->machno == 0 && (active.machs & (1<<m->machno)) == 0)
- active.ispanic = 0;
- once = active.machs & (1<<m->machno);
- /*
- * setting exiting will make hzclock() on each processor call exit(0),
- * which calls shutdown(0) and arch->reset(), which on mp systems is
- * mpshutdown, from which there is no return: the processor is idled
- * or initiates a reboot. clearing our bit in machs avoids calling
- * exit(0) from hzclock() on this processor.
- */
- active.machs &= ~(1<<m->machno);
- active.exiting = 1;
- unlock(&active);
-
- if(once)
- iprint("cpu%d: exiting\n", m->machno);
-
- /* wait for any other processors to shutdown */
- spllo();
- for(ms = 5*1000; ms > 0; ms -= TK2MS(2)){
- delay(TK2MS(2));
- if(active.machs == 0 && consactive() == 0)
- break;
- }
-
- if(active.ispanic){
- if(!cpuserver)
- for(;;)
- halt();
- if(getconf("*debug"))
- delay(5*60*1000);
- else
- delay(10000);
- }else
- delay(1000);
-}
-
-void
-reboot(void *entry, void *code, ulong size)
-{
- void (*f)(ulong, ulong, ulong);
+ void (*f)(uintptr, uintptr, ulong);
ulong *pdb;
- writeconf();
-
- /*
- * the boot processor is cpu0. execute this function on it
- * so that the new kernel has the same cpu0. this only matters
- * because the hardware has a notion of which processor was the
- * boot processor and we look at it at start up.
- */
- if (m->machno != 0) {
- procwired(up, 0);
- sched();
- }
-
- shutdown(0);
-
- /*
- * should be the only processor running now
- */
- if (m->machno != 0)
- print("on cpu%d (not 0)!\n", m->machno);
- if (active.machs)
- print("still have active ap processors!\n");
-
- print("shutting down...\n");
- delay(200);
-
splhi();
-
- /* turn off buffered serial console */
- serialoq = nil;
-
- /* shutdown devices */
- chandevshutdown();
arch->introff();
/*
f = (void*)REBOOTADDR;
memmove(f, rebootcode, sizeof(rebootcode));
- print("rebooting...\n");
-
/* off we go - never to return */
coherence();
- (*f)(PADDR(entry), PADDR(code), size);
+ (*f)(entry, code, size);
+ for(;;);
}
void
-exit(int ispanic)
+exit(int)
{
- shutdown(ispanic);
+ cpushutdown();
+ if(m->machno)
+ rebootjump(0, 0, 0);
arch->reset();
}
-int
-isaconfig(char *class, int ctlrno, ISAConf *isa)
-{
- char cc[32], *p;
- int i;
-
- snprint(cc, sizeof cc, "%s%d", class, ctlrno);
- p = getconf(cc);
- if(p == nil)
- return 0;
-
- isa->type = "";
- isa->nopt = tokenize(p, isa->opt, NISAOPT);
- for(i = 0; i < isa->nopt; i++){
- p = isa->opt[i];
- if(cistrncmp(p, "type=", 5) == 0)
- isa->type = p + 5;
- else if(cistrncmp(p, "port=", 5) == 0)
- isa->port = strtoul(p+5, &p, 0);
- else if(cistrncmp(p, "irq=", 4) == 0)
- isa->irq = strtoul(p+4, &p, 0);
- else if(cistrncmp(p, "dma=", 4) == 0)
- isa->dma = strtoul(p+4, &p, 0);
- else if(cistrncmp(p, "mem=", 4) == 0)
- isa->mem = strtoul(p+4, &p, 0);
- else if(cistrncmp(p, "size=", 5) == 0)
- isa->size = strtoul(p+5, &p, 0);
- else if(cistrncmp(p, "freq=", 5) == 0)
- isa->freq = strtoul(p+5, &p, 0);
- }
- return 1;
-}
-
-int
-cistrcmp(char *a, char *b)
+void
+reboot(void *entry, void *code, ulong size)
{
- int ac, bc;
-
- for(;;){
- ac = *a++;
- bc = *b++;
-
- if(ac >= 'A' && ac <= 'Z')
- ac = 'a' + (ac - 'A');
- if(bc >= 'A' && bc <= 'Z')
- bc = 'a' + (bc - 'A');
- ac -= bc;
- if(ac)
- return ac;
- if(bc == 0)
- break;
- }
- return 0;
-}
+ writeconf();
+ vmxshutdown();
-int
-cistrncmp(char *a, char *b, int n)
-{
- unsigned ac, bc;
-
- while(n > 0){
- ac = *a++;
- bc = *b++;
- n--;
-
- if(ac >= 'A' && ac <= 'Z')
- ac = 'a' + (ac - 'A');
- if(bc >= 'A' && bc <= 'Z')
- bc = 'a' + (bc - 'A');
-
- ac -= bc;
- if(ac)
- return ac;
- if(bc == 0)
- break;
+ /*
+ * the boot processor is cpu0. execute this function on it
+ * so that the new kernel has the same cpu0. this only matters
+ * because the hardware has a notion of which processor was the
+ * boot processor and we look at it at start up.
+ */
+ if (m->machno != 0) {
+ procwired(up, 0);
+ sched();
}
+ cpushutdown();
+ delay(1000);
+ splhi();
- return 0;
-}
+ /* turn off buffered serial console */
+ serialoq = nil;
-/*
- * put the processor in the halt state if we've no processes to run.
- * an interrupt will get us going again.
- */
-void
-idlehands(void)
-{
- extern int nrdy;
+ /* shutdown devices */
+ chandevshutdown();
- if(conf.nmach == 1)
- halt();
- else if(m->cpuidcx & Monitor)
- mwait(&nrdy);
+ rebootjump((ulong)entry & ~0xF0000000UL, PADDR(code), size);
}