xref: /csrg-svn/sys/luna68k/stand/init_main.c (revision 64271)
157086Sakito /*
257086Sakito  * Copyright (c) 1992 OMRON Corporation.
363199Sbostic  * Copyright (c) 1992, 1993
463199Sbostic  *	The Regents of the University of California.  All rights reserved.
557086Sakito  *
657086Sakito  * This code is derived from software contributed to Berkeley by
757086Sakito  * OMRON Corporation.
857086Sakito  *
957086Sakito  * %sccs.include.redist.c%
1057086Sakito  *
11*64271Smckusick  *	@(#)init_main.c	8.2 (Berkeley) 08/15/93
1257086Sakito  */
1357086Sakito 
1457086Sakito #include <sys/param.h>
1557086Sakito #include <sys/systm.h>
1657086Sakito #include <machine/cpu.h>
1757086Sakito #include <machine/stinger.h>
1857086Sakito #include <luna68k/stand/romvec.h>
1957086Sakito #include <luna68k/stand/status.h>
2057086Sakito 
2157086Sakito extern int cpuspeed;
2257086Sakito extern int dipsw1, dipsw2;
2357086Sakito 
2457086Sakito extern char default_file[];
2557086Sakito 
26*64271Smckusick #define	VERS_LOCAL	"Phase-31"
2757086Sakito 
2857086Sakito extern int howto;
2957086Sakito extern int devtype;
3057618Sakito        int nplane;
3157086Sakito 
3257086Sakito /* KIFF */
3357086Sakito 
3457086Sakito struct KernInter  KIFF;
3557086Sakito struct KernInter *kiff = &KIFF;
3657086Sakito 
3757086Sakito /* for command parser */
3857086Sakito 
3957086Sakito #define BUFFSIZE 100
4057086Sakito #define MAXARGS  30
4157086Sakito 
4257086Sakito char buffer[BUFFSIZE];
4357086Sakito 
4457086Sakito int   argc;
4557086Sakito char *argv[MAXARGS];
4657086Sakito 
4757086Sakito char  prompt[16];
4857086Sakito 
main()4957086Sakito main()
5057086Sakito {
5157086Sakito 	int i, status;
5257086Sakito 	int *p;
5357086Sakito 
5457086Sakito 	/*
5557086Sakito 	 * Initialize the console before we print anything out.
5657086Sakito 	 */
5757086Sakito 	cpuspeed = MHZ_25;				/* for DELAY() macro */
5857086Sakito 
5957618Sakito 	nplane   = get_plane_numbers();
6057618Sakito 
6157086Sakito 	cninit();
6257086Sakito 
6357086Sakito 	printf("\n\nStinger ver 0.0 [%s]\n\n", VERS_LOCAL);
6457086Sakito 
6557086Sakito 	kiff->maxaddr = (caddr_t) (ROM_memsize -1);
6657594Sakito 	kiff->dipsw   = ~((dipsw2 << 8) | dipsw1) & 0xFFFF;
6757618Sakito 	kiff->plane   = nplane;
6857086Sakito 
6957086Sakito 	i = (int) kiff->maxaddr + 1;
7057086Sakito 	printf("Physical Memory = 0x%x  ", i);
7157086Sakito 	i >>= 20;
7257086Sakito 	printf("(%d MB)\n", i);
7357086Sakito 	printf("\n");
7457086Sakito 
7557086Sakito 	bcopy(VERS_LOCAL, prompt, sizeof(VERS_LOCAL));
7657086Sakito 	prompt[sizeof(VERS_LOCAL) - 1]	= '>';
7757086Sakito 	prompt[sizeof(VERS_LOCAL)]	= ' ';
7857086Sakito 	prompt[sizeof(VERS_LOCAL) + 1]	= 0;
7957086Sakito 
8057086Sakito 	/*
8157086Sakito 	 * IO configuration
8257086Sakito 	 */
8357086Sakito 
8457086Sakito 	find_devs();
8557086Sakito 	configure();
8657086Sakito 	printf("\n");
8757086Sakito 
8857086Sakito 	howto = reorder_dipsw(dipsw2);
8957086Sakito 
9057086Sakito 	if ((howto & 0xFE) == 0) {
9157086Sakito 		printf("auto-boot %s\n", default_file);
9257086Sakito 
9357086Sakito 		i = open(default_file, 0);
9457086Sakito 		if (i >= 0) {
9557086Sakito 			bootunix(howto, devtype, i);
9657086Sakito 			close(i);
9757086Sakito 		}
9857086Sakito 	}
9957086Sakito 
10057086Sakito 	/*
10157086Sakito 	 * Main Loop
10257086Sakito 	 */
10357086Sakito 
10457086Sakito 	do {
10557086Sakito 		bzero(buffer, BUFFSIZE);
10657086Sakito 		if (getline(prompt, buffer) > 0) {
10757086Sakito 			argc = getargs(buffer, argv, sizeof(argv)/sizeof(char *));
10857086Sakito 
10957086Sakito 			status = parse(argc, argv);
11057086Sakito 			if (status == ST_NOTFOUND)
11157086Sakito 				printf("Command \"%s\" is not found !!\n", argv[0]);
11257086Sakito 		}
11357086Sakito 	} while(status != ST_EXIT);
11457086Sakito 
11557086Sakito 	exit();
11657086Sakito }
11757086Sakito 
11857086Sakito int
get_plane_numbers()11957618Sakito get_plane_numbers()
12057618Sakito {
12157618Sakito 	register int r = ROM_plane;
12257618Sakito 	register int n = 0;
12357618Sakito 
12457618Sakito 	for (; r ; r >>= 1)
12557618Sakito 		if (r & 0x1)
12657618Sakito 			n++;
12757618Sakito 
12857618Sakito 	return(n);
12957618Sakito }
13057618Sakito 
13157618Sakito int
reorder_dipsw(dipsw)13257086Sakito reorder_dipsw(dipsw)
13357086Sakito 	int dipsw;
13457086Sakito {
13557086Sakito 	int i, sw = 0;
13657086Sakito 
13757086Sakito 	for (i = 0; i < 8; i++) {
13857086Sakito 		if ((dipsw & 0x01) == 0)
13957086Sakito 			sw += 1;
14057086Sakito 
14157086Sakito 		if (i == 7)
14257086Sakito 			break;
14357086Sakito 
14457086Sakito 		sw <<= 1;
14557086Sakito 		dipsw >>= 1;
14657086Sakito 	}
14757086Sakito 
14857086Sakito 	return(sw);
14957086Sakito }
150