1 /*
2  *  Port on Texas Instruments TMS320C6x architecture
3  *
4  *  Copyright (C) 2004, 2009, 2010, 2011 Texas Instruments Incorporated
5  *  Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License version 2 as
9  *  published by the Free Software Foundation.
10  */
11 #include <linux/module.h>
12 #include <linux/syscalls.h>
13 #include <linux/uaccess.h>
14 
15 #include <asm/syscalls.h>
16 
17 #ifdef CONFIG_ACCESS_CHECK
_access_ok(unsigned long addr,unsigned long size)18 int _access_ok(unsigned long addr, unsigned long size)
19 {
20 	if (!size)
21 		return 1;
22 
23 	if (!addr || addr > (0xffffffffUL - (size - 1)))
24 		goto _bad_access;
25 
26 	if (segment_eq(get_fs(), KERNEL_DS))
27 		return 1;
28 
29 	if (memory_start <= addr && (addr + size - 1) < memory_end)
30 		return 1;
31 
32 _bad_access:
33 	pr_debug("Bad access attempt: pid[%d] addr[%08lx] size[0x%lx]\n",
34 		 current->pid, addr, size);
35 	return 0;
36 }
37 EXPORT_SYMBOL(_access_ok);
38 #endif
39 
40 /* sys_cache_sync -- sync caches over given range */
sys_cache_sync(unsigned long s,unsigned long e)41 asmlinkage int sys_cache_sync(unsigned long s, unsigned long e)
42 {
43 	L1D_cache_block_writeback_invalidate(s, e);
44 	L1P_cache_block_invalidate(s, e);
45 
46 	return 0;
47 }
48 
49 /* Provide the actual syscall number to call mapping. */
50 #undef __SYSCALL
51 #define __SYSCALL(nr, call) [nr] = (call),
52 
53 /*
54  * Use trampolines
55  */
56 #define sys_pread64		sys_pread_c6x
57 #define sys_pwrite64		sys_pwrite_c6x
58 #define sys_truncate64		sys_truncate64_c6x
59 #define sys_ftruncate64		sys_ftruncate64_c6x
60 #define sys_fadvise64		sys_fadvise64_c6x
61 #define sys_fadvise64_64	sys_fadvise64_64_c6x
62 #define sys_fallocate		sys_fallocate_c6x
63 
64 /* Use sys_mmap_pgoff directly */
65 #define sys_mmap2 sys_mmap_pgoff
66 
67 /*
68  * Note that we can't include <linux/unistd.h> here since the header
69  * guard will defeat us; <asm/unistd.h> checks for __SYSCALL as well.
70  */
71 void *sys_call_table[__NR_syscalls] = {
72 	[0 ... __NR_syscalls-1] = sys_ni_syscall,
73 #include <asm/unistd.h>
74 };
75