xref: /original-bsd/sys/luna68k/stand/init_main.c (revision 95ecee29)
1 /*
2  * Copyright (c) 1992 OMRON Corporation.
3  * Copyright (c) 1992, 1993
4  *	The Regents of the University of California.  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	8.2 (Berkeley) 08/15/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-31"
27 
28 extern int howto;
29 extern int devtype;
30        int nplane;
31 
32 /* KIFF */
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 	nplane   = get_plane_numbers();
60 
61 	cninit();
62 
63 	printf("\n\nStinger ver 0.0 [%s]\n\n", VERS_LOCAL);
64 
65 	kiff->maxaddr = (caddr_t) (ROM_memsize -1);
66 	kiff->dipsw   = ~((dipsw2 << 8) | dipsw1) & 0xFFFF;
67 	kiff->plane   = nplane;
68 
69 	i = (int) kiff->maxaddr + 1;
70 	printf("Physical Memory = 0x%x  ", i);
71 	i >>= 20;
72 	printf("(%d MB)\n", i);
73 	printf("\n");
74 
75 	bcopy(VERS_LOCAL, prompt, sizeof(VERS_LOCAL));
76 	prompt[sizeof(VERS_LOCAL) - 1]	= '>';
77 	prompt[sizeof(VERS_LOCAL)]	= ' ';
78 	prompt[sizeof(VERS_LOCAL) + 1]	= 0;
79 
80 	/*
81 	 * IO configuration
82 	 */
83 
84 	find_devs();
85 	configure();
86 	printf("\n");
87 
88 	howto = reorder_dipsw(dipsw2);
89 
90 	if ((howto & 0xFE) == 0) {
91 		printf("auto-boot %s\n", default_file);
92 
93 		i = open(default_file, 0);
94 		if (i >= 0) {
95 			bootunix(howto, devtype, i);
96 			close(i);
97 		}
98 	}
99 
100 	/*
101 	 * Main Loop
102 	 */
103 
104 	do {
105 		bzero(buffer, BUFFSIZE);
106 		if (getline(prompt, buffer) > 0) {
107 			argc = getargs(buffer, argv, sizeof(argv)/sizeof(char *));
108 
109 			status = parse(argc, argv);
110 			if (status == ST_NOTFOUND)
111 				printf("Command \"%s\" is not found !!\n", argv[0]);
112 		}
113 	} while(status != ST_EXIT);
114 
115 	exit();
116 }
117 
118 int
119 get_plane_numbers()
120 {
121 	register int r = ROM_plane;
122 	register int n = 0;
123 
124 	for (; r ; r >>= 1)
125 		if (r & 0x1)
126 			n++;
127 
128 	return(n);
129 }
130 
131 int
132 reorder_dipsw(dipsw)
133 	int dipsw;
134 {
135 	int i, sw = 0;
136 
137 	for (i = 0; i < 8; i++) {
138 		if ((dipsw & 0x01) == 0)
139 			sw += 1;
140 
141 		if (i == 7)
142 			break;
143 
144 		sw <<= 1;
145 		dipsw >>= 1;
146 	}
147 
148 	return(sw);
149 }
150