Annotation of coherent/b/kernel/coh.386/main.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * File:       main.c
        !             3:  */
        !             4: 
        !             5: /*
        !             6:  * Includes.
        !             7:  */
        !             8: #include <sys/coherent.h>
        !             9: #include <sys/devices.h>
        !            10: #include <sys/fdisk.h>
        !            11: #include <sys/proc.h>
        !            12: #include <sys/seg.h>
        !            13: #include <sys/stat.h>
        !            14: #include <sys/typed.h>
        !            15: #include <sys/param.h>
        !            16: 
        !            17: /*
        !            18:  * Definitions.
        !            19:  *     Constants.
        !            20:  *     Macros with argument lists.
        !            21:  *     Typedefs.
        !            22:  *     Enums.
        !            23:  */
        !            24: #ifndef VERSION                /* This should be specified at compile time */
        !            25: #define VERSION        "..."
        !            26: #endif
        !            27: #ifndef RELEASE
        !            28: #define RELEASE "0"
        !            29: #endif
        !            30: 
        !            31: /*
        !            32:  * Functions.
        !            33:  *     Import Functions.
        !            34:  *     Export Functions.
        !            35:  *     Local Functions.
        !            36:  */
        !            37: int read_cmos();
        !            38: 
        !            39: static void atcount();
        !            40: static void rpdev();
        !            41: 
        !            42: /*
        !            43:  * Global Data.
        !            44:  *     Import Variables.
        !            45:  *     Export Variables.
        !            46:  *     Local Variables.
        !            47:  */
        !            48: extern dev_t rootdev;
        !            49: extern dev_t pipedev;
        !            50: extern int ronflag;
        !            51: extern int PHYS_MEM;
        !            52: 
        !            53: /*
        !            54:  * Patchable variable.
        !            55:  *
        !            56:  * PS1DRIVES is the number of PS1 type drives in the system. It is 0 unless you
        !            57:  *     are actually on a PS1.
        !            58:  */
        !            59: int    PS1DRIVES = 0;
        !            60: 
        !            61: short n_atdr;
        !            62: char version[] = VERSION;
        !            63: char release[] = RELEASE;
        !            64: char copyright[] = "Copyright 1982,1993 Mark Williams Company\n";
        !            65: 
        !            66: unsigned long  _entry = 0;             /* really the serial number */
        !            67: unsigned long  __ = 0;                 /* really the serial number also */
        !            68: 
        !            69: main()
        !            70: {
        !            71:        register SEG *sp;
        !            72: #ifdef _I386
        !            73:        extern int BPFMAX;
        !            74:        int speed1, speed2;
        !            75:        char * ndpTypeName();
        !            76:        extern int (*ndpEmFn)();
        !            77:        extern short ndpType;
        !            78: #else
        !            79:        extern int realmode;
        !            80: #endif
        !            81: 
        !            82:        CHIRP('a');
        !            83: 
        !            84: #ifdef _I386
        !            85:        wrNdpUser(0);
        !            86:        wrNdpSaved(0);
        !            87:        u.u_bpfmax = BPFMAX;
        !            88: #endif
        !            89:        u.u_error = 0;
        !            90:        bufinit();
        !            91:        _CHIRP('0', 156);
        !            92:        cltinit();
        !            93:        _CHIRP('1', 156);
        !            94:        pcsinit();
        !            95:        _CHIRP('2', 156);
        !            96:        seginit();
        !            97:        _CHIRP('3', 156);
        !            98:        atcount();
        !            99:        _CHIRP('4', 156);
        !           100:        rpdev();
        !           101:        _CHIRP('5', 156);
        !           102:        devinit();
        !           103:        _CHIRP('6', 156);
        !           104: #ifdef _I386
        !           105:        rlinit();
        !           106:        _CHIRP('7', 156);
        !           107: 
        !           108:        putchar_init();
        !           109:        _CHIRP('8', 156);
        !           110:        printf("*** COHERENT Version %s - 386 Mode.  %uKB free memory. ***\n",
        !           111:                release, ctob(allocno())/1024);
        !           112:        if ((int11() & 0x30) == 0x30)
        !           113:                printf("Monochrome.  ");
        !           114:        else
        !           115:                printf("Color.  ");
        !           116:        senseNdp();
        !           117:        printf(ndpTypeName());
        !           118:        if (ndpType <= 1 && ndpEmFn)
        !           119:                printf("FP Emulation.  ");
        !           120: #if 0
        !           121:        if (int11() & 2)
        !           122:                printf("x87.  ");
        !           123:        else
        !           124:                printf("No x87.  ");
        !           125: #endif
        !           126: #else
        !           127:        printf("*** COHERENT Version %s - %s Mode.  %uKB free memory. ***\n",
        !           128:                release, (realmode ? "Real" : "Protected"), msize);
        !           129: #endif
        !           130:        printf( "%u buffers.  %u clists.\n", NBUF, NCLIST);
        !           131:        printf( "%uKB kalloc pool.  %u KB phys pool.\n",
        !           132:          ALLSIZE/1024, PHYS_MEM/1024);
        !           133:        printf(copyright);
        !           134: 
        !           135: #ifdef _I386
        !           136:        /*
        !           137:         * Make sure that we get a speed rating that does not cross 0.
        !           138:         */
        !           139:        do {
        !           140:                speed1 = read_t0();
        !           141:                speed2 = read_t0();
        !           142:        } while (speed1 < speed2);
        !           143: 
        !           144:        T_PIGGY(0x400,printf("CPU snail rating: %d\n", speed1 - speed2));
        !           145: #endif /* _I386 */
        !           146: 
        !           147:        if (_entry) {
        !           148:                printf("Serial Number ");
        !           149:                printf("%U\n", _entry);
        !           150:        }
        !           151: 
        !           152:        /*
        !           153:         * Verify correct serial number
        !           154:         */
        !           155:        if (_entry != __)
        !           156: panic("Verification error - call Mark Williams Company at +1-708-291-6700\n");
        !           157: 
        !           158:        /*
        !           159:         * Turn on clock, mount root device, start off processes
        !           160:         * and return.
        !           161:         */
        !           162:        batflag = 1;
        !           163: #ifdef _I386
        !           164:        iprocp = SELF;
        !           165:        CHIRP('b');
        !           166:        if (pfork()) {
        !           167:                CHIRP('i');
        !           168:                idle();
        !           169:        } else {
        !           170:                fsminit();
        !           171:                CHIRP('-');
        !           172:                eprocp = SELF;
        !           173:                eveinit();
        !           174:                CHIRP('=');
        !           175:        }
        !           176: #else
        !           177:        if ((sp=salloc((fsize_t)UPASIZE, SFNCLR|SFNSWP)) == NULL)
        !           178:                panic("Cannot allocate user area");
        !           179:        if ((iprocp=process(idle))==NULL || (eprocp=process(NULL))==NULL)
        !           180:                panic("Cannot create process");
        !           181:        eveinit(sp);
        !           182:        fsminit();
        !           183: #endif
        !           184:        CHIRP('c');
        !           185: }
        !           186: 
        !           187: /*
        !           188:  * atcount()
        !           189:  *
        !           190:  * Read CMOS and return 0,1, or 2 as number of installed "at" drives.
        !           191:  */
        !           192: void
        !           193: atcount()
        !           194: {
        !           195:        int u;
        !           196:        n_atdr = 0;
        !           197: 
        !           198:         if (PS1DRIVES > 0)
        !           199:                n_atdr = PS1DRIVES;
        !           200:        else {
        !           201:                /*
        !           202:                 * Count nonzero drive types.
        !           203:                 *
        !           204:                 *      High nibble of CMOS 0x12 is drive 0's type.
        !           205:                 *      Low  nibble of CMOS 0x12 is drive 1's type.
        !           206:                 */
        !           207:                u = read_cmos(0x12);
        !           208:                if (u & 0x00F0)
        !           209:                        n_atdr++;
        !           210:                if (u & 0x000F)
        !           211:                        n_atdr++;
        !           212:        }
        !           213: }
        !           214: 
        !           215: /*
        !           216:  * rpdev()
        !           217:  *
        !           218:  * If rootdev is zero, try to use data from tboot to set it.
        !           219:  * If pipedev is zero, make it 0x883 if ronflag == 1, else make it rootdev.
        !           220:  * Call rpdev() AFTER calling atcount().
        !           221:  */
        !           222: static void rpdev()
        !           223: {
        !           224:        FIFO *ffp;
        !           225:        typed_space *tp;
        !           226:        int found;
        !           227:        extern typed_space boot_gift;
        !           228:        unsigned root_ptn, root_drv, root_maj, root_min;
        !           229: 
        !           230:        if (rootdev == makedev(0,0)) {
        !           231:                found = 0;
        !           232:                if (ffp = fifo_open(&boot_gift, 0)) {
        !           233:                        int rc;
        !           234: 
        !           235:                        for (rc = 0; !found && (tp = fifo_read(ffp)); rc++) {
        !           236:                                BIOS_ROOTDEV *brp = (BIOS_ROOTDEV *)tp->ts_data;
        !           237:                                if (T_BIOS_ROOTDEV == tp->ts_type) {
        !           238:                                        found = 1;
        !           239:                                        root_ptn = brp->rd_partition;
        !           240:                                }
        !           241:                        }
        !           242:                        fifo_close(ffp);
        !           243: 
        !           244:                }
        !           245: 
        !           246:                if (found) {
        !           247:                        /*
        !           248:                         * root_drv = BIOS # of root drive
        !           249:                         * root_ptn = partition # in range 0..3
        !           250:                         * if root on second "at" device, add 4 to minor #
        !           251:                         * if root on second scsi device, add 16 to minor #
        !           252:                         */
        !           253:                        root_drv = root_ptn/NPARTN;
        !           254:                        root_ptn %= NPARTN;
        !           255:                        if (n_atdr > root_drv) {
        !           256:                                root_maj = AT_MAJOR;
        !           257:                                root_min = root_drv*NPARTN + root_ptn;
        !           258:                        } else { /* root on SCSI device */
        !           259:                                root_maj = SCSI_MAJOR;
        !           260:                                root_min = (root_drv-n_atdr)*16 + root_ptn;
        !           261:                        }
        !           262:                        rootdev = makedev(root_maj, root_min);
        !           263:                        printf("rootdev=(%d,%d)\n", root_maj, root_min);
        !           264:                }
        !           265:        }
        !           266:        if (pipedev == makedev(0,0)) {
        !           267:                if (ronflag)
        !           268:                        pipedev = makedev(RM_MAJOR, 0x83);
        !           269:                else
        !           270:                        pipedev = rootdev;
        !           271:                printf("pipedev=(%d,%d)\n", (pipedev>>8)&0xff, pipedev&0xff);
        !           272:        }
        !           273: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.