Linux Audio

Check our new training course

Loading...
v4.17
 1/*
 2 * arch/xtensa/kernel/syscall.c
 3 *
 4 * This file is subject to the terms and conditions of the GNU General Public
 5 * License.  See the file "COPYING" in the main directory of this archive
 6 * for more details.
 7 *
 8 * Copyright (C) 2001 - 2005 Tensilica Inc.
 9 * Copyright (C) 2000 Silicon Graphics, Inc.
10 * Copyright (C) 1995 - 2000 by Ralf Baechle
11 *
12 * Joe Taylor <joe@tensilica.com, joetylr@yahoo.com>
13 * Marc Gauthier <marc@tensilica.com, marc@alumni.uwaterloo.ca>
14 * Chris Zankel <chris@zankel.net>
15 * Kevin Chea
16 *
17 */
18#include <linux/uaccess.h>
19#include <asm/syscall.h>
20#include <asm/unistd.h>
21#include <linux/linkage.h>
22#include <linux/stringify.h>
23#include <linux/errno.h>
24#include <linux/syscalls.h>
25#include <linux/file.h>
26#include <linux/fs.h>
27#include <linux/mman.h>
28#include <linux/sched/mm.h>
29#include <linux/shm.h>
30
31typedef void (*syscall_t)(void);
 
32
33syscall_t sys_call_table[__NR_syscall_count] /* FIXME __cacheline_aligned */= {
34	[0 ... __NR_syscall_count - 1] = (syscall_t)&sys_ni_syscall,
35
36#define __SYSCALL(nr,symbol,nargs) [ nr ] = (syscall_t)symbol,
37#include <uapi/asm/unistd.h>
38};
39
40#define COLOUR_ALIGN(addr, pgoff) \
41	((((addr) + SHMLBA - 1) & ~(SHMLBA - 1)) + \
42	 (((pgoff) << PAGE_SHIFT) & (SHMLBA - 1)))
43
44asmlinkage long xtensa_shmat(int shmid, char __user *shmaddr, int shmflg)
45{
46	unsigned long ret;
47	long err;
48
49	err = do_shmat(shmid, shmaddr, shmflg, &ret, SHMLBA);
50	if (err)
51		return err;
52	return (long)ret;
53}
54
55asmlinkage long xtensa_fadvise64_64(int fd, int advice,
56		unsigned long long offset, unsigned long long len)
57{
58	return ksys_fadvise64_64(fd, offset, len, advice);
59}
60
61#ifdef CONFIG_MMU
62unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
63		unsigned long len, unsigned long pgoff, unsigned long flags)
64{
65	struct vm_area_struct *vmm;
66
67	if (flags & MAP_FIXED) {
68		/* We do not accept a shared mapping if it would violate
69		 * cache aliasing constraints.
70		 */
71		if ((flags & MAP_SHARED) &&
72				((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
73			return -EINVAL;
74		return addr;
75	}
76
77	if (len > TASK_SIZE)
78		return -ENOMEM;
79	if (!addr)
80		addr = TASK_UNMAPPED_BASE;
81
82	if (flags & MAP_SHARED)
83		addr = COLOUR_ALIGN(addr, pgoff);
84	else
85		addr = PAGE_ALIGN(addr);
86
87	for (vmm = find_vma(current->mm, addr); ; vmm = vmm->vm_next) {
88		/* At this point:  (!vmm || addr < vmm->vm_end). */
89		if (TASK_SIZE - len < addr)
90			return -ENOMEM;
91		if (!vmm || addr + len <= vm_start_gap(vmm))
92			return addr;
93		addr = vmm->vm_end;
94		if (flags & MAP_SHARED)
95			addr = COLOUR_ALIGN(addr, pgoff);
96	}
97}
98#endif
v5.9
 1/*
 2 * arch/xtensa/kernel/syscall.c
 3 *
 4 * This file is subject to the terms and conditions of the GNU General Public
 5 * License.  See the file "COPYING" in the main directory of this archive
 6 * for more details.
 7 *
 8 * Copyright (C) 2001 - 2005 Tensilica Inc.
 9 * Copyright (C) 2000 Silicon Graphics, Inc.
10 * Copyright (C) 1995 - 2000 by Ralf Baechle
11 *
12 * Joe Taylor <joe@tensilica.com, joetylr@yahoo.com>
13 * Marc Gauthier <marc@tensilica.com, marc@alumni.uwaterloo.ca>
14 * Chris Zankel <chris@zankel.net>
15 * Kevin Chea
16 *
17 */
18#include <linux/uaccess.h>
19#include <asm/syscall.h>
20#include <asm/unistd.h>
21#include <linux/linkage.h>
22#include <linux/stringify.h>
23#include <linux/errno.h>
24#include <linux/syscalls.h>
25#include <linux/file.h>
26#include <linux/fs.h>
27#include <linux/mman.h>
28#include <linux/sched/mm.h>
29#include <linux/shm.h>
30
31syscall_t sys_call_table[__NR_syscalls] /* FIXME __cacheline_aligned */= {
32	[0 ... __NR_syscalls - 1] = (syscall_t)&sys_ni_syscall,
33
34#define __SYSCALL(nr, entry, nargs)[nr] = (syscall_t)entry,
35#include <asm/syscall_table.h>
36#undef __SYSCALL
 
 
37};
38
39#define COLOUR_ALIGN(addr, pgoff) \
40	((((addr) + SHMLBA - 1) & ~(SHMLBA - 1)) + \
41	 (((pgoff) << PAGE_SHIFT) & (SHMLBA - 1)))
42
43asmlinkage long xtensa_shmat(int shmid, char __user *shmaddr, int shmflg)
44{
45	unsigned long ret;
46	long err;
47
48	err = do_shmat(shmid, shmaddr, shmflg, &ret, SHMLBA);
49	if (err)
50		return err;
51	return (long)ret;
52}
53
54asmlinkage long xtensa_fadvise64_64(int fd, int advice,
55		unsigned long long offset, unsigned long long len)
56{
57	return ksys_fadvise64_64(fd, offset, len, advice);
58}
59
60#ifdef CONFIG_MMU
61unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
62		unsigned long len, unsigned long pgoff, unsigned long flags)
63{
64	struct vm_area_struct *vmm;
65
66	if (flags & MAP_FIXED) {
67		/* We do not accept a shared mapping if it would violate
68		 * cache aliasing constraints.
69		 */
70		if ((flags & MAP_SHARED) &&
71				((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
72			return -EINVAL;
73		return addr;
74	}
75
76	if (len > TASK_SIZE)
77		return -ENOMEM;
78	if (!addr)
79		addr = TASK_UNMAPPED_BASE;
80
81	if (flags & MAP_SHARED)
82		addr = COLOUR_ALIGN(addr, pgoff);
83	else
84		addr = PAGE_ALIGN(addr);
85
86	for (vmm = find_vma(current->mm, addr); ; vmm = vmm->vm_next) {
87		/* At this point:  (!vmm || addr < vmm->vm_end). */
88		if (TASK_SIZE - len < addr)
89			return -ENOMEM;
90		if (!vmm || addr + len <= vm_start_gap(vmm))
91			return addr;
92		addr = vmm->vm_end;
93		if (flags & MAP_SHARED)
94			addr = COLOUR_ALIGN(addr, pgoff);
95	}
96}
97#endif