1/* $NetBSD: linux_machdep.h,v 1.6 2007/12/04 18:40:14 dsl Exp $ */ 2 3/*- 4 * Copyright (c) 1998 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by ITOH Yasufumi. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32#ifndef _M68K_LINUX_MACHDEP_H 33#define _M68K_LINUX_MACHDEP_H 34 35#include <m68k/frame.h> 36#include <compat/linux/common/linux_types.h> 37#include <compat/linux/common/linux_signal.h> 38#include <compat/linux/common/linux_siginfo.h> 39 40/* 41 * Signal stack definitions for old signal interface. 42 */ 43 44struct linux_sigcontext { 45 linux_old_sigset_t sc_mask; /* signal mask to restore */ 46 u_int sc_sp; /* usp to restore */ 47 u_int sc_d0; 48 u_int sc_d1; 49 u_int sc_a0; 50 u_int sc_a1; 51 u_short sc_ps; /* processor status (sr reg) */ 52 u_int sc_pc; 53 54 /* 55 * The Linux sigstate (state of hardware). 56 */ 57 struct linux_sigstate { 58 u_short ss_format:4, /* frame # */ 59 ss_vector:12; /* vector offset */ 60 struct linux_fpframe { 61 u_int fpf_regs[2][3]; /* only fp0 and fp1 */ 62 u_int fpf_fpcr; 63 u_int fpf_fpsr; 64 u_int fpf_fpiar; 65 union FPF_u1 FPF_u1; 66 union FPF_u2 FPF_u2; 67 } ss_fpstate; /* 68881/68882 state info */ 68 union F_u ss_frame; /* original exception frame */ 69 } sc_ss; 70}; 71 72/* 73 * The Linux compatible signal frame 74 * On Linux, the sigtramp code is on the frame structure. 75 */ 76struct linux_sigframe { 77 void *sf_psigtramp; 78 int sf_signum; /* signo for handler */ 79 int sf_code; /* Linux stores vector offset here */ 80 struct linux_sigcontext *sf_scp; /* context ptr for handler */ 81 int sf_sigtramp[2]; 82 struct linux_sigc2 { 83#if LINUX__NSIG_WORDS > 1 84 /* This breaks backward compatibility, but Linux 2.1 has.... */ 85 u_long c_extrasigmask[LINUX__NSIG_WORDS - 1]; 86#endif 87 struct linux_sigcontext c_sc; /* actual context */ 88 } sf_c; 89}; 90 91#define LINUX_SF_SIGTRAMP0 0xDEFC0014 /* addaw #20,sp */ 92#define LINUX_SF_SIGTRAMP1 (0x70004E40 | (LINUX_SYS_sigreturn << 16)) 93 /* moveq #LINUX_SYS_sigreturn,d0; trap #0 */ 94 95/* 96 * Signal stack definitions for new RT signal interface. 97 */ 98 99typedef struct linux_gregset { 100 u_int gr_regs[16]; /* d0-d7/a0-a6/usp */ 101 u_int gr_pc; 102 u_int gr_sr; 103} linux_gregset_t; 104 105typedef struct linux_fpregset { 106 u_int fpr_fpcr; 107 u_int fpr_fpsr; 108 u_int fpr_fpiar; 109 u_int fpr_regs[8][3]; /* fp0-fp7 */ 110} linux_fpregset_t; 111 112struct linux_mcontext { 113 int mc_version; 114 linux_gregset_t mc_gregs; 115 linux_fpregset_t mc_fpregs; 116}; 117 118#define LINUX_MCONTEXT_VERSION 2 119 120struct linux_ucontext { 121 u_long uc_flags; /* 0 */ 122 struct linux_ucontext *uc_link; /* 0 */ 123 linux_stack_t uc_stack; 124 struct linux_mcontext uc_mc; 125 struct linux_rt_sigstate { 126 struct linux_rt_fpframe { 127 union FPF_u1 FPF_u1; 128 union FPF_u2 FPF_u2; 129 } ss_fpstate; 130 unsigned int ss_unused1:16, 131 ss_format:4, 132 ss_vector:12; 133 union F_u ss_frame; /* original exception frame */ 134 int ss_unused2[4]; 135 } uc_ss; 136 linux_sigset_t uc_sigmask; 137}; 138 139/* 140 * The Linux compatible RT signal frame 141 * On Linux, the sigtramp code is on the frame structure. 142 */ 143struct linux_rt_sigframe { 144 void *sf_psigtramp; 145 int sf_signum; 146 struct linux_siginfo *sf_pinfo; 147 void *sf_puc; 148 struct linux_siginfo sf_info; 149 struct linux_ucontext sf_uc; 150 int sf_sigtramp[2]; 151}; 152 153#define LINUX_RT_SF_SIGTRAMP0 (0x203C0000 | (LINUX_SYS_rt_sigreturn >> 16)) 154#define LINUX_RT_SF_SIGTRAMP1 (0x00004E40 | (LINUX_SYS_rt_sigreturn << 16)) 155 /* movel #LINUX_SYS_rt_sigreturn,#d0; trap #0 */ 156 157#ifdef _KERNEL 158__BEGIN_DECLS 159void linux_syscall_intern(struct proc *); 160__END_DECLS 161#endif /* !_KERNEL */ 162 163#endif /* _M68K_LINUX_MACHDEP_H */ 164