1 /*
2 * Copyright (c) 2011-2012 IBM Corporation. All rights reserved.
3 * Copyright (c) 2016 Los Alamos National Security, LLC. All rights
4 * reserved.
5 * Copyright (c) 2017 Research Organization for Information Science
6 * and Technology (RIST). All rights reserved.
7 * $COPYRIGHT$
8 */
9
10 /** @file
11 *
12 * Cross Memory Attach syscall definitions.
13 *
14 * These are only needed temporarily until these new syscalls
15 * are incorporated into glibc
16 */
17
18 #ifndef OPAL_SYS_CMA_H
19 #define OPAL_SYS_CMA_H 1
20
21 #if !defined(OPAL_ASSEMBLY_ARCH)
22 /* need opal_config.h for the assembly architecture */
23 #include "opal_config.h"
24 #endif
25
26 #include "opal/sys/architecture.h"
27
28 #ifdef HAVE_SYS_TYPES_H
29 #include <sys/types.h>
30 #endif
31
32 #ifdef HAVE_UNISTD_H
33 #include <sys/unistd.h>
34 #endif
35
36 #ifdef __linux__
37
38 /* Cross Memory Attach is so far only supported under linux */
39
40 #if OPAL_ASSEMBLY_ARCH == OPAL_X86_64
41 #define __NR_process_vm_readv 310
42 #define __NR_process_vm_writev 311
43 #elif OPAL_ASSEMBLY_ARCH == OPAL_IA32
44 #define __NR_process_vm_readv 347
45 #define __NR_process_vm_writev 348
46 #elif OPAL_ASSEMBLY_ARCH == OPAL_IA64
47 #define __NR_process_vm_readv 1332
48 #define __NR_process_vm_writev 1333
49 #elif OPAL_ASSEMBLY_ARCH == OPAL_POWERPC32
50 #define __NR_process_vm_readv 351
51 #define __NR_process_vm_writev 352
52 #elif OPAL_ASSEMBLY_ARCH == OPAL_POWERPC64
53 #define __NR_process_vm_readv 351
54 #define __NR_process_vm_writev 352
55 #elif OPAL_ASSEMBLY_ARCH == OPAL_ARM
56
57 #define __NR_process_vm_readv 376
58 #define __NR_process_vm_writev 377
59
60 #elif OPAL_ASSEMBLY_ARCH == OPAL_ARM64
61
62 /* ARM64 uses the asm-generic syscall numbers */
63
64 #define __NR_process_vm_readv 270
65 #define __NR_process_vm_writev 271
66
67 #elif OPAL_ASSEMBLY_ARCH == OPAL_MIPS
68
69 #if _MIPS_SIM == _MIPS_SIM_ABI64
70
71 #define __NR_process_vm_readv 5304
72 #define __NR_process_vm_writev 5305
73
74 #elif _MIPS_SIM == _MIPS_SIM_NABI32
75
76 #define __NR_process_vm_readv 6309
77 #define __NR_process_vm_writev 6310
78
79 #else
80
81 #error "Unsupported MIPS architecture for process_vm_readv and process_vm_writev syscalls"
82
83 #endif
84
85 #elif OPAL_ASSEMBLY_ARCH == OPAL_S390
86
87 #define __NR_process_vm_readv 340
88 #define __NR_process_vm_writev 341
89
90 #elif OPAL_ASSEMBLY_ARCH == OPAL_S390X
91
92 #define __NR_process_vm_readv 340
93 #define __NR_process_vm_writev 341
94
95 #else
96 #error "Unsupported architecture for process_vm_readv and process_vm_writev syscalls"
97 #endif
98
99
100 static inline ssize_t
process_vm_readv(pid_t pid,const struct iovec * lvec,unsigned long liovcnt,const struct iovec * rvec,unsigned long riovcnt,unsigned long flags)101 process_vm_readv(pid_t pid,
102 const struct iovec *lvec,
103 unsigned long liovcnt,
104 const struct iovec *rvec,
105 unsigned long riovcnt,
106 unsigned long flags)
107 {
108 return syscall(__NR_process_vm_readv, pid, lvec, liovcnt, rvec, riovcnt, flags);
109 }
110
111 static inline ssize_t
process_vm_writev(pid_t pid,const struct iovec * lvec,unsigned long liovcnt,const struct iovec * rvec,unsigned long riovcnt,unsigned long flags)112 process_vm_writev(pid_t pid,
113 const struct iovec *lvec,
114 unsigned long liovcnt,
115 const struct iovec *rvec,
116 unsigned long riovcnt,
117 unsigned long flags)
118 {
119 return syscall(__NR_process_vm_writev, pid, lvec, liovcnt, rvec, riovcnt, flags);
120 }
121
122 #endif /* __linux__ */
123
124 #endif /* OPAL_SYS_CMA_H */
125