11da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/*
21da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *    Copyright (C) 2001 Matthew Wilcox <willy at parisc-linux.org>
31da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *    Copyright (C) 2003 Carlos O'Donell <carlos at parisc-linux.org>
41da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
51da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *    This program is free software; you can redistribute it and/or modify
61da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *    it under the terms of the GNU General Public License as published by
71da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *    the Free Software Foundation; either version 2 of the License, or
81da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *    (at your option) any later version.
91da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *    This program is distributed in the hope that it will be useful,
111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *    but WITHOUT ANY WARRANTY; without even the implied warranty of
121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *    GNU General Public License for more details.
141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *    You should have received a copy of the GNU General Public License
161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *    along with this program; if not, write to the Free Software
171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */
191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#ifndef _PARISC64_KERNEL_SIGNAL32_H
201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define _PARISC64_KERNEL_SIGNAL32_H
211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/compat.h>
23f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin
24f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin/* 32-bit ucontext as seen from an 64-bit kernel */
25f671c45df23005692daa200aba768c642fb14ef2Kyle McMartinstruct compat_ucontext {
26f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin        compat_uint_t uc_flags;
27f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin        compat_uptr_t uc_link;
28f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin        compat_stack_t uc_stack;        /* struct compat_sigaltstack (12 bytes)*/
29f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin        /* FIXME: Pad out to get uc_mcontext to start at an 8-byte aligned boundary */
30f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin        compat_uint_t pad[1];
31f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin        struct compat_sigcontext uc_mcontext;
32f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin        compat_sigset_t uc_sigmask;     /* mask last for extensibility */
33f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin};
341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* ELF32 signal handling */
361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
37ce3959604878c1c693979ec552069dc8bdb5ccdeAl Viroint copy_siginfo_to_user32 (compat_siginfo_t __user *to, const siginfo_t *from);
38f671c45df23005692daa200aba768c642fb14ef2Kyle McMartinint copy_siginfo_from_user32 (siginfo_t *to, compat_siginfo_t __user *from);
39f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin
40f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin/* In a deft move of uber-hackery, we decide to carry the top half of all
41f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin * 64-bit registers in a non-portable, non-ABI, hidden structure.
42f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin * Userspace can read the hidden structure if it *wants* but is never
437022672e4046fac4699aa5f8ff2a5213b7ec4ff9Simon Arlott * guaranteed to be in the same place. In fact the uc_sigmask from the
44f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin * ucontext_t structure may push the hidden register file downards
45f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin */
46f671c45df23005692daa200aba768c642fb14ef2Kyle McMartinstruct compat_regfile {
47f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin        /* Upper half of all the 64-bit registers that were truncated
48f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin           on a copy to a 32-bit userspace */
49f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin        compat_int_t rf_gr[32];
50f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin        compat_int_t rf_iasq[2];
51f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin        compat_int_t rf_iaoq[2];
52f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin        compat_int_t rf_sar;
53f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin};
54f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin
55f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin#define COMPAT_SIGRETURN_TRAMP 4
56f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin#define COMPAT_SIGRESTARTBLOCK_TRAMP 5
57f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin#define COMPAT_TRAMP_SIZE (COMPAT_SIGRETURN_TRAMP + \
58f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin				COMPAT_SIGRESTARTBLOCK_TRAMP)
59f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin
60f671c45df23005692daa200aba768c642fb14ef2Kyle McMartinstruct compat_rt_sigframe {
61f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin        /* XXX: Must match trampoline size in arch/parisc/kernel/signal.c
62f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin                Secondary to that it must protect the ERESTART_RESTARTBLOCK
63f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin                trampoline we left on the stack (we were bad and didn't
64f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin                change sp so we could run really fast.) */
65f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin        compat_uint_t tramp[COMPAT_TRAMP_SIZE];
66f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin        compat_siginfo_t info;
67f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin        struct compat_ucontext uc;
68f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin        /* Hidden location of truncated registers, *must* be last. */
69f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin        struct compat_regfile regs;
70f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin};
71f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin
72f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin/*
73f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin * The 32-bit ABI wants at least 48 bytes for a function call frame:
74f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin * 16 bytes for arg0-arg3, and 32 bytes for magic (the only part of
75f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin * which Linux/parisc uses is sp-20 for the saved return pointer...)
76f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin * Then, the stack pointer must be rounded to a cache line (64 bytes).
77f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin */
78f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin#define SIGFRAME32              64
79f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin#define FUNCTIONCALLFRAME32     48
80f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin#define PARISC_RT_SIGFRAME_SIZE32 (((sizeof(struct compat_rt_sigframe) + FUNCTIONCALLFRAME32) + SIGFRAME32) & -SIGFRAME32)
81f671c45df23005692daa200aba768c642fb14ef2Kyle McMartin
821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsvoid sigset_32to64(sigset_t *s64, compat_sigset_t *s32);
831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsvoid sigset_64to32(compat_sigset_t *s32, sigset_t *s64);
841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldslong restore_sigcontext32(struct compat_sigcontext __user *sc,
851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		struct compat_regfile __user *rf,
861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		struct pt_regs *regs);
871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldslong setup_sigcontext32(struct compat_sigcontext __user *sc,
881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		struct compat_regfile __user *rf,
891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		struct pt_regs *regs, int in_syscall);
901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif
92