| plan 9 kernel history: overview | file list | diff list |
1997/0109/pc/main.c (diff list | history)
| 1997/0109/sys/src/9/pc/main.c:6,65 – 1997/0327/sys/src/9/pc/main.c:6,103 (short | long | prev | next) | ||
| 1991/0706 | #include "io.h" | |
| 1991/0716 | #include "ureg.h" #include "init.h" | |
| 1992/0918 |
| |
| 1991/0629 | ||
| 1997/0327 | Mach *m; | |
| 1992/0904 | ||
| 1992/0903 |
| |
| 1997/0327 | static uchar *sp; /* stack pointer for /boot */ | |
| 1992/0903 | ||
| 1992/0923 |
| |
| 1993/0330 |
| |
| 1997/0327 | /* * 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 1024 bytes available at CONFADDR. */ #define BOOTLINE ((char *)CONFADDR) #define BOOTLINELEN 64 #define BOOTARGS ((char*)(CONFADDR+BOOTLINELEN)) #define BOOTARGSLEN (1024-BOOTLINELEN) | |
| 1993/0330 | #define MAXCONF 32 | |
| 1993/0915 | char bootdisk[NAMELEN]; | |
| 1994/0607 |
| |
| 1993/0330 | char *confname[MAXCONF]; char *confval[MAXCONF]; int nconf; | |
| 1993/0915 |
| |
| 1995/0523 |
| |
| 1993/0915 |
| |
| 1997/0327 | extern void ns16552install(void); /* botch: config */ | |
| 1993/0915 | ||
| 1997/0327 | static int isoldbcom; static void bcompatibility(void) { uchar *bda; if(strncmp(BOOTARGS, "ZORT 0\r\n", 8) == 0) return; isoldbcom = 1; memmove(BOOTARGS, KADDR(1024), BOOTARGSLEN); memmove(BOOTLINE, KADDR(0x100), BOOTLINELEN); bda = KADDR(0x400); bda[0x13] = 639; bda[0x14] = 639>>8; } | |
| 1991/0716 | void | |
| 1991/0702 | main(void) | |
| 1991/0625 | { | |
| 1991/1210 |
| |
| 1992/0902 |
| |
| 1997/0327 | outb(0x3F2, 0x00); /* botch: turn off the floppy motor */ /* * There is a little leeway here in the ordering but care must be * taken with dependencies: * function depends on * ======== ========== * machinit m->machno, m->pdb * cpuidentify m * memscan cpuidentify (needs to know processor * type for caching, etc.) * archinit memscan (MP config table may be at the * top of system physical memory); * conf.nmach (not critical, mpinit will check); * confinit meminit * arch->intrinit trapinit */ conf.nmach = 1; MACHP(0) = (Mach*)CPU0MACH; m->pdb = (void*)CPU0PDB; | |
| 1991/0711 | machinit(); | |
| 1991/1113 |
| |
| 1997/0327 | active.exiting = 0; cpuidentify(); bcompatibility(); memscan(); archinit(); | |
| 1991/0711 | confinit(); | |
| 1992/0625 | xinit(); | |
| 1993/0915 |
| |
| 1997/0327 | trapinit(); | |
| 1991/0703 | screeninit(); | |
| 1991/0716 | printinit(); | |
| 1991/0711 |
| |
| 1996/01171 |
| |
| 1994/1007 |
| |
| 1997/0327 | if(isoldbcom) print(" ****OLD B.COM - UPGRADE****\n"); | |
| 1992/0625 | pageinit(); | |
| 1997/0327 | mmuinit(); if(arch->intrinit) arch->intrinit(); ns16552install(); /* botch: config */ | |
| 1991/0906 | mathinit(); | |
| 1991/0718 |
| |
| 1992/0409 | kbdinit(); | |
| 1997/0327 | if(arch->clockenable) arch->clockenable(); | |
| 1991/0716 | procinit0(); initseg(); | |
| 1994/0302 |
| |
| 1997/0327 | cpuidprint(); | |
| 1995/0329 | links(); | |
| 1991/0716 | chandevreset(); swapinit(); | |
| 1997/0109/sys/src/9/pc/main.c:67,98 – 1997/0327/sys/src/9/pc/main.c:105,121 | ||
| 1991/0716 | schedinit(); | |
| 1991/0712 | } | |
| 1991/0706 | ||
| 1992/0902 |
| |
| 1992/0903 |
| |
| 1994/0525 |
| |
| 1992/0903 |
| |
| 1992/0902 |
| |
| 1991/0716 | void | |
| 1991/1210 |
| |
| 1992/0923 |
| |
| 1991/1210 | ||
| 1992/0923 |
| |
| 1992/0918 |
| |
| 1992/0923 |
| |
| 1991/1210 |
| |
| 1991/0716 | machinit(void) | |
| 1991/0712 | { | |
| 1991/0716 |
| |
| 1997/0327 | int machno; void *pdb; | |
| 1991/0712 | ||
| 1991/0716 |
| |
| 1997/0327 | machno = m->machno; pdb = m->pdb; | |
| 1991/0716 | memset(m, 0, sizeof(Mach)); | |
| 1997/0327 | m->machno = machno; m->pdb = pdb; | |
| 1991/0625 | } | |
| 1991/0716 | void | |
| 1997/0109/sys/src/9/pc/main.c:119,125 – 1997/0327/sys/src/9/pc/main.c:142,148 | ||
| 1991/0716 | * Then early kproc's will have a root and dot. */ | |
| 1993/0915 | up->slash = namec("#/", Atodir, 0, 0); | |
| 1997/0327 | up->dot = cclone(up->slash, 0); | |
| 1991/0712 | ||
| 1991/0716 | chandevinit(); | |
| 1997/0109/sys/src/9/pc/main.c:128,137 – 1997/0327/sys/src/9/pc/main.c:151,156 | ||
| 1992/0918 | strcat(tstr, " %s"); ksetterm(tstr); | |
| 1991/0927 | ksetenv("cputype", "386"); | |
| 1995/1121 |
| |
| 1993/0915 | for(i = 0; i < nconf; i++) if(confname[i]) ksetenv(confname[i], confval[i]); | |
| 1997/0109/sys/src/9/pc/main.c:223,229 – 1997/0327/sys/src/9/pc/main.c:242,248 | ||
| 1992/0323 | ac = 0; | |
| 1994/0219 | av[ac++] = pusharg("/386/9dos"); | |
| 1992/0903 |
| |
| 1997/0327 | cp[BOOTLINELEN-1] = 0; | |
| 1993/0915 | buf[0] = 0; | |
| 1992/0903 | if(strncmp(cp, "fd!", 3) == 0){ sprint(buf, "local!#f/fd%ddisk", atoi(cp+3)); | |
| 1997/0109/sys/src/9/pc/main.c:285,376 – 1997/0327/sys/src/9/pc/main.c:304,327 | ||
| 1993/0915 | return 0; } | |
| 1994/0814 |
| |
| 1994/0815 |
| |
| 1994/0814 |
| |
| 1994/1210 |
| |
| 1994/0814 |
| |
| 1994/1210 |
| |
| 1993/0915 |
| |
| 1994/1210 |
| |
| 1995/1019 |
| |
| 1994/1210 |
| |
| 1995/1219 |
| |
| 1995/1019 |
| |
| 1994/1210 |
| |
| 1995/1019 |
| |
| 1995/1219 |
| |
| 1995/1019 |
| |
| 1995/1219 |
| |
| 1995/1019 |
| |
| 1994/1210 |
| |
| 1996/0203 | static int | |
| 1997/0327 | getcfields(char* lp, char** fields, int n, char* sep) | |
| 1996/0203 | { int i; | |
| 1997/0327 | for(i = 0; lp && *lp && i < n; i++){ while(*lp && strchr(sep, *lp) != 0) *lp++ = 0; | |
| 1996/0203 | if(*lp == 0) break; | |
| 1997/0327 | fields[i] = lp; while(*lp && strchr(sep, *lp) == 0){ | |
| 1996/0203 | if(*lp == '\\' && *(lp+1) == '\n') *lp++ = ' '; lp++; } } | |
| 1997/0327 | ||
| 1996/0203 | return i; } | |
| 1997/0109/sys/src/9/pc/main.c:377,390 – 1997/0327/sys/src/9/pc/main.c:328,339 | ||
| 1994/1210 | void | |
| 1991/0711 | confinit(void) { | |
| 1994/0814 |
| |
| 1997/0327 | long i, j, n; | |
| 1992/1002 | int pcnt; | |
| 1992/0715 |
| |
| 1996/0203 |
| |
| 1997/0327 | char *cp; char *line[MAXCONF], *p, *q; | |
| 1994/0513 | extern int defmaxmsg; | |
| 1991/0711 | ||
| 1993/0416 |
| |
| 1991/0711 | /* | |
| 1993/1113 | * parse configuration args from dos file plan9.ini | |
| 1993/0416 | */ | |
| 1997/0109/sys/src/9/pc/main.c:404,410 – 1997/0327/sys/src/9/pc/main.c:353,360 | ||
| 1996/0203 | } *p = 0; | |
| 1997/0327 | pcnt = 0; n = getcfields(cp, line, MAXCONF, "\n"); | |
| 1993/0416 | for(j = 0; j < n; j++){ | |
| 1996/0203 | if(*line[j] == '#') continue; | |
| 1997/0109/sys/src/9/pc/main.c:416,522 – 1997/0327/sys/src/9/pc/main.c:366,384 | ||
| 1993/0416 | *(line[j]+NAMELEN-1) = 0; confname[nconf] = line[j]; confval[nconf] = cp; | |
| 1997/0327 | if(cistrcmp(confname[nconf], "kernelpercent") == 0) | |
| 1993/0416 | pcnt = 100 - atoi(confval[nconf]); | |
| 1994/0513 |
| |
| 1997/0327 | if(cistrcmp(confname[nconf], "defmaxmsg") == 0){ | |
| 1994/0513 | i = atoi(confval[nconf]); if(i < defmaxmsg && i >=128) defmaxmsg = i; } | |
| 1994/0607 |
| |
| 1993/0416 | nconf++; } | |
| 1994/0814 | ||
| 1993/0416 |
| |
| 1993/0915 |
| |
| 1991/0711 |
| |
| 1993/0915 |
| |
| 1991/0711 |
| |
| 1993/0915 |
| |
| 1991/0711 |
| |
| 1993/0915 |
| |
| 1991/0711 |
| |
| 1993/0915 |
| |
| 1997/0327 | meminit(); | |
| 1993/0915 | ||
| 1991/0711 |
| |
| 1993/0915 |
| |
| 1991/0711 |
| |
| 1992/1019 |
| |
| 1993/0915 |
| |
| 1991/0711 |
| |
| 1993/0915 | ||
| 1991/0711 |
| |
| 1993/0915 |
| |
| 1991/0711 |
| |
| 1994/0815 |
| |
| 1994/0814 |
| |
| 1994/0817 |
| |
| 1994/0814 |
| |
| 1995/0523 |
| |
| 1994/0817 |
| |
| 1994/0814 |
| |
| 1995/0523 |
| |
| 1991/0711 |
| |
| 1994/0814 | ||
| 1993/0915 |
| |
| 1994/0814 |
| |
| 1993/0915 |
| |
| 1994/0814 |
| |
| 1993/0915 |
| |
| 1994/0813 |
| |
| 1993/0915 |
| |
| 1994/0813 |
| |
| 1993/0915 |
| |
| 1994/0814 |
| |
| 1993/0915 |
| |
| 1994/1210 |
| |
| 1993/0915 | ||
| 1991/0711 | conf.npage = conf.npage0 + conf.npage1; | |
| 1992/1113 |
| |
| 1993/0416 | if(pcnt < 10) pcnt = 70; | |
| 1992/1014 | conf.upages = (conf.npage*pcnt)/100; | |
| 1997/0109/sys/src/9/pc/main.c:525,536 – 1997/0327/sys/src/9/pc/main.c:387,396 | ||
| 1994/0923 | conf.nproc = 100 + ((conf.npage*BY2PG)/MB)*5; | |
| 1996/0612 | if(cpuserver) | |
| 1997/0109 | conf.nproc *= 3; | |
| 1993/0401 |
| |
| 1997/0327 | if(conf.nproc > 2000) conf.nproc = 2000; | |
| 1993/0401 | conf.nswap = conf.nproc*80; | |
| 1993/0413 |
| |
| 1997/0327 | conf.nimage = 200; | |
| 1991/0711 | } | |
| 1991/0913 | char *mathmsg[] = | |
| 1997/0109/sys/src/9/pc/main.c:549,555 – 1997/0327/sys/src/9/pc/main.c:409,415 | ||
| 1991/0912 | * math coprocessor error */ void | |
| 1993/1124 |
| |
| 1997/0327 | matherror(Ureg *ur, void*) | |
| 1991/0912 | { | |
| 1991/0913 | ulong status; int i; | |
| 1997/0109/sys/src/9/pc/main.c:556,563 – 1997/0327/sys/src/9/pc/main.c:416,421 | ||
| 1991/0913 | char *msg; char note[ERRLEN]; | |
| 1993/1124 |
| |
| 1991/0913 | /* * a write cycle to port 0xF0 clears the interrupt latch attached * to the error# line from the 387 | |
| 1997/0109/sys/src/9/pc/main.c:591,599 – 1997/0327/sys/src/9/pc/main.c:449,456 | ||
| 1991/0906 | * math coprocessor emulation fault */ void | |
| 1993/1124 |
| |
| 1997/0327 | mathemu(Ureg*, void*) | |
| 1991/0906 | { | |
| 1993/1124 |
| |
| 1993/0915 | switch(up->fpstate){ | |
| 1991/0906 | case FPinit: fpinit(); | |
| 1997/0109/sys/src/9/pc/main.c:613,622 – 1997/0327/sys/src/9/pc/main.c:470,477 | ||
| 1991/0906 | * math coprocessor segment overrun */ void | |
| 1993/1124 |
| |
| 1997/0327 | mathover(Ureg*, void*) | |
| 1991/0906 | { | |
| 1993/1124 |
| |
| 1993/0915 |
| |
| 1992/0805 | pexit("math overrun", 0); | |
| 1991/0906 | } | |
| 1997/0109/sys/src/9/pc/main.c:623,632 – 1997/0327/sys/src/9/pc/main.c:478,488 | ||
| 1991/0906 | void mathinit(void) { | |
| 1993/1124 |
| |
| 1997/0327 | intrenable(VectorCERR, matherror, 0, BUSUNKNOWN); if(X86FAMILY(m->cpuidax) == 3) intrenable(VectorIRQ13, matherror, 0, BUSUNKNOWN); intrenable(VectorCNA, mathemu, 0, BUSUNKNOWN); intrenable(VectorCSO, mathover, 0, BUSUNKNOWN); | |
| 1991/0906 | } /* | |
| 1997/0109/sys/src/9/pc/main.c:654,778 – 1997/0327/sys/src/9/pc/main.c:510,552 | ||
| 1991/0906 | } | |
| 1991/0712 | } | |
| 1991/0716 |
| |
| 1991/0712 |
| |
| 1991/0716 | void | |
| 1992/0122 |
| |
| 1997/0327 | exit(int ispanic) | |
| 1991/0712 | { | |
| 1992/0711 |
| |
| 1991/0712 |
| |
| 1997/0327 | int ms, once; | |
| 1991/0712 | ||
| 1991/0906 |
| |
| 1991/1210 |
| |
| 1991/0803 |
| |
| 1997/0327 | 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); active.machs &= ~(1<<m->machno); active.exiting = 1; unlock(&active); | |
| 1991/0803 |
| |
| 1992/0812 |
| |
| 1991/0803 |
| |
| 1993/1013 |
| |
| 1996/0202 |
| |
| 1991/0803 |
| |
| 1997/0327 | if(once) print("cpu%d: exiting\n", m->machno); | |
| 1996/01171 | spllo(); | |
| 1993/0915 |
| |
| 1997/0327 | for(ms = 5*1000; ms > 0; ms -= TK2MS(2)){ delay(TK2MS(2)); if(active.machs == 0 && consactive() == 0) break; } if(active.ispanic && m->machno == 0){ | |
| 1993/1113 | if(cpuserver) | |
| 1993/0915 | delay(10000); else for(;;); | |
| 1996/01171 |
| |
| 1997/0327 | } else | |
| 1996/01171 | delay(1000); | |
| 1992/0903 | ||
| 1992/0923 |
| |
| 1997/0327 | arch->reset(); | |
| 1991/0803 | } | |
| 1991/1210 |
| |
| 1991/0803 |
| |
| 1991/1210 | int | |
| 1991/0803 |
| |
| 1992/0923 |
| |
| 1991/1210 |
| |
| 1991/0803 |
| |
| 1991/1210 |
| |
| 1991/0803 |
| |
| 1991/1210 |
| |
| 1991/0803 |
| |
| 1992/0923 |
| |
| 1991/0803 |
| |
| 1991/1210 |
| |
| 1991/0803 |
| |
| 1991/1210 |
| |
| 1991/0803 |
| |
| 1992/0923 |
| |
| 1991/0803 |
| |
| 1991/0913 |
| |
| 1991/1210 |
| |
| 1991/0803 |
| |
| 1992/0923 |
| |
| 1991/1210 |
| |
| 1991/0803 |
| |
| 1991/1001 |
| |
| 1991/1210 |
| |
| 1991/1001 |
| |
| 1992/0923 |
| |
| 1991/1210 |
| |
| 1993/0915 |
| |
| 1995/0920 | char cc[NAMELEN], *p, *q, *r; | |
| 1997/0109/sys/src/9/pc/main.c:780,786 – 1997/0327/sys/src/9/pc/main.c:554,560 | ||
| 1993/0915 | sprint(cc, "%s%d", class, ctlrno); for(n = 0; n < nconf; n++){ | |
| 1997/0327 | if(cistrncmp(confname[n], cc, NAMELEN)) | |
| 1993/0915 | continue; | |
| 1995/0920 | isa->nopt = 0; | |
| 1993/0915 | p = confval[n]; | |
| 1997/0109/sys/src/9/pc/main.c:789,795 – 1997/0327/sys/src/9/pc/main.c:563,569 | ||
| 1993/0915 | p++; if(*p == '\0') break; | |
| 1997/0327 | if(cistrncmp(p, "type=", 5) == 0){ | |
| 1993/0915 | p += 5; for(q = isa->type; q < &isa->type[NAMELEN-1]; q++){ if(*p == '\0' || *p == ' ' || *p == '\t') | |
| 1997/0109/sys/src/9/pc/main.c:798,819 – 1997/0327/sys/src/9/pc/main.c:572,589 | ||
| 1993/0915 | } *q = '\0'; } | |
| 1997/0327 | else if(cistrncmp(p, "port=", 5) == 0) | |
| 1993/0915 | isa->port = strtoul(p+5, &p, 0); | |
| 1997/0327 | else if(cistrncmp(p, "irq=", 4) == 0) | |
| 1993/0915 | isa->irq = strtoul(p+4, &p, 0); | |
| 1995/0803 |
| |
| 1997/0327 | else if(cistrncmp(p, "dma=", 4) == 0) | |
| 1996/0425 | isa->dma = strtoul(p+4, &p, 0); | |
| 1993/0915 |
| |
| 1997/0327 | else if(cistrncmp(p, "mem=", 4) == 0) | |
| 1993/0915 | isa->mem = strtoul(p+4, &p, 0); | |
| 1997/0327 | else if(cistrncmp(p, "size=", 5) == 0) | |
| 1993/0915 | isa->size = strtoul(p+5, &p, 0); | |
| 1994/0823 |
| |
| 1997/0327 | else if(cistrncmp(p, "freq=", 5) == 0) | |
| 1994/0823 | isa->freq = strtoul(p+5, &p, 0); | |
| 1995/0920 |
| |
| 1997/0109/sys/src/9/pc/main.c:867,871 – 1997/0327/sys/src/9/pc/main.c:637,666 | ||
| 1995/0222 | if(bc == 0) break; } | |
| 1997/0327 | return 0; } 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; } | |
| 1995/0222 | return 0; } | |