| plan 9 kernel history: overview | file list | diff list |
1993/0915/pc/main.c (diff list | history)
| 1993/0416/sys/src/9/pc/main.c:26,35 – 1993/0915/sys/src/9/pc/main.c:26,40 (short | long | prev | next) | ||
| 1993/0330 | #define BOOTARGSLEN 1024 #define MAXCONF 32 | |
| 1993/0915 | char bootdisk[NAMELEN]; | |
| 1993/0330 | char *confname[MAXCONF]; char *confval[MAXCONF]; int nconf; | |
| 1993/0915 | /* memory map */ #define MAXMEG 64 char mmap[MAXMEG+2]; | |
| 1991/0716 | void | |
| 1991/0702 | main(void) | |
| 1991/0625 | { | |
| 1993/0416/sys/src/9/pc/main.c:40,45 – 1993/0915/sys/src/9/pc/main.c:45,51 | ||
| 1991/1113 | active.machs = 1; | |
| 1991/0711 | confinit(); | |
| 1992/0625 | xinit(); | |
| 1993/0915 | dmainit(); | |
| 1991/0703 | screeninit(); | |
| 1991/0716 | printinit(); | |
| 1991/0711 | mmuinit(); | |
| 1993/0416/sys/src/9/pc/main.c:51,58 – 1993/0915/sys/src/9/pc/main.c:57,64 | ||
| 1992/0409 | kbdinit(); | |
| 1991/0716 | procinit0(); initseg(); | |
| 1993/0915 | links(); | |
| 1991/0716 | chandevreset(); | |
| 1993/0416/sys/src/9/pc/main.c:94,103 – 1993/0915/sys/src/9/pc/main.c:100,109 | ||
| 1993/0330 | int i; | |
| 1992/0918 | char tstr[32]; | |
| 1991/0716 |
| |
| 1993/0915 | up->nerrlab = 0; m->proc = up->p; up->state = Running; up->mach = m; | |
| 1991/0712 | ||
| 1991/0720 | spllo(); | |
| 1993/0416/sys/src/9/pc/main.c:105,125 – 1993/0915/sys/src/9/pc/main.c:111,133 | ||
| 1991/0716 | * These are o.k. because rootinit is null. * Then early kproc's will have a root and dot. */ | |
| 1993/0915 | up->slash = namec("#/", Atodir, 0, 0); up->dot = clone(up->slash, 0); | |
| 1991/0712 | ||
| 1992/0516 |
| |
| 1993/0915 | iallocinit(); | |
| 1991/0716 | chandevinit(); | |
| 1991/0926 | if(!waserror()){ | |
| 1993/0330 |
| |
| 1992/0923 | strcpy(tstr, arch->id); | |
| 1992/0918 | strcat(tstr, " %s"); ksetterm(tstr); | |
| 1991/0927 | ksetenv("cputype", "386"); | |
| 1993/0915 | for(i = 0; i < nconf; i++) if(confname[i]) ksetenv(confname[i], confval[i]); | |
| 1991/0926 | poperror(); } | |
| 1993/0915 | kproc("alarm", alarmkproc, 0); | |
| 1992/0323 | touser(sp); | |
| 1991/0712 | } | |
| 1993/0416/sys/src/9/pc/main.c:152,172 – 1993/0915/sys/src/9/pc/main.c:160,171 | ||
| 1991/0719 | * 4 bytes for gotolabel's return PC | |
| 1991/0716 | */ p->sched.pc = (ulong)init0; | |
| 1991/0720 |
| |
| 1991/0716 |
| |
| 1993/0915 | p->sched.sp = (ulong)p->kstack+KSTACK-(1+MAXSYSARG)*BY2WD; | |
| 1991/0716 | /* | |
| 1993/0915 | s = newseg(SG_STACK, USTKTOP-USTKSIZE, USTKSIZE/BY2PG); | |
| 1991/0716 | p->seg[SSEG] = s; | |
| 1992/0323 | pg = newpage(1, 0, USTKTOP-BY2PG); segpage(s, pg); | |
| 1993/0416/sys/src/9/pc/main.c:178,185 – 1993/0915/sys/src/9/pc/main.c:177,187 | ||
| 1991/0716 | * Text */ s = newseg(SG_TEXT, UTZERO, 1); | |
| 1993/0915 | s->flushme++; | |
| 1991/0716 | p->seg[TSEG] = s; | |
| 1993/0915 | pg = newpage(1, 0, UTZERO); memset(pg->cachectl, PG_TXTFLUSH, sizeof(pg->cachectl)); segpage(s, pg); | |
| 1991/0716 | k = kmap(s->map[0]->pages[0]); memmove((ulong*)VA(k), initcode, sizeof initcode); kunmap(k); | |
| 1993/0416/sys/src/9/pc/main.c:213,225 – 1993/0915/sys/src/9/pc/main.c:215,244 | ||
| 1992/0323 | av[ac++] = pusharg("/386/9safari"); av[ac++] = pusharg("-p"); | |
| 1992/0903 | cp[64] = 0; | |
| 1993/0915 | buf[0] = 0; | |
| 1992/0903 | if(strncmp(cp, "fd!", 3) == 0){ sprint(buf, "local!#f/fd%ddisk", atoi(cp+3)); av[ac++] = pusharg(buf); | |
| 1993/0915 | } else if(strncmp(cp, "h!", 2) == 0){ sprint(buf, "local!#H/hd%dfs", atoi(cp+2)); av[ac++] = pusharg(buf); | |
| 1992/0903 | } else if(strncmp(cp, "hd!", 3) == 0){ | |
| 1993/0114 |
| |
| 1993/0915 | sprint(buf, "local!#H/hd%ddisk", atoi(cp+3)); | |
| 1992/0903 | av[ac++] = pusharg(buf); | |
| 1993/0915 | } else if(strncmp(cp, "s!", 2) == 0){ sprint(buf, "local!#w/sd%dfs", atoi(cp+2)); av[ac++] = pusharg(buf); } else if(strncmp(cp, "sd!", 3) == 0){ sprint(buf, "local!#w/sd%ddisk", atoi(cp+3)); av[ac++] = pusharg(buf); | |
| 1992/0903 | } | |
| 1993/0915 | if(buf[0]){ cp = strchr(buf, '!'); if(cp){ strcpy(bootdisk, cp+1); addconf("bootdisk", bootdisk); } } | |
| 1992/0323 | /* 4 byte word align stack */ sp = (uchar*)((ulong)sp & ~3); | |
| 1993/0416/sys/src/9/pc/main.c:236,244 – 1993/0915/sys/src/9/pc/main.c:255,284 | ||
| 1991/0716 | Conf conf; | |
| 1991/0711 | void | |
| 1993/0915 | addconf(char *name, char *val) { if(nconf >= MAXCONF) return; confname[nconf] = name; confval[nconf] = val; nconf++; } char* getconf(char *name) { int i; for(i = 0; i < nconf; i++) if(strcmp(confname[i], name) == 0) return confval[i]; return 0; } void | |
| 1991/0711 | confinit(void) { | |
| 1993/0416 |
| |
| 1993/0915 | long x, i, j, n; | |
| 1992/1002 | int pcnt; | |
| 1992/0715 | ulong ktop; | |
| 1993/0330 | char *cp; | |
| 1993/0416/sys/src/9/pc/main.c:249,255 – 1993/0915/sys/src/9/pc/main.c:289,295 | ||
| 1991/0711 | /* | |
| 1993/0416 | * parse configuration args from dos file p9rc */ | |
| 1993/0915 | cp = BOOTARGS; /* where b.com leaves its config */ | |
| 1993/0416 | cp[BOOTARGSLEN-1] = 0; n = getfields(cp, line, MAXCONF, '\n'); for(j = 0; j < n; j++){ | |
| 1993/0416/sys/src/9/pc/main.c:268,314 – 1993/0915/sys/src/9/pc/main.c:308,383 | ||
| 1993/0416 | pcnt = 100 - atoi(confval[nconf]); nconf++; } | |
| 1991/0823 |
| |
| 1992/1113 |
| |
| 1992/0429 |
| |
| 1993/0915 | * size memory above 1 meg. Kernel sits at 1 meg. We * only recognize MB size chunks. | |
| 1991/0711 | */ | |
| 1991/0823 |
| |
| 1993/0915 | memset(mmap, ' ', sizeof(mmap)); | |
| 1991/0711 | x = 0x12345678; | |
| 1992/1019 |
| |
| 1993/0915 | for(i = 1; i <= MAXMEG; i++){ | |
| 1991/0711 | /* | |
| 1993/0915 | * write the first & last word in a megabyte of memory | |
| 1991/0711 | */ | |
| 1992/0625 |
| |
| 1992/1019 |
| |
| 1991/0711 |
| |
| 1993/0915 | *mapaddr(KZERO|(i*MB)) = x; *mapaddr(KZERO|((i+1)*MB-BY2WD)) = x; | |
| 1991/0711 | /* | |
| 1993/0915 | * write the first and last word in all previous megs to * handle address wrap around | |
| 1991/0711 | */ | |
| 1992/1019 | for(j = 1; j < i; j++){ | |
| 1992/0625 |
| |
| 1992/1019 |
| |
| 1993/0915 | *mapaddr(KZERO|(j*MB)) = ~x; *mapaddr(KZERO|((j+1)*MB-BY2WD)) = ~x; | |
| 1991/0711 | } | |
| 1993/0915 | ||
| 1991/0711 | /* | |
| 1993/0915 | * check for correct value | |
| 1991/0711 | */ | |
| 1992/0625 |
| |
| 1992/1019 |
| |
| 1991/0711 |
| |
| 1993/0217 |
| |
| 1993/0915 | if(*mapaddr(KZERO|(i*MB)) == x && *mapaddr(KZERO|((i+1)*MB-BY2WD)) == x){ mmap[i] = 'x'; /* * zero memory to set ECC but skip over the kernel */ if(i != 1) for(j = 0; j < MB/BY2PG; j += BY2PG) memset(mapaddr(KZERO|(i*MB+j)), 0, BY2PG); } | |
| 1991/0711 | x += 0x3141526; } | |
| 1992/1019 |
| |
| 1992/0625 |
| |
| 1992/1016 |
| |
| 1993/0915 | /* * bank0 usually goes from the end of kernel bss to the end of memory */ ktop = PGROUND((ulong)end); ktop = PADDR(ktop); conf.base0 = ktop; for(i = 1; mmap[i] == 'x'; i++) ; conf.npage0 = (i*MB - ktop)/BY2PG; conf.topofmem = i*MB; /* * bank1 usually goes from the end of BOOTARGS to 640k */ conf.base1 = (ulong)(BOOTARGS+BOOTARGSLEN); conf.base1 = PGROUND(conf.base1); conf.base1 = PADDR(conf.base1); conf.npage1 = (640*1024-conf.base1)/BY2PG; /* * if there is a hole in memory (due to a shadow BIOS) make the * memory after the hole be bank 1. The memory from 0 to 640k * is lost. */ for(; i <= MAXMEG; i++) if(mmap[i] == 'x'){ conf.base1 = i*MB; for(j = i+1; mmap[j] == 'x'; j++) ; conf.npage1 = (j - i)*MB/BY2PG; conf.topofmem = j*MB; break; } | |
| 1991/0711 | conf.npage = conf.npage0 + conf.npage1; | |
| 1992/1113 | conf.ldepth = 0; | |
| 1993/0416 | if(pcnt < 10) | |
| 1993/0416/sys/src/9/pc/main.c:315,327 – 1993/0915/sys/src/9/pc/main.c:384,390 | ||
| 1993/0416 | pcnt = 70; | |
| 1992/1014 | conf.upages = (conf.npage*pcnt)/100; | |
| 1992/1016 |
| |
| 1991/0711 | ||
| 1992/0625 |
| |
| 1993/0401 |
| |
| 1993/0915 | conf.nproc = 30 + ((conf.npage*BY2PG)/MB)*5; | |
| 1993/0401 | conf.monitor = 1; conf.nswap = conf.nproc*80; conf.nimage = 50; | |
| 1993/0416/sys/src/9/pc/main.c:363,386 – 1993/0915/sys/src/9/pc/main.c:426,449 | ||
| 1992/0806 | /* * save floating point state to check out error */ | |
| 1993/0915 | fpenv(&up->fpsave); status = up->fpsave.status; | |
| 1992/0806 | msg = 0; | |
| 1991/0913 | for(i = 0; i < 8; i++) if((1<<i) & status){ msg = mathmsg[i]; | |
| 1992/0806 |
| |
| 1993/0915 | sprint(note, "sys: fp: %s fppc=0x%lux", msg, up->fpsave.pc); postnote(up->p, 1, note, NDebug); | |
| 1991/0913 | break; } | |
| 1992/0806 | if(msg == 0){ | |
| 1993/0915 | sprint(note, "sys: fp: unknown fppc=0x%lux", up->fpsave.pc); postnote(up->p, 1, note, NDebug); | |
| 1992/0806 | } if(ur->pc & KZERO) panic("fp: status %lux fppc=0x%lux pc=0x%lux", status, | |
| 1993/0915 | up->fpsave.pc, ur->pc); | |
| 1991/0912 | } /* | |
| 1993/0416/sys/src/9/pc/main.c:390,403 – 1993/0915/sys/src/9/pc/main.c:453,466 | ||
| 1991/0906 | mathemu(Ureg *ur) { | |
| 1992/0711 | USED(ur); | |
| 1991/0906 |
| |
| 1993/0915 | switch(up->fpstate){ | |
| 1991/0906 | case FPinit: fpinit(); | |
| 1993/0915 | up->fpstate = FPactive; | |
| 1991/0906 | break; case FPinactive: | |
| 1993/0915 | fprestore(&up->fpsave); up->fpstate = FPactive; | |
| 1991/0906 | break; case FPactive: | |
| 1992/0805 | panic("math emu", 0); | |
| 1993/0416/sys/src/9/pc/main.c:412,418 – 1993/0915/sys/src/9/pc/main.c:475,481 | ||
| 1991/0906 | mathover(Ureg *ur) { | |
| 1992/0711 | USED(ur); | |
| 1992/0805 |
| |
| 1993/0915 | print("sys: fp: math overrun pc 0x%lux pid %d\n", ur->pc, up->pid); | |
| 1992/0805 | pexit("math overrun", 0); | |
| 1991/0906 | } | |
| 1993/0416/sys/src/9/pc/main.c:445,451 – 1993/0915/sys/src/9/pc/main.c:508,514 | ||
| 1992/0805 | if(p->state == Moribund) fpoff(); else | |
| 1993/0915 | fpsave(&up->fpsave); | |
| 1992/0805 | p->fpstate = FPinactive; | |
| 1991/0906 | } | |
| 1991/0712 | } | |
| 1993/0416/sys/src/9/pc/main.c:473,480 – 1993/0915/sys/src/9/pc/main.c:536,547 | ||
| 1991/0803 | { u = 0; print("exiting\n"); | |
| 1992/0812 |
| |
| 1993/0915 | if(ispanic){ if(cpuflag) delay(10000); else for(;;); } | |
| 1992/0903 | ||
| 1992/0923 | (*arch->reset)(); | |
| 1991/0803 | } | |
| 1993/0416/sys/src/9/pc/main.c:540,543 – 1993/0915/sys/src/9/pc/main.c:607,676 | ||
| 1992/0923 | return (*arch->modempower)(onoff); else | |
| 1991/1210 | return 0; | |
| 1993/0915 | } static int parseether(uchar *to, char *from) { char nip[4]; char *p; int i; p = from; for(i = 0; i < 6; i++){ if(*p == 0) return -1; nip[0] = *p++; if(*p == 0) return -1; nip[1] = *p++; nip[2] = 0; to[i] = strtoul(nip, 0, 16); if(*p == ':') p++; } return 0; } int isaconfig(char *class, int ctlrno, ISAConf *isa) { char cc[NAMELEN], *p, *q; int n; sprint(cc, "%s%d", class, ctlrno); for(n = 0; n < nconf; n++){ if(strncmp(confname[n], cc, NAMELEN)) continue; p = confval[n]; while(*p){ while(*p == ' ' || *p == '\t') p++; if(*p == '\0') break; if(strncmp(p, "type=", 5) == 0){ p += 5; for(q = isa->type; q < &isa->type[NAMELEN-1]; q++){ if(*p == '\0' || *p == ' ' || *p == '\t') break; *q = *p++; } *q = '\0'; } else if(strncmp(p, "port=", 5) == 0) isa->port = strtoul(p+5, &p, 0); else if(strncmp(p, "irq=", 4) == 0) isa->irq = strtoul(p+4, &p, 0); else if(strncmp(p, "mem=", 4) == 0) isa->mem = strtoul(p+4, &p, 0); else if(strncmp(p, "size=", 5) == 0) isa->size = strtoul(p+5, &p, 0); else if(strncmp(p, "ea=", 3) == 0) parseether(isa->ea, p+3); while(*p && *p != ' ' && *p != '\t') p++; } return 1; } return 0; | |
| 1991/0803 | } | |