システムコールと引数
linux-2.4.18 のソースからシステムコール番号とシステムコールの引数をまとめてみました。
レジスタに値をセットして、
mov r0, #0 swi #0x900001 @ sys_exit
のようにして呼び出します。
EABI の場合は、r7 にシステムコール番号を指定します。
mov r0, #0 mov r7, #1 @ sys_exit swi #0
返り値も引数の型もいろいろありますが、結局32ビットの値かアドレスです。
sys# | SWI# | type | NAME | arg1 (r0) | arg2 (r1) | arg3 (r2) | arg4 (r3) | arg5 (r4) | arg6 (r5) |
---|---|---|---|---|---|---|---|---|---|
1 | 900001 | long | sys_exit | int error_code | |||||
2 | 900002 | int | sys_fork | struct pt_regs *regs | |||||
3 | 900003 | ssize_t | sys_read | unsigned int fd | char * buf | size_t count | |||
4 | 900004 | ssize_t | sys_write | unsigned int fd | const char * buf | size_t count | |||
5 | 900005 | long | sys_open | const char * filename | int flags | int mode | |||
6 | 900006 | long | sys_close | unsigned int fd | |||||
8 | 900008 | long | sys_creat | const char * pathname | int mode | ||||
9 | 900009 | long | sys_link | const char * oldname | const char * newname | ||||
10 | 90000A | long | sys_unlink | const char * pathname | |||||
11 | 90000B | int | sys_execve | char *filenamei | char **argv | char **envp | struct pt_regs *regs | ||
12 | 90000C | long | sys_chdir | const char * filename | |||||
13 | 90000D | long | sys_time | int * tloc | |||||
14 | 90000E | long | sys_mknod | const char * filename | int mode | dev_t dev | |||
15 | 90000F | long | sys_chmod | const char * filename | mode_t mode | ||||
16 | 900010 | long | sys_lchown16 | const char * filename | old_uid_t user | old_gid_t group | |||
19 | 900013 | off_t | sys_lseek | unsigned int fd | off_t offset | unsigned int origin | |||
20 | 900014 | long | sys_getpid | void | |||||
21 | 900015 | long | sys_mprotect | unsigned long start | size_t len | unsigned long prot | |||
22 | 900016 | long | sys_oldumount | char * name | |||||
23 | 900017 | long | sys_setuid16 | old_uid_t uid | |||||
24 | 900018 | long | sys_getuid16 | void | |||||
25 | 900019 | long | sys_stime | int * tptr | |||||
26 | 90001A | int | sys_ptrace | long request | long pid | long addr | long data | ||
27 | 90001B | unsigned long | sys_alarm | unsigned int seconds | |||||
29 | 90001D | int | sys_pause | void | |||||
30 | 90001E | long | sys_utime | char * filename | struct utimbuf * times | ||||
33 | 900021 | long | sys_access | const char * filename | int mode | ||||
34 | 900022 | long | sys_nice | int increment | |||||
36 | 900024 | long | sys_sync | void | |||||
37 | 900025 | long | sys_kill | int pid | int sig | ||||
38 | 900026 | long | sys_rename | const char * oldname | const char * newname | ||||
39 | 900027 | long | sys_mkdir | const char * pathname | int mode | ||||
40 | 900028 | long | sys_rmdir | const char * pathname | |||||
41 | 900029 | long | sys_dup | unsigned int fildes | |||||
42 | 90002A | int | sys_pipe | unsigned long * fildes | |||||
43 | 90002B | long | sys_times | struct tms * tbuf | |||||
45 | 90002D | unsigned long | sys_brk | unsigned long brk | |||||
46 | 90002E | long | sys_setgid16 | old_gid_t gid | |||||
47 | 90002F | long | sys_getgid16 | void | |||||
49 | 900031 | long | sys_geteuid16 | void | |||||
50 | 900032 | long | sys_getegid16 | void | |||||
51 | 900033 | long | sys_acct | const char *name | |||||
52 | 900034 | long | sys_umount | char * name | int flags | ||||
54 | 900036 | long | sys_ioctl | unsigned int fd | unsigned int cmd | unsigned long arg | |||
55 | 900037 | long | sys_fcntl | unsigned int fd | unsigned int cmd | unsigned long arg | |||
57 | 900039 | long | sys_setpgid | pid_t pid | pid_t pgid | ||||
60 | 90003C | long | sys_umask | int mask | |||||
61 | 90003D | long | sys_chroot | const char * filename | |||||
62 | 90003E | long | sys_ustat | dev_t dev | struct ustat * ubuf | ||||
63 | 90003F | long | sys_dup2 | unsigned int oldfd | unsigned int newfd | ||||
64 | 900040 | long | sys_getppid | void | |||||
65 | 900041 | long | sys_getpgrp | void | |||||
66 | 900042 | long | sys_setsid | void | |||||
67 | 900043 | long | sys_sgetmask | void | |||||
70 | 900046 | long | sys_setreuid16 | old_uid_t ruid | old_uid_t euid | ||||
71 | 900047 | long | sys_setregid16 | old_gid_t rgid | old_gid_t egid | ||||
72 | 900048 | int | sys_sigsuspend | int restart | unsigned long oldmask | old_sigset_t mask | struct pt_regs *regs | ||
73 | 900049 | long | sys_sigpending | old_sigset_t *set | |||||
74 | 90004A | long | sys_sethostname | char *name | int len | ||||
75 | 90004B | long | sys_setrlimit | unsigned int resource | struct rlimit *rlim | ||||
76 | 90004C | long | sys_old_getrlimit | unsigned int resource | struct rlimit *rlim | ||||
77 | 90004D | long | sys_getrusage | int who | struct rusage *ru | ||||
78 | 90004E | long | sys_gettimeofday | struct timeval *tv | struct timezone *tz | ||||
79 | 90004F | long | sys_settimeofday | struct timeval *tv | struct timezone *tz | ||||
80 | 900050 | long | sys_getgroups16 | int gidsetsize | old_gid_t *grouplist | ||||
81 | 900051 | long | sys_setgroups16 | int gidsetsize | old_gid_t *grouplist | ||||
82 | 900052 | int | old_select | struct sel_arg_struct *arg | |||||
83 | 900053 | long | sys_symlink | const char * oldname | const char * newname | ||||
85 | 900055 | long | sys_readlink | const char * path | char * buf | int bufsiz | |||
86 | 900056 | long | sys_uselib | const char * library | |||||
87 | 900057 | long | sys_swapon | const char * specialfile | int swap_flags | ||||
88 | 900058 | long | sys_reboot | int magic1 | int magic2 | unsigned int cmd | void * arg | ||
89 | 900059 | int | old_readdir | unsigned int fd | void * dirent | unsigned int count | |||
90 | 90005A | int | old_mmap | struct mmap_arg_struct *arg | |||||
91 | 90005B | long | sys_munmap | unsigned long addr | size_t len | ||||
92 | 90005C | long | sys_truncate | const char * path | unsigned long length | ||||
93 | 90005D | long | sys_ftruncate | unsigned int fd | unsigned long length | ||||
94 | 90005E | long | sys_fchmod | unsigned int fd | mode_t mode | ||||
95 | 90005F | long | sys_fchown16 | unsigned int fd | old_uid_t user | old_gid_t group | |||
96 | 900060 | long | sys_getpriority | int which | int who | ||||
97 | 900061 | long | sys_setpriority | int which | int who | int niceval | |||
99 | 900063 | long | sys_statfs | const char * path | struct statfs * buf | ||||
100 | 900064 | long | sys_fstatfs | unsigned int fd | struct statfs * buf | ||||
102 | 900066 | long | sys_socketcall | int call | unsigned long *args | ||||
103 | 900067 | long | sys_syslog | int type | char * buf | int len | |||
104 | 900068 | long | sys_setitimer | int which | struct itimerval *value | struct itimerval *ovalue | |||
105 | 900069 | long | sys_getitimer | int which | struct itimerval *value | ||||
106 | 90006A | long | sys_newstat | char * filename | struct stat * statbuf | ||||
107 | 90006B | long | sys_newlstat | char * filename | struct stat * statbuf | ||||
108 | 90006C | long | sys_newfstat | unsigned int fd | struct stat * statbuf | ||||
111 | 90006F | int | sys_vfork | struct pt_regs *regs | |||||
114 | 900072 | long | sys_wait4 | pid_t pid | unsigned int * stat_addr | int options | struct rusage * ru | ||
115 | 900073 | long | sys_swapoff | const char * specialfile | |||||
116 | 900074 | long | sys_sysinfo | struct sysinfo *info | |||||
117 | 900075 | int | sys_ipc | uint call | int first | int second | int third | void *ptr | long fifth |
118 | 900076 | long | sys_fsync | unsigned int fd | |||||
119 | 900077 | int | sys_sigreturn | struct pt_regs *regs | |||||
120 | 900078 | int | sys_clone | unsigned long clone_flags | unsigned long newsp | struct pt_regs *regs | |||
121 | 900079 | long | sys_setdomainname | char *name | int len | ||||
122 | 90007A | long | sys_newuname | struct new_utsname * name | |||||
124 | 90007C | long | sys_adjtimex | struct timex *txc_p | |||||
125 | 90007D | unsigned long | sys_mremap | unsigned long addr | unsigned long old_len | unsigned long new_len | unsigned long flags | unsigned long new_addr | |
126 | 90007E | long | sys_sigprocmask | int how | old_sigset_t *set | old_sigset_t *oset | |||
127 | 90007F | unsigned long | sys_create_module | const char *name_user | size_t size | ||||
128 | 900080 | long | sys_init_module | const char *name_user | struct module *mod_user | ||||
129 | 900081 | long | sys_delete_module | const char *name_user | |||||
130 | 900082 | long | sys_get_kernel_syms | struct kernel_sym *table | |||||
131 | 900083 | long | sys_quotactl | int cmd | const char *special | int id | caddr_t addr | ||
132 | 900084 | long | sys_getpgid | pid_t pid | |||||
133 | 900085 | long | sys_fchdir | unsigned int fd | |||||
134 | 900086 | long | sys_bdflush | int func | long data | ||||
135 | 900087 | long | sys_sysfs | int option | unsigned long arg1 | unsigned long arg2 | |||
136 | 900088 | long | sys_personality | u_long personality | |||||
138 | 90008A | long | sys_setfsuid16 | old_uid_t uid | |||||
139 | 90008B | long | sys_setfsgid16 | old_gid_t gid | |||||
140 | 90008C | long | sys_llseek | unsigned int fd | unsigned long offset_high | unsigned long offset_low | loff_t * result | unsigned int origin | |
141 | 90008D | long | sys_getdents | unsigned int fd | void * dirent | unsigned int count | |||
142 | 90008E | long | sys_select | int n | fd_set *inp | fd_set *outp | fd_set *exp | struct timeval *tvp | |
143 | 90008F | long | sys_flock | unsigned int fd | unsigned int cmd | ||||
144 | 900090 | long | sys_msync | unsigned long start | size_t len | int flags | |||
145 | 900091 | ssize_t | sys_readv | unsigned long fd | const struct iovec * vector | unsigned long count | |||
146 | 900092 | ssize_t | sys_writev | unsigned long fd | const struct iovec * vector | unsigned long count | |||
147 | 900093 | long | sys_getsid | pid_t pid | |||||
148 | 900094 | long | sys_fdatasync | unsigned int fd | |||||
150 | 900096 | long | sys_mlock | unsigned long start | size_t len | ||||
151 | 900097 | long | sys_munlock | unsigned long start | size_t len | ||||
152 | 900098 | long | sys_mlockall | int flags | |||||
153 | 900099 | long | sys_munlockall | void | |||||
154 | 90009A | long | sys_sched_setparam | pid_t pid | struct sched_param *param | ||||
155 | 90009B | long | sys_sched_getparam | pid_t pid | struct sched_param *param | ||||
156 | 90009C | long | sys_sched_setscheduler | pid_t pid | int policy | struct sched_param *param | |||
157 | 90009D | long | sys_sched_getscheduler | pid_t pid | |||||
158 | 90009E | long | sys_sched_yield | void | |||||
159 | 90009F | long | sys_sched_get_priority_max | int policy | |||||
160 | 9000A0 | long | sys_sched_get_priority_min | int policy | |||||
161 | 9000A1 | long | sys_sched_rr_get_interval | pid_t pid | struct timespec *interval | ||||
162 | 9000A2 | long | sys_nanosleep | struct timespec *rqtp | struct timespec *rmtp | ||||
163 | 9000A3 | unsigned long | sys_arm_mremap | unsigned long addr | unsigned long old_len | unsigned long new_len | unsigned long flags | ||
164 | 9000A4 | long | sys_setresuid16 | old_uid_t ruid | old_uid_t euid | old_uid_t suid | |||
165 | 9000A5 | long | sys_getresuid16 | old_uid_t *ruid | old_uid_t *euid | old_uid_t *suid | |||
167 | 9000A7 | long | sys_query_module | const char *name_user | int which | char *buf | size_t bufsize | size_t *ret | |
168 | 9000A8 | long | sys_poll | struct pollfd * ufds | unsigned int nfds | long timeout | |||
169 | 9000A9 | int | sys_nfsservctl | int cmd | void *argp | void *resp | |||
170 | 9000AA | long | sys_setresgid16 | old_gid_t rgid | old_gid_t egid | old_gid_t sgid | |||
171 | 9000AB | long | sys_getresgid16 | old_gid_t *rgid | old_gid_t *egid | old_gid_t *sgid | |||
172 | 9000AC | long | sys_prctl | int option | unsigned long arg2 | unsigned long arg3 | unsigned long arg4 | unsigned long arg5 | |
173 | 9000AD | int | sys_rt_sigreturn | struct pt_regs *regs | |||||
174 | 9000AE | long | sys_rt_sigaction | int sig | const struct sigaction *act | struct sigaction *oact | size_t sigsetsize | ||
175 | 9000AF | long | sys_rt_sigprocmask | int how | sigset_t *set | sigset_t *oset | size_t sigsetsize | ||
176 | 9000B0 | long | sys_rt_sigpending | sigset_t *set | size_t sigsetsize | ||||
177 | 9000B1 | long | sys_rt_sigtimedwait | const sigset_t *uthese | siginfo_t *uinfo | const struct timespec *uts | size_t sigsetsize | ||
178 | 9000B2 | long | sys_rt_sigqueueinfo | int pid | int sig | siginfo_t *uinfo | |||
179 | 9000B3 | int | sys_rt_sigsuspend | sigset_t *unewset | size_t sigsetsize | struct pt_regs *regs | |||
180 | 9000B4 | ssize_t | sys_pread | unsigned int fd | char * buf | size_t count | loff_t pos | ||
181 | 9000B5 | ssize_t | sys_pwrite | unsigned int fd | const char * buf | size_t count | loff_t pos | ||
182 | 9000B6 | long | sys_chown16 | const char * filename | old_uid_t user | old_gid_t group | |||
183 | 9000B7 | long | sys_getcwd | char *buf | unsigned long size | ||||
184 | 9000B8 | long | sys_capget | cap_user_header_t header | cap_user_data_t dataptr | ||||
185 | 9000B9 | long | sys_capset | cap_user_header_t header | const cap_user_data_t data | ||||
186 | 9000BA | int | sys_sigaction | int sig | const struct old_sigaction *act | struct old_sigaction *oact | |||
187 | 9000BB | ssize_t | sys_sendfile | int out_fd | int in_fd | off_t *offset | size_t count | ||
190 | 9000BE | long | sys_utimes | char * filename | struct timeval * utimes | ||||
191 | 9000BF | long | sys_getrlimit | unsigned int resource | struct rlimit *rlim | ||||
192 | 9000C0 | long | sys_mmap2 | unsigned long addr | unsigned long len | unsigned long prot | unsigned long flags | unsigned long fd | unsigned long pgoff |
193 | 9000C1 | long | sys_truncate64 | const char * path | loff_t length | ||||
194 | 9000C2 | long | sys_ftruncate64 | unsigned int fd | loff_t length | ||||
195 | 9000C3 | long | sys_stat64 | char * filename | struct stat64 * statbuf | long flags | |||
196 | 9000C4 | long | sys_lstat64 | char * filename | struct stat64 * statbuf | long flags | |||
197 | 9000C5 | long | sys_fstat64 | unsigned long fd | struct stat64 * statbuf | long flags | |||
198 | 9000C6 | long | sys_lchown | const char * filename | uid_t user | gid_t group | |||
199 | 9000C7 | long | sys_getuid | void | |||||
200 | 9000C8 | long | sys_getgid | void | |||||
201 | 9000C9 | long | sys_geteuid | void | |||||
202 | 9000CA | long | sys_getegid | void | |||||
203 | 9000CB | long | sys_setreuid | uid_t ruid | uid_t euid | ||||
204 | 9000CC | long | sys_setregid | gid_t rgid | gid_t egid | ||||
205 | 9000CD | long | sys_getgroups | int gidsetsize | gid_t *grouplist | ||||
206 | 9000CE | long | sys_setgroups | int gidsetsize | gid_t *grouplist | ||||
207 | 9000CF | long | sys_fchown | unsigned int fd | uid_t user | gid_t group | |||
208 | 9000D0 | long | sys_setresuid | uid_t ruid | uid_t euid | uid_t suid | |||
209 | 9000D1 | long | sys_getresuid | uid_t *ruid | uid_t *euid | uid_t *suid | |||
210 | 9000D2 | long | sys_setresgid | gid_t rgid | gid_t egid | gid_t sgid | |||
211 | 9000D3 | long | sys_getresgid | gid_t *rgid | gid_t *egid | gid_t *sgid | |||
212 | 9000D4 | long | sys_chown | const char * filename | uid_t user | gid_t group | |||
213 | 9000D5 | long | sys_setuid | uid_t uid | |||||
214 | 9000D6 | long | sys_setgid | gid_t gid | |||||
215 | 9000D7 | long | sys_setfsuid | uid_t uid | |||||
216 | 9000D8 | long | sys_setfsgid | gid_t gid | |||||
217 | 9000D9 | long | sys_getdents64 | unsigned int fd | void * dirent | unsigned int count | |||
218 | 9000DA | long | sys_pivot_root | const char *new_root | const char *put_old | ||||
219 | 9000DB | long | sys_mincore | unsigned long start | size_t len | unsigned char * vec | |||
220 | 9000DC | long | sys_madvise | unsigned long start | size_t len | int behavior | |||
221 | 9000DD | long | sys_fcntl64 | unsigned int fd | unsigned int cmd | unsigned long arg | |||
224 | 9000E0 | long | sys_gettid | void | |||||
225 | 9000E1 | ssize_t | sys_readahead | int fd | loff_t offset | size_t count | |||
S | 1 | long | sys_socket | int family | int type | int protocol | |||
S | 2 | long | sys_bind | int fd | struct sockaddr *umyaddr | int addrlen | |||
S | 3 | long | sys_connect | int fd | struct sockaddr *uservaddr | int addrlen | |||
S | 4 | long | sys_listen | int fd | int backlog | ||||
S | 5 | long | sys_accept | int fd | struct sockaddr *upeer_sockaddr | int *upeer_addrlen | |||
S | 6 | long | sys_getsockname | int fd | struct sockaddr *usockaddr | int *usockaddr_len | |||
S | 7 | long | sys_getpeername | int fd | struct sockaddr *usockaddr | int *usockaddr_len | |||
S | 8 | long | sys_socketpair | int family | int type | int protocol | int usockvec[2] | ||
S | 9 | long | sys_send | int fd | void * buff | size_t len | unsigned flags | ||
S | 10 | long | sys_recv | int fd | void * ubuf | size_t size | unsigned flags | ||
S | 11 | long | sys_sendto | int fd | void * buff | size_t len | unsigned flags | struct sockaddr *addr | int addr_len |
S | 12 | long | sys_recvfrom | int fd | void * ubuf | size_t size | unsigned flags | struct sockaddr *addr | int *addr_len |
S | 13 | long | sys_shutdown | int fd | int how | ||||
S | 14 | long | sys_setsockopt | int fd | int level | int optname | char *optval | int optlen | |
S | 15 | long | sys_getsockopt | int fd | int level | int optname | char *optval | int *optlen | |
S | 16 | long | sys_sendmsg | int fd | struct msghdr *msg | unsigned flags | |||
S | 17 | long | sys_recvmsg | int fd | struct msghdr *msg | unsigned int flags |
先頭が S でとなっている行は、ネットワーク関連のシステムコールで sys_socketcall (102) の第1引数に次の列の番号 (10進) を設定して呼び出します。 引数はメモリに格納して先頭アドレスを sys_socketcall の第2引数に設定します。