source: trunk/libs/newlib/src/libgloss/arm/linux-syscalls0.S @ 621

Last change on this file since 621 was 444, checked in by satin@…, 7 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 3.8 KB
Line 
1/** Linux system call interface for the ARM processor.
2 * Written by Shaun Jackman <sjackman@gmail.com>.
3 * Copyright 2006 Pathway Connectivity
4 *
5 * Permission to use, copy, modify, and distribute this software
6 * is freely granted, provided that this notice is preserved.
7 */
8
9#include "linux-syscall.h"
10
11#if __thumb__
12# define FUNC(name) .type name, %function; .thumb_func; name:
13# define SET .thumb_set
14#else
15# define FUNC(name) .type name, %function; name:
16# define SET .set
17#endif
18
19#define GLOBAL(name) .global name; FUNC(name)
20#define SIZE(name) .size name, .-name
21
22# define SYSCALL4(name) \
23        GLOBAL(_ ## name); \
24        swi #SYS_ ## name; \
25        b _set_errno; \
26        SIZE(_ ## name)
27
28# define SYSCALL6(name) \
29        GLOBAL(_ ## name); \
30        push { r4 - r5 }; \
31        ldr r4, [sp, #8]; \
32        ldr r5, [sp, #12]; \
33        swi #SYS_ ## name; \
34        pop { r4 - r5 }; \
35        b _set_errno; \
36        SIZE(_ ## name)
37
38#define SYSCALL0(name) SYSCALL3(name)
39#define SYSCALL3(name) SYSCALL4(name)
40#define SYSCALL1(name) SYSCALL3(name)
41#define SYSCALL2(name) SYSCALL3(name)
42#define SYSCALL5(name) SYSCALL6(name)
43
44SYSCALL1(alarm)
45SYSCALL1(brk)
46SYSCALL1(chdir)
47SYSCALL2(chmod)
48SYSCALL3(chown)
49SYSCALL1(close)
50SYSCALL1(dup)
51SYSCALL2(dup2)
52SYSCALL3(execve)
53SYSCALL1(exit)
54SYSCALL3(fcntl)
55SYSCALL2(fstat)
56SYSCALL2(ftruncate)
57SYSCALL3(getdents)
58SYSCALL0(getegid)
59SYSCALL0(geteuid)
60SYSCALL0(getgid)
61SYSCALL2(getgroups)
62SYSCALL1(getpgid)
63SYSCALL0(getpgrp)
64SYSCALL0(getpid)
65SYSCALL0(getuid)
66SYSCALL2(gettimeofday)
67SYSCALL3(ioctl)
68SYSCALL2(kill)
69SYSCALL3(lchown)
70SYSCALL2(link)
71SYSCALL3(lseek)
72SYSCALL2(lstat)
73SYSCALL2(mkdir)
74SYSCALL3(mknod)
75SYSCALL2(nanosleep)
76SYSCALL3(open)
77SYSCALL0(pause)
78SYSCALL1(pipe)
79SYSCALL3(read)
80SYSCALL3(readlink)
81SYSCALL4(reboot)
82SYSCALL1(rmdir)
83SYSCALL5(select)
84SYSCALL2(setpgid)
85SYSCALL1(setgid)
86SYSCALL0(setsid)
87SYSCALL1(setuid)
88SYSCALL3(sigprocmask)
89SYSCALL2(socketcall)
90SYSCALL2(stat)
91SYSCALL1(stime)
92SYSCALL2(symlink)
93SYSCALL1(sync)
94SYSCALL1(sysinfo)
95SYSCALL1(times)
96SYSCALL2(truncate)
97SYSCALL1(umask)
98SYSCALL1(uname)
99SYSCALL1(unlink)
100SYSCALL2(utime)
101SYSCALL0(vfork)
102SYSCALL4(wait4)
103SYSCALL3(write)
104
105#define ALIAS(name) .GLOBAL name; SET name, _ ## name
106
107ALIAS(alarm)
108ALIAS(chdir)
109ALIAS(chmod)
110ALIAS(chown)
111ALIAS(dup)
112ALIAS(dup2)
113ALIAS(ftruncate)
114ALIAS(getdents)
115ALIAS(getegid)
116ALIAS(geteuid)
117ALIAS(getgid)
118ALIAS(getgroups)
119ALIAS(getpgid)
120ALIAS(getpgrp)
121ALIAS(getuid)
122ALIAS(ioctl)
123ALIAS(lchown)
124ALIAS(lstat)
125ALIAS(mkdir)
126ALIAS(mknod)
127ALIAS(nanosleep)
128ALIAS(pause)
129ALIAS(pipe)
130ALIAS(readlink)
131ALIAS(rmdir)
132ALIAS(select)
133ALIAS(setgid)
134ALIAS(setpgid)
135ALIAS(setsid)
136ALIAS(setuid)
137ALIAS(sigprocmask)
138ALIAS(stime)
139ALIAS(symlink)
140ALIAS(sync)
141ALIAS(sysinfo)
142ALIAS(truncate)
143ALIAS(umask)
144ALIAS(uname)
145ALIAS(utime)
146ALIAS(vfork)
147ALIAS(wait4)
148
149# define SOCKETCALL(name, NAME) \
150        GLOBAL(name); \
151        push { r0 - r3 }; \
152        mov r0, #SYS_ ## NAME; \
153        b _socketcall_tail; \
154        SIZE(name)
155
156FUNC(_socketcall_tail)
157        mov r1, sp
158        push { lr }
159        bl _socketcall
160        pop { r3 }
161        add sp, #16
162#if defined(__ARM_ARCH_2__) || defined(__ARM_ARCH_3__) \
163    || defined(__ARM_ARCH_3M__) || defined(__ARM_ARCH_4__)
164        mov pc, r3
165#else
166        bx r3
167#endif
168        SIZE(_socketcall_tail)
169
170#define SOCKETCALL2(name, NAME) SOCKETCALL(name, NAME)
171#define SOCKETCALL3(name, NAME) SOCKETCALL(name, NAME)
172#define SOCKETCALL4(name, NAME) SOCKETCALL(name, NAME)
173#define SOCKETCALL5(name, NAME) SOCKETCALL(name, NAME)
174#define SOCKETCALL6(name, NAME) SOCKETCALL(name, NAME)
175
176SOCKETCALL3(accept, ACCEPT)
177SOCKETCALL3(bind, BIND)
178SOCKETCALL3(connect, CONNECT)
179SOCKETCALL3(getpeername, GETPEERNAME)
180SOCKETCALL3(getsockname, GETSOCKNAME)
181SOCKETCALL5(getsockopt, GETSOCKOPT)
182SOCKETCALL2(listen, LISTEN)
183SOCKETCALL4(recv, RECV)
184SOCKETCALL6(recvfrom, RECVFROM)
185SOCKETCALL3(recvmsg, RECVMSG)
186SOCKETCALL4(send, SEND)
187SOCKETCALL3(sendmsg, SENDMSG)
188SOCKETCALL6(sendto, SENDTO)
189SOCKETCALL5(setsockopt, SETSOCKOPT)
190SOCKETCALL2(shutdown, SHUTDOWN)
191SOCKETCALL3(socket, SOCKET)
192SOCKETCALL4(socketpair, SOCKETPAIR)
Note: See TracBrowser for help on using the repository browser.