/*1* Copyright (C) 2001 Matthew Wilcox <willy at parisc-linux.org>2* Copyright (C) 2003 Carlos O'Donell <carlos at parisc-linux.org>3*4* This program is free software; you can redistribute it and/or modify5* it under the terms of the GNU General Public License as published by6* the Free Software Foundation; either version 2 of the License, or7* (at your option) any later version.8*9* This program is distributed in the hope that it will be useful,10* but WITHOUT ANY WARRANTY; without even the implied warranty of11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12* GNU General Public License for more details.13*14* You should have received a copy of the GNU General Public License15* along with this program; if not, write to the Free Software16* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA17*/18#ifndef _PARISC64_KERNEL_SIGNAL32_H19#define _PARISC64_KERNEL_SIGNAL32_H2021#include <linux/compat.h>2223typedef compat_uptr_t compat_sighandler_t;2425typedef struct compat_sigaltstack {26compat_uptr_t ss_sp;27compat_int_t ss_flags;28compat_size_t ss_size;29} compat_stack_t;3031/* Most things should be clean enough to redefine this at will, if care32is taken to make libc match. */3334struct compat_sigaction {35compat_sighandler_t sa_handler;36compat_uint_t sa_flags;37compat_sigset_t sa_mask; /* mask last for extensibility */38};3940/* 32-bit ucontext as seen from an 64-bit kernel */41struct compat_ucontext {42compat_uint_t uc_flags;43compat_uptr_t uc_link;44compat_stack_t uc_stack; /* struct compat_sigaltstack (12 bytes)*/45/* FIXME: Pad out to get uc_mcontext to start at an 8-byte aligned boundary */46compat_uint_t pad[1];47struct compat_sigcontext uc_mcontext;48compat_sigset_t uc_sigmask; /* mask last for extensibility */49};5051/* ELF32 signal handling */5253struct k_sigaction32 {54struct compat_sigaction sa;55};5657typedef struct compat_siginfo {58int si_signo;59int si_errno;60int si_code;6162union {63int _pad[((128/sizeof(int)) - 3)];6465/* kill() */66struct {67unsigned int _pid; /* sender's pid */68unsigned int _uid; /* sender's uid */69} _kill;7071/* POSIX.1b timers */72struct {73compat_timer_t _tid; /* timer id */74int _overrun; /* overrun count */75char _pad[sizeof(unsigned int) - sizeof(int)];76compat_sigval_t _sigval; /* same as below */77int _sys_private; /* not to be passed to user */78} _timer;7980/* POSIX.1b signals */81struct {82unsigned int _pid; /* sender's pid */83unsigned int _uid; /* sender's uid */84compat_sigval_t _sigval;85} _rt;8687/* SIGCHLD */88struct {89unsigned int _pid; /* which child */90unsigned int _uid; /* sender's uid */91int _status; /* exit code */92compat_clock_t _utime;93compat_clock_t _stime;94} _sigchld;9596/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */97struct {98unsigned int _addr; /* faulting insn/memory ref. */99} _sigfault;100101/* SIGPOLL */102struct {103int _band; /* POLL_IN, POLL_OUT, POLL_MSG */104int _fd;105} _sigpoll;106} _sifields;107} compat_siginfo_t;108109int copy_siginfo_to_user32 (compat_siginfo_t __user *to, siginfo_t *from);110int copy_siginfo_from_user32 (siginfo_t *to, compat_siginfo_t __user *from);111112/* In a deft move of uber-hackery, we decide to carry the top half of all113* 64-bit registers in a non-portable, non-ABI, hidden structure.114* Userspace can read the hidden structure if it *wants* but is never115* guaranteed to be in the same place. In fact the uc_sigmask from the116* ucontext_t structure may push the hidden register file downards117*/118struct compat_regfile {119/* Upper half of all the 64-bit registers that were truncated120on a copy to a 32-bit userspace */121compat_int_t rf_gr[32];122compat_int_t rf_iasq[2];123compat_int_t rf_iaoq[2];124compat_int_t rf_sar;125};126127#define COMPAT_SIGRETURN_TRAMP 4128#define COMPAT_SIGRESTARTBLOCK_TRAMP 5129#define COMPAT_TRAMP_SIZE (COMPAT_SIGRETURN_TRAMP + \130COMPAT_SIGRESTARTBLOCK_TRAMP)131132struct compat_rt_sigframe {133/* XXX: Must match trampoline size in arch/parisc/kernel/signal.c134Secondary to that it must protect the ERESTART_RESTARTBLOCK135trampoline we left on the stack (we were bad and didn't136change sp so we could run really fast.) */137compat_uint_t tramp[COMPAT_TRAMP_SIZE];138compat_siginfo_t info;139struct compat_ucontext uc;140/* Hidden location of truncated registers, *must* be last. */141struct compat_regfile regs;142};143144/*145* The 32-bit ABI wants at least 48 bytes for a function call frame:146* 16 bytes for arg0-arg3, and 32 bytes for magic (the only part of147* which Linux/parisc uses is sp-20 for the saved return pointer...)148* Then, the stack pointer must be rounded to a cache line (64 bytes).149*/150#define SIGFRAME32 64151#define FUNCTIONCALLFRAME32 48152#define PARISC_RT_SIGFRAME_SIZE32 (((sizeof(struct compat_rt_sigframe) + FUNCTIONCALLFRAME32) + SIGFRAME32) & -SIGFRAME32)153154void sigset_32to64(sigset_t *s64, compat_sigset_t *s32);155void sigset_64to32(compat_sigset_t *s32, sigset_t *s64);156int do_sigaltstack32 (const compat_stack_t __user *uss32,157compat_stack_t __user *uoss32, unsigned long sp);158long restore_sigcontext32(struct compat_sigcontext __user *sc,159struct compat_regfile __user *rf,160struct pt_regs *regs);161long setup_sigcontext32(struct compat_sigcontext __user *sc,162struct compat_regfile __user *rf,163struct pt_regs *regs, int in_syscall);164165#endif166167168