1 /* $NetBSD: db_machdep.c,v 1.17 2001/05/28 22:00:12 chs Exp $ */ 2 3 /*- 4 * Copyright (c) 1996 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Gordon W. Ross. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. All advertising materials mentioning features or use of this software 19 * must display the following acknowledgement: 20 * This product includes software developed by the NetBSD 21 * Foundation, Inc. and its contributors. 22 * 4. Neither the name of The NetBSD Foundation nor the names of its 23 * contributors may be used to endorse or promote products derived 24 * from this software without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 * POSSIBILITY OF SUCH DAMAGE. 37 */ 38 39 /* 40 * Machine-dependent functions used by ddb 41 */ 42 43 #include <sys/param.h> 44 #include <sys/proc.h> 45 46 #include <machine/db_machdep.h> 47 #include <machine/pte.h> 48 49 #include <sun3/sun3/machdep.h> 50 #ifdef _SUN3_ 51 #include <sun3/sun3/control.h> 52 #endif /* SUN3 */ 53 54 #include <ddb/db_command.h> 55 #include <ddb/db_output.h> 56 #include <ddb/db_interface.h> 57 58 static void db_mach_abort __P((db_expr_t, int, db_expr_t, char *)); 59 static void db_mach_halt __P((db_expr_t, int, db_expr_t, char *)); 60 static void db_mach_reboot __P((db_expr_t, int, db_expr_t, char *)); 61 static void db_mach_pagemap __P((db_expr_t, int, db_expr_t, char *)); 62 63 const struct db_command db_machine_command_table[] = { 64 { "abort", db_mach_abort, 0, 0 }, 65 { "halt", db_mach_halt, 0, 0 }, 66 { "pgmap", db_mach_pagemap, CS_SET_DOT, 0 }, 67 { "reboot", db_mach_reboot, 0, 0 }, 68 { NULL } 69 }; 70 71 /* 72 * Machine-specific ddb commands for the sun3: 73 * abort: Drop into monitor via abort (allows continue) 74 * halt: Exit to monitor as in halt(8) 75 * reboot: Reboot the machine as in reboot(8) 76 * pgmap: Given addr, Print addr, segmap, pagemap, pte 77 */ 78 79 static void 80 db_mach_abort(addr, have_addr, count, modif) 81 db_expr_t addr; 82 int have_addr; 83 db_expr_t count; 84 char * modif; 85 { 86 sunmon_abort(); 87 } 88 89 static void 90 db_mach_halt(addr, have_addr, count, modif) 91 db_expr_t addr; 92 int have_addr; 93 db_expr_t count; 94 char * modif; 95 { 96 sunmon_halt(); 97 } 98 99 static void 100 db_mach_reboot(addr, have_addr, count, modif) 101 db_expr_t addr; 102 int have_addr; 103 db_expr_t count; 104 char * modif; 105 { 106 sunmon_reboot(""); 107 } 108 109 110 static void pte_print __P((int)); 111 112 static void 113 db_mach_pagemap(addr, have_addr, count, modif) 114 db_expr_t addr; 115 int have_addr; 116 db_expr_t count; 117 char * modif; 118 { 119 u_long va = m68k_trunc_page((u_long)addr); 120 int pte; 121 #ifdef _SUN3_ 122 int sme; 123 124 sme = get_segmap(va); 125 if (sme == 0xFF) { 126 pte = 0; 127 } else { 128 pte = get_pte(va); 129 } 130 db_printf("0x%08lx [%02x] 0x%08x", va, sme, pte); 131 #endif /* SUN3 */ 132 #ifdef _SUN3X_ 133 pte = get_pte(va); 134 db_printf("0x%08lx 0x%08x", va, pte); 135 #endif /* SUN3X */ 136 137 pte_print(pte); 138 db_next = va + NBPG; 139 } 140 141 #ifdef _SUN3_ 142 static void 143 pte_print(pte) 144 int pte; 145 { 146 int t; 147 static const char *pgt_names[] = { 148 "MEM", "OBIO", "VMES", "VMEL", 149 }; 150 151 if (pte & PG_VALID) { 152 db_printf(" V"); 153 if (pte & PG_WRITE) 154 db_printf(" W"); 155 if (pte & PG_SYSTEM) 156 db_printf(" S"); 157 if (pte & PG_NC) 158 db_printf(" NC"); 159 if (pte & PG_REF) 160 db_printf(" Ref"); 161 if (pte & PG_MOD) 162 db_printf(" Mod"); 163 164 t = (pte >> PG_TYPE_SHIFT) & 3; 165 db_printf(" %s", pgt_names[t]); 166 db_printf(" PA=0x%x\n", PG_PA(pte)); 167 } else 168 db_printf(" INVALID\n"); 169 } 170 #endif /* SUN3 */ 171 172 #ifdef _SUN3X_ 173 static void 174 pte_print(pte) 175 int pte; 176 { 177 178 if (pte & MMU_SHORT_PTE_DT) { 179 if (pte & MMU_SHORT_PTE_CI) 180 db_printf(" CI"); 181 if (pte & MMU_SHORT_PTE_M) 182 db_printf(" Mod"); 183 if (pte & MMU_SHORT_PTE_USED) 184 db_printf(" Ref"); 185 if (pte & MMU_SHORT_PTE_WP) 186 db_printf(" WP"); 187 db_printf(" DT%d\n", pte & MMU_SHORT_PTE_DT); 188 } else 189 db_printf(" INVALID\n"); 190 } 191 #endif /* SUN3X */ 192