summaryrefslogtreecommitdiff
path: root/arch/um/kernel/tt/syscall_kern.c
blob: 3fda9a03c59aa5d0d767df04fe542d488e811171 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* 
 * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
 * Licensed under the GPL
 */

#include "linux/types.h"
#include "linux/utime.h"
#include "linux/sys.h"
#include "linux/ptrace.h"
#include "asm/unistd.h"
#include "asm/ptrace.h"
#include "asm/uaccess.h"
#include "asm/stat.h"
#include "sysdep/syscalls.h"
#include "sysdep/sigcontext.h"
#include "kern_util.h"
#include "syscall.h"

void syscall_handler_tt(int sig, struct pt_regs *regs)
{
	void *sc;
	long result;
	int syscall;
#ifdef CONFIG_SYSCALL_DEBUG
	int index;
#endif
	sc = UPT_SC(&regs->regs);
	SC_START_SYSCALL(sc);

	syscall = UPT_SYSCALL_NR(&regs->regs);

#ifdef CONFIG_SYSCALL_DEBUG
	index = record_syscall_start(syscall);
#endif

	syscall_trace(&regs->regs, 0);

	current->thread.nsyscalls++;
	nsyscalls++;

	if((syscall >= NR_syscalls) || (syscall < 0))
		result = -ENOSYS;
	else result = EXECUTE_SYSCALL(syscall, regs);

	/* regs->sc may have changed while the system call ran (there may
	 * have been an interrupt or segfault), so it needs to be refreshed.
	 */
	UPT_SC(&regs->regs) = sc;

	SC_SET_SYSCALL_RETURN(sc, result);

	syscall_trace(&regs->regs, 1);
#ifdef CONFIG_SYSCALL_DEBUG
  	record_syscall_end(index, result);
#endif
}