1132332Smarcel/* 2132332Smarcel * Copyright (c) 2004 Marcel Moolenaar 3224685Smarius * Copyright (c) 2011 Marius Strobl <marius@FreeBSD.org> 4132332Smarcel * All rights reserved. 5132332Smarcel * 6132332Smarcel * Redistribution and use in source and binary forms, with or without 7132332Smarcel * modification, are permitted provided that the following conditions 8132332Smarcel * are met: 9132332Smarcel * 10132332Smarcel * 1. Redistributions of source code must retain the above copyright 11132332Smarcel * notice, this list of conditions and the following disclaimer. 12132332Smarcel * 2. Redistributions in binary form must reproduce the above copyright 13132332Smarcel * notice, this list of conditions and the following disclaimer in the 14132332Smarcel * documentation and/or other materials provided with the distribution. 15132332Smarcel * 16132332Smarcel * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17132332Smarcel * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18132332Smarcel * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19132332Smarcel * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20132332Smarcel * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21132332Smarcel * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22132332Smarcel * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23132332Smarcel * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24132332Smarcel * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25132332Smarcel * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26132332Smarcel */ 27132332Smarcel 28132332Smarcel#include <sys/cdefs.h> 29132332Smarcel__FBSDID("$FreeBSD$"); 30132332Smarcel 31224685Smarius#include <sys/types.h> 32224685Smarius#include <string.h> 33181059Smarcel#include <thread_db.h> 34132360Smarcel#include <ucontext.h> 35224685Smarius#include <machine/fsr.h> 36132351Sscottl 37181059Smarcel#include "libpthread_db.h" 38181059Smarcel 39132332Smarcelvoid 40224685Smariuspt_reg_to_ucontext(const struct reg *r, ucontext_t *uc) 41132332Smarcel{ 42224685Smarius 43224685Smarius memcpy(&uc->uc_mcontext, r, MIN(sizeof(uc->uc_mcontext), sizeof(*r))); 44132332Smarcel} 45132332Smarcel 46132332Smarcelvoid 47224685Smariuspt_ucontext_to_reg(const ucontext_t *uc, struct reg *r) 48132332Smarcel{ 49224685Smarius 50224685Smarius memcpy(r, &uc->uc_mcontext, MIN(sizeof(uc->uc_mcontext), sizeof(*r))); 51132332Smarcel} 52132332Smarcel 53132332Smarcelvoid 54224685Smariuspt_fpreg_to_ucontext(const struct fpreg* r, ucontext_t *uc) 55132332Smarcel{ 56224685Smarius mcontext_t *mc = &uc->uc_mcontext; 57224685Smarius 58224685Smarius memcpy(mc->mc_fp, r->fr_regs, MIN(sizeof(mc->mc_fp), 59224685Smarius sizeof(r->fr_regs))); 60254157Smarius mc->_mc_fsr = r->fr_fsr; 61254157Smarius mc->_mc_gsr = r->fr_gsr; 62254157Smarius mc->_mc_fprs |= FPRS_FEF; 63132332Smarcel} 64132332Smarcel 65132332Smarcelvoid 66224685Smariuspt_ucontext_to_fpreg(const ucontext_t *uc, struct fpreg *r) 67132332Smarcel{ 68224685Smarius const mcontext_t *mc = &uc->uc_mcontext; 69224685Smarius 70254157Smarius if ((mc->_mc_fprs & FPRS_FEF) != 0) { 71224685Smarius memcpy(r->fr_regs, mc->mc_fp, MIN(sizeof(mc->mc_fp), 72224685Smarius sizeof(r->fr_regs))); 73254157Smarius r->fr_fsr = mc->_mc_fsr; 74254157Smarius r->fr_gsr = mc->_mc_gsr; 75224685Smarius } else 76224685Smarius memset(r, 0, sizeof(*r)); 77132332Smarcel} 78132332Smarcel 79132332Smarcelvoid 80132332Smarcelpt_md_init(void) 81132332Smarcel{ 82224685Smarius 83132332Smarcel} 84132332Smarcel 85132332Smarcelint 86181341Smarcelpt_reg_sstep(struct reg *reg __unused, int step __unused) 87132332Smarcel{ 88224685Smarius 89132332Smarcel return (0); 90132332Smarcel} 91