|
|
1.1 ! root 1: /* ! 2: * File: main.c ! 3: */ ! 4: ! 5: /* ! 6: * Includes. ! 7: */ ! 8: #include <kernel/param.h> ! 9: #include <kernel/typed.h> ! 10: ! 11: #include <sys/coherent.h> ! 12: #include <sys/devices.h> ! 13: #include <sys/fdisk.h> ! 14: #include <sys/proc.h> ! 15: #include <sys/seg.h> ! 16: #include <sys/stat.h> ! 17: ! 18: /* ! 19: * Definitions. ! 20: * Constants. ! 21: * Macros with argument lists. ! 22: * Typedefs. ! 23: * Enums. ! 24: */ ! 25: #ifndef VERSION /* This should be specified at compile time */ ! 26: #define VERSION "..." ! 27: #endif ! 28: #ifndef RELEASE ! 29: #define RELEASE "0" ! 30: #endif ! 31: ! 32: /* ! 33: * Functions. ! 34: * Import Functions. ! 35: * Export Functions. ! 36: * Local Functions. ! 37: */ ! 38: int read_cmos(); ! 39: ! 40: static void set_at_drive_ct(); ! 41: static void rpdev(); ! 42: ! 43: /* ! 44: * Global Data. ! 45: * Import Variables. ! 46: * Export Variables. ! 47: * Local Variables. ! 48: */ ! 49: ! 50: /* ! 51: * Configurable variables - see ker/conf/cohmain/Space.c ! 52: * ! 53: * at_drive_ct must be initialized at the number of "at" drives for PS1 ! 54: * and ValuePoint systems as the number of hard drives is not in CMOS. ! 55: */ ! 56: extern short at_drive_ct; ! 57: ! 58: extern dev_t rootdev; ! 59: extern dev_t pipedev; ! 60: extern int ronflag; ! 61: extern int PHYS_MEM; ! 62: extern unsigned long _entry; /* really the serial number */ ! 63: extern unsigned long _bar; /* really the serial number also */ ! 64: ! 65: /* End of configurable variables. */ ! 66: ! 67: char version[] = VERSION; ! 68: char release[] = RELEASE; ! 69: char copyright[] = "Copyright 1982,1993 Mark Williams Company\n"; ! 70: ! 71: #ifdef TRACER ! 72: ! 73: /* ! 74: * Take a checksum of the kernel text. ! 75: */ ! 76: static unsigned theSum; ! 77: ! 78: static unsigned ! 79: checkSum () ! 80: { ! 81: extern char stext [], __end_text []; ! 82: char * tmp = stext; ! 83: unsigned sum = 0; ! 84: while (tmp != __end_text) ! 85: sum = sum * 5 + * tmp ++; ! 86: return sum; ! 87: } ! 88: ! 89: /* ! 90: * Check the current kernel text segment against the boot checksum ! 91: */ ! 92: ! 93: int ! 94: checkTheSum () ! 95: { ! 96: unsigned newSum; ! 97: ! 98: if ((newSum = checkSum ()) != theSum) ! 99: panic ("Kernel checksum failure, %x vs %x", theSum, newSum); ! 100: return 0; ! 101: } ! 102: #endif /* defined (TRACER) */ ! 103: ! 104: ! 105: main() ! 106: { ! 107: extern int BPFMAX; ! 108: char * ndpTypeName(); ! 109: extern int (*ndpEmFn)(); ! 110: extern short ndpType; ! 111: ! 112: #ifdef TRACER ! 113: theSum = checkSum (); ! 114: #endif ! 115: ! 116: CHIRP('a'); ! 117: while (& u + 1 < & u) { ! 118: _CHIRP ('t', 8); ! 119: _CHIRP ('k', 6); ! 120: _CHIRP ('u', 4); ! 121: _CHIRP ('h', 2); ! 122: _CHIRP ('p', 0); ! 123: } ! 124: ! 125: #if _I386 ! 126: wrNdpUser(0); ! 127: wrNdpSaved(0); ! 128: u.u_bpfmax = BPFMAX; ! 129: #endif ! 130: u.u_error = 0; ! 131: bufinit(); ! 132: _CHIRP('0', 156); ! 133: cltinit(); ! 134: _CHIRP('1', 156); ! 135: pcsinit(); ! 136: _CHIRP('2', 156); ! 137: seginit(); ! 138: _CHIRP('3', 156); ! 139: set_at_drive_ct(); ! 140: _CHIRP('4', 156); ! 141: rpdev(); ! 142: _CHIRP('5', 156); ! 143: devinit(); ! 144: _CHIRP('6', 156); ! 145: rlinit(); ! 146: _CHIRP('7', 156); ! 147: ! 148: putchar_init(); ! 149: _CHIRP('8', 156); ! 150: printf("*** COHERENT Version %s - 386 Mode. %uKB free memory. ***\n", ! 151: release, ctob(allocno())/1024); ! 152: ! 153: /* Print default display type, based on BIOS int11h call. */ ! 154: if ((int11 () & 0x30) == 0x30) ! 155: printf ("Monochrome. "); ! 156: else ! 157: printf ("Color. "); ! 158: ! 159: /* Display FP coprocessor/emulation setting. */ ! 160: senseNdp (); ! 161: printf (ndpTypeName ()); ! 162: if (ndpType <= 1 && ndpEmFn) ! 163: printf ("FP Emulation. "); ! 164: ! 165: /* Display general system configuration parameters. */ ! 166: printf ("%u buffers. %u buckets. %u clists.\n", ! 167: NBUF, NHASH, NCLIST); ! 168: printf ("%uKB kalloc pool. %u KB phys pool.\n", ! 169: ALLSIZE / 1024, PHYS_MEM / 1024); ! 170: printf (copyright); ! 171: ! 172: if (_entry) { ! 173: printf ("Serial Number "); ! 174: printf ("%lu\n", _entry); ! 175: } ! 176: ! 177: /* ! 178: * Verify correct serial number ! 179: */ ! 180: if (_entry != _bar) ! 181: panic("Verification error - call Mark Williams Company at +1-708-291-6700\n"); ! 182: ! 183: /* ! 184: * Turn on clock, mount root device, start off processes ! 185: * and return. ! 186: */ ! 187: batflag = 1; ! 188: ! 189: iprocp = SELF; ! 190: CHIRP('b'); ! 191: if (pfork()) { ! 192: CHIRP('i'); ! 193: idle(); ! 194: } else { ! 195: fsminit(); ! 196: CHIRP('-'); ! 197: eprocp = SELF; ! 198: eveinit(); ! 199: CHIRP('='); ! 200: } ! 201: ! 202: #ifdef TRACER ! 203: checkTheSum (); ! 204: #endif ! 205: CHIRP ('c'); ! 206: } ! 207: ! 208: /* ! 209: * set_at_drive_ct() ! 210: * ! 211: * If "at_drive_ct" is already nonzero, don't change it. ! 212: * Else, read CMOS and return 0,1, or 2 as number of installed "at" drives. ! 213: */ ! 214: void ! 215: set_at_drive_ct() ! 216: { ! 217: int u; ! 218: ! 219: if (at_drive_ct <= 0) { ! 220: /* ! 221: * Count nonzero drive types. ! 222: * ! 223: * High nibble of CMOS 0x12 is drive 0's type. ! 224: * Low nibble of CMOS 0x12 is drive 1's type. ! 225: */ ! 226: u = read_cmos(0x12); ! 227: if (u & 0x00F0) ! 228: at_drive_ct++; ! 229: if (u & 0x000F) ! 230: at_drive_ct++; ! 231: } ! 232: } ! 233: ! 234: /* ! 235: * rpdev() ! 236: * ! 237: * If rootdev is zero, try to use data from tboot to set it. ! 238: * If pipedev is zero, make it 0x883 if ronflag == 1, else make it rootdev. ! 239: * Call rpdev() AFTER calling set_at_drive_ct(). ! 240: */ ! 241: static void rpdev() ! 242: { ! 243: FIFO *ffp; ! 244: typed_space *tp; ! 245: int found; ! 246: extern typed_space boot_gift; ! 247: unsigned root_ptn, root_drv, root_maj, root_min; ! 248: ! 249: if (rootdev == makedev(0,0)) { ! 250: found = 0; ! 251: if (ffp = fifo_open(&boot_gift, 0)) { ! 252: int rc; ! 253: ! 254: for (rc = 0; !found && (tp = fifo_read(ffp)); rc++) { ! 255: BIOS_ROOTDEV *brp = (BIOS_ROOTDEV *)tp->ts_data; ! 256: if (T_BIOS_ROOTDEV == tp->ts_type) { ! 257: found = 1; ! 258: root_ptn = brp->rd_partition; ! 259: } ! 260: } ! 261: fifo_close(ffp); ! 262: ! 263: } ! 264: ! 265: if (found) { ! 266: /* ! 267: * root_drv = BIOS # of root drive ! 268: * root_ptn = partition # in range 0..3 ! 269: * if root on second "at" device, add 4 to minor # ! 270: * if root on second scsi device, add 16 to minor # ! 271: */ ! 272: root_drv = root_ptn/NPARTN; ! 273: root_ptn %= NPARTN; ! 274: if (at_drive_ct > root_drv) { ! 275: root_maj = AT_MAJOR; ! 276: root_min = root_drv*NPARTN + root_ptn; ! 277: } else { /* root on SCSI device */ ! 278: root_maj = SCSI_MAJOR; ! 279: root_min = (root_drv-at_drive_ct)*16 + root_ptn; ! 280: } ! 281: rootdev = makedev(root_maj, root_min); ! 282: printf("rootdev=(%d,%d)\n", root_maj, root_min); ! 283: } ! 284: } ! 285: ! 286: if (pipedev == makedev(0,0)) { ! 287: if (ronflag) ! 288: pipedev = makedev(RM_MAJOR, 0x83); ! 289: else ! 290: pipedev = rootdev; ! 291: printf("pipedev=(%d,%d)\n", (pipedev>>8)&0xff, pipedev&0xff); ! 292: } ! 293: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.