kvm_minidump_mips.c (214904) | kvm_minidump_mips.c (217744) |
---|---|
1/*- 2 * Copyright (c) 2010 Oleksandr Tymoshenko 3 * Copyright (c) 2008 Semihalf, Grzegorz Bernacki 4 * Copyright (c) 2006 Peter Wemm 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 14 unchanged lines hidden (view full) --- 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 * 27 * From: FreeBSD: src/lib/libkvm/kvm_minidump_arm.c r214223 28 */ 29 30#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2010 Oleksandr Tymoshenko 3 * Copyright (c) 2008 Semihalf, Grzegorz Bernacki 4 * Copyright (c) 2006 Peter Wemm 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 14 unchanged lines hidden (view full) --- 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 * 27 * From: FreeBSD: src/lib/libkvm/kvm_minidump_arm.c r214223 28 */ 29 30#include <sys/cdefs.h> |
31__FBSDID("$FreeBSD: head/lib/libkvm/kvm_minidump_mips.c 214904 2010-11-07 03:26:22Z gonzo $"); | 31__FBSDID("$FreeBSD: head/lib/libkvm/kvm_minidump_mips.c 217744 2011-01-23 11:08:28Z uqs $"); |
32 33/* 34 * MIPS machine dependent routines for kvm and minidumps. 35 */ 36 37#include <sys/param.h> 38#include <sys/user.h> 39#include <sys/proc.h> --- 95 unchanged lines hidden (view full) --- 135 free(vm->ptemap); 136 free(vm); 137 kd->vmst = NULL; 138} 139 140int 141_kvm_minidump_initvtop(kvm_t *kd) 142{ | 32 33/* 34 * MIPS machine dependent routines for kvm and minidumps. 35 */ 36 37#include <sys/param.h> 38#include <sys/user.h> 39#include <sys/proc.h> --- 95 unchanged lines hidden (view full) --- 135 free(vm->ptemap); 136 free(vm); 137 kd->vmst = NULL; 138} 139 140int 141_kvm_minidump_initvtop(kvm_t *kd) 142{ |
143 u_long pa; | |
144 struct vmstate *vmst; 145 off_t off; 146 147 vmst = _kvm_malloc(kd, sizeof(*vmst)); 148 if (vmst == 0) { 149 _kvm_err(kd, kd->program, "cannot allocate vm"); 150 return (-1); 151 } --- 25 unchanged lines hidden (view full) --- 177 vmst->bitmap = _kvm_malloc(kd, vmst->hdr.bitmapsize); 178 if (vmst->bitmap == NULL) { 179 _kvm_err(kd, kd->program, "cannot allocate %d bytes for " 180 "bitmap", vmst->hdr.bitmapsize); 181 return (-1); 182 } 183 184 if (pread(kd->pmfd, vmst->bitmap, vmst->hdr.bitmapsize, off) != | 143 struct vmstate *vmst; 144 off_t off; 145 146 vmst = _kvm_malloc(kd, sizeof(*vmst)); 147 if (vmst == 0) { 148 _kvm_err(kd, kd->program, "cannot allocate vm"); 149 return (-1); 150 } --- 25 unchanged lines hidden (view full) --- 176 vmst->bitmap = _kvm_malloc(kd, vmst->hdr.bitmapsize); 177 if (vmst->bitmap == NULL) { 178 _kvm_err(kd, kd->program, "cannot allocate %d bytes for " 179 "bitmap", vmst->hdr.bitmapsize); 180 return (-1); 181 } 182 183 if (pread(kd->pmfd, vmst->bitmap, vmst->hdr.bitmapsize, off) != |
185 vmst->hdr.bitmapsize) { | 184 (ssize_t)vmst->hdr.bitmapsize) { |
186 _kvm_err(kd, kd->program, "cannot read %d bytes for page bitmap", 187 vmst->hdr.bitmapsize); 188 return (-1); 189 } 190 off += round_page(vmst->hdr.bitmapsize); 191 192 vmst->ptemap = _kvm_malloc(kd, vmst->hdr.ptesize); 193 if (vmst->ptemap == NULL) { 194 _kvm_err(kd, kd->program, "cannot allocate %d bytes for " 195 "ptemap", vmst->hdr.ptesize); 196 return (-1); 197 } 198 199 if (pread(kd->pmfd, vmst->ptemap, vmst->hdr.ptesize, off) != | 185 _kvm_err(kd, kd->program, "cannot read %d bytes for page bitmap", 186 vmst->hdr.bitmapsize); 187 return (-1); 188 } 189 off += round_page(vmst->hdr.bitmapsize); 190 191 vmst->ptemap = _kvm_malloc(kd, vmst->hdr.ptesize); 192 if (vmst->ptemap == NULL) { 193 _kvm_err(kd, kd->program, "cannot allocate %d bytes for " 194 "ptemap", vmst->hdr.ptesize); 195 return (-1); 196 } 197 198 if (pread(kd->pmfd, vmst->ptemap, vmst->hdr.ptesize, off) != |
200 vmst->hdr.ptesize) { | 199 (ssize_t)vmst->hdr.ptesize) { |
201 _kvm_err(kd, kd->program, "cannot read %d bytes for ptemap", 202 vmst->hdr.ptesize); 203 return (-1); 204 } 205 206 off += vmst->hdr.ptesize; 207 208 /* Build physical address hash table for sparse pages */ --- 5 unchanged lines hidden (view full) --- 214int 215_kvm_minidump_kvatop(kvm_t *kd, u_long va, off_t *pa) 216{ 217 struct vmstate *vm; 218 pt_entry_t pte; 219 u_long offset, pteindex, a; 220 off_t ofs; 221 pt_entry_t *ptemap; | 200 _kvm_err(kd, kd->program, "cannot read %d bytes for ptemap", 201 vmst->hdr.ptesize); 202 return (-1); 203 } 204 205 off += vmst->hdr.ptesize; 206 207 /* Build physical address hash table for sparse pages */ --- 5 unchanged lines hidden (view full) --- 213int 214_kvm_minidump_kvatop(kvm_t *kd, u_long va, off_t *pa) 215{ 216 struct vmstate *vm; 217 pt_entry_t pte; 218 u_long offset, pteindex, a; 219 off_t ofs; 220 pt_entry_t *ptemap; |
222 int i; | |
223 224 if (ISALIVE(kd)) { 225 _kvm_err(kd, 0, "kvm_kvatop called in live kernel!"); 226 return (0); 227 } 228 229 offset = va & PAGE_MASK; 230 /* Operate with page-aligned address */ 231 va &= ~PAGE_MASK; 232 233 vm = kd->vmst; 234 ptemap = vm->ptemap; 235 236#if defined(__mips_n64) 237 if (va >= MIPS_XKPHYS_START && va < MIPS_XKPHYS_END) 238 a = (MIPS_XKPHYS_TO_PHYS(va)); 239 else 240#endif | 221 222 if (ISALIVE(kd)) { 223 _kvm_err(kd, 0, "kvm_kvatop called in live kernel!"); 224 return (0); 225 } 226 227 offset = va & PAGE_MASK; 228 /* Operate with page-aligned address */ 229 va &= ~PAGE_MASK; 230 231 vm = kd->vmst; 232 ptemap = vm->ptemap; 233 234#if defined(__mips_n64) 235 if (va >= MIPS_XKPHYS_START && va < MIPS_XKPHYS_END) 236 a = (MIPS_XKPHYS_TO_PHYS(va)); 237 else 238#endif |
241 if (va >= MIPS_KSEG0_START && va < MIPS_KSEG0_END) | 239 if (va >= (u_long)MIPS_KSEG0_START && va < (u_long)MIPS_KSEG0_END) |
242 a = (MIPS_KSEG0_TO_PHYS(va)); | 240 a = (MIPS_KSEG0_TO_PHYS(va)); |
243 else if (va >= MIPS_KSEG1_START && va < MIPS_KSEG1_END) | 241 else if (va >= (u_long)MIPS_KSEG1_START && va < (u_long)MIPS_KSEG1_END) |
244 a = (MIPS_KSEG1_TO_PHYS(va)); 245 else if (va >= vm->hdr.kernbase) { 246 pteindex = (va - vm->hdr.kernbase) >> PAGE_SHIFT; 247 pte = ptemap[pteindex]; 248 if (!pte) { 249 _kvm_err(kd, kd->program, "_kvm_vatop: pte not valid"); 250 goto invalid; 251 } --- 24 unchanged lines hidden --- | 242 a = (MIPS_KSEG1_TO_PHYS(va)); 243 else if (va >= vm->hdr.kernbase) { 244 pteindex = (va - vm->hdr.kernbase) >> PAGE_SHIFT; 245 pte = ptemap[pteindex]; 246 if (!pte) { 247 _kvm_err(kd, kd->program, "_kvm_vatop: pte not valid"); 248 goto invalid; 249 } --- 24 unchanged lines hidden --- |