libpthread_md.c revision 302408
1325322Sgordon/*-
2325322Sgordon * Copyright (c) 2015 Ruslan Bukin <br@bsdpad.com>
3325322Sgordon * All rights reserved.
4325322Sgordon *
5325322Sgordon * Portions of this software were developed by SRI International and the
6325322Sgordon * University of Cambridge Computer Laboratory under DARPA/AFRL contract
7325322Sgordon * FA8750-10-C-0237 ("CTSRD"), as part of the DARPA CRASH research programme.
8331986Sgordon *
9325322Sgordon * Portions of this software were developed by the University of Cambridge
10325322Sgordon * Computer Laboratory as part of the CTSRD Project, with support from the
11325322Sgordon * UK Higher Education Innovation Fund (HEIF).
12331986Sgordon *
13331986Sgordon * Redistribution and use in source and binary forms, with or without
14331986Sgordon * modification, are permitted provided that the following conditions
15325322Sgordon * are met:
16331986Sgordon * 1. Redistributions of source code must retain the above copyright
17331986Sgordon *    notice, this list of conditions and the following disclaimer.
18325322Sgordon * 2. Redistributions in binary form must reproduce the above copyright
19325322Sgordon *    notice, this list of conditions and the following disclaimer in the
20325322Sgordon *    documentation and/or other materials provided with the distribution.
21325322Sgordon *
22325322Sgordon * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
23325322Sgordon * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24325322Sgordon * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25331986Sgordon * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
26331986Sgordon * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27325322Sgordon * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28331986Sgordon * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29331986Sgordon * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30331986Sgordon * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31331986Sgordon * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32331986Sgordon * SUCH DAMAGE.
33331986Sgordon */
34331986Sgordon
35331986Sgordon#include <sys/cdefs.h>
36331986Sgordon__FBSDID("$FreeBSD: stable/11/lib/libthread_db/arch/riscv/libpthread_md.c 294908 2016-01-27 10:34:07Z br $");
37331986Sgordon
38331986Sgordon#include <sys/types.h>
39331986Sgordon#include <string.h>
40331986Sgordon#include <thread_db.h>
41331986Sgordon
42331986Sgordon#include "libpthread_db.h"
43331986Sgordon
44331986Sgordonvoid
45331986Sgordonpt_reg_to_ucontext(const struct reg *r, ucontext_t *uc)
46325322Sgordon{
47325322Sgordon	mcontext_t *mc;
48325322Sgordon
49325322Sgordon	mc = &uc->uc_mcontext;
50325322Sgordon
51325322Sgordon	memcpy(mc->mc_gpregs.gp_t, r->t, sizeof(mc->mc_gpregs.gp_t));
52325322Sgordon	memcpy(mc->mc_gpregs.gp_s, r->s, sizeof(mc->mc_gpregs.gp_s));
53325322Sgordon	memcpy(mc->mc_gpregs.gp_a, r->a, sizeof(mc->mc_gpregs.gp_a));
54325322Sgordon	mc->mc_gpregs.gp_ra = r->ra;
55325322Sgordon	mc->mc_gpregs.gp_sp = r->sp;
56330568Sgordon	mc->mc_gpregs.gp_gp = r->gp;
57330568Sgordon	mc->mc_gpregs.gp_tp = r->tp;
58330568Sgordon	mc->mc_gpregs.gp_sepc = r->sepc;
59330568Sgordon	mc->mc_gpregs.gp_sstatus = r->sstatus;
60325322Sgordon}
61325322Sgordon
62325322Sgordonvoid
63331986Sgordonpt_ucontext_to_reg(const ucontext_t *uc, struct reg *r)
64331986Sgordon{
65331986Sgordon	const mcontext_t *mc;
66331986Sgordon
67331986Sgordon	mc = &uc->uc_mcontext;
68331986Sgordon
69331986Sgordon	memcpy(r->t, mc->mc_gpregs.gp_t, sizeof(mc->mc_gpregs.gp_t));
70331986Sgordon	memcpy(r->s, mc->mc_gpregs.gp_s, sizeof(mc->mc_gpregs.gp_s));
71331986Sgordon	memcpy(r->a, mc->mc_gpregs.gp_a, sizeof(mc->mc_gpregs.gp_a));
72331986Sgordon	r->ra = mc->mc_gpregs.gp_ra;
73331986Sgordon	r->sp = mc->mc_gpregs.gp_sp;
74331986Sgordon	r->gp = mc->mc_gpregs.gp_gp;
75331986Sgordon	r->tp = mc->mc_gpregs.gp_tp;
76331986Sgordon	r->sepc = mc->mc_gpregs.gp_sepc;
77331986Sgordon	r->sstatus = mc->mc_gpregs.gp_sstatus;
78331986Sgordon}
79331986Sgordon
80331986Sgordonvoid
81331986Sgordonpt_fpreg_to_ucontext(const struct fpreg *r __unused, ucontext_t *uc __unused)
82331986Sgordon{
83331986Sgordon
84325322Sgordon	/* RISCVTODO */
85325322Sgordon}
86331986Sgordon
87325322Sgordonvoid
88331986Sgordonpt_ucontext_to_fpreg(const ucontext_t *uc __unused, struct fpreg *r __unused)
89331986Sgordon{
90325322Sgordon
91331986Sgordon	/* RISCVTODO */
92331986Sgordon}
93325322Sgordon
94325322Sgordonvoid
95325322Sgordonpt_md_init(void)
96331986Sgordon{
97331986Sgordon}
98331986Sgordon
99331986Sgordonint
100325322Sgordonpt_reg_sstep(struct reg *reg __unused, int step __unused)
101325322Sgordon{
102325322Sgordon
103331986Sgordon	return (0);
104325322Sgordon}
105325322Sgordon