1*0e64ee4cSderaadt /* $OpenBSD: kvm_hppa.c,v 1.11 2021/12/01 16:53:28 deraadt Exp $ */
2f4c27b7eSmickey
3f4c27b7eSmickey /*
4f4c27b7eSmickey * Copyright (c) 2002, Miodrag Vallat.
5f4c27b7eSmickey * All rights reserved.
6f4c27b7eSmickey *
7f4c27b7eSmickey * Redistribution and use in source and binary forms, with or without
8f4c27b7eSmickey * modification, are permitted provided that the following conditions
9f4c27b7eSmickey * are met:
10f4c27b7eSmickey * 1. Redistributions of source code must retain the above copyright
11f4c27b7eSmickey * notice, this list of conditions and the following disclaimer.
12f4c27b7eSmickey * 2. Redistributions in binary form must reproduce the above copyright
13f4c27b7eSmickey * notice, this list of conditions and the following disclaimer in the
14f4c27b7eSmickey * documentation and/or other materials provided with the distribution.
15f4c27b7eSmickey *
16f4c27b7eSmickey * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17f4c27b7eSmickey * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18f4c27b7eSmickey * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19f4c27b7eSmickey * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20f4c27b7eSmickey * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21f4c27b7eSmickey * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22f4c27b7eSmickey * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23f4c27b7eSmickey * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24f4c27b7eSmickey * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25f4c27b7eSmickey * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26f4c27b7eSmickey */
27f4c27b7eSmickey
28*0e64ee4cSderaadt #include <sys/types.h>
29*0e64ee4cSderaadt #include <sys/signal.h>
3048073bb9Sderaadt #include <sys/proc.h>
3148073bb9Sderaadt #include <sys/stat.h>
32f4c27b7eSmickey
33f4c27b7eSmickey #include <unistd.h>
34b7e5637aSmiod #include <stdlib.h>
35f4c27b7eSmickey #include <kvm.h>
36f4c27b7eSmickey
37f4c27b7eSmickey #include <db.h>
38f4c27b7eSmickey
39f4c27b7eSmickey #include "kvm_private.h"
40f4c27b7eSmickey
41f4c27b7eSmickey void
_kvm_freevtop(kvm_t * kd)42551fad64Sderaadt _kvm_freevtop(kvm_t *kd)
43f4c27b7eSmickey {
44f4c27b7eSmickey free(kd->vmst);
45551fad64Sderaadt kd->vmst = NULL;
46551fad64Sderaadt }
47f4c27b7eSmickey
48f4c27b7eSmickey int
_kvm_initvtop(kvm_t * kd)49551fad64Sderaadt _kvm_initvtop(kvm_t *kd)
50f4c27b7eSmickey {
51f4c27b7eSmickey return (0);
52f4c27b7eSmickey }
53f4c27b7eSmickey
54f4c27b7eSmickey int
_kvm_kvatop(kvm_t * kd,u_long va,paddr_t * pa)55fdd3f45bSmickey _kvm_kvatop(kvm_t *kd, u_long va, paddr_t *pa)
56f4c27b7eSmickey {
57f4c27b7eSmickey if (ISALIVE(kd)) {
58f4c27b7eSmickey _kvm_err(kd, 0, "vatop called in live kernel!");
59551fad64Sderaadt return (0);
60f4c27b7eSmickey }
61f4c27b7eSmickey
621ff387b6Smiod /* XXX this only really works for the kernel image only */
631ff387b6Smiod *pa = va;
647468fac6Sderaadt return (kd->nbpg - (va & (kd->nbpg - 1)));
65f4c27b7eSmickey }
66f4c27b7eSmickey
67f4c27b7eSmickey /*
68f4c27b7eSmickey * Translate a physical address to a file offset in the crash dump.
69f4c27b7eSmickey */
70f4c27b7eSmickey off_t
_kvm_pa2off(kvm_t * kd,paddr_t pa)71fdd3f45bSmickey _kvm_pa2off(kvm_t *kd, paddr_t pa)
72f4c27b7eSmickey {
731ff387b6Smiod return (kd->dump_off + pa);
74f4c27b7eSmickey }
75