Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * linux/arch/sh/kernel/sys_sh.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  * This file contains various random system calls that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  * have a non-standard calling sequence on the Linux/SuperH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  * platform.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9)  * Taken from i386 version.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/smp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/sem.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/msg.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/shm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/stat.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/syscalls.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/mman.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/file.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/utsname.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <linux/ipc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <asm/syscalls.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #include <asm/unistd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #include <asm/cacheflush.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #include <asm/cachectl.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) asmlinkage int old_mmap(unsigned long addr, unsigned long len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	unsigned long prot, unsigned long flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 	int fd, unsigned long off)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 	if (off & ~PAGE_MASK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 	return ksys_mmap_pgoff(addr, len, prot, flags, fd, off>>PAGE_SHIFT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 	unsigned long prot, unsigned long flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 	unsigned long fd, unsigned long pgoff)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 	 * The shift for mmap2 is constant, regardless of PAGE_SIZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 	 * setting.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 	if (pgoff & ((1 << (PAGE_SHIFT - 12)) - 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 	pgoff >>= PAGE_SHIFT - 12;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 	return ksys_mmap_pgoff(addr, len, prot, flags, fd, pgoff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) /* sys_cacheflush -- flush (part of) the processor cache.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) asmlinkage int sys_cacheflush(unsigned long addr, unsigned long len, int op)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 	struct vm_area_struct *vma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 	if ((op <= 0) || (op > (CACHEFLUSH_D_PURGE|CACHEFLUSH_I)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 	 * Verify that the specified address region actually belongs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 	 * to this process.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 	if (addr + len < addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 		return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) 	mmap_read_lock(current->mm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) 	vma = find_vma (current->mm, addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) 	if (vma == NULL || addr < vma->vm_start || addr + len > vma->vm_end) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) 		mmap_read_unlock(current->mm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) 		return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) 	switch (op & CACHEFLUSH_D_PURGE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) 		case CACHEFLUSH_D_INVAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) 			__flush_invalidate_region((void *)addr, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) 		case CACHEFLUSH_D_WB:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) 			__flush_wback_region((void *)addr, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) 		case CACHEFLUSH_D_PURGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) 			__flush_purge_region((void *)addr, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) 	if (op & CACHEFLUSH_I)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) 		flush_icache_range(addr, addr+len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) 	mmap_read_unlock(current->mm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) }