modified SYSCALLS.TXT to support SuperH architecture
This commit is contained in:

committed by
Tony Sim

parent
90ec5f2a3f
commit
ce0595d01d
@@ -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" )
|
||||
|
Reference in New Issue
Block a user