merge from open-source master

This commit is contained in:
Jean-Baptiste Queru 2009-11-15 10:58:55 -08:00
commit 817b4c45f0
3 changed files with 135 additions and 22 deletions

View File

@ -22,6 +22,9 @@
# assembler template for the syscall; it's up to the bionic implementation to provide
# a relevant C stub
#
# - additionally, if the syscall number is different amoung ARM, x86 and SuperH, use:
# return_type funcname[:syscall_name](parameters) arm_number,x86_number,superh_number
#
# the file is processed by a python script named gensyscalls.py
#
@ -65,7 +68,7 @@ int getrusage(int who, struct rusage* r_usage) 77
int setgroups:setgroups32(int, const gid_t *) 206
pid_t getpgrp(void) stub
int setpgid(pid_t, pid_t) 57
pid_t vfork(void) 190,-1
pid_t vfork(void) 190,-1,190
int setregid:setregid32(gid_t, gid_t) 204
int chroot(const char *) 61
int prctl(int option, unsigned int arg2, unsigned int arg3, unsigned int arg4, unsigned int arg5) 172
@ -102,7 +105,7 @@ int __fcntl:fcntl(int, int, void*) 55
int flock(int, int) 143
int fchmod(int, mode_t) 94
int dup(int) 41
int pipe(int *) 42
int pipe(int *) 42,42,-1
int dup2(int, int) 63
int select:_newselect(int, struct fd_set *, struct fd_set *, struct fd_set *, struct timeval *) 142
int ftruncate(int, off_t) 93
@ -190,21 +193,24 @@ int sendmsg(int, const struct msghdr *, unsigned int) 296,-1
int recvmsg(int, struct msghdr *, unsigned int) 297,-1
# sockets for x86. These are done as an "indexed" call to socketcall syscall.
int socket:socketcall:1 (int, int, int) -1,102
int bind:socketcall:2 (int, struct sockaddr *, int) -1,102
int connect:socketcall:3(int, struct sockaddr *, socklen_t) -1,102
int listen:socketcall:4(int, int) -1,102
int accept:socketcall:5(int, struct sockaddr *, socklen_t *) -1,102
int getsockname:socketcall:6(int, struct sockaddr *, socklen_t *) -1,102
int getpeername:socketcall:7(int, struct sockaddr *, socklen_t *) -1,102
int socketpair:socketcall:8(int, int, int, int*) -1,102
int sendto:socketcall:11(int, const void *, size_t, int, const struct sockaddr *, socklen_t) -1,102
int recvfrom:socketcall:12(int, void *, size_t, unsigned int, struct sockaddr *, socklen_t *) -1,102
int shutdown:socketcall:13(int, int) -1,102
int setsockopt:socketcall:14(int, int, int, const void *, socklen_t) -1,102
int getsockopt:socketcall:15(int, int, int, void *, socklen_t *) -1,102
int sendmsg:socketcall:16(int, const struct msghdr *, unsigned int) -1,102
int recvmsg:socketcall:17(int, struct msghdr *, unsigned int) -1,102
int socket:socketcall:1 (int, int, int) -1,102,-1
int bind:socketcall:2 (int, struct sockaddr *, int) -1,102,-1
int connect:socketcall:3(int, struct sockaddr *, socklen_t) -1,102,-1
int listen:socketcall:4(int, int) -1,102,-1
int accept:socketcall:5(int, struct sockaddr *, socklen_t *) -1,102,-1
int getsockname:socketcall:6(int, struct sockaddr *, socklen_t *) -1,102,-1
int getpeername:socketcall:7(int, struct sockaddr *, socklen_t *) -1,102,-1
int socketpair:socketcall:8(int, int, int, int*) -1,102,-1
int sendto:socketcall:11(int, const void *, size_t, int, const struct sockaddr *, socklen_t) -1,102,-1
int recvfrom:socketcall:12(int, void *, size_t, unsigned int, struct sockaddr *, socklen_t *) -1,102,-1
int shutdown:socketcall:13(int, int) -1,102,-1
int setsockopt:socketcall:14(int, int, int, const void *, socklen_t) -1,102,-1
int getsockopt:socketcall:15(int, int, int, void *, socklen_t *) -1,102,-1
int sendmsg:socketcall:16(int, const struct msghdr *, unsigned int) -1,102,-1
int recvmsg:socketcall:17(int, struct msghdr *, unsigned int) -1,102,-1
# sockets for sh.
int __socketcall:__socketcall(int, unsigned long*) -1,-1,102
# scheduler & real-time
int sched_setscheduler(pid_t pid, int policy, const struct sched_param *param) 156
@ -234,9 +240,9 @@ int epoll_create(int size) 250,254
int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event) 251,255
int epoll_wait(int epfd, struct epoll_event *events, int max, int timeout) 252,256
int inotify_init(void) 316,291
int inotify_add_watch(int, const char *, unsigned int) 317,292
int inotify_rm_watch(int, unsigned int) 318,293
int inotify_init(void) 316,291,290
int inotify_add_watch(int, const char *, unsigned int) 317,292,291
int inotify_rm_watch(int, unsigned int) 318,293,292
int poll(struct pollfd *, unsigned int, long) 168

View File

@ -194,6 +194,7 @@ class SysCallsTxtParser:
if number == "stub":
syscall_id = -1
syscall_id2 = -1
syscall_id3 = -1
else:
try:
if number[0] == '#':
@ -201,14 +202,21 @@ class SysCallsTxtParser:
numbers = string.split(number,',')
syscall_id = int(numbers[0])
syscall_id2 = syscall_id
syscall_id3 = syscall_id
if len(numbers) > 1:
syscall_id2 = int(numbers[1])
syscall_id3 = syscall_id2
if len(numbers) > 2:
syscall_id3 = int(numbers[2])
except:
E("invalid syscall number in '%s'" % line)
return
print str(syscall_id) + ':' + str(syscall_id2) + ':' + str(syscall_id3)
t = { "id" : syscall_id,
"id2" : syscall_id2,
"id3" : syscall_id3,
"cid" : call_id,
"name" : syscall_name,
"func" : syscall_func,

View File

@ -31,7 +31,7 @@ print "bionic_root is %s" % bionic_root
bionic_temp = "/tmp/bionic_gensyscalls/"
# all architectures, update as you see fit
all_archs = [ "arm", "x86" ]
all_archs = [ "arm", "x86", "sh" ]
def make_dir( path ):
if not os.path.exists(path):
@ -188,6 +188,62 @@ thumb_call_long = thumb_header + """\
.fnend
"""
# SuperH assembler templates for each syscall stub
#
superh_header = """/* autogenerated by gensyscalls.py */
#include <sys/linux-syscalls.h>
.text
.type %(fname)s, @function
.globl %(fname)s
.align 4
%(fname)s:
"""
superh_call_default = """
/* invoke trap */
mov.l 0f, r3 /* trap num */
trapa #(%(numargs)s + 0x10)
/* check return value */
cmp/pz r0
bt %(idname)s_end
/* keep error number */
sts.l pr, @-r15
mov.l 1f, r1
jsr @r1
mov r0, r4
lds.l @r15+, pr
%(idname)s_end:
rts
nop
.align 2
0: .long %(idname)s
1: .long __set_syscall_errno
"""
superh_5args_header = """
/* get ready for additonal arg */
mov.l @r15, r0
"""
superh_6args_header = """
/* get ready for additonal arg */
mov.l @r15, r0
mov.l @(4, r15), r1
"""
superh_7args_header = """
/* get ready for additonal arg */
mov.l @r15, r0
mov.l @(4, r15), r1
mov.l @(8, r15), r2
"""
class State:
def __init__(self):
@ -285,6 +341,23 @@ class State:
return thumb_call_default % t
def superh_genstub(self, fname, flags, idname):
numargs = int(flags)
t = { "fname" : fname,
"idname" : idname,
"numargs" : numargs }
superh_call = superh_header
if flags:
if numargs == 5:
superh_call += superh_5args_header
if numargs == 6:
superh_call += superh_6args_header
if numargs == 7:
superh_call += superh_7args_header
superh_call += superh_call_default
return superh_call % t
def process_file(self,input):
parser = SysCallsTxtParser()
parser.parse_file(input)
@ -314,6 +387,9 @@ class State:
E("cid for dispatch syscalls is only supported for x86 in "
"'%s'" % syscall_name)
return
if t["id3"] >= 0:
t["asm-sh"] = self.superh_genstub(syscall_func,len(syscall_params),"__NR_"+syscall_name)
def gen_NR_syscall(self,fp,name,id):
@ -363,6 +439,20 @@ class State:
gen_syscalls[sc_name] = True
fp.write( "#endif\n" );
# all superh-specific syscalls
fp.write( "\n#if defined(__SH3__) || defined(__SH4__) \n" );
for sc in self.syscalls:
sc_id = sc["id"]
sc_id2 = sc["id2"]
sc_id3 = sc["id3"]
sc_name = sc["name"]
if sc_id2 != sc_id3 and sc_id3 >= 0:
self.gen_NR_syscall( fp, sc_name, sc_id3 )
else:
if sc_id != sc_id2 and sc_id2 >= 0:
self.gen_NR_syscall( fp, sc_name, sc_id2 )
fp.write( "#endif\n" );
fp.write( "\n#endif\n" )
fp.write( "\n#endif /* _BIONIC_LINUX_SYSCALLS_H_ */\n" );
fp.close()
@ -395,7 +485,8 @@ class State:
fp.write( "syscall_src := \n" )
arch_test = {
"arm": lambda x: x.has_key("asm-arm") or x.has_key("asm-thumb"),
"x86": lambda x: x.has_key("asm-x86")
"x86": lambda x: x.has_key("asm-x86"),
"sh": lambda x: x.has_key("asm-sh")
}
for sc in self.syscalls:
@ -432,6 +523,14 @@ class State:
fp.close()
self.new_stubs.append( fname )
if sc.has_key("asm-sh"):
fname = "arch-sh/syscalls/%s.S" % sc["func"]
D( ">>> generating "+fname )
fp = create_file( fname )
fp.write(sc["asm-sh"])
fp.close()
self.new_stubs.append( fname )
def regenerate(self):
D( "scanning for existing architecture-specific stub files" )