long _syspipe(int fd[2]) { Chan *c[2]; Dev *d; static char *datastr[] = {"data", "data1"}; d = devtab[devno('|', 0)]; c[0] = namec("#|", Atodir, 0, 0); c[1] = 0; fd[0] = -1; fd[1] = -1; if(waserror()){ cclose(c[0]); if(c[1]) cclose(c[1]); nexterror(); } c[1] = cclone(c[0]); if(walk(&c[0], datastr+0, 1, 1, nil) < 0) error(Egreg); if(walk(&c[1], datastr+1, 1, 1, nil) < 0) error(Egreg); c[0] = d->open(c[0], ORDWR); c[1] = d->open(c[1], ORDWR); if(newfd2(fd, c) < 0) error(Enofd); poperror(); return 0; }
void init0(void) { Osenv *o; up->nerrlab = 0; print("before spllo"); spllo(); print("Sun Sparc %s\n", sparam->name); print("bank 0: %ldM 1: %ldM\n", bank[0], bank[1]); print("frame buffer id %lux slot %ld %s\n",conf.monitor,fbslot,fbstr); if(waserror()) panic("init0"); /* * These are o.k. because rootinit is null. * Then early kproc's will have a root and dot. */ o = up->env; o->pgrp->slash = namec("#/", Atodir, 0, 0); cnameclose(o->pgrp->slash->name); o->pgrp->slash->name = newcname("/"); o->pgrp->dot = cclone(o->pgrp->slash); chandevinit(); poperror(); disinit("/osinit.dis"); }
/* * starting place for first process */ void init0(void) { 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); chandevinit(); if(!waserror()){ ksetenv("terminal", "bitsy", 0); ksetenv("cputype", "arm", 0); if(cpuserver) ksetenv("service", "cpu", 0); else ksetenv("service", "terminal", 0); poperror(); } kproc("alarm", alarmkproc, 0); kproc("power", powerkproc, 0); touser(sp); }
void init0(void) { // char **p, *q, name[KNAMELEN]; // int n; 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); chandevinit(); if(!waserror()){ snprint(buf, sizeof(buf), "power %s mtx", conffile); ksetenv("terminal", buf, 0); ksetenv("cputype", "power", 0); if(cpuserver) ksetenv("service", "cpu", 0); else ksetenv("service", "terminal", 0); /* for(p = confenv; *p; p++) { q = strchr(p[0], '='); if(q == 0) continue; n = q-p[0]; if(n >= KNAMELEN) n = KNAMELEN-1; memmove(name, p[0], n); name[n] = 0; if(name[0] != '*') ksetenv(name, q+1, 0); ksetenv(name, q+1, 1); } */ poperror(); } kproc("alarm", alarmkproc, 0); kproc("mmusweep", mmusweep, 0); touser((void*)(USTKTOP-8)); }
int syspipe(int fd[2]) { ERRSTACK(1); struct dev *d; struct chan *c[2]; static char *names[] = { "data", "data1" }; d = &devtab[devno("pipe", 0)]; c[0] = 0; c[1] = 0; fd[0] = -1; fd[1] = -1; if (waserror()) { /* need to remove from the fd table and make sure the chan is closed * exactly once. if fd[i] >= 0, then the fd is valid (or it was!) and * the fd table has the only ref (newfd() currently decrefs/consumes the * reference). cclose() doesn't care if you pass it 0 (like kfree()). */ if (fd[0] >= 0) close_fd(¤t->open_files, fd[0]); else cclose(c[0]); if (fd[1] >= 0) close_fd(¤t->open_files, fd[1]); else cclose(c[1]); poperror(); return -1; } c[0] = namec("#pipe", Atodir, 0, 0); c[1] = cclone(c[0]); if (walk(&c[0], &names[0], 1, FALSE, NULL) < 0) error(EINVAL, ERROR_FIXME); if (walk(&c[1], &names[1], 1, FALSE, NULL) < 0) error(EINVAL, ERROR_FIXME); c[0] = d->open(c[0], O_RDWR); c[1] = d->open(c[1], O_RDWR); fd[0] = newfd(c[0], 0); if (fd[0] < 0) error(-fd[0], ERROR_FIXME); fd[1] = newfd(c[1], 0); if (fd[1] < 0) error(-fd[1], ERROR_FIXME); poperror(); return 0; }
static int32_t unionread(Chan *c, void *va, int32_t n) { Proc *up = externup(); int i; int32_t nr; Mhead *mh; Mount *mount; qlock(&c->umqlock); mh = c->umh; rlock(&mh->lock); mount = mh->mount; /* bring mount in sync with c->uri and c->umc */ for(i = 0; mount != nil && i < c->uri; i++) mount = mount->next; nr = 0; while(mount != nil){ /* Error causes component of union to be skipped */ if(mount->to && !waserror()){ if(c->umc == nil){ c->umc = cclone(mount->to); c->umc = c->umc->dev->open(c->umc, OREAD); } nr = c->umc->dev->read(c->umc, va, n, c->umc->offset); c->umc->offset += nr; poperror(); } if(nr > 0) break; /* Advance to next element */ c->uri++; if(c->umc){ cclose(c->umc); c->umc = nil; } mount = mount->next; } runlock(&mh->lock); qunlock(&c->umqlock); return nr; }
void syspipe(Ar0* ar0, ...) { Proc *up = externup(); int *a, fd[2]; Chan *c[2]; static char *datastr[] = {"data", "data1"}; va_list list; va_start(list, ar0); /* * int pipe(int fd[2]); */ a = va_arg(list, int*); va_end(list); a = validaddr(a, sizeof(fd), 1); evenaddr(PTR2UINT(a)); c[0] = namec("#|", Atodir, 0, 0); c[1] = nil; fd[0] = -1; fd[1] = -1; if(waserror()){ cclose(c[0]); if(c[1]) cclose(c[1]); nexterror(); } c[1] = cclone(c[0]); if(walk(&c[0], datastr+0, 1, 1, nil) < 0) error(Egreg); if(walk(&c[1], datastr+1, 1, 1, nil) < 0) error(Egreg); c[0] = c[0]->dev->open(c[0], ORDWR); c[1] = c[1]->dev->open(c[1], ORDWR); if(newfd2(fd, c) < 0) error(Enofd); poperror(); a[0] = fd[0]; a[1] = fd[1]; ar0->i = 0; }
/* * starting place for first process */ void init0(void) { int i; char buf[2*KNAMELEN]; up->nerrlab = 0; coherence(); 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); chandevinit(); if(!waserror()){ snprint(buf, sizeof(buf), "%s %s", "ARM", conffile); ksetenv("terminal", buf, 0); ksetenv("cputype", "arm", 0); if(cpuserver) ksetenv("service", "cpu", 0); else ksetenv("service", "terminal", 0); snprint(buf, sizeof(buf), "-a %s", getethermac()); ksetenv("etherargs", buf, 0); /* convert plan9.ini variables to #e and #ec */ for(i = 0; i < nconf; i++) { ksetenv(confname[i], confval[i], 0); ksetenv(confname[i], confval[i], 1); } poperror(); } kproc("alarm", alarmkproc, 0); touser(sp); assert(0); /* shouldn't have returned */ }
void init0(void) { Osenv *o; int i; char buf[2*KNAMELEN]; up->nerrlab = 0; spllo(); if(waserror()) panic("init0"); /* * These are o.k. because rootinit is null. * Then early kproc's will have a root and dot. */ o = up->env; o->pgrp->slash = namec("#/", Atodir, 0, 0); cnameclose(o->pgrp->slash->name); o->pgrp->slash->name = newcname("/"); o->pgrp->dot = cclone(o->pgrp->slash); chandevinit(); if(!waserror()){ ksetenv("cputype", "power", 0); snprint(buf, sizeof(buf), "power %s", conffile); ksetenv("terminal", buf, 0); poperror(); } for(i = 0; i < nconf; i++) if(confname[i][0] != '*'){ if(!waserror()){ ksetenv(confname[i], confval[i], 0); poperror(); } } poperror(); disinit("/osinit.dis"); }
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); chandevinit(); if(0 && !waserror()){ /* not needed by boot */ snprint(buf, sizeof(buf), "%s %s", arch->id, conffile); ksetenv("terminal", buf, 0); ksetenv("cputype", "386", 0); if(cpuserver) 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); } poperror(); } kproc("alarm", alarmkproc, 0); conschan = enamecopen("#c/cons", ORDWR); bootloadproc(0); panic("bootloadproc returned"); }
void init0(void) { // char **p, *q, name[KNAMELEN]; 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); chandevinit(); if(!waserror()){ snprint(buf, sizeof(buf), "power %s mtx", conffile); ksetenv("terminal", buf, 0); ksetenv("cputype", "power", 0); if(cpuserver) ksetenv("service", "cpu", 0); else ksetenv("service", "terminal", 0); for(i = 0; i < nconf; i++){ if(plan9ini[i].name[0] != '*') ksetenv(plan9ini[i].name, plan9ini[i].val, 0); ksetenv(plan9ini[i].name, plan9ini[i].val, 1); } poperror(); } kproc("alarm", alarmkproc, 0); kproc("mmusweep", mmusweep, 0); touser((void*)(USTKTOP-sizeof(Tos))); }
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); chandevinit(); if(!waserror()){ snprint(buf, sizeof(buf), "alpha %s alphapc", conffile); ksetenv("terminal", buf, 0); ksetenv("cputype", "alpha", 0); if(cpuserver) ksetenv("service", "cpu", 0); else ksetenv("service", "terminal", 0); for(i = 0; i < nconf; i++) if(confname[i]){ if(confname[i][0] != '*') ksetenv(confname[i], confval[i], 0); ksetenv(confname[i], confval[i], 1); } poperror(); } kproc("alarm", alarmkproc, 0); touser((uchar*)(USTKTOP - sizeof(argbuf))); }
void init0(void) { Mach *m = machp(); char buf[2*KNAMELEN]; m->externup->nerrlab = 0; /* * if(consuart == nil) * i8250console("0"); */ spllo(); /* * These are o.k. because rootinit is null. * Then early kproc's will have a root and dot. */ m->externup->slash = namec("#/", Atodir, 0, 0); pathclose(m->externup->slash->path); m->externup->slash->path = newpath("/"); m->externup->dot = cclone(m->externup->slash); devtabinit(); if(!waserror()){ snprint(buf, sizeof(buf), "%s %s", "AMD64", conffile); ksetenv("terminal", buf, 0); ksetenv("cputype", cputype, 0); if(cpuserver) ksetenv("service", "cpu", 0); else ksetenv("service", "terminal", 0); ksetenv("pgsz", "2097152", 0); // no longer. confsetenv(); poperror(); } kproc("alarm", alarmkproc, 0); //debugtouser((void *)UTZERO); touser(sp); }
long syspipe(uint32 *arg) { int fd[2]; Chan *c[2]; Dev *d; static char *datastr[] = {"data", "data1"}; int *ufd; ufd = uvalidaddr(arg[0], 2*BY2WD, 1); evenaddr(arg[0]); d = devtab[devno('|', 0)]; c[0] = namec("#|", Atodir, 0, 0); c[1] = 0; fd[0] = -1; fd[1] = -1; if(waserror()){ cclose(c[0]); if(c[1]) cclose(c[1]); nexterror(); } c[1] = cclone(c[0]); if(walk(&c[0], datastr+0, 1, 1, nil) < 0) error(Egreg); if(walk(&c[1], datastr+1, 1, 1, nil) < 0) error(Egreg); c[0] = d->open(c[0], ORDWR); c[1] = d->open(c[1], ORDWR); if(newfd2(fd, c) < 0) error(Enofd); poperror(); ufd[0] = fd[0]; ufd[1] = fd[1]; return 0; }
void init0(void) { Osenv *o; char buf[2*KNAMELEN]; up->nerrlab = 0; //print("Starting init0()\n"); spllo(); if(waserror()) panic("init0 %r"); /* These are o.k. because rootinit is null. * Then early kproc's will have a root and dot. */ o = up->env; o->pgrp->slash = namec("#/", Atodir, 0, 0); cnameclose(o->pgrp->slash->name); o->pgrp->slash->name = newcname("/"); o->pgrp->dot = cclone(o->pgrp->slash); chandevinit(); if(!waserror()){ ksetenv("cputype", "arm", 0); snprint(buf, sizeof(buf), "arm %s", conffile); ksetenv("terminal", buf, 0); snprint(buf, sizeof(buf), "%s", getethermac()); ksetenv("ethermac", buf, 0); poperror(); } poperror(); disinit("/osinit.dis"); }
long syspipe(ulong *arg) { int fd[2]; Chan *c[2]; Dev *d; static char *datastr[] = {"data", "data1"}; validaddr(arg[0], sizeof(fd), 1); validalign(arg[0], sizeof(int)); d = devtab[devno('|', 0)]; c[0] = namec("#|", Atodir, 0, 0); c[1] = 0; fd[0] = -1; fd[1] = -1; if(waserror()){ cclose(c[0]); if(c[1]) cclose(c[1]); nexterror(); } c[1] = cclone(c[0]); if(walk(&c[0], datastr+0, 1, 1, nil) < 0) error(Egreg); if(walk(&c[1], datastr+1, 1, 1, nil) < 0) error(Egreg); c[0] = d->open(c[0], ORDWR); c[1] = d->open(c[1], ORDWR); if(newfd2(fd, c) < 0) error(Enofd); poperror(); ((int*)arg[0])[0] = fd[0]; ((int*)arg[0])[1] = fd[1]; return 0; }
void emuinit(void *imod) { Osenv *e; char *wdir; e = up->env; e->pgrp = newpgrp(); e->fgrp = newfgrp(nil); e->egrp = newegrp(); e->errstr = e->errbuf0; e->syserrstr = e->errbuf1; e->user = strdup(""); links(); chandevinit(); if(waserror()) panic("setting root and dot"); e->pgrp->slash = namec("#/", Atodir, 0, 0); cnameclose(e->pgrp->slash->name); e->pgrp->slash->name = newcname("/"); e->pgrp->dot = cclone(e->pgrp->slash); poperror(); strcpy(up->text, "main"); if(kopen("#c/cons", OREAD) != 0) fprint(2, "failed to make fd0 from #c/cons: %r\n"); kopen("#c/cons", OWRITE); kopen("#c/cons", OWRITE); /* the setid cannot precede the bind of #U */ kbind("#U", "/", MAFTER|MCREATE); setid(eve, 0); kbind("#^", "/dev", MBEFORE); /* snarf */ kbind("#^", "/chan", MBEFORE); kbind("#m", "/dev", MBEFORE); /* pointer */ kbind("#c", "/dev", MBEFORE); kbind("#p", "/prog", MREPL); kbind("#d", "/fd", MREPL); kbind("#I", "/net", MAFTER); /* will fail on Plan 9 */ /* BUG: we actually only need to do these on Plan 9 */ kbind("#U/dev", "/dev", MAFTER); kbind("#U/net", "/net", MAFTER); kbind("#U/net.alt", "/net.alt", MAFTER); if(cputype != nil) ksetenv("cputype", cputype, 1); putenvqv("emuargs", rebootargv, rebootargc, 1); putenvq("emuroot", rootdir, 1); ksetenv("emuhost", hosttype, 1); wdir = malloc(1024); if(wdir != nil){ if(getwd(wdir, 1024) != nil) putenvq("emuwdir", wdir, 1); free(wdir); } kproc("main", disinit, imod, KPDUPFDG|KPDUPPG|KPDUPENVG); for(;;) ospause(); }
void init0(void) { int i; char buf[2*KNAMELEN]; assert(up != nil); up->nerrlab = 0; barriers(); intrack(~0); clrmchk(); barriers(); 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); dmainit(); /* starts dma kprocs */ devtabinit(); if(!waserror()){ snprint(buf, sizeof(buf), "power %s", conffile); ksetenv("terminal", buf, 0); ksetenv("cputype", "power", 0); if(cpuserver) ksetenv("service", "cpu", 0); else ksetenv("service", "terminal", 0); /* virtex configuration */ ksetenv("nvram", "/boot/nvram", 0); ksetenv("nvroff", "0", 0); ksetenv("nvrlen", "512", 0); ksetenv("nobootprompt", "tcp", 0); poperror(); } for(i = 0; i < nconf; i++){ if(confval[i] == nil) continue; if(confname[i][0] != '*'){ if(!waserror()){ ksetenv(confname[i], confval[i], 0); poperror(); } } if(!waserror()){ ksetenv(confname[i], confval[i], 1); poperror(); } } kproc("alarm", alarmkproc, 0); if (securemem) kproc("mutate", mutateproc, 0); else print("no secure memory found\n"); /* * The initial value of the user stack must be such * that the total used is larger than the maximum size * of the argument list checked in syscall. */ sync(); isync(); touser(sp); }