|
|
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.4 92/01/22 09:48:40 bin ! 15: * update by hal... post 321 beta ! 16: * ! 17: * Revision 1.4 92/01/21 16:08:34 hal ! 18: * Merged with 386 main.c. Call read_cmos(). ! 19: * ! 20: * Revision 1.3 92/01/15 10:16:02 hal ! 21: * Trivial banner change. ! 22: * ! 23: * Revision 1.2 88/06/29 12:00:29 src ! 24: * Real/Protected mode status now printed during boot sequence. ! 25: * Three part serial numbers now supported, moved to optional fourth line. ! 26: * ! 27: * Revision 1.1 88/03/24 16:13:58 src ! 28: * Initial revision ! 29: * ! 30: * 87/04/09 Allan Cornish /usr/src/sys/coh/main.c ! 31: * Serial numbers changed to support group. ! 32: * ! 33: * 87/01/05 Allan Cornish /usr/src/sys/coh/main.c ! 34: * Copyright notice revised to include 1987. ! 35: */ ! 36: ! 37: /* ! 38: * Includes. ! 39: */ ! 40: #include <sys/coherent.h> ! 41: #include <sys/devices.h> ! 42: #include <sys/fdisk.h> ! 43: #include <sys/proc.h> ! 44: #include <sys/seg.h> ! 45: #include <sys/stat.h> ! 46: #include <sys/typed.h> ! 47: #include <sys/uproc.h> ! 48: ! 49: /* ! 50: * Definitions. ! 51: * Constants. ! 52: * Macros with argument lists. ! 53: * Typedefs. ! 54: * Enums. ! 55: */ ! 56: #ifndef VERSION /* This should be specified at compile time */ ! 57: #define VERSION "..." ! 58: #endif ! 59: typedef unsigned char uchar; ! 60: typedef unsigned int uint; ! 61: typedef unsigned long ulong; ! 62: ! 63: /* ! 64: * Functions. ! 65: * Import Functions. ! 66: * Export Functions. ! 67: * Local Functions. ! 68: */ ! 69: int read_cmos(); ! 70: ! 71: static void atcount(); ! 72: static void rpdev(); ! 73: ! 74: /* ! 75: * Global Data. ! 76: * Import Variables. ! 77: * Export Variables. ! 78: * Local Variables. ! 79: */ ! 80: extern dev_t rootdev; ! 81: extern dev_t pipedev; ! 82: extern int ronflag; ! 83: ! 84: short n_atdr; ! 85: char version[] = VERSION; ! 86: #ifdef _I386 ! 87: char copyright[] = "\ ! 88: Copyright 1982,1992 Mark Williams Company\n\ ! 89: Copyright 1991 Inst. O'Donnell, Bievres, France\n"; ! 90: #else ! 91: char copyright[] = "\ ! 92: Copyright 1982,1992 Mark Williams Company\n"; ! 93: #endif ! 94: ! 95: #ifdef _I386 ! 96: unsigned serialnum0 = 0; ! 97: unsigned serialnum1 = 0; ! 98: static long sntime = 870409113L; ! 99: static long snm = 0; ! 100: static long snmcopy = 0; ! 101: #else ! 102: unsigned long _entry = 0; /* really the serial number */ ! 103: unsigned long __ = 0; /* really the serial number also */ ! 104: #endif ! 105: ! 106: main() ! 107: { ! 108: register SEG *sp; ! 109: #ifndef _I386 ! 110: extern int realmode; ! 111: #endif ! 112: ! 113: u.u_error = 0; ! 114: bufinit(); ! 115: cltinit(); ! 116: pcsinit(); ! 117: seginit(); ! 118: atcount(); ! 119: rpdev(); ! 120: devinit(); ! 121: #ifdef _I386 ! 122: printf("\nCOHERENT Version %s - 386 Mode (mem=%u Kbytes)\n", ! 123: version, ctob(allocno())/1024); ! 124: #else ! 125: printf("\Mark Williams COHERENT Version %s - %s Mode (mem=%u Kbytes)\n", ! 126: version, (realmode ? "Real" : "Protected"), msize ); ! 127: #endif ! 128: printf(copyright); ! 129: ! 130: #ifdef _I386 ! 131: if ( snm ) { ! 132: printf("Serial Number %u", (unsigned) snm ); ! 133: if ( serialnum0 ) { ! 134: printf(":%u", (unsigned) serialnum0 ); ! 135: if ( serialnum1 ) ! 136: printf(":%u", (unsigned) serialnum1 ); ! 137: } ! 138: printf("\n"); ! 139: } ! 140: ! 141: /* ! 142: * Verify correct serial number ! 143: */ ! 144: if (snm != snmcopy) ! 145: panic("Verification error - call Mark Williams Company at 1-800-MWC-1700\n"); ! 146: #else ! 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-800-MARK-WMS\n"); ! 157: #endif ! 158: ! 159: /* ! 160: * Turn on clock, mount root device, start off processes ! 161: * and return. ! 162: */ ! 163: batflag = 1; ! 164: #ifdef _I386 ! 165: iprocp = SELF; ! 166: if (pfork()) { ! 167: idle(); ! 168: } else { ! 169: fsminit(); ! 170: eprocp = SELF; ! 171: eveinit(); ! 172: } ! 173: #else ! 174: if ((sp=salloc((fsize_t)UPASIZE, SFNCLR|SFNSWP)) == NULL) ! 175: panic("Cannot allocate user area"); ! 176: if ((iprocp=process(idle))==NULL || (eprocp=process(NULL))==NULL) ! 177: panic("Cannot create process"); ! 178: eveinit(sp); ! 179: fsminit(); ! 180: #endif ! 181: } ! 182: ! 183: /* ! 184: * atcount() ! 185: * ! 186: * Read CMOS and return 0,1, or 2 as number of installed "at" drives. ! 187: */ ! 188: static void atcount() ! 189: { ! 190: int u; ! 191: n_atdr = 0; ! 192: ! 193: /* ! 194: * Count nonzero drive types. ! 195: * ! 196: * High nibble of CMOS 0x12 is drive 0's type. ! 197: * Low nibble of CMOS 0x12 is drive 1's type. ! 198: */ ! 199: u = read_cmos(0x12); ! 200: if (u & 0x00F0) ! 201: n_atdr++; ! 202: if (u & 0x000F) ! 203: n_atdr++; ! 204: } ! 205: ! 206: /* ! 207: * rpdev() ! 208: * ! 209: * If rootdev is zero, try to use data from tboot to set it. ! 210: * If pipedev is zero, make it 0x883 if ronflag == 1, else make it rootdev. ! 211: * Call rpdev() AFTER calling atcount(). ! 212: */ ! 213: static void rpdev() ! 214: { ! 215: FIFO *ffp; ! 216: typed_space *tp; ! 217: int found; ! 218: extern typed_space boot_gift; ! 219: unsigned root_ptn, root_drv, root_maj, root_min; ! 220: ! 221: if (rootdev == makedev(0,0)) { ! 222: found = 0; ! 223: if (F_NULL != (ffp = fifo_open(&boot_gift, 0))) { ! 224: ! 225: for (; !found && T_NULL != (tp = fifo_read(ffp)); ) { ! 226: BIOS_ROOTDEV *brp = (BIOS_ROOTDEV *)tp->ts_data; ! 227: if (T_BIOS_ROOTDEV == tp->ts_type) { ! 228: found = 1; ! 229: root_ptn = brp->rd_partition; ! 230: } ! 231: } ! 232: fifo_close(ffp); ! 233: ! 234: } ! 235: if (found) { ! 236: /* ! 237: * root_drv = BIOS # of root drive ! 238: * root_ptn = partition # in range 0..3 ! 239: * if root on second "at" device, add 4 to minor # ! 240: * if root on second scsi device, add 16 to minor # ! 241: */ ! 242: root_drv = root_ptn/NPARTN; ! 243: root_ptn %= NPARTN; ! 244: if (n_atdr > root_drv) { ! 245: root_maj = AT_MAJOR; ! 246: root_min = root_drv*NPARTN + root_ptn; ! 247: } else { /* root on SCSI device */ ! 248: root_maj = SCSI_MAJOR; ! 249: root_min = (root_drv-n_atdr)*16 + root_ptn; ! 250: } ! 251: rootdev = makedev(root_maj, root_min); ! 252: printf("rootdev=(%d,%d)\n", root_maj, root_min); ! 253: } ! 254: } ! 255: if (pipedev == makedev(0,0)) { ! 256: if (ronflag) ! 257: pipedev = makedev(RM_MAJOR, 0x83); ! 258: else ! 259: pipedev = rootdev; ! 260: printf("pipedev=(%d,%d)\n", (pipedev>>8)&0xff, pipedev&0xff); ! 261: } ! 262: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.