mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-06 22:58:29 +00:00
sh: Provide asm/syscall.h for SH-5.
This provides the asm/syscall.h implementation for sh64 parts. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
This commit is contained in:
parent
6ac034375f
commit
94e2fb3d3e
3 changed files with 108 additions and 32 deletions
|
@ -1,6 +1,80 @@
|
||||||
#ifndef __ASM_SH_SYSCALL_64_H
|
#ifndef __ASM_SH_SYSCALL_64_H
|
||||||
#define __ASM_SH_SYSCALL_64_H
|
#define __ASM_SH_SYSCALL_64_H
|
||||||
|
|
||||||
#include <asm-generic/syscall.h>
|
#include <linux/kernel.h>
|
||||||
|
#include <linux/sched.h>
|
||||||
|
#include <asm/ptrace.h>
|
||||||
|
|
||||||
|
/* The system call number is given by the user in R9 */
|
||||||
|
static inline long syscall_get_nr(struct task_struct *task,
|
||||||
|
struct pt_regs *regs)
|
||||||
|
{
|
||||||
|
return (regs->syscall_nr >= 0) ? regs->regs[9] : -1L;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void syscall_rollback(struct task_struct *task,
|
||||||
|
struct pt_regs *regs)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* XXX: This needs some thought. On SH we don't
|
||||||
|
* save away the original R9 value anywhere.
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline bool syscall_has_error(struct pt_regs *regs)
|
||||||
|
{
|
||||||
|
return (regs->sr & 0x1) ? true : false;
|
||||||
|
}
|
||||||
|
static inline void syscall_set_error(struct pt_regs *regs)
|
||||||
|
{
|
||||||
|
regs->sr |= 0x1;
|
||||||
|
}
|
||||||
|
static inline void syscall_clear_error(struct pt_regs *regs)
|
||||||
|
{
|
||||||
|
regs->sr &= ~0x1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline long syscall_get_error(struct task_struct *task,
|
||||||
|
struct pt_regs *regs)
|
||||||
|
{
|
||||||
|
return syscall_has_error(regs) ? regs->regs[9] : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline long syscall_get_return_value(struct task_struct *task,
|
||||||
|
struct pt_regs *regs)
|
||||||
|
{
|
||||||
|
return regs->regs[9];
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void syscall_set_return_value(struct task_struct *task,
|
||||||
|
struct pt_regs *regs,
|
||||||
|
int error, long val)
|
||||||
|
{
|
||||||
|
if (error) {
|
||||||
|
syscall_set_error(regs);
|
||||||
|
regs->regs[9] = -error;
|
||||||
|
} else {
|
||||||
|
syscall_clear_error(regs);
|
||||||
|
regs->regs[9] = val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void syscall_get_arguments(struct task_struct *task,
|
||||||
|
struct pt_regs *regs,
|
||||||
|
unsigned int i, unsigned int n,
|
||||||
|
unsigned long *args)
|
||||||
|
{
|
||||||
|
BUG_ON(i + n > 6);
|
||||||
|
memcpy(args, ®s->reg[2 + i], n * sizeof(args[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void syscall_set_arguments(struct task_struct *task,
|
||||||
|
struct pt_regs *regs,
|
||||||
|
unsigned int i, unsigned int n,
|
||||||
|
const unsigned long *args)
|
||||||
|
{
|
||||||
|
BUG_ON(i + n > 6);
|
||||||
|
memcpy(®s->reg[2 + i], args, n * sizeof(args[0]));
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* __ASM_SH_SYSCALL_64_H */
|
#endif /* __ASM_SH_SYSCALL_64_H */
|
||||||
|
|
|
@ -533,7 +533,6 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
|
||||||
/* Set up the stack frame */
|
/* Set up the stack frame */
|
||||||
if (ka->sa.sa_flags & SA_SIGINFO)
|
if (ka->sa.sa_flags & SA_SIGINFO)
|
||||||
ret = setup_rt_frame(sig, ka, info, oldset, regs);
|
ret = setup_rt_frame(sig, ka, info, oldset, regs);
|
||||||
|
|
|
@ -47,6 +47,34 @@ static int
|
||||||
handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
|
handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
|
||||||
sigset_t *oldset, struct pt_regs * regs);
|
sigset_t *oldset, struct pt_regs * regs);
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
handle_syscall_restart(struct pt_regs *regs, struct sigaction *sa)
|
||||||
|
{
|
||||||
|
/* If we're not from a syscall, bail out */
|
||||||
|
if (regs->syscall_nr < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* check for system call restart.. */
|
||||||
|
switch (regs->regs[REG_RET]) {
|
||||||
|
case -ERESTART_RESTARTBLOCK:
|
||||||
|
case -ERESTARTNOHAND:
|
||||||
|
no_system_call_restart:
|
||||||
|
regs->regs[REG_RET] = -EINTR;
|
||||||
|
regs->sr |= 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case -ERESTARTSYS:
|
||||||
|
if (!(sa->sa_flags & SA_RESTART))
|
||||||
|
goto no_system_call_restart;
|
||||||
|
/* fallthrough */
|
||||||
|
case -ERESTARTNOINTR:
|
||||||
|
/* Decode syscall # */
|
||||||
|
regs->regs[REG_RET] = regs->syscall_nr;
|
||||||
|
regs->pc -= 4;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Note that 'init' is a special process: it doesn't get signals it doesn't
|
* Note that 'init' is a special process: it doesn't get signals it doesn't
|
||||||
* want to handle. Thus you cannot kill init even with a SIGKILL even by
|
* want to handle. Thus you cannot kill init even with a SIGKILL even by
|
||||||
|
@ -81,6 +109,9 @@ static int do_signal(struct pt_regs *regs, sigset_t *oldset)
|
||||||
|
|
||||||
signr = get_signal_to_deliver(&info, &ka, regs, 0);
|
signr = get_signal_to_deliver(&info, &ka, regs, 0);
|
||||||
if (signr > 0) {
|
if (signr > 0) {
|
||||||
|
if (regs->sr & 1)
|
||||||
|
handle_syscall_restart(regs, &ka.sa);
|
||||||
|
|
||||||
/* Whee! Actually deliver the signal. */
|
/* Whee! Actually deliver the signal. */
|
||||||
if (handle_signal(signr, &info, &ka, oldset, regs) == 0) {
|
if (handle_signal(signr, &info, &ka, oldset, regs) == 0) {
|
||||||
/*
|
/*
|
||||||
|
@ -128,7 +159,6 @@ no_signal:
|
||||||
/*
|
/*
|
||||||
* Atomically swap in the new signal mask, and wait for a signal.
|
* Atomically swap in the new signal mask, and wait for a signal.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
asmlinkage int
|
asmlinkage int
|
||||||
sys_sigsuspend(old_sigset_t mask,
|
sys_sigsuspend(old_sigset_t mask,
|
||||||
unsigned long r3, unsigned long r4, unsigned long r5,
|
unsigned long r3, unsigned long r4, unsigned long r5,
|
||||||
|
@ -234,20 +264,16 @@ sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss,
|
||||||
return do_sigaltstack(uss, uoss, REF_REG_SP);
|
return do_sigaltstack(uss, uoss, REF_REG_SP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Do a signal return; undo the signal stack.
|
* Do a signal return; undo the signal stack.
|
||||||
*/
|
*/
|
||||||
|
struct sigframe {
|
||||||
struct sigframe
|
|
||||||
{
|
|
||||||
struct sigcontext sc;
|
struct sigcontext sc;
|
||||||
unsigned long extramask[_NSIG_WORDS-1];
|
unsigned long extramask[_NSIG_WORDS-1];
|
||||||
long long retcode[2];
|
long long retcode[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct rt_sigframe
|
struct rt_sigframe {
|
||||||
{
|
|
||||||
struct siginfo __user *pinfo;
|
struct siginfo __user *pinfo;
|
||||||
void *puc;
|
void *puc;
|
||||||
struct siginfo info;
|
struct siginfo info;
|
||||||
|
@ -449,7 +475,6 @@ badframe:
|
||||||
/*
|
/*
|
||||||
* Set up a signal frame.
|
* Set up a signal frame.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs,
|
setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs,
|
||||||
unsigned long mask)
|
unsigned long mask)
|
||||||
|
@ -714,34 +739,12 @@ give_sigsegv:
|
||||||
/*
|
/*
|
||||||
* OK, we're invoking a handler
|
* OK, we're invoking a handler
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
|
handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
|
||||||
sigset_t *oldset, struct pt_regs * regs)
|
sigset_t *oldset, struct pt_regs * regs)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Are we from a system call? */
|
|
||||||
if (regs->syscall_nr >= 0) {
|
|
||||||
/* If so, check system call restarting.. */
|
|
||||||
switch (regs->regs[REG_RET]) {
|
|
||||||
case -ERESTART_RESTARTBLOCK:
|
|
||||||
case -ERESTARTNOHAND:
|
|
||||||
no_system_call_restart:
|
|
||||||
regs->regs[REG_RET] = -EINTR;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case -ERESTARTSYS:
|
|
||||||
if (!(ka->sa.sa_flags & SA_RESTART))
|
|
||||||
goto no_system_call_restart;
|
|
||||||
/* fallthrough */
|
|
||||||
case -ERESTARTNOINTR:
|
|
||||||
/* Decode syscall # */
|
|
||||||
regs->regs[REG_RET] = regs->syscall_nr;
|
|
||||||
regs->pc -= 4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set up the stack frame */
|
/* Set up the stack frame */
|
||||||
if (ka->sa.sa_flags & SA_SIGINFO)
|
if (ka->sa.sa_flags & SA_SIGINFO)
|
||||||
ret = setup_rt_frame(sig, ka, info, oldset, regs);
|
ret = setup_rt_frame(sig, ka, info, oldset, regs);
|
||||||
|
|
Loading…
Add table
Reference in a new issue