1/* $NetBSD: kvm_or1k.c,v 1.3 2023/08/23 14:00:11 rin Exp $ */ 2 3/*- 4 * Copyright (c) 2014 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Matt Thomas of 3am Software Foundry. 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 * 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32/* 33 * OR1K machine dependent routines for kvm. 34 */ 35 36#include <sys/param.h> 37#include <sys/exec.h> 38#include <sys/types.h> 39 40#include <uvm/uvm_extern.h> 41 42#include <db.h> 43#include <limits.h> 44#include <kvm.h> 45#include <stdlib.h> 46#include <unistd.h> 47 48#include "kvm_private.h" 49 50#include <sys/kcore.h> 51#include <machine/kcore.h> 52#include <machine/vmparam.h> 53 54__RCSID("$NetBSD: kvm_or1k.c,v 1.3 2023/08/23 14:00:11 rin Exp $"); 55 56void 57_kvm_freevtop(kvm_t *kd) 58{ 59 if (kd->vmst != 0) 60 free(kd->vmst); 61} 62 63/*ARGSUSED*/ 64int 65_kvm_initvtop(kvm_t *kd) 66{ 67 68 return 0; 69} 70 71/* 72 * Translate a KVA to a PA 73 */ 74int 75_kvm_kvatop(kvm_t *kd, vaddr_t va, paddr_t *pa) 76{ 77// cpu_kcore_hdr_t *cpu_kh; 78 79 if (ISALIVE(kd)) { 80 _kvm_err(kd, 0, "vatop called in live kernel!"); 81 return 0; 82 } 83 84 /* No hit -- no translation */ 85 *pa = (u_long)~0UL; 86 return 0; 87} 88 89off_t 90_kvm_pa2off(kvm_t *kd, paddr_t pa) 91{ 92 cpu_kcore_hdr_t *cpu_kh; 93 phys_ram_seg_t *ram; 94 off_t off; 95 void *e; 96 97 cpu_kh = kd->cpu_data; 98 e = (char *) kd->cpu_data + kd->cpu_dsize; 99 ram = (void *)((char *)(void *)cpu_kh + ALIGN(sizeof *cpu_kh)); 100 off = kd->dump_off; 101 do { 102 if (pa >= ram->start && (pa - ram->start) < ram->size) { 103 return off + (pa - ram->start); 104 } 105 ram++; 106 off += ram->size; 107 } while ((void *) ram < e && ram->size); 108 109 _kvm_err(kd, 0, "pa2off failed for pa %#" PRIxPADDR "\n", pa); 110 return (off_t) -1; 111} 112 113/* 114 * Machine-dependent initialization for ALL open kvm descriptors, 115 * not just those for a kernel crash dump. Some architectures 116 * have to deal with these NOT being constants! (i.e. m68k) 117 */ 118int 119_kvm_mdopen(kvm_t *kd) 120{ 121 kd->min_uva = VM_MIN_ADDRESS; 122 kd->max_uva = VM_MAXUSER_ADDRESS; 123 124 return (0); 125} 126