2006-05-30 19:40:47 +02:00
|
|
|
/** Linux system call interface for the ARM processor.
|
|
|
|
* Written by Shaun Jackman <sjackman@gmail.com>.
|
|
|
|
* Copyright 2006 Pathway Connectivity
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software
|
|
|
|
* is freely granted, provided that this notice is preserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "linux-syscall.h"
|
|
|
|
|
|
|
|
#if __thumb__
|
|
|
|
# define FUNC(name) .type name, %function; .thumb_func; name:
|
|
|
|
# define SET .thumb_set
|
|
|
|
#else
|
|
|
|
# define FUNC(name) .type name, %function; name:
|
|
|
|
# define SET .set
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define GLOBAL(name) .global name; FUNC(name)
|
|
|
|
#define SIZE(name) .size name, .-name
|
|
|
|
|
|
|
|
# define SYSCALL4(name) \
|
|
|
|
GLOBAL(_ ## name); \
|
|
|
|
swi #SYS_ ## name; \
|
|
|
|
b _set_errno; \
|
|
|
|
SIZE(_ ## name)
|
|
|
|
|
|
|
|
# define SYSCALL6(name) \
|
|
|
|
GLOBAL(_ ## name); \
|
|
|
|
push { r4 - r5 }; \
|
|
|
|
ldr r4, [sp, #8]; \
|
|
|
|
ldr r5, [sp, #12]; \
|
|
|
|
swi #SYS_ ## name; \
|
|
|
|
pop { r4 - r5 }; \
|
|
|
|
b _set_errno; \
|
|
|
|
SIZE(_ ## name)
|
|
|
|
|
|
|
|
#define SYSCALL0(name) SYSCALL3(name)
|
|
|
|
#define SYSCALL3(name) SYSCALL4(name)
|
|
|
|
#define SYSCALL1(name) SYSCALL3(name)
|
|
|
|
#define SYSCALL2(name) SYSCALL3(name)
|
|
|
|
#define SYSCALL5(name) SYSCALL6(name)
|
|
|
|
|
|
|
|
SYSCALL1(alarm)
|
|
|
|
SYSCALL1(brk)
|
|
|
|
SYSCALL1(chdir)
|
|
|
|
SYSCALL2(chmod)
|
|
|
|
SYSCALL3(chown)
|
|
|
|
SYSCALL1(close)
|
|
|
|
SYSCALL1(dup)
|
|
|
|
SYSCALL2(dup2)
|
|
|
|
SYSCALL3(execve)
|
|
|
|
SYSCALL1(exit)
|
|
|
|
SYSCALL3(fcntl)
|
|
|
|
SYSCALL2(fstat)
|
2006-07-04 Shaun Jackman <sjackman@gmail.com>
* arm/linux-syscalls0.S (ftruncate, getegid, geteuid, getgid,
getgroups, getpgid, getpgrp, getuid, lchown, pause, pipe,
setpgid, setgid, setsid, setuid, sigprocmask, sync, uname): New
system call.
2006-07-05 01:58:02 +02:00
|
|
|
SYSCALL2(ftruncate)
|
2006-05-30 19:40:47 +02:00
|
|
|
SYSCALL3(getdents)
|
2006-07-04 Shaun Jackman <sjackman@gmail.com>
* arm/linux-syscalls0.S (ftruncate, getegid, geteuid, getgid,
getgroups, getpgid, getpgrp, getuid, lchown, pause, pipe,
setpgid, setgid, setsid, setuid, sigprocmask, sync, uname): New
system call.
2006-07-05 01:58:02 +02:00
|
|
|
SYSCALL0(getegid)
|
|
|
|
SYSCALL0(geteuid)
|
|
|
|
SYSCALL0(getgid)
|
|
|
|
SYSCALL2(getgroups)
|
|
|
|
SYSCALL1(getpgid)
|
|
|
|
SYSCALL0(getpgrp)
|
2006-05-30 19:40:47 +02:00
|
|
|
SYSCALL0(getpid)
|
2006-07-04 Shaun Jackman <sjackman@gmail.com>
* arm/linux-syscalls0.S (ftruncate, getegid, geteuid, getgid,
getgroups, getpgid, getpgrp, getuid, lchown, pause, pipe,
setpgid, setgid, setsid, setuid, sigprocmask, sync, uname): New
system call.
2006-07-05 01:58:02 +02:00
|
|
|
SYSCALL0(getuid)
|
2006-05-30 19:40:47 +02:00
|
|
|
SYSCALL2(gettimeofday)
|
|
|
|
SYSCALL3(ioctl)
|
|
|
|
SYSCALL2(kill)
|
2006-07-04 Shaun Jackman <sjackman@gmail.com>
* arm/linux-syscalls0.S (ftruncate, getegid, geteuid, getgid,
getgroups, getpgid, getpgrp, getuid, lchown, pause, pipe,
setpgid, setgid, setsid, setuid, sigprocmask, sync, uname): New
system call.
2006-07-05 01:58:02 +02:00
|
|
|
SYSCALL3(lchown)
|
2006-05-30 19:40:47 +02:00
|
|
|
SYSCALL2(link)
|
|
|
|
SYSCALL3(lseek)
|
|
|
|
SYSCALL2(lstat)
|
|
|
|
SYSCALL2(mkdir)
|
|
|
|
SYSCALL3(mknod)
|
|
|
|
SYSCALL2(nanosleep)
|
|
|
|
SYSCALL3(open)
|
2006-07-04 Shaun Jackman <sjackman@gmail.com>
* arm/linux-syscalls0.S (ftruncate, getegid, geteuid, getgid,
getgroups, getpgid, getpgrp, getuid, lchown, pause, pipe,
setpgid, setgid, setsid, setuid, sigprocmask, sync, uname): New
system call.
2006-07-05 01:58:02 +02:00
|
|
|
SYSCALL0(pause)
|
|
|
|
SYSCALL1(pipe)
|
2006-05-30 19:40:47 +02:00
|
|
|
SYSCALL3(read)
|
|
|
|
SYSCALL3(readlink)
|
|
|
|
SYSCALL4(reboot)
|
|
|
|
SYSCALL1(rmdir)
|
|
|
|
SYSCALL5(select)
|
2006-07-04 Shaun Jackman <sjackman@gmail.com>
* arm/linux-syscalls0.S (ftruncate, getegid, geteuid, getgid,
getgroups, getpgid, getpgrp, getuid, lchown, pause, pipe,
setpgid, setgid, setsid, setuid, sigprocmask, sync, uname): New
system call.
2006-07-05 01:58:02 +02:00
|
|
|
SYSCALL2(setpgid)
|
|
|
|
SYSCALL1(setgid)
|
|
|
|
SYSCALL0(setsid)
|
|
|
|
SYSCALL1(setuid)
|
|
|
|
SYSCALL3(sigprocmask)
|
2006-05-30 19:40:47 +02:00
|
|
|
SYSCALL2(socketcall)
|
|
|
|
SYSCALL2(stat)
|
|
|
|
SYSCALL1(stime)
|
|
|
|
SYSCALL2(symlink)
|
2006-07-04 Shaun Jackman <sjackman@gmail.com>
* arm/linux-syscalls0.S (ftruncate, getegid, geteuid, getgid,
getgroups, getpgid, getpgrp, getuid, lchown, pause, pipe,
setpgid, setgid, setsid, setuid, sigprocmask, sync, uname): New
system call.
2006-07-05 01:58:02 +02:00
|
|
|
SYSCALL1(sync)
|
2006-05-30 19:40:47 +02:00
|
|
|
SYSCALL1(sysinfo)
|
|
|
|
SYSCALL1(times)
|
|
|
|
SYSCALL2(truncate)
|
|
|
|
SYSCALL1(umask)
|
2006-07-04 Shaun Jackman <sjackman@gmail.com>
* arm/linux-syscalls0.S (ftruncate, getegid, geteuid, getgid,
getgroups, getpgid, getpgrp, getuid, lchown, pause, pipe,
setpgid, setgid, setsid, setuid, sigprocmask, sync, uname): New
system call.
2006-07-05 01:58:02 +02:00
|
|
|
SYSCALL1(uname)
|
2006-05-30 19:40:47 +02:00
|
|
|
SYSCALL1(unlink)
|
|
|
|
SYSCALL2(utime)
|
|
|
|
SYSCALL0(vfork)
|
|
|
|
SYSCALL4(wait4)
|
|
|
|
SYSCALL3(write)
|
|
|
|
|
|
|
|
#define ALIAS(name) .GLOBAL name; SET name, _ ## name
|
|
|
|
|
|
|
|
ALIAS(alarm)
|
|
|
|
ALIAS(chdir)
|
|
|
|
ALIAS(chmod)
|
|
|
|
ALIAS(chown)
|
|
|
|
ALIAS(dup)
|
|
|
|
ALIAS(dup2)
|
2006-07-04 Shaun Jackman <sjackman@gmail.com>
* arm/linux-syscalls0.S (ftruncate, getegid, geteuid, getgid,
getgroups, getpgid, getpgrp, getuid, lchown, pause, pipe,
setpgid, setgid, setsid, setuid, sigprocmask, sync, uname): New
system call.
2006-07-05 01:58:02 +02:00
|
|
|
ALIAS(ftruncate)
|
2006-05-30 19:40:47 +02:00
|
|
|
ALIAS(getdents)
|
2006-07-04 Shaun Jackman <sjackman@gmail.com>
* arm/linux-syscalls0.S (ftruncate, getegid, geteuid, getgid,
getgroups, getpgid, getpgrp, getuid, lchown, pause, pipe,
setpgid, setgid, setsid, setuid, sigprocmask, sync, uname): New
system call.
2006-07-05 01:58:02 +02:00
|
|
|
ALIAS(getegid)
|
|
|
|
ALIAS(geteuid)
|
|
|
|
ALIAS(getgid)
|
|
|
|
ALIAS(getgroups)
|
|
|
|
ALIAS(getpgid)
|
|
|
|
ALIAS(getpgrp)
|
|
|
|
ALIAS(getuid)
|
2006-05-30 19:40:47 +02:00
|
|
|
ALIAS(ioctl)
|
2006-07-04 Shaun Jackman <sjackman@gmail.com>
* arm/linux-syscalls0.S (ftruncate, getegid, geteuid, getgid,
getgroups, getpgid, getpgrp, getuid, lchown, pause, pipe,
setpgid, setgid, setsid, setuid, sigprocmask, sync, uname): New
system call.
2006-07-05 01:58:02 +02:00
|
|
|
ALIAS(lchown)
|
2006-05-30 19:40:47 +02:00
|
|
|
ALIAS(lstat)
|
|
|
|
ALIAS(mkdir)
|
|
|
|
ALIAS(mknod)
|
|
|
|
ALIAS(nanosleep)
|
2006-07-04 Shaun Jackman <sjackman@gmail.com>
* arm/linux-syscalls0.S (ftruncate, getegid, geteuid, getgid,
getgroups, getpgid, getpgrp, getuid, lchown, pause, pipe,
setpgid, setgid, setsid, setuid, sigprocmask, sync, uname): New
system call.
2006-07-05 01:58:02 +02:00
|
|
|
ALIAS(pause)
|
|
|
|
ALIAS(pipe)
|
2006-05-30 19:40:47 +02:00
|
|
|
ALIAS(readlink)
|
|
|
|
ALIAS(rmdir)
|
|
|
|
ALIAS(select)
|
2006-07-04 Shaun Jackman <sjackman@gmail.com>
* arm/linux-syscalls0.S (ftruncate, getegid, geteuid, getgid,
getgroups, getpgid, getpgrp, getuid, lchown, pause, pipe,
setpgid, setgid, setsid, setuid, sigprocmask, sync, uname): New
system call.
2006-07-05 01:58:02 +02:00
|
|
|
ALIAS(setgid)
|
|
|
|
ALIAS(setpgid)
|
|
|
|
ALIAS(setsid)
|
|
|
|
ALIAS(setuid)
|
|
|
|
ALIAS(sigprocmask)
|
2006-05-30 19:40:47 +02:00
|
|
|
ALIAS(stime)
|
|
|
|
ALIAS(symlink)
|
2006-07-04 Shaun Jackman <sjackman@gmail.com>
* arm/linux-syscalls0.S (ftruncate, getegid, geteuid, getgid,
getgroups, getpgid, getpgrp, getuid, lchown, pause, pipe,
setpgid, setgid, setsid, setuid, sigprocmask, sync, uname): New
system call.
2006-07-05 01:58:02 +02:00
|
|
|
ALIAS(sync)
|
2006-05-30 19:40:47 +02:00
|
|
|
ALIAS(sysinfo)
|
|
|
|
ALIAS(truncate)
|
|
|
|
ALIAS(umask)
|
2006-07-04 Shaun Jackman <sjackman@gmail.com>
* arm/linux-syscalls0.S (ftruncate, getegid, geteuid, getgid,
getgroups, getpgid, getpgrp, getuid, lchown, pause, pipe,
setpgid, setgid, setsid, setuid, sigprocmask, sync, uname): New
system call.
2006-07-05 01:58:02 +02:00
|
|
|
ALIAS(uname)
|
2006-05-30 19:40:47 +02:00
|
|
|
ALIAS(utime)
|
|
|
|
ALIAS(vfork)
|
|
|
|
ALIAS(wait4)
|
|
|
|
|
|
|
|
# define SOCKETCALL(name, NAME) \
|
|
|
|
GLOBAL(name); \
|
|
|
|
push { r0 - r3 }; \
|
|
|
|
mov r0, #SYS_ ## NAME; \
|
|
|
|
b _socketcall_tail; \
|
|
|
|
SIZE(name)
|
|
|
|
|
|
|
|
FUNC(_socketcall_tail)
|
|
|
|
mov r1, sp
|
|
|
|
push { lr }
|
|
|
|
bl _socketcall
|
|
|
|
pop { r3 }
|
|
|
|
add sp, #16
|
2006-10-03 18:33:50 +02:00
|
|
|
#if defined(__ARM_ARCH_2__) || defined(__ARM_ARCH_3__) \
|
|
|
|
|| defined(__ARM_ARCH_3M__) || defined(__ARM_ARCH_4__)
|
2006-10-02 21:57:46 +02:00
|
|
|
mov pc, r3
|
2006-10-03 18:33:50 +02:00
|
|
|
#else
|
|
|
|
bx r3
|
2006-10-02 21:57:46 +02:00
|
|
|
#endif
|
2006-05-30 19:40:47 +02:00
|
|
|
SIZE(_socketcall_tail)
|
|
|
|
|
|
|
|
#define SOCKETCALL2(name, NAME) SOCKETCALL(name, NAME)
|
|
|
|
#define SOCKETCALL3(name, NAME) SOCKETCALL(name, NAME)
|
|
|
|
#define SOCKETCALL4(name, NAME) SOCKETCALL(name, NAME)
|
|
|
|
#define SOCKETCALL5(name, NAME) SOCKETCALL(name, NAME)
|
|
|
|
#define SOCKETCALL6(name, NAME) SOCKETCALL(name, NAME)
|
|
|
|
|
|
|
|
SOCKETCALL3(accept, ACCEPT)
|
|
|
|
SOCKETCALL3(bind, BIND)
|
|
|
|
SOCKETCALL3(connect, CONNECT)
|
|
|
|
SOCKETCALL3(getpeername, GETPEERNAME)
|
|
|
|
SOCKETCALL3(getsockname, GETSOCKNAME)
|
|
|
|
SOCKETCALL5(getsockopt, GETSOCKOPT)
|
|
|
|
SOCKETCALL2(listen, LISTEN)
|
|
|
|
SOCKETCALL4(recv, RECV)
|
|
|
|
SOCKETCALL6(recvfrom, RECVFROM)
|
|
|
|
SOCKETCALL3(recvmsg, RECVMSG)
|
|
|
|
SOCKETCALL4(send, SEND)
|
|
|
|
SOCKETCALL3(sendmsg, SENDMSG)
|
|
|
|
SOCKETCALL6(sendto, SENDTO)
|
|
|
|
SOCKETCALL5(setsockopt, SETSOCKOPT)
|
|
|
|
SOCKETCALL2(shutdown, SHUTDOWN)
|
|
|
|
SOCKETCALL3(socket, SOCKET)
|
|
|
|
SOCKETCALL4(socketpair, SOCKETPAIR)
|