1 /* $NetBSD: machdep.c,v 1.8 2001/01/02 04:14:34 simonb 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 <hp300/stand/common/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_385: 74 cp = "385"; break; 75 case HP_400: 76 cp = "400"; break; 77 case HP_425: 78 switch (mmuid) { 79 case MMUID_425_T: 80 cp = "425t"; break; 81 case MMUID_425_S: 82 cp = "425s"; break; 83 case MMUID_425_E: 84 cp = "425e"; break; 85 default: 86 cp = "425"; break; 87 } 88 break; 89 case HP_433: 90 switch (mmuid) { 91 case MMUID_433_T: 92 cp = "433t"; break; 93 case MMUID_433_S: 94 cp = "433s"; break; 95 default: 96 cp = "433"; break; 97 } 98 break; 99 default: 100 cp = "???"; break; 101 } 102 return(cp); 103 } 104 105 int userom; 106 107 struct trapframe { 108 int dregs[8]; 109 int aregs[8]; 110 int whoknows; 111 short sr; 112 int pc; 113 short frame; 114 }; 115 116 trap(fp) 117 struct trapframe *fp; 118 { 119 static int intrap = 0; 120 121 if (intrap) 122 return(0); 123 intrap = 1; 124 125 #if 0 126 userom = 1; 127 #endif 128 129 printf("Got unexpected trap: format=%x vector=%x ps=%x pc=%x\n", 130 (fp->frame>>12)&0xF, fp->frame&0xFFF, fp->sr, fp->pc); 131 printf("dregs: %x %x %x %x %x %x %x %x\n", 132 fp->dregs[0], fp->dregs[1], fp->dregs[2], fp->dregs[3], 133 fp->dregs[4], fp->dregs[5], fp->dregs[6], fp->dregs[7]); 134 printf("aregs: %x %x %x %x %x %x %x %x\n", 135 fp->aregs[0], fp->aregs[1], fp->aregs[2], fp->aregs[3], 136 fp->aregs[4], fp->aregs[5], fp->aregs[6], fp->aregs[7]); 137 138 #if 0 139 userom = 0; 140 #endif 141 142 intrap = 0; 143 return(0); 144 } 145 146 #define ROWS 24 147 #define COLS 80 148 149 void 150 romputchar(c) 151 int c; 152 { 153 static char buf[COLS]; 154 static int col = 0, row = 0; 155 int i; 156 157 switch (c) { 158 case '\0': 159 break; 160 case '\r': 161 break; /* ignore */ 162 case '\n': 163 for (i = col; i < COLS-1; i++) 164 buf[i] = ' '; 165 buf[i] = '\0'; 166 romout(row, buf); 167 col = 0; 168 if (++row == ROWS) 169 row = 0; 170 break; 171 172 case '\t': 173 do { 174 romputchar(' '); 175 } while (col & 7); 176 break; 177 178 default: 179 buf[col] = c; 180 if (++col == COLS-1) 181 romputchar('\n'); 182 break; 183 } 184 } 185 186 void 187 machdep_start(entry, howto, loadaddr, ssym, esym) 188 char *entry; 189 int howto; 190 char *loadaddr; 191 char *ssym, *esym; 192 { 193 194 /* Adjust entry point. */ 195 transfer(entry, howto, opendev, cons_scode, loadaddr, esym); 196 } 197 198 void 199 transfer(entry, howto, od, csc, lr, es) 200 char *entry; 201 int howto, od, csc; 202 char *lr, *es; 203 { 204 205 printf("Entry point: 0x%lx\n", (u_long)entry); 206 207 #ifdef EXEC_DEBUG 208 printf("\n\nReturn to boot...\n"); 209 (void) getchar(); 210 #endif 211 212 _transfer(entry, howto, od, csc, lr, es); 213 } 214