1 /* $NetBSD: kvm_alpha.c,v 1.4 1996/10/01 19:04:02 cgd Exp $ */ 2 3 /* 4 * Copyright (c) 1994, 1995 Carnegie-Mellon University. 5 * All rights reserved. 6 * 7 * Author: Chris G. Demetriou 8 * 9 * Permission to use, copy, modify and distribute this software and 10 * its documentation is hereby granted, provided that both the copyright 11 * notice and this permission notice appear in all copies of the 12 * software, derivative works or modified versions, and any portions 13 * thereof, and that both notices appear in supporting documentation. 14 * 15 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 16 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 17 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 18 * 19 * Carnegie Mellon requests users of this software to return to 20 * 21 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 22 * School of Computer Science 23 * Carnegie Mellon University 24 * Pittsburgh PA 15213-3890 25 * 26 * any improvements or extensions that they make and grant Carnegie the 27 * rights to redistribute these changes. 28 */ 29 30 #include <sys/param.h> 31 #include <sys/user.h> 32 #include <sys/proc.h> 33 #include <sys/stat.h> 34 #include <sys/kcore.h> 35 #include <machine/kcore.h> 36 #include <unistd.h> 37 #include <nlist.h> 38 #include <kvm.h> 39 40 #include <vm/vm.h> 41 #include <vm/vm_param.h> 42 43 #include <limits.h> 44 #include <db.h> 45 46 #include "kvm_private.h" 47 48 void 49 _kvm_freevtop(kd) 50 kvm_t *kd; 51 { 52 53 } 54 55 int 56 _kvm_initvtop(kd) 57 kvm_t *kd; 58 { 59 60 return (0); 61 } 62 63 int 64 _kvm_kvatop(kd, va, pa) 65 kvm_t *kd; 66 u_long va; 67 u_long *pa; 68 { 69 cpu_kcore_hdr_t *cpu_kh; 70 int rv, page_off; 71 72 if (ISALIVE(kd)) { 73 _kvm_err(kd, 0, "vatop called in live kernel!"); 74 return(0); 75 } 76 77 cpu_kh = kd->cpu_data; 78 page_off = va & (cpu_kh->page_size - 1); 79 80 if (va >= ALPHA_K0SEG_BASE && va <= ALPHA_K0SEG_END) { 81 /* 82 * Direct-mapped address. Just convert it. 83 */ 84 *pa = ALPHA_K0SEG_TO_PHYS(va); 85 rv = cpu_kh->page_size - page_off; 86 } else if (va >= ALPHA_K1SEG_BASE && va <= ALPHA_K1SEG_END) { 87 /* 88 * Real kernel virtual address. Do the translation. 89 */ 90 /* XXX TRANSLATE IT! */ 91 goto barf; /* XXX */ 92 } else { 93 /* 94 * The address is from space (not a KV address). Return 95 * values that indicate that it can't be used. 96 */ 97 barf: /* XXX */ 98 *pa = -1; 99 rv = 0; 100 } 101 102 /* printf("_kvm_kvatop va = 0x%lx, returning pa = 0x%lx, rv = 0x%lx\n", va, *pa, rv); */ 103 return (rv); 104 } 105 106 /* 107 * Translate a physical address to a file-offset in the crash-dump. 108 */ 109 off_t 110 _kvm_pa2off(kd, pa) 111 kvm_t *kd; 112 u_long pa; 113 { 114 off_t off; 115 cpu_kcore_hdr_t *cpu_kh; 116 117 cpu_kh = kd->cpu_data; 118 119 off = 0; 120 pa -= cpu_kh->core_seg.start; 121 122 return (kd->dump_off + off + pa); 123 } 124