blob: 640dc3ec8f5dd7377f0cee342db35b300624280d [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Copyright (C) 2001 Matthew Wilcox <willy at parisc-linux.org>
3 * Copyright (C) 2003 Carlos O'Donell <carlos at parisc-linux.org>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#ifndef _PARISC64_KERNEL_SIGNAL32_H
20#define _PARISC64_KERNEL_SIGNAL32_H
21
22#include <linux/compat.h>
Kyle McMartinf671c452006-01-15 14:10:29 -050023
24typedef compat_uptr_t compat_sighandler_t;
25
Kyle McMartinf671c452006-01-15 14:10:29 -050026/* Most things should be clean enough to redefine this at will, if care
27 is taken to make libc match. */
28
29struct compat_sigaction {
30 compat_sighandler_t sa_handler;
31 compat_uint_t sa_flags;
32 compat_sigset_t sa_mask; /* mask last for extensibility */
33};
34
35/* 32-bit ucontext as seen from an 64-bit kernel */
36struct compat_ucontext {
37 compat_uint_t uc_flags;
38 compat_uptr_t uc_link;
39 compat_stack_t uc_stack; /* struct compat_sigaltstack (12 bytes)*/
40 /* FIXME: Pad out to get uc_mcontext to start at an 8-byte aligned boundary */
41 compat_uint_t pad[1];
42 struct compat_sigcontext uc_mcontext;
43 compat_sigset_t uc_sigmask; /* mask last for extensibility */
44};
Linus Torvalds1da177e2005-04-16 15:20:36 -070045
46/* ELF32 signal handling */
47
48struct k_sigaction32 {
49 struct compat_sigaction sa;
50};
51
Kyle McMartinf671c452006-01-15 14:10:29 -050052int copy_siginfo_to_user32 (compat_siginfo_t __user *to, siginfo_t *from);
53int copy_siginfo_from_user32 (siginfo_t *to, compat_siginfo_t __user *from);
54
55/* In a deft move of uber-hackery, we decide to carry the top half of all
56 * 64-bit registers in a non-portable, non-ABI, hidden structure.
57 * Userspace can read the hidden structure if it *wants* but is never
Simon Arlott70226722007-05-11 20:42:34 +010058 * guaranteed to be in the same place. In fact the uc_sigmask from the
Kyle McMartinf671c452006-01-15 14:10:29 -050059 * ucontext_t structure may push the hidden register file downards
60 */
61struct compat_regfile {
62 /* Upper half of all the 64-bit registers that were truncated
63 on a copy to a 32-bit userspace */
64 compat_int_t rf_gr[32];
65 compat_int_t rf_iasq[2];
66 compat_int_t rf_iaoq[2];
67 compat_int_t rf_sar;
68};
69
70#define COMPAT_SIGRETURN_TRAMP 4
71#define COMPAT_SIGRESTARTBLOCK_TRAMP 5
72#define COMPAT_TRAMP_SIZE (COMPAT_SIGRETURN_TRAMP + \
73 COMPAT_SIGRESTARTBLOCK_TRAMP)
74
75struct compat_rt_sigframe {
76 /* XXX: Must match trampoline size in arch/parisc/kernel/signal.c
77 Secondary to that it must protect the ERESTART_RESTARTBLOCK
78 trampoline we left on the stack (we were bad and didn't
79 change sp so we could run really fast.) */
80 compat_uint_t tramp[COMPAT_TRAMP_SIZE];
81 compat_siginfo_t info;
82 struct compat_ucontext uc;
83 /* Hidden location of truncated registers, *must* be last. */
84 struct compat_regfile regs;
85};
86
87/*
88 * The 32-bit ABI wants at least 48 bytes for a function call frame:
89 * 16 bytes for arg0-arg3, and 32 bytes for magic (the only part of
90 * which Linux/parisc uses is sp-20 for the saved return pointer...)
91 * Then, the stack pointer must be rounded to a cache line (64 bytes).
92 */
93#define SIGFRAME32 64
94#define FUNCTIONCALLFRAME32 48
95#define PARISC_RT_SIGFRAME_SIZE32 (((sizeof(struct compat_rt_sigframe) + FUNCTIONCALLFRAME32) + SIGFRAME32) & -SIGFRAME32)
96
Linus Torvalds1da177e2005-04-16 15:20:36 -070097void sigset_32to64(sigset_t *s64, compat_sigset_t *s32);
98void sigset_64to32(compat_sigset_t *s32, sigset_t *s64);
Linus Torvalds1da177e2005-04-16 15:20:36 -070099long restore_sigcontext32(struct compat_sigcontext __user *sc,
100 struct compat_regfile __user *rf,
101 struct pt_regs *regs);
102long setup_sigcontext32(struct compat_sigcontext __user *sc,
103 struct compat_regfile __user *rf,
104 struct pt_regs *regs, int in_syscall);
105
106#endif