Home | History | Annotate | Line # | Download | only in common
      1 /*	$NetBSD: machdep.c,v 1.16 2023/01/15 06:19:46 tsutsui 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. Neither the name of the University nor the names of its contributors
     21  *    may be used to endorse or promote products derived from this software
     22  *    without specific prior written permission.
     23  *
     24  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     27  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     28  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     30  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     33  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     34  * SUCH DAMAGE.
     35  *
     36  * from: Utah $Hdr: machdep.c 1.10 92/06/18
     37  *
     38  *	@(#)machdep.c	8.1 (Berkeley) 6/10/93
     39  */
     40 
     41 #include <sys/param.h>
     42 #include <lib/libsa/stand.h>
     43 #include <hp300/stand/common/samachdep.h>
     44 
     45 char *
     46 getmachineid(void)
     47 {
     48 	extern int machineid;
     49 	char *cp;
     50 
     51 	switch (machineid) {
     52 	case HP_320:
     53 		cp = "320"; break;
     54 	case HP_330:
     55 		cp = "318/319/330"; break;
     56 	case HP_340:
     57 		cp = "340"; break;
     58 	case HP_345:
     59 		cp = "345"; break;
     60 	case HP_350:
     61 		cp = "350"; break;
     62 	case HP_360:
     63 		cp = "360"; break;
     64 	case HP_362:
     65 		cp = "362"; break;
     66 	case HP_370:
     67 		cp = "370"; break;
     68 	case HP_375:
     69 		cp = "375"; break;
     70 	case HP_380:
     71 		cp = "380"; break;
     72 	case HP_382:
     73 		cp = "382"; break;
     74 	case HP_385:
     75 		cp = "385"; break;
     76 	case HP_400:
     77 		cp = "400"; break;
     78 	case HP_425:
     79 		switch (mmuid) {
     80 		case MMUID_425_T:
     81 			cp = "425t"; break;
     82 		case MMUID_425_S:
     83 			cp = "425s"; break;
     84 		case MMUID_425_E:
     85 			cp = "425e"; break;
     86 		default:
     87 			cp = "425"; break;
     88 		}
     89 		break;
     90 	case HP_433:
     91 		switch (mmuid) {
     92 		case MMUID_433_T:
     93 			cp = "433t"; break;
     94 		case MMUID_433_S:
     95 			cp = "433s"; break;
     96 		default:
     97 			cp = "433"; break;
     98 		}
     99 		break;
    100 	default:
    101 		cp = "???"; break;
    102 	}
    103 	return cp;
    104 }
    105 
    106 int userom;
    107 
    108 int
    109 trap(struct trapframe *fp)
    110 {
    111 	static int intrap = 0;
    112 
    113 	if (intrap)
    114 		return 0;
    115 	intrap = 1;
    116 
    117 #if 0
    118 	userom = 1;
    119 #endif
    120 
    121 	printf("Got unexpected trap: format=%x vector=%x ps=%x pc=%x\n",
    122 		  fp->tf_format, fp->tf_format, fp->tf_sr, fp->tf_pc);
    123 	printf("dregs: %x %x %x %x %x %x %x %x\n",
    124 	       fp->tf_regs[0], fp->tf_regs[1],
    125 	       fp->tf_regs[2], fp->tf_regs[3],
    126 	       fp->tf_regs[4], fp->tf_regs[5],
    127 	       fp->tf_regs[6], fp->tf_regs[7]);
    128 	printf("aregs: %x %x %x %x %x %x %x %x\n",
    129 	       fp->tf_regs[8], fp->tf_regs[9],
    130 	       fp->tf_regs[10], fp->tf_regs[11],
    131 	       fp->tf_regs[12], fp->tf_regs[13],
    132 	       fp->tf_regs[14], fp->tf_regs[15]);
    133 
    134 #if 0
    135 	userom = 0;
    136 #endif
    137 
    138 	intrap = 0;
    139 	return 0;
    140 }
    141 
    142 #define ROWS	24
    143 #define COLS	80
    144 
    145 void
    146 romputchar(int c)
    147 {
    148 	static char buf[COLS];
    149 	static int col = 0, row = 0;
    150 	int i;
    151 
    152 	switch (c) {
    153 	case '\0':
    154 		break;
    155 	case '\r':
    156 		break;	/* ignore */
    157 	case '\n':
    158 		for (i = col; i < COLS-1; i++)
    159 			buf[i] = ' ';
    160 		buf[i] = '\0';
    161 		romout(row, buf);
    162 		col = 0;
    163 		if (++row == ROWS)
    164 			row = 0;
    165 		break;
    166 
    167 	case '\t':
    168 		do {
    169 			romputchar(' ');
    170 		} while (col & 7);
    171 		break;
    172 
    173 	default:
    174 		buf[col] = c;
    175 		if (++col == COLS-1)
    176 			romputchar('\n');
    177 		break;
    178 	}
    179 }
    180 
    181 void
    182 machdep_start(char *entry, int howto, char *loadaddr, char *ssym, char *esym)
    183 {
    184 
    185 	/* Adjust entry point. */
    186 	transfer(entry, howto, opendev, cons_scode, loadaddr, esym);
    187 }
    188 
    189 void
    190 transfer(char *entry, int howto, int od, int csc, char *lr, char *es)
    191 {
    192 
    193 	printf("Entry point: 0x%lx\n", (u_long)entry);
    194 
    195 #ifdef EXEC_DEBUG
    196 	printf("\n\nReturn to boot...\n");
    197 	(void)getchar();
    198 #endif
    199 
    200 	_transfer(entry, howto, od, csc, lr, es);
    201 }
    202