1 /* 2 * Copyright (c) 1992 OMRON Corporation. 3 * Copyright (c) 1992 The Regents of the University of California. 4 * All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * OMRON Corporation. 8 * 9 * %sccs.include.redist.c% 10 * 11 * @(#)init_main.c 7.3 (Berkeley) 01/18/93 12 */ 13 14 #include <sys/param.h> 15 #include <sys/systm.h> 16 #include <machine/cpu.h> 17 #include <machine/stinger.h> 18 #include <luna68k/stand/romvec.h> 19 #include <luna68k/stand/status.h> 20 21 extern int cpuspeed; 22 extern int dipsw1, dipsw2; 23 24 extern char default_file[]; 25 26 #define VERS_LOCAL "Phase-27" 27 28 extern int howto; 29 extern int devtype; 30 31 /* KIFF */ 32 33 34 struct KernInter KIFF; 35 struct KernInter *kiff = &KIFF; 36 37 /* for command parser */ 38 39 #define BUFFSIZE 100 40 #define MAXARGS 30 41 42 char buffer[BUFFSIZE]; 43 44 int argc; 45 char *argv[MAXARGS]; 46 47 char prompt[16]; 48 49 main() 50 { 51 int i, status; 52 int *p; 53 54 /* 55 * Initialize the console before we print anything out. 56 */ 57 cpuspeed = MHZ_25; /* for DELAY() macro */ 58 59 cninit(); 60 61 printf("\n\nStinger ver 0.0 [%s]\n\n", VERS_LOCAL); 62 63 kiff->maxaddr = (caddr_t) (ROM_memsize -1); 64 kiff->dipsw = ~((dipsw2 << 8) | dipsw1) & 0xFFFF; 65 66 i = (int) kiff->maxaddr + 1; 67 printf("Physical Memory = 0x%x ", i); 68 i >>= 20; 69 printf("(%d MB)\n", i); 70 printf("\n"); 71 72 bcopy(VERS_LOCAL, prompt, sizeof(VERS_LOCAL)); 73 prompt[sizeof(VERS_LOCAL) - 1] = '>'; 74 prompt[sizeof(VERS_LOCAL)] = ' '; 75 prompt[sizeof(VERS_LOCAL) + 1] = 0; 76 77 /* 78 * IO configuration 79 */ 80 81 find_devs(); 82 configure(); 83 printf("\n"); 84 85 howto = reorder_dipsw(dipsw2); 86 87 if ((howto & 0xFE) == 0) { 88 printf("auto-boot %s\n", default_file); 89 90 i = open(default_file, 0); 91 if (i >= 0) { 92 bootunix(howto, devtype, i); 93 close(i); 94 } 95 } 96 97 /* 98 * Main Loop 99 */ 100 101 do { 102 bzero(buffer, BUFFSIZE); 103 if (getline(prompt, buffer) > 0) { 104 argc = getargs(buffer, argv, sizeof(argv)/sizeof(char *)); 105 106 status = parse(argc, argv); 107 if (status == ST_NOTFOUND) 108 printf("Command \"%s\" is not found !!\n", argv[0]); 109 } 110 } while(status != ST_EXIT); 111 112 exit(); 113 } 114 115 int 116 reorder_dipsw(dipsw) 117 int dipsw; 118 { 119 int i, sw = 0; 120 121 for (i = 0; i < 8; i++) { 122 if ((dipsw & 0x01) == 0) 123 sw += 1; 124 125 if (i == 7) 126 break; 127 128 sw <<= 1; 129 dipsw >>= 1; 130 } 131 132 return(sw); 133 } 134 135 /* 136 int 137 exit() 138 { 139 ROM_abort(); 140 } 141 */ 142