libpthread_md.c revision 181044
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: head/lib/libthread_db/arch/arm/libpthread_md.c 181044 2008-07-31 05:25:52Z marcel $");
29173703Scognet
30173703Scognet#include <string.h>
31173703Scognet#include <sys/types.h>
32173703Scognet#include <proc_service.h>
33173703Scognet#include <thread_db.h>
34173703Scognet
35173703Scognet#include "libpthread_db.h"
36173703Scognet
37173703Scognetvoid
38173703Scognetpt_reg_to_ucontext(const struct reg *r, ucontext_t *uc)
39173703Scognet{
40173703Scognet	mcontext_t *mc = &uc->uc_mcontext;
41173703Scognet	__greg_t *gr = mc->__gregs;
42173703Scognet
43173703Scognet	gr[_REG_R0] = r->r[0];
44173703Scognet	gr[_REG_R1] = r->r[1];
45173703Scognet	gr[_REG_R2] = r->r[2];
46173703Scognet	gr[_REG_R3] = r->r[3];
47173703Scognet	gr[_REG_R4] = r->r[4];
48173703Scognet	gr[_REG_R5] = r->r[5];
49173703Scognet	gr[_REG_R6] = r->r[6];
50173703Scognet	gr[_REG_R7] = r->r[7];
51173703Scognet	gr[_REG_R8] = r->r[8];
52173703Scognet	gr[_REG_R9] = r->r[9];
53173703Scognet	gr[_REG_R10] = r->r[10];
54173703Scognet	gr[_REG_R11] = r->r[11];
55173703Scognet	gr[_REG_R12] = r->r[12];
56173703Scognet	gr[_REG_SP] = r->r_sp;
57173703Scognet	gr[_REG_LR] = r->r_lr;
58173703Scognet	gr[_REG_PC] = r->r_pc;
59173703Scognet	gr[_REG_CPSR] = r->r_cpsr;
60173703Scognet}
61173703Scognet
62173703Scognetvoid
63173703Scognetpt_ucontext_to_reg(const ucontext_t *uc, struct reg *r)
64173703Scognet{
65173703Scognet	const mcontext_t *mc = &uc->uc_mcontext;
66173703Scognet
67173703Scognet	const __greg_t *gr = mc->__gregs;
68173703Scognet
69173703Scognet	r->r[0] = gr[_REG_R0];
70173703Scognet	r->r[1] = gr[_REG_R1];
71173703Scognet	r->r[2] = gr[_REG_R2];
72173703Scognet	r->r[3] = gr[_REG_R3];
73173703Scognet	r->r[4] = gr[_REG_R4];
74173703Scognet	r->r[5] = gr[_REG_R5];
75173703Scognet	r->r[6] = gr[_REG_R6];
76173703Scognet	r->r[7] = gr[_REG_R7];
77173703Scognet	r->r[8] = gr[_REG_R8];
78173703Scognet	r->r[9] = gr[_REG_R9];
79173703Scognet	r->r[10] = gr[_REG_R10];
80173703Scognet	r->r[11] = gr[_REG_R11];
81173703Scognet	r->r[12] = gr[_REG_R12];
82173703Scognet	r->r_sp = gr[_REG_SP];
83173703Scognet	r->r_lr = gr[_REG_LR];
84173703Scognet	r->r_pc = gr[_REG_PC];
85173703Scognet	r->r_cpsr = gr[_REG_CPSR];
86173703Scognet}
87173703Scognet
88173703Scognetvoid
89173703Scognetpt_fpreg_to_ucontext(const struct fpreg *r, ucontext_t *uc)
90173703Scognet{
91173703Scognet	mcontext_t *mc = &uc->uc_mcontext;
92173703Scognet
93173703Scognet	/* XXX */
94173703Scognet	memset(&mc->__fpu.__fpregs, 0, sizeof(__fpregset_t));
95173703Scognet}
96173703Scognet
97173703Scognetvoid
98173703Scognetpt_ucontext_to_fpreg(const ucontext_t *uc, struct fpreg *r)
99173703Scognet{
100173703Scognet
101173703Scognet	/* XXX */
102173703Scognet	memset(r, 0, sizeof(*r));
103173703Scognet}
104173703Scognet
105173703Scognetvoid
106173703Scognetpt_md_init(void)
107173703Scognet{
108173703Scognet}
109173703Scognet
110173703Scognetint
111173703Scognetpt_reg_sstep(struct reg *reg, int step)
112173703Scognet{
113173703Scognet
114173703Scognet	/* XXX */
115181044Smarcel	return (0);
116173703Scognet}
117