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