1 /* $NetBSD: db_machdep.c,v 1.2 2001/06/11 21:35:59 fredette 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/promlib.h> 48 #include <machine/pte.h> 49 50 #include <sun2/sun2/machdep.h> 51 #include <sun2/sun2/control.h> 52 53 #include <ddb/db_command.h> 54 #include <ddb/db_output.h> 55 #include <ddb/db_interface.h> 56 57 static void db_mach_abort __P((db_expr_t, int, db_expr_t, char *)); 58 static void db_mach_halt __P((db_expr_t, int, db_expr_t, char *)); 59 static void db_mach_reboot __P((db_expr_t, int, db_expr_t, char *)); 60 static void db_mach_pagemap __P((db_expr_t, int, db_expr_t, char *)); 61 62 const struct db_command db_machine_command_table[] = { 63 { "abort", db_mach_abort, 0, 0 }, 64 { "halt", db_mach_halt, 0, 0 }, 65 { "pgmap", db_mach_pagemap, CS_SET_DOT, 0 }, 66 { "reboot", db_mach_reboot, 0, 0 }, 67 { (char *)0, } 68 }; 69 70 /* 71 * Machine-specific ddb commands for the sun2: 72 * abort: Drop into monitor via abort (allows continue) 73 * halt: Exit to monitor as in halt(8) 74 * reboot: Reboot the machine as in reboot(8) 75 * pgmap: Given addr, Print addr, segmap, pagemap, pte 76 */ 77 78 static void 79 db_mach_abort(addr, have_addr, count, modif) 80 db_expr_t addr; 81 int have_addr; 82 db_expr_t count; 83 char * modif; 84 { 85 prom_abort(); 86 } 87 88 static void 89 db_mach_halt(addr, have_addr, count, modif) 90 db_expr_t addr; 91 int have_addr; 92 db_expr_t count; 93 char * modif; 94 { 95 prom_halt(); 96 } 97 98 static void 99 db_mach_reboot(addr, have_addr, count, modif) 100 db_expr_t addr; 101 int have_addr; 102 db_expr_t count; 103 char * modif; 104 { 105 prom_boot(""); 106 } 107 108 109 static void pte_print __P((int)); 110 111 static void 112 db_mach_pagemap(addr, have_addr, count, modif) 113 db_expr_t addr; 114 int have_addr; 115 db_expr_t count; 116 char * modif; 117 { 118 u_long va = m68k_trunc_page((u_long)addr); 119 int pte; 120 int sme; 121 122 sme = get_segmap(va); 123 if (sme == 0xFF) pte = 0; 124 else pte = get_pte(va); 125 db_printf("0x%08lx [%02x] 0x%08x", va, sme, pte); 126 127 pte_print(pte); 128 db_next = va + NBPG; 129 } 130 131 static void 132 pte_print(pte) 133 int pte; 134 { 135 int t; 136 static char *pgt_names[] = { 137 "MEM", "OBIO", "VME0", "VME8", 138 }; 139 140 if (pte & PG_VALID) { 141 db_printf(" V"); 142 if (pte & PG_WRITE) 143 db_printf(" W"); 144 if (pte & PG_SYSTEM) 145 db_printf(" S"); 146 if (pte & PG_NC) 147 db_printf(" NC"); 148 if (pte & PG_REF) 149 db_printf(" Ref"); 150 if (pte & PG_MOD) 151 db_printf(" Mod"); 152 153 t = (pte >> PG_TYPE_SHIFT) & 3; 154 db_printf(" %s", pgt_names[t]); 155 db_printf(" PA=0x%x\n", PG_PA(pte)); 156 } 157 else db_printf(" INVALID\n"); 158 } 159