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