Home | History | Annotate | Line # | Download | only in common
machdep.c revision 1.2
      1 /*	$NetBSD: machdep.c,v 1.2 1997/04/27 21:13:55 thorpej Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1988 University of Utah.
      5  * Copyright (c) 1982, 1986, 1990, 1993
      6  *	The Regents of the University of California.  All rights reserved.
      7  *
      8  * This code is derived from software contributed to Berkeley by
      9  * the Systems Programming Group of the University of Utah Computer
     10  * Science Department.
     11  *
     12  * Redistribution and use in source and binary forms, with or without
     13  * modification, are permitted provided that the following conditions
     14  * are met:
     15  * 1. Redistributions of source code must retain the above copyright
     16  *    notice, this list of conditions and the following disclaimer.
     17  * 2. Redistributions in binary form must reproduce the above copyright
     18  *    notice, this list of conditions and the following disclaimer in the
     19  *    documentation and/or other materials provided with the distribution.
     20  * 3. All advertising materials mentioning features or use of this software
     21  *    must display the following acknowledgement:
     22  *	This product includes software developed by the University of
     23  *	California, Berkeley and its contributors.
     24  * 4. Neither the name of the University nor the names of its contributors
     25  *    may be used to endorse or promote products derived from this software
     26  *    without specific prior written permission.
     27  *
     28  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     29  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     30  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     31  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     32  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     33  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     34  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     35  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     36  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     37  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     38  * SUCH DAMAGE.
     39  *
     40  * from: Utah $Hdr: machdep.c 1.10 92/06/18
     41  *
     42  *	@(#)machdep.c	8.1 (Berkeley) 6/10/93
     43  */
     44 
     45 #include <sys/param.h>
     46 #include "samachdep.h"
     47 
     48 char *
     49 getmachineid()
     50 {
     51 	extern int machineid;
     52 	char *cp;
     53 
     54 	switch (machineid) {
     55 	case HP_320:
     56 		cp = "320"; break;
     57 	case HP_330:
     58 		cp = "318/319/330"; break;
     59 	case HP_340:
     60 		cp = "340"; break;
     61 	case HP_345:
     62 		cp = "345"; break;
     63 	case HP_350:
     64 		cp = "350"; break;
     65 	case HP_360:
     66 		cp = "360"; break;
     67 	case HP_370:
     68 		cp = "370"; break;
     69 	case HP_375:
     70 		cp = "375"; break;
     71 	case HP_380:
     72 		cp = "380"; break;
     73 	case HP_400:
     74 		cp = "400"; break;
     75 	case HP_425:
     76 		cp = "425"; break;
     77 	case HP_433:
     78 		cp = "433"; break;
     79 	default:
     80 		cp = "???"; break;
     81 	}
     82 	return(cp);
     83 }
     84 
     85 #ifdef ROMPRF
     86 int userom;
     87 #endif
     88 
     89 struct trapframe {
     90 	int dregs[8];
     91 	int aregs[8];
     92 	int whoknows;
     93 	short sr;
     94 	int pc;
     95 	short frame;
     96 };
     97 
     98 trap(fp)
     99 	struct trapframe *fp;
    100 {
    101 	static int intrap = 0;
    102 
    103 	if (intrap)
    104 		return(0);
    105 	intrap = 1;
    106 #ifdef ROMPRF
    107 	userom = 1;
    108 #endif
    109 	printf("Got unexpected trap: format=%x vector=%x ps=%x pc=%x\n",
    110 		  (fp->frame>>12)&0xF, fp->frame&0xFFF, fp->sr, fp->pc);
    111 	printf("dregs: %x %x %x %x %x %x %x %x\n",
    112 	       fp->dregs[0], fp->dregs[1], fp->dregs[2], fp->dregs[3],
    113 	       fp->dregs[4], fp->dregs[5], fp->dregs[6], fp->dregs[7]);
    114 	printf("aregs: %x %x %x %x %x %x %x %x\n",
    115 	       fp->aregs[0], fp->aregs[1], fp->aregs[2], fp->aregs[3],
    116 	       fp->aregs[4], fp->aregs[5], fp->aregs[6], fp->aregs[7]);
    117 #ifdef ROMPRF
    118 	userom = 0;
    119 #endif
    120 	intrap = 0;
    121 	return(0);
    122 }
    123 
    124 #ifdef ROMPRF
    125 #define ROWS	46
    126 #define COLS	128
    127 
    128 romputchar(c)
    129 	register int c;
    130 {
    131 	static char buf[COLS];
    132 	static int col = 0, row = 0;
    133 	register int i;
    134 
    135 	switch (c) {
    136 	case '\0':
    137 		break;
    138 	case '\r':
    139 		break;	/* ignore */
    140 	case '\n':
    141 		for (i = col; i < COLS-1; i++)
    142 			buf[i] = ' ';
    143 		buf[i] = '\0';
    144 		romout(row, buf);
    145 		col = 0;
    146 		if (++row == ROWS)
    147 			row = 0;
    148 		break;
    149 
    150 	case '\t':
    151 		do {
    152 			romputchar(' ');
    153 		} while (col & 7);
    154 		break;
    155 
    156 	default:
    157 		buf[col] = c;
    158 		if (++col == COLS-1)
    159 			romputchar('\n');
    160 		break;
    161 	}
    162 }
    163 #endif
    164 
    165 void
    166 machdep_start(entry, howto, loadaddr, ssym, esym)
    167 	char *entry;
    168 	int howto;
    169 	char *loadaddr;
    170 	char *ssym, *esym;
    171 {
    172 
    173 	asm("movl %0,d7" : : "m" (howto));
    174 	asm("movl %0,d6" : : "m" (opendev));
    175 	asm("movl %0,d5" : : "m" (cons_scode));
    176 	asm("movl %0,a5" : : "a" (loadaddr));
    177 	asm("movl %0,a4" : : "a" (esym));
    178 	(*((int (*)())entry))();
    179 }
    180