15e53a4f9SPedro F. Giffuni /*-
2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause
35e53a4f9SPedro F. Giffuni *
4ebbcec3aSOlivier Houchard * Copyright (c) 2007 Olivier Houchard
5ebbcec3aSOlivier Houchard * All rights reserved.
6ebbcec3aSOlivier Houchard *
7ebbcec3aSOlivier Houchard * Redistribution and use in source and binary forms, with or without
8ebbcec3aSOlivier Houchard * modification, are permitted provided that the following conditions
9ebbcec3aSOlivier Houchard * are met:
10ebbcec3aSOlivier Houchard * 1. Redistributions of source code must retain the above copyright
11ebbcec3aSOlivier Houchard * notice, this list of conditions and the following disclaimer.
12ebbcec3aSOlivier Houchard * 2. Redistributions in binary form must reproduce the above copyright
13ebbcec3aSOlivier Houchard * notice, this list of conditions and the following disclaimer in the
14ebbcec3aSOlivier Houchard * documentation and/or other materials provided with the distribution.
15ebbcec3aSOlivier Houchard *
16ebbcec3aSOlivier Houchard * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17ebbcec3aSOlivier Houchard * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18ebbcec3aSOlivier Houchard * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19ebbcec3aSOlivier Houchard * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20ebbcec3aSOlivier Houchard * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21ebbcec3aSOlivier Houchard * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22ebbcec3aSOlivier Houchard * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23ebbcec3aSOlivier Houchard * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24ebbcec3aSOlivier Houchard * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25ebbcec3aSOlivier Houchard * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26ebbcec3aSOlivier Houchard * SUCH DAMAGE.
27ebbcec3aSOlivier Houchard */
28ebbcec3aSOlivier Houchard
29ebbcec3aSOlivier Houchard #include <sys/cdefs.h>
30ebbcec3aSOlivier Houchard #include <sys/types.h>
31820c1c55SMarcel Moolenaar #include <string.h>
32ebbcec3aSOlivier Houchard #include <thread_db.h>
33ebbcec3aSOlivier Houchard
34ebbcec3aSOlivier Houchard #include "libpthread_db.h"
35ebbcec3aSOlivier Houchard
36ebbcec3aSOlivier Houchard void
pt_reg_to_ucontext(const struct reg * r,ucontext_t * uc)37ebbcec3aSOlivier Houchard pt_reg_to_ucontext(const struct reg *r, ucontext_t *uc)
38ebbcec3aSOlivier Houchard {
39ebbcec3aSOlivier Houchard mcontext_t *mc = &uc->uc_mcontext;
40ebbcec3aSOlivier Houchard __greg_t *gr = mc->__gregs;
41ebbcec3aSOlivier Houchard
42ebbcec3aSOlivier Houchard gr[_REG_R0] = r->r[0];
43ebbcec3aSOlivier Houchard gr[_REG_R1] = r->r[1];
44ebbcec3aSOlivier Houchard gr[_REG_R2] = r->r[2];
45ebbcec3aSOlivier Houchard gr[_REG_R3] = r->r[3];
46ebbcec3aSOlivier Houchard gr[_REG_R4] = r->r[4];
47ebbcec3aSOlivier Houchard gr[_REG_R5] = r->r[5];
48ebbcec3aSOlivier Houchard gr[_REG_R6] = r->r[6];
49ebbcec3aSOlivier Houchard gr[_REG_R7] = r->r[7];
50ebbcec3aSOlivier Houchard gr[_REG_R8] = r->r[8];
51ebbcec3aSOlivier Houchard gr[_REG_R9] = r->r[9];
52ebbcec3aSOlivier Houchard gr[_REG_R10] = r->r[10];
53ebbcec3aSOlivier Houchard gr[_REG_R11] = r->r[11];
54ebbcec3aSOlivier Houchard gr[_REG_R12] = r->r[12];
55ebbcec3aSOlivier Houchard gr[_REG_SP] = r->r_sp;
56ebbcec3aSOlivier Houchard gr[_REG_LR] = r->r_lr;
57ebbcec3aSOlivier Houchard gr[_REG_PC] = r->r_pc;
58ebbcec3aSOlivier Houchard gr[_REG_CPSR] = r->r_cpsr;
59ebbcec3aSOlivier Houchard }
60ebbcec3aSOlivier Houchard
61ebbcec3aSOlivier Houchard void
pt_ucontext_to_reg(const ucontext_t * uc,struct reg * r)62ebbcec3aSOlivier Houchard pt_ucontext_to_reg(const ucontext_t *uc, struct reg *r)
63ebbcec3aSOlivier Houchard {
64ebbcec3aSOlivier Houchard const mcontext_t *mc = &uc->uc_mcontext;
65ebbcec3aSOlivier Houchard
66ebbcec3aSOlivier Houchard const __greg_t *gr = mc->__gregs;
67ebbcec3aSOlivier Houchard
68ebbcec3aSOlivier Houchard r->r[0] = gr[_REG_R0];
69ebbcec3aSOlivier Houchard r->r[1] = gr[_REG_R1];
70ebbcec3aSOlivier Houchard r->r[2] = gr[_REG_R2];
71ebbcec3aSOlivier Houchard r->r[3] = gr[_REG_R3];
72ebbcec3aSOlivier Houchard r->r[4] = gr[_REG_R4];
73ebbcec3aSOlivier Houchard r->r[5] = gr[_REG_R5];
74ebbcec3aSOlivier Houchard r->r[6] = gr[_REG_R6];
75ebbcec3aSOlivier Houchard r->r[7] = gr[_REG_R7];
76ebbcec3aSOlivier Houchard r->r[8] = gr[_REG_R8];
77ebbcec3aSOlivier Houchard r->r[9] = gr[_REG_R9];
78ebbcec3aSOlivier Houchard r->r[10] = gr[_REG_R10];
79ebbcec3aSOlivier Houchard r->r[11] = gr[_REG_R11];
80ebbcec3aSOlivier Houchard r->r[12] = gr[_REG_R12];
81ebbcec3aSOlivier Houchard r->r_sp = gr[_REG_SP];
82ebbcec3aSOlivier Houchard r->r_lr = gr[_REG_LR];
83ebbcec3aSOlivier Houchard r->r_pc = gr[_REG_PC];
84ebbcec3aSOlivier Houchard r->r_cpsr = gr[_REG_CPSR];
85ebbcec3aSOlivier Houchard }
86ebbcec3aSOlivier Houchard
87ebbcec3aSOlivier Houchard void
pt_fpreg_to_ucontext(const struct fpreg * r,ucontext_t * uc)886926e269SKornel Dulęba pt_fpreg_to_ucontext(const struct fpreg *r, ucontext_t *uc)
89ebbcec3aSOlivier Houchard {
906926e269SKornel Dulęba mcontext_vfp_t *mc_vfp;
91ebbcec3aSOlivier Houchard
926926e269SKornel Dulęba mc_vfp = uc->uc_mcontext.mc_vfp_ptr;
936926e269SKornel Dulęba
946926e269SKornel Dulęba if (mc_vfp != NULL)
956926e269SKornel Dulęba memcpy(mc_vfp, r, sizeof(*r));
96ebbcec3aSOlivier Houchard }
97ebbcec3aSOlivier Houchard
98ebbcec3aSOlivier Houchard void
pt_ucontext_to_fpreg(const ucontext_t * uc,struct fpreg * r)996926e269SKornel Dulęba pt_ucontext_to_fpreg(const ucontext_t *uc, struct fpreg *r)
100ebbcec3aSOlivier Houchard {
1016926e269SKornel Dulęba mcontext_vfp_t *mc_vfp;
102ebbcec3aSOlivier Houchard
1036926e269SKornel Dulęba mc_vfp = uc->uc_mcontext.mc_vfp_ptr;
1046926e269SKornel Dulęba
1056926e269SKornel Dulęba if (mc_vfp != NULL)
1066926e269SKornel Dulęba memcpy(r, &mc_vfp, sizeof(*r));
107ebbcec3aSOlivier Houchard }
108ebbcec3aSOlivier Houchard
109ebbcec3aSOlivier Houchard void
pt_md_init(void)110ebbcec3aSOlivier Houchard pt_md_init(void)
111ebbcec3aSOlivier Houchard {
112ebbcec3aSOlivier Houchard }
113ebbcec3aSOlivier Houchard
114ebbcec3aSOlivier Houchard int
pt_reg_sstep(struct reg * reg __unused,int step __unused)115f60a5b31SMarcel Moolenaar pt_reg_sstep(struct reg *reg __unused, int step __unused)
116ebbcec3aSOlivier Houchard {
117ebbcec3aSOlivier Houchard
118ebbcec3aSOlivier Houchard /* XXX */
1192f6a179eSMarcel Moolenaar return (0);
120ebbcec3aSOlivier Houchard }
121