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.1 (Berkeley) 12/13/92 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-25" 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->argc = 0; 65 kiff->argv = (char **) 0; 66 67 i = (int) kiff->maxaddr + 1; 68 printf("Physical Memory = 0x%x ", i); 69 i >>= 20; 70 printf("(%d MB)\n", i); 71 printf("\n"); 72 73 bcopy(VERS_LOCAL, prompt, sizeof(VERS_LOCAL)); 74 prompt[sizeof(VERS_LOCAL) - 1] = '>'; 75 prompt[sizeof(VERS_LOCAL)] = ' '; 76 prompt[sizeof(VERS_LOCAL) + 1] = 0; 77 78 /* 79 * IO configuration 80 */ 81 82 find_devs(); 83 configure(); 84 printf("\n"); 85 86 howto = reorder_dipsw(dipsw2); 87 88 if ((howto & 0xFE) == 0) { 89 printf("auto-boot %s\n", default_file); 90 91 i = open(default_file, 0); 92 if (i >= 0) { 93 bootunix(howto, devtype, i); 94 close(i); 95 } 96 } 97 98 /* 99 * Main Loop 100 */ 101 102 do { 103 bzero(buffer, BUFFSIZE); 104 if (getline(prompt, buffer) > 0) { 105 argc = getargs(buffer, argv, sizeof(argv)/sizeof(char *)); 106 107 status = parse(argc, argv); 108 if (status == ST_NOTFOUND) 109 printf("Command \"%s\" is not found !!\n", argv[0]); 110 } 111 } while(status != ST_EXIT); 112 113 exit(); 114 } 115 116 int 117 reorder_dipsw(dipsw) 118 int dipsw; 119 { 120 int i, sw = 0; 121 122 for (i = 0; i < 8; i++) { 123 if ((dipsw & 0x01) == 0) 124 sw += 1; 125 126 if (i == 7) 127 break; 128 129 sw <<= 1; 130 dipsw >>= 1; 131 } 132 133 return(sw); 134 } 135 136 /* 137 int 138 exit() 139 { 140 ROM_abort(); 141 } 142 */ 143