1173703Scognet/*
2173703Scognet * Copyright (c) 2007 Olivier Houchard
3173703Scognet * All rights reserved.
4173703Scognet *
5173703Scognet * Redistribution and use in source and binary forms, with or without
6173703Scognet * modification, are permitted provided that the following conditions
7173703Scognet * are met:
8173703Scognet * 1. Redistributions of source code must retain the above copyright
9173703Scognet *    notice, this list of conditions and the following disclaimer.
10173703Scognet * 2. Redistributions in binary form must reproduce the above copyright
11173703Scognet *    notice, this list of conditions and the following disclaimer in the
12173703Scognet *    documentation and/or other materials provided with the distribution.
13173703Scognet *
14173703Scognet * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15173703Scognet * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16173703Scognet * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17173703Scognet * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18173703Scognet * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19173703Scognet * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20173703Scognet * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21173703Scognet * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22173703Scognet * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23173703Scognet * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24173703Scognet * SUCH DAMAGE.
25173703Scognet */
26173703Scognet
27173703Scognet#include <sys/cdefs.h>
28173703Scognet__FBSDID("$FreeBSD: releng/11.0/lib/libthread_db/arch/arm/libpthread_md.c 254450 2013-08-17 14:42:40Z andrew $");
29173703Scognet
30181059Smarcel#include <sys/types.h>
31173703Scognet#include <string.h>
32173703Scognet#include <thread_db.h>
33173703Scognet
34173703Scognet#include "libpthread_db.h"
35173703Scognet
36173703Scognetvoid
37173703Scognetpt_reg_to_ucontext(const struct reg *r, ucontext_t *uc)
38173703Scognet{
39173703Scognet	mcontext_t *mc = &uc->uc_mcontext;
40173703Scognet	__greg_t *gr = mc->__gregs;
41173703Scognet
42173703Scognet	gr[_REG_R0] = r->r[0];
43173703Scognet	gr[_REG_R1] = r->r[1];
44173703Scognet	gr[_REG_R2] = r->r[2];
45173703Scognet	gr[_REG_R3] = r->r[3];
46173703Scognet	gr[_REG_R4] = r->r[4];
47173703Scognet	gr[_REG_R5] = r->r[5];
48173703Scognet	gr[_REG_R6] = r->r[6];
49173703Scognet	gr[_REG_R7] = r->r[7];
50173703Scognet	gr[_REG_R8] = r->r[8];
51173703Scognet	gr[_REG_R9] = r->r[9];
52173703Scognet	gr[_REG_R10] = r->r[10];
53173703Scognet	gr[_REG_R11] = r->r[11];
54173703Scognet	gr[_REG_R12] = r->r[12];
55173703Scognet	gr[_REG_SP] = r->r_sp;
56173703Scognet	gr[_REG_LR] = r->r_lr;
57173703Scognet	gr[_REG_PC] = r->r_pc;
58173703Scognet	gr[_REG_CPSR] = r->r_cpsr;
59173703Scognet}
60173703Scognet
61173703Scognetvoid
62173703Scognetpt_ucontext_to_reg(const ucontext_t *uc, struct reg *r)
63173703Scognet{
64173703Scognet	const mcontext_t *mc = &uc->uc_mcontext;
65173703Scognet
66173703Scognet	const __greg_t *gr = mc->__gregs;
67173703Scognet
68173703Scognet	r->r[0] = gr[_REG_R0];
69173703Scognet	r->r[1] = gr[_REG_R1];
70173703Scognet	r->r[2] = gr[_REG_R2];
71173703Scognet	r->r[3] = gr[_REG_R3];
72173703Scognet	r->r[4] = gr[_REG_R4];
73173703Scognet	r->r[5] = gr[_REG_R5];
74173703Scognet	r->r[6] = gr[_REG_R6];
75173703Scognet	r->r[7] = gr[_REG_R7];
76173703Scognet	r->r[8] = gr[_REG_R8];
77173703Scognet	r->r[9] = gr[_REG_R9];
78173703Scognet	r->r[10] = gr[_REG_R10];
79173703Scognet	r->r[11] = gr[_REG_R11];
80173703Scognet	r->r[12] = gr[_REG_R12];
81173703Scognet	r->r_sp = gr[_REG_SP];
82173703Scognet	r->r_lr = gr[_REG_LR];
83173703Scognet	r->r_pc = gr[_REG_PC];
84173703Scognet	r->r_cpsr = gr[_REG_CPSR];
85173703Scognet}
86173703Scognet
87173703Scognetvoid
88181341Smarcelpt_fpreg_to_ucontext(const struct fpreg *r __unused, ucontext_t *uc)
89173703Scognet{
90173703Scognet	mcontext_t *mc = &uc->uc_mcontext;
91173703Scognet
92173703Scognet	/* XXX */
93254450Sandrew	memset(&mc->__fpu, 0, sizeof(mc->__fpu));
94173703Scognet}
95173703Scognet
96173703Scognetvoid
97181341Smarcelpt_ucontext_to_fpreg(const ucontext_t *uc __unused, struct fpreg *r)
98173703Scognet{
99173703Scognet
100173703Scognet	/* XXX */
101173703Scognet	memset(r, 0, sizeof(*r));
102173703Scognet}
103173703Scognet
104173703Scognetvoid
105173703Scognetpt_md_init(void)
106173703Scognet{
107173703Scognet}
108173703Scognet
109173703Scognetint
110181341Smarcelpt_reg_sstep(struct reg *reg __unused, int step __unused)
111173703Scognet{
112173703Scognet
113173703Scognet	/* XXX */
114181044Smarcel	return (0);
115173703Scognet}
116