1 /* $NetBSD: kvm_m68k.c,v 1.19 2014/01/27 21:00:01 matt Exp $ */
4 * Copyright (c) 1997 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Gordon W. Ross and Jason R. Thorpe.
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 * Run-time kvm dispatcher for m68k machines.
34 * The actual MD code is in the files:
35 * kvm_m68k_cmn.c kvm_sun3.c ...
37 * Note: This file has to build on ALL m68k machines,
38 * so do NOT include any <machine/[*].h> files here.
41 #include <sys/param.h>
43 #include <sys/kcore.h>
44 #include <sys/sysctl.h>
45 #include <sys/types.h>
57 #include <m68k/kcore.h>
59 #include "kvm_private.h"
62 __RCSID("$NetBSD: kvm_m68k.c,v 1.19 2014/01/27 21:00:01 matt Exp $");
70 * Match specific kcore types first, falling into a default.
72 static struct name_ops optbl
[] = {
73 { "sun2", &_kvm_ops_sun2
},
74 { "sun3", &_kvm_ops_sun3
},
75 { "sun3x", &_kvm_ops_sun3x
},
76 { NULL
, &_kvm_ops_cmn
},
80 * Prepare for translation of kernel virtual addresses into offsets
81 * into crash dump files. This is where we do the dispatch work.
84 _kvm_initvtop(kvm_t
*kd
)
90 vm
= (struct vmstate
*)_kvm_malloc(kd
, sizeof (*vm
));
97 * Use the machine name in the kcore header to determine
98 * our ops vector. When we reach an ops vector with
99 * no name, we've found a default.
102 h
->name
[sizeof(h
->name
) - 1] = '\0'; /* sanity */
103 for (nop
= optbl
; nop
->name
!= NULL
; nop
++)
104 if (strcmp(nop
->name
, h
->name
) == 0)
110 * Compute pgshift and pgofset.
112 for (vm
->pgshift
= 0; (1 << vm
->pgshift
) < h
->page_size
; vm
->pgshift
++)
114 if ((1 << vm
->pgshift
) != h
->page_size
)
116 vm
->pgofset
= h
->page_size
- 1;
118 if ((vm
->ops
->initvtop
)(kd
) < 0)
130 _kvm_freevtop(kvm_t
*kd
)
132 (kd
->vmst
->ops
->freevtop
)(kd
);
137 _kvm_kvatop(kvm_t
*kd
, vaddr_t va
, paddr_t
*pap
)
139 return ((kd
->vmst
->ops
->kvatop
)(kd
, va
, pap
));
143 _kvm_pa2off(kvm_t
*kd
, paddr_t pa
)
145 return ((kd
->vmst
->ops
->pa2off
)(kd
, pa
));
149 * Machine-dependent initialization for ALL open kvm descriptors,
150 * not just those for a kernel crash dump. Some architectures
151 * have to deal with these NOT being constants! (i.e. m68k)
154 _kvm_mdopen(kvm_t
*kd
)
157 extern struct ps_strings
*__ps_strings
;
159 #if 0 /* XXX - These vary across m68k machines... */
160 kd
->usrstack
= USRSTACK
;
161 kd
->min_uva
= VM_MIN_ADDRESS
;
162 kd
->max_uva
= VM_MAXUSER_ADDRESS
;
164 /* This is somewhat hack-ish, but it works. */
165 max_uva
= (u_long
) (__ps_strings
+ 1);
166 kd
->usrstack
= max_uva
;
167 kd
->max_uva
= max_uva
;