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