1*104ea677Schristos /* $NetBSD: kvm_sh3.c,v 1.10 2022/01/10 19:51:30 christos Exp $ */
2b86435dfSmsaitoh
3b86435dfSmsaitoh /*-
4b86435dfSmsaitoh * Copyright (c) 1989, 1992, 1993
5b86435dfSmsaitoh * The Regents of the University of California. All rights reserved.
6b86435dfSmsaitoh *
7b86435dfSmsaitoh * This code is derived from software developed by the Computer Systems
8b86435dfSmsaitoh * Engineering group at Lawrence Berkeley Laboratory under DARPA contract
9b86435dfSmsaitoh * BG 91-66 and contributed to Berkeley.
10b86435dfSmsaitoh *
11b86435dfSmsaitoh * Redistribution and use in source and binary forms, with or without
12b86435dfSmsaitoh * modification, are permitted provided that the following conditions
13b86435dfSmsaitoh * are met:
14b86435dfSmsaitoh * 1. Redistributions of source code must retain the above copyright
15b86435dfSmsaitoh * notice, this list of conditions and the following disclaimer.
16b86435dfSmsaitoh * 2. Redistributions in binary form must reproduce the above copyright
17b86435dfSmsaitoh * notice, this list of conditions and the following disclaimer in the
18b86435dfSmsaitoh * documentation and/or other materials provided with the distribution.
19eb7c1594Sagc * 3. Neither the name of the University nor the names of its contributors
20b86435dfSmsaitoh * may be used to endorse or promote products derived from this software
21b86435dfSmsaitoh * without specific prior written permission.
22b86435dfSmsaitoh *
23b86435dfSmsaitoh * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24b86435dfSmsaitoh * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25b86435dfSmsaitoh * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26b86435dfSmsaitoh * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27b86435dfSmsaitoh * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28b86435dfSmsaitoh * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29b86435dfSmsaitoh * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30b86435dfSmsaitoh * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31b86435dfSmsaitoh * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32b86435dfSmsaitoh * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33b86435dfSmsaitoh * SUCH DAMAGE.
34b86435dfSmsaitoh */
35b86435dfSmsaitoh
36b86435dfSmsaitoh #include <sys/cdefs.h>
37b86435dfSmsaitoh #if defined(LIBC_SCCS) && !defined(lint)
38b86435dfSmsaitoh #if 0
39b86435dfSmsaitoh static char sccsid[] = "@(#)kvm_hp300.c 8.1 (Berkeley) 6/4/93";
40b86435dfSmsaitoh #else
41*104ea677Schristos __RCSID("$NetBSD: kvm_sh3.c,v 1.10 2022/01/10 19:51:30 christos Exp $");
42b86435dfSmsaitoh #endif
43b86435dfSmsaitoh #endif /* LIBC_SCCS and not lint */
44b86435dfSmsaitoh
45b86435dfSmsaitoh /*
4610344af6Sscw * SH3 machine dependent routines for kvm.
47b86435dfSmsaitoh */
48b86435dfSmsaitoh
49b86435dfSmsaitoh #include <sys/param.h>
50b86435dfSmsaitoh #include <sys/proc.h>
51b86435dfSmsaitoh #include <sys/stat.h>
52b86435dfSmsaitoh #include <sys/kcore.h>
53962a341dSjym #include <sys/types.h>
54962a341dSjym
55b86435dfSmsaitoh #include <stdlib.h>
56b86435dfSmsaitoh #include <unistd.h>
57b86435dfSmsaitoh #include <nlist.h>
58b86435dfSmsaitoh #include <kvm.h>
59b86435dfSmsaitoh
603b8ac18dSmrg #include <uvm/uvm_extern.h>
61b86435dfSmsaitoh
62b86435dfSmsaitoh #include <limits.h>
63b86435dfSmsaitoh #include <db.h>
64b86435dfSmsaitoh
65b86435dfSmsaitoh #include "kvm_private.h"
66b86435dfSmsaitoh
67b86435dfSmsaitoh #include <machine/pte.h>
68cce919e0Smatt #include <machine/vmparam.h>
69b86435dfSmsaitoh
70b86435dfSmsaitoh #ifndef btop
71b86435dfSmsaitoh #define btop(x) (((unsigned)(x)) >> PGSHIFT) /* XXX */
72b86435dfSmsaitoh #define ptob(x) ((caddr_t)((x) << PGSHIFT)) /* XXX */
73b86435dfSmsaitoh #endif
74b86435dfSmsaitoh
75b86435dfSmsaitoh void
_kvm_freevtop(kvm_t * kd)766dc46b92Sjym _kvm_freevtop(kvm_t *kd)
77b86435dfSmsaitoh {
78b86435dfSmsaitoh
79b86435dfSmsaitoh /* Not actually used for anything right now, but safe. */
80b86435dfSmsaitoh if (kd->vmst != 0)
81b86435dfSmsaitoh free(kd->vmst);
82b86435dfSmsaitoh }
83b86435dfSmsaitoh
84b86435dfSmsaitoh /*ARGSUSED*/
85b86435dfSmsaitoh int
_kvm_initvtop(kvm_t * kd)866dc46b92Sjym _kvm_initvtop(kvm_t *kd)
87b86435dfSmsaitoh {
88b86435dfSmsaitoh
89b86435dfSmsaitoh return (0);
90b86435dfSmsaitoh }
91b86435dfSmsaitoh
92b86435dfSmsaitoh /*
93b86435dfSmsaitoh * Translate a kernel virtual address to a physical address.
94b86435dfSmsaitoh */
95b86435dfSmsaitoh int
_kvm_kvatop(kvm_t * kd,vaddr_t va,paddr_t * pa)96962a341dSjym _kvm_kvatop(kvm_t *kd, vaddr_t va, paddr_t *pa)
97b86435dfSmsaitoh {
98b86435dfSmsaitoh _kvm_err(kd, 0, "vatop not yet implemented!");
99b86435dfSmsaitoh return 0;
100b86435dfSmsaitoh }
101b86435dfSmsaitoh
102b86435dfSmsaitoh /*
103b86435dfSmsaitoh * Translate a physical address to a file-offset in the crash dump.
104b86435dfSmsaitoh */
105b86435dfSmsaitoh off_t
_kvm_pa2off(kvm_t * kd,paddr_t pa)106962a341dSjym _kvm_pa2off(kvm_t *kd, paddr_t pa)
107b86435dfSmsaitoh {
108b86435dfSmsaitoh _kvm_err(kd, 0, "pa2off not yet implemented!");
109b86435dfSmsaitoh return 0;
110b86435dfSmsaitoh }
111b86435dfSmsaitoh
112b86435dfSmsaitoh /*
113b86435dfSmsaitoh * Machine-dependent initialization for ALL open kvm descriptors,
114b86435dfSmsaitoh * not just those for a kernel crash dump. Some architectures
115b86435dfSmsaitoh * have to deal with these NOT being constants! (i.e. m68k)
116b86435dfSmsaitoh */
117b86435dfSmsaitoh int
_kvm_mdopen(kvm_t * kd)1186dc46b92Sjym _kvm_mdopen(kvm_t *kd)
119b86435dfSmsaitoh {
120b86435dfSmsaitoh
121b86435dfSmsaitoh kd->min_uva = VM_MIN_ADDRESS;
122b86435dfSmsaitoh kd->max_uva = VM_MAXUSER_ADDRESS;
123b86435dfSmsaitoh
124b86435dfSmsaitoh return (0);
125b86435dfSmsaitoh }
126