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