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