1 /* $NetBSD: kvm_or1k.c,v 1.1 2014/09/03 19:34:26 matt Exp $ */
4 * Copyright (c) 2014 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Matt Thomas of 3am Software Foundry.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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.
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.
33 * OR1K machine dependent routines for kvm.
36 #include <sys/param.h>
38 #include <sys/types.h>
40 #include <uvm/uvm_extern.h>
48 #include "kvm_private.h"
50 #include <sys/kcore.h>
51 #include <machine/kcore.h>
52 #include <machine/vmparam.h>
54 __RCSID("$NetBSD: kvm_or1k.c,v 1.1 2014/09/03 19:34:26 matt Exp $");
57 _kvm_freevtop(kvm_t
*kd
)
65 _kvm_initvtop(kvm_t
*kd
)
72 * Translate a KVA to a PA
75 _kvm_kvatop(kvm_t
*kd
, vaddr_t va
, paddr_t
*pa
)
77 // cpu_kcore_hdr_t *cpu_kh;
80 _kvm_err(kd
, 0, "vatop called in live kernel!");
84 /* No hit -- no translation */
90 _kvm_pa2off(kvm_t
*kd
, paddr_t pa
)
92 cpu_kcore_hdr_t
*cpu_kh
;
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
));
102 if (pa
>= ram
->start
&& (pa
- ram
->start
) < ram
->size
) {
103 return off
+ (pa
- ram
->start
);
107 } while ((void *) ram
< e
&& ram
->size
);
109 _kvm_err(kd
, 0, "pa2off failed for pa %#" PRIxPADDR
"\n", pa
);
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)
119 _kvm_mdopen(kvm_t
*kd
)
121 kd
->usrstack
= USRSTACK
;
122 kd
->min_uva
= VM_MIN_ADDRESS
;
123 kd
->max_uva
= VM_MAXUSER_ADDRESS
;