xref: /netbsd-src/usr.sbin/crash/arch/sparc.c (revision 28d11a42f4cf335fb13a37aafcb24db0c83c3555)
1*28d11a42Schristos /*	$NetBSD: sparc.c,v 1.1 2013/03/04 20:10:51 christos Exp $	*/
2*28d11a42Schristos 
3*28d11a42Schristos /*-
4*28d11a42Schristos  * Copyright (c) 2009 The NetBSD Foundation, Inc.
5*28d11a42Schristos  * All rights reserved.
6*28d11a42Schristos  *
7*28d11a42Schristos  * This code is derived from software contributed to The NetBSD Foundation
8*28d11a42Schristos  * by Andrew Doran.
9*28d11a42Schristos  *
10*28d11a42Schristos  * Redistribution and use in source and binary forms, with or without
11*28d11a42Schristos  * modification, are permitted provided that the following conditions
12*28d11a42Schristos  * are met:
13*28d11a42Schristos  * 1. Redistributions of source code must retain the above copyright
14*28d11a42Schristos  *    notice, this list of conditions and the following disclaimer.
15*28d11a42Schristos  * 2. Redistributions in binary form must reproduce the above copyright
16*28d11a42Schristos  *    notice, this list of conditions and the following disclaimer in the
17*28d11a42Schristos  *    documentation and/or other materials provided with the distribution.
18*28d11a42Schristos  *
19*28d11a42Schristos  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20*28d11a42Schristos  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21*28d11a42Schristos  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22*28d11a42Schristos  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23*28d11a42Schristos  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24*28d11a42Schristos  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25*28d11a42Schristos  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26*28d11a42Schristos  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27*28d11a42Schristos  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28*28d11a42Schristos  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29*28d11a42Schristos  * POSSIBILITY OF SUCH DAMAGE.
30*28d11a42Schristos  */
31*28d11a42Schristos 
32*28d11a42Schristos #include <sys/cdefs.h>
33*28d11a42Schristos #ifndef lint
34*28d11a42Schristos __RCSID("$NetBSD: sparc.c,v 1.1 2013/03/04 20:10:51 christos Exp $");
35*28d11a42Schristos #endif /* not lint */
36*28d11a42Schristos 
37*28d11a42Schristos #include <ddb/ddb.h>
38*28d11a42Schristos 
39*28d11a42Schristos #include <kvm.h>
40*28d11a42Schristos #include <nlist.h>
41*28d11a42Schristos #include <err.h>
42*28d11a42Schristos #include <stdlib.h>
43*28d11a42Schristos 
44*28d11a42Schristos #include <machine/pcb.h>
45*28d11a42Schristos 
46*28d11a42Schristos #include "extern.h"
47*28d11a42Schristos 
48*28d11a42Schristos static struct nlist nl[] = {
49*28d11a42Schristos 	{ .n_name = "dumppcb" },
50*28d11a42Schristos 	{ .n_name = NULL },
51*28d11a42Schristos };
52*28d11a42Schristos 
53*28d11a42Schristos struct pcb	pcb;
54*28d11a42Schristos 
55*28d11a42Schristos void
db_mach_init(kvm_t * kd)56*28d11a42Schristos db_mach_init(kvm_t *kd)
57*28d11a42Schristos {
58*28d11a42Schristos 
59*28d11a42Schristos 	if (kvm_nlist(kd, nl) == -1) {
60*28d11a42Schristos 		errx(EXIT_FAILURE, "kvm_nlist: %s", kvm_geterr(kd));
61*28d11a42Schristos 	}
62*28d11a42Schristos 	if ((size_t)kvm_read(kd, nl[0].n_value, &pcb, sizeof(pcb)) !=
63*28d11a42Schristos 	    sizeof(pcb)) {
64*28d11a42Schristos 		errx(EXIT_FAILURE, "cannot read dumppcb: %s", kvm_geterr(kd));
65*28d11a42Schristos 	}
66*28d11a42Schristos }
67