]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/kern/makesyscalls.sh
xnu-6153.81.5.tar.gz
[apple/xnu.git] / bsd / kern / makesyscalls.sh
index d8b11ba6c22708e25c8f520d9c0688cf04b2c7fd..ffdacf957769351a6efd2f3cd3aed1a6d73c9d38 100755 (executable)
@@ -34,6 +34,10 @@ output_sysprotofile=0
 output_syshdrfile=0
 output_syscalltablefile=0
 output_auditevfile=0
 output_syshdrfile=0
 output_syscalltablefile=0
 output_auditevfile=0
+output_tracecodes=0
+output_systrace=0
+
+use_stdout=0
 
 # output files:
 syscallnamesfile="syscalls.c"
 
 # output files:
 syscallnamesfile="syscalls.c"
@@ -46,7 +50,8 @@ auditevfile="audit_kevents.c"
 syscallprefix="SYS_"
 switchname="sysent"
 namesname="syscallnames"
 syscallprefix="SYS_"
 switchname="sysent"
 namesname="syscallnames"
-
+tracecodename="syscall.codes"
+systraceargsfile="systrace_args.c"
 # tmp files:
 syslegal="sysent.syslegal.$$"
 sysent="sysent.switch.$$"
 # tmp files:
 syslegal="sysent.syslegal.$$"
 sysent="sysent.switch.$$"
@@ -56,14 +61,18 @@ sysprotoend="sysprotoend.$$"
 syscallnamestempfile="syscallnamesfile.$$"
 syshdrtempfile="syshdrtempfile.$$"
 audittempfile="audittempfile.$$"
 syscallnamestempfile="syscallnamesfile.$$"
 syshdrtempfile="syshdrtempfile.$$"
 audittempfile="audittempfile.$$"
+tracecodetempfile="tracecodetempfile.$$"
+systraceargstempfile="systraceargstempfile.$$"
+systraceargdesctempfile="systraceargdesctempfile.$$"
+systracerettempfile="systracerettempfile.$$"
 
 
-trap "rm $syslegal $sysent $sysinc $sysarg $sysprotoend $syscallnamestempfile $syshdrtempfile $audittempfile" 0
+trap "rm $syslegal $sysent $sysinc $sysarg $sysprotoend $syscallnamestempfile $syshdrtempfile $audittempfile $tracecodetempfile $systraceargstempfile $systraceargdesctempfile $systracerettempfile" 0
 
 
-touch $syslegal $sysent $sysinc $sysarg $sysprotoend $syscallnamestempfile $syshdrtempfile $audittempfile
+touch $syslegal $sysent $sysinc $sysarg $sysprotoend $syscallnamestempfile $syshdrtempfile $audittempfile $tracecodetempfile $systraceargstempfile $systraceargdesctempfile $systracerettempfile
 
 case $# in
     0)
 
 case $# in
     0)
-       echo "usage: $0 input-file [<names|proto|header|table|audit> [<config-file>]]" 1>&2
+       echo "usage: $0 input-file [<names|proto|header|table|audit|trace> [<config-file>]]" 1>&2
        exit 1
        ;;
 esac
        exit 1
        ;;
 esac
@@ -88,6 +97,13 @@ if [ -n "$1" ]; then
        audit)
            output_auditevfile=1
            ;;
        audit)
            output_auditevfile=1
            ;;
+       systrace)
+           output_systrace=1
+           ;;
+       trace)
+           output_tracecodes=1
+           use_stdout=1
+           ;;
     esac
     shift;
 else
     esac
     shift;
 else
@@ -96,6 +112,7 @@ else
     output_syshdrfile=1
     output_syscalltablefile=1
     output_auditevfile=1
     output_syshdrfile=1
     output_syscalltablefile=1
     output_auditevfile=1
+    output_tracecodes=1
 fi
 
 if [ -n "$1" -a -f "$1" ]; then
 fi
 
 if [ -n "$1" -a -f "$1" ]; then
@@ -131,7 +148,11 @@ s/\$//g
                syscallnamestempfile = \"$syscallnamestempfile\"
                syshdrfile = \"$syshdrfile\"
                syshdrtempfile = \"$syshdrtempfile\"
                syscallnamestempfile = \"$syscallnamestempfile\"
                syshdrfile = \"$syshdrfile\"
                syshdrtempfile = \"$syshdrtempfile\"
+               systraceargstempfile = \"$systraceargstempfile\"
+               systraceargdesctempfile = \"$systraceargdesctempfile\"
+               systracerettempfile = \"$systracerettempfile\"
                audittempfile = \"$audittempfile\"
                audittempfile = \"$audittempfile\"
+               tracecodetempfile = \"$tracecodetempfile\"
                syscallprefix = \"$syscallprefix\"
                switchname = \"$switchname\"
                namesname = \"$namesname\"
                syscallprefix = \"$syscallprefix\"
                switchname = \"$switchname\"
                namesname = \"$namesname\"
@@ -172,7 +193,7 @@ s/\$//g
        }
        NR == 1 {
                printf "\n/* The casts are bogus but will do for now. */\n" > sysent
        }
        NR == 1 {
                printf "\n/* The casts are bogus but will do for now. */\n" > sysent
-               printf "__private_extern__ struct sysent %s[] = {\n",switchname > sysent
+               printf "__private_extern__ const struct sysent %s[] = {\n",switchname > sysent
 
                printf "#ifndef %s\n", sysproto_h > sysarg
                printf "#define\t%s\n\n", sysproto_h > sysarg
 
                printf "#ifndef %s\n", sysproto_h > sysarg
                printf "#define\t%s\n\n", sysproto_h > sysarg
@@ -190,7 +211,12 @@ s/\$//g
                printf "#include <mach/shared_region.h>\n" > sysarg
                printf "\n#ifdef KERNEL\n" > sysarg
                printf "#ifdef __APPLE_API_PRIVATE\n" > sysarg
                printf "#include <mach/shared_region.h>\n" > sysarg
                printf "\n#ifdef KERNEL\n" > sysarg
                printf "#ifdef __APPLE_API_PRIVATE\n" > sysarg
-               printf "#ifndef __arm__\n" > sysarg
+               printf "/*\n" > sysarg
+               printf " * The kernel may support multiple userspace ABIs, and must use\n" > sysarg
+               printf " * argument structures with elements large enough for any of them.\n" > sysarg
+               printf "*/\n" > sysarg
+               printf "\n" > sysarg
+               printf "#if CONFIG_REQUIRES_U32_MUNGING\n" > sysarg
                printf "#define\tPAD_(t)\t(sizeof(uint64_t) <= sizeof(t) \\\n " > sysarg
                printf "\t\t? 0 : sizeof(uint64_t) - sizeof(t))\n" > sysarg
                printf "#else\n" > sysarg
                printf "#define\tPAD_(t)\t(sizeof(uint64_t) <= sizeof(t) \\\n " > sysarg
                printf "\t\t? 0 : sizeof(uint64_t) - sizeof(t))\n" > sysarg
                printf "#else\n" > sysarg
@@ -205,76 +231,7 @@ s/\$//g
                printf "#define\tPADR_(t)\t0\n" > sysarg
                printf "#endif\n" > sysarg
                printf "\n__BEGIN_DECLS\n" > sysarg
                printf "#define\tPADR_(t)\t0\n" > sysarg
                printf "#endif\n" > sysarg
                printf "\n__BEGIN_DECLS\n" > sysarg
-               printf "#ifndef __MUNGE_ONCE\n" > sysarg
-               printf "#define __MUNGE_ONCE\n" > sysarg
-               printf "#ifndef __arm__\n" > sysarg
-               printf "void munge_w(const void *, void *);  \n" > sysarg
-               printf "void munge_ww(const void *, void *);  \n" > sysarg
-               printf "void munge_www(const void *, void *);  \n" > sysarg
-               printf "void munge_wwww(const void *, void *);  \n" > sysarg
-               printf "void munge_wwwww(const void *, void *);  \n" > sysarg
-               printf "void munge_wwwwww(const void *, void *);  \n" > sysarg
-               printf "void munge_wwwwwww(const void *, void *);  \n" > sysarg
-               printf "void munge_wwwwwwww(const void *, void *);  \n" > sysarg
-               printf "void munge_wl(const void *, void *);  \n" > sysarg
-               printf "void munge_wlw(const void *, void *);  \n" > sysarg
-               printf "void munge_wwwl(const void *, void *);  \n" > sysarg
-               printf "void munge_wwwlw(const void *, void *);  \n" > sysarg
-               printf "void munge_wwwlww(const void *, void *);  \n" > sysarg
-               printf "void munge_wwlwww(const void *, void *);  \n" > sysarg
-               printf "void munge_wwwwlw(const void *, void *);  \n" > sysarg
-               printf "void munge_wwwwl(const void *, void *);  \n" > sysarg
-               printf "void munge_wwwwwl(const void *, void *);  \n" > sysarg
-               printf "void munge_wwwwwwll(const void *, void *);  \n" > sysarg
-               printf "void munge_wwwwwwlw(const void *, void *);  \n" > sysarg
-               printf "void munge_wsw(const void *, void *);  \n" > sysarg
-               printf "void munge_wws(const void *, void *);  \n" > sysarg
-               printf "void munge_wwwsw(const void *, void *);  \n" > sysarg
-               printf "void munge_llllll(const void *, void *); \n" > sysarg
-               printf "#else \n" > sysarg
-               printf "#define munge_w  NULL \n" > sysarg
-               printf "#define munge_ww  NULL \n" > sysarg
-               printf "#define munge_www  NULL \n" > sysarg
-               printf "#define munge_wwww  NULL \n" > sysarg
-               printf "#define munge_wwwww  NULL \n" > sysarg
-               printf "#define munge_wwwwww  NULL \n" > sysarg
-               printf "#define munge_wwwwwww  NULL \n" > sysarg
-               printf "#define munge_wwwwwwww  NULL \n" > sysarg
-               printf "#define munge_wl  NULL \n" > sysarg
-               printf "#define munge_wlw  NULL \n" > sysarg
-               printf "#define munge_wwwl  NULL \n" > sysarg
-               printf "#define munge_wwwlw  NULL \n" > sysarg
-               printf "#define munge_wwwlww  NULL\n" > sysarg
-               printf "#define munge_wwlwww  NULL \n" > sysarg
-               printf "#define munge_wwwwl  NULL \n" > sysarg
-               printf "#define munge_wwwwlw  NULL \n" > sysarg
-               printf "#define munge_wwwwwl  NULL \n" > sysarg
-               printf "#define munge_wwwwwwlw  NULL \n" > sysarg
-               printf "#define munge_wsw  NULL \n" > sysarg
-               printf "#define munge_wws  NULL \n" > sysarg
-               printf "#define munge_wwwsw  NULL \n" > sysarg
-               printf "#define munge_llllll  NULL \n" > sysarg
-               printf "#endif // ! __arm__\n" > sysarg
-               printf "#ifdef __ppc__\n" > sysarg
-               printf "void munge_d(const void *, void *);  \n" > sysarg
-               printf "void munge_dd(const void *, void *);  \n" > sysarg
-               printf "void munge_ddd(const void *, void *);  \n" > sysarg
-               printf "void munge_dddd(const void *, void *);  \n" > sysarg
-               printf "void munge_ddddd(const void *, void *);  \n" > sysarg
-               printf "void munge_dddddd(const void *, void *);  \n" > sysarg
-               printf "void munge_ddddddd(const void *, void *);  \n" > sysarg
-               printf "void munge_dddddddd(const void *, void *);  \n" > sysarg
-               printf "#else \n" > sysarg
-               printf "#define munge_d  NULL \n" > sysarg
-               printf "#define munge_dd  NULL \n" > sysarg
-               printf "#define munge_ddd  NULL \n" > sysarg
-               printf "#define munge_dddd  NULL \n" > sysarg
-               printf "#define munge_ddddd  NULL \n" > sysarg
-               printf "#define munge_dddddd  NULL \n" > sysarg
-               printf "#define munge_ddddddd  NULL \n" > sysarg
-               printf "#define munge_dddddddd  NULL \n" > sysarg
-               printf "#endif // __ppc__\n" > sysarg
-               printf "#endif /* !__MUNGE_ONCE */\n" > sysarg
+               printf "#include <sys/munge.h>\n" > sysarg
                
                printf "\n" > sysarg
 
                
                printf "\n" > sysarg
 
@@ -286,6 +243,19 @@ s/\$//g
                printf "#include <bsm/audit_kevents.h>\n\n" > audittempfile
                printf "#if CONFIG_AUDIT\n\n" > audittempfile
                printf "au_event_t sys_au_event[] = {\n" > audittempfile
                printf "#include <bsm/audit_kevents.h>\n\n" > audittempfile
                printf "#if CONFIG_AUDIT\n\n" > audittempfile
                printf "au_event_t sys_au_event[] = {\n" > audittempfile
+
+               printf "/*\n * System call argument to DTrace register array conversion.\n */\n" > systraceargstempfile
+               printf "#include <sys/systrace_args.h>\n" > systraceargstempfile
+               printf "void\nsystrace_args(int sysnum, void *params, uint64_t *uarg)\n{\n" > systraceargstempfile
+               printf "\tint64_t *iarg  = (int64_t *) uarg;\n" > systraceargstempfile
+               printf "\tswitch (sysnum) {\n" > systraceargstempfile
+
+               printf "void\nsystrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)\n{\n\tconst char *p = NULL;\n" > systraceargdesctempfile
+               printf "\tswitch (sysnum) {\n" > systraceargdesctempfile
+
+               printf "void\nsystrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)\n{\n\tconst char *p = NULL;\n" > systracerettempfile
+               printf "\tswitch (sysnum) {\n" > systracerettempfile
+
                next
        }
        NF == 0 || $1 ~ /^;/ {
                next
        }
        NF == 0 || $1 ~ /^;/ {
@@ -301,6 +271,9 @@ s/\$//g
                print > syscallnamestempfile
                print > sysprotoend
                print > audittempfile
                print > syscallnamestempfile
                print > sysprotoend
                print > audittempfile
+               print > systraceargstempfile
+               print > systraceargdesctempfile
+               print > systracerettempfile
                savesyscall = syscall_num
                skip_for_header = 0
                next
                savesyscall = syscall_num
                skip_for_header = 0
                next
@@ -311,6 +284,9 @@ s/\$//g
                print > syscallnamestempfile
                print > sysprotoend
                print > audittempfile
                print > syscallnamestempfile
                print > sysprotoend
                print > audittempfile
+               print > systraceargstempfile
+               print > systraceargdesctempfile
+               print > systracerettempfile
                syscall_num = savesyscall
                skip_for_header = 1
                next
                syscall_num = savesyscall
                skip_for_header = 1
                next
@@ -321,6 +297,9 @@ s/\$//g
                print > syscallnamestempfile
                print > sysprotoend
                print > audittempfile
                print > syscallnamestempfile
                print > sysprotoend
                print > audittempfile
+               print > systraceargstempfile
+               print > systraceargdesctempfile
+               print > systracerettempfile
                skip_for_header = 0
                next
        }
                skip_for_header = 0
                next
        }
@@ -354,6 +333,7 @@ s/\$//g
                argc = 0
                argssize = "0"
                additional_comments = " "
                argc = 0
                argssize = "0"
                additional_comments = " "
+               obs_comments = "_"
 
                # find start and end of call name and arguments
                if ($current_field != "{")
 
                # find start and end of call name and arguments
                if ($current_field != "{")
@@ -411,9 +391,15 @@ s/\$//g
                        current_field = comments_start + 1
                        while (current_field < comments_end) {
                                additional_comments = additional_comments $current_field " "
                        current_field = comments_start + 1
                        while (current_field < comments_end) {
                                additional_comments = additional_comments $current_field " "
+                               obs_comments = obs_comments $current_field "_"
                                current_field++
                        }
                }
                                current_field++
                        }
                }
+               sub(/old/, "obs", obs_comments)
+               obs_comments = substr(obs_comments, 1, length(obs_comments)-1)
+               if (obs_comments == "_") {
+                       obs_comments = ""
+               }
 
                # get function return type
                current_field = args_start + 1
 
                # get function return type
                current_field = args_start + 1
@@ -423,6 +409,9 @@ s/\$//g
                current_field++
                funcname = $current_field
                argalias = funcname "_args"
                current_field++
                funcname = $current_field
                argalias = funcname "_args"
+               if (substr(argalias, 1, 4) == "sys_") {
+                       argalias = substr(argalias, 5)
+               }
                current_field++ # bump past function name
 
                if ($current_field != "(")
                current_field++ # bump past function name
 
                if ($current_field != "(")
@@ -472,13 +461,9 @@ s/\$//g
                add_sysnames_entry = 1
                add_sysheader_entry = 1
                add_sysproto_entry = 1
                add_sysnames_entry = 1
                add_sysheader_entry = 1
                add_sysproto_entry = 1
-               add_64bit_unsafe = 0
-               add_64bit_fakesafe = 0
-               add_resv = "0"
-               my_flags = "0"
 
 
 
 
-               if ($3 != "ALL" && $3 != "UALL") {
+               if ($3 != "ALL") {
                        files_keyword_OK = 0
                        add_sysent_entry = 0
                        add_sysnames_entry = 0
                        files_keyword_OK = 0
                        add_sysent_entry = 0
                        add_sysnames_entry = 0
@@ -501,21 +486,12 @@ s/\$//g
                                add_sysproto_entry = 1
                                files_keyword_OK = 1
                        }
                                add_sysproto_entry = 1
                                files_keyword_OK = 1
                        }
-                       if (match($3, "[U]") != 0) {
-                               add_64bit_unsafe = 1
-                       }
-                       if (match($3, "[F]") != 0) {
-                               add_64bit_fakesafe = 1
-                       }
                        
                        if (files_keyword_OK == 0) {
                                printf "%s: line %d: unrecognized keyword %s\n", infile, NR, $2
                                exit 1
                        }
                }
                        
                        if (files_keyword_OK == 0) {
                                printf "%s: line %d: unrecognized keyword %s\n", infile, NR, $2
                                exit 1
                        }
                }
-               else if ($3 == "UALL") {
-                       add_64bit_unsafe = 1;
-               }
                
                
                parseline()
                
                
                parseline()
@@ -523,67 +499,87 @@ s/\$//g
                # output function argument structures to sysproto.h and build the
                # name of the appropriate argument mungers
                munge32 = "NULL"
                # output function argument structures to sysproto.h and build the
                # name of the appropriate argument mungers
                munge32 = "NULL"
-               munge64 = "NULL"
                size32 = 0
 
                if ((funcname != "nosys" && funcname != "enosys") || (syscall_num == 0 && funcname == "nosys")) {
                size32 = 0
 
                if ((funcname != "nosys" && funcname != "enosys") || (syscall_num == 0 && funcname == "nosys")) {
+                       printf("\t/* %s */\n\tcase %d: {\n", funcname, syscall_num) > systraceargstempfile
+                       printf("\t/* %s */\n\tcase %d:\n", funcname, syscall_num) > systraceargdesctempfile
+                       printf("\t/* %s */\n\tcase %d:\n", funcname, syscall_num) > systracerettempfile
+                       if (argc > 0) {
+                               printf("\t\tswitch(ndx) {\n") > systraceargdesctempfile
+                               printf("\t\tstruct %s *p = params;\n", argalias) > systraceargstempfile
+                               for (i = 1; i <= argc; i++) {
+                                       arg = argtype[i]
+                                       sub("__restrict$", "", arg)
+                                       if (index(arg, "*") > 0)
+                                               printf("\t\tcase %d:\n\t\t\tp = \"userland %s\";\n\t\t\tbreak;\n", i - 1, arg) > systraceargdesctempfile
+                                       else
+                                               printf("\t\tcase %d:\n\t\t\tp = \"%s\";\n\t\t\tbreak;\n", i - 1, arg) > systraceargdesctempfile
+                                       if (index(arg, "*") > 0 || arg == "caddr_t")
+                                               printf("\t\tuarg[%d] = (intptr_t) p->%s; /* %s */\n", \
+                                                       i - 1, \
+                                                       argname[i], arg) > systraceargstempfile
+                                       else if (substr(arg, 1, 1) == "u" || arg == "size_t")
+                                               printf("\t\tuarg[%d] = p->%s; /* %s */\n", \
+                                                       i - 1, \
+                                                       argname[i], arg) > systraceargstempfile
+                                       else
+                                               printf("\t\tiarg[%d] = p->%s; /* %s */\n", \
+                                                       i - 1, \
+                                                       argname[i], arg) > systraceargstempfile
+                               }
+                               printf("\t\tdefault:\n\t\t\tbreak;\n\t\t};\n") > systraceargdesctempfile
+
+                       }
+                       printf("\t\tbreak;\n\t}\n", argc) > systraceargstempfile
+                       printf("\t\tif (ndx == 0 || ndx == 1)\n") > systracerettempfile
+                       printf("\t\t\tp = \"%s\";\n", returntype) > systracerettempfile
+                       printf("\t\tbreak;\n") > systracerettempfile
+                       printf("\t\tbreak;\n") > systraceargdesctempfile
                        if (argc != 0) {
                                if (add_sysproto_entry == 1) {
                                        printf("struct %s {\n", argalias) > sysarg
                                }
                                munge32 = "munge_"
                        if (argc != 0) {
                                if (add_sysproto_entry == 1) {
                                        printf("struct %s {\n", argalias) > sysarg
                                }
                                munge32 = "munge_"
-                               munge64 = "munge_"
                                for (i = 1; i <= argc; i++) {
                                        # Build name of argument munger.
                                        # We account for all sys call argument types here.
                                        # This is where you add any new types.  With LP64 support
                                        # each argument consumes 64-bits.  
                                for (i = 1; i <= argc; i++) {
                                        # Build name of argument munger.
                                        # We account for all sys call argument types here.
                                        # This is where you add any new types.  With LP64 support
                                        # each argument consumes 64-bits.  
-                                       # see .../xnu/bsd/dev/ppc/munge.s for munge argument types.
+                                       # see .../xnu/bsd/dev/munge.c for munge argument types.
                                        if (argtype[i] == "long") {
                                        if (argtype[i] == "long") {
-                                               if (add_64bit_unsafe == 0)
-                                                       ext_argtype[i] = "user_long_t";
+                                               ext_argtype[i] = "user_long_t";
                                                munge32 = munge32 "s"
                                                munge32 = munge32 "s"
-                                               munge64 = munge64 "d"
                                                size32 += 4
                                        }
                                        else if (argtype[i] == "u_long") {
                                                size32 += 4
                                        }
                                        else if (argtype[i] == "u_long") {
-                                               if (add_64bit_unsafe == 0)
-                                                       ext_argtype[i] = "user_ulong_t";
+                                               ext_argtype[i] = "user_ulong_t";
                                                munge32 = munge32 "w"
                                                munge32 = munge32 "w"
-                                               munge64 = munge64 "d"
                                                size32 += 4
                                        }
                                        else if (argtype[i] == "size_t") {
                                                size32 += 4
                                        }
                                        else if (argtype[i] == "size_t") {
-                                               if (add_64bit_unsafe == 0)
-                                                       ext_argtype[i] = "user_size_t";
+                                               ext_argtype[i] = "user_size_t";
                                                munge32 = munge32 "w"
                                                munge32 = munge32 "w"
-                                               munge64 = munge64 "d"
                                                size32 += 4
                                        }
                                        else if (argtype[i] == "ssize_t") {
                                                size32 += 4
                                        }
                                        else if (argtype[i] == "ssize_t") {
-                                               if (add_64bit_unsafe == 0)
-                                                       ext_argtype[i] = "user_ssize_t";
+                                               ext_argtype[i] = "user_ssize_t";
                                                munge32 = munge32 "s"
                                                munge32 = munge32 "s"
-                                               munge64 = munge64 "d"
                                                size32 += 4
                                        }
                                        else if (argtype[i] == "user_ssize_t" || argtype[i] == "user_long_t") {
                                                munge32 = munge32 "s"
                                                size32 += 4
                                        }
                                        else if (argtype[i] == "user_ssize_t" || argtype[i] == "user_long_t") {
                                                munge32 = munge32 "s"
-                                               munge64 = munge64 "d"
                                                size32 += 4
                                        }
                                        else if (argtype[i] == "user_addr_t" || argtype[i] == "user_size_t" ||
                                                argtype[i] == "user_ulong_t") {
                                                munge32 = munge32 "w"
                                                size32 += 4
                                        }
                                        else if (argtype[i] == "user_addr_t" || argtype[i] == "user_size_t" ||
                                                argtype[i] == "user_ulong_t") {
                                                munge32 = munge32 "w"
-                                               munge64 = munge64 "d"
                                                size32 += 4
                                        }
                                        else if (argtype[i] == "caddr_t" || argtype[i] == "semun_t" ||
                                                size32 += 4
                                        }
                                        else if (argtype[i] == "caddr_t" || argtype[i] == "semun_t" ||
-                                               match(argtype[i], "[\*]") != 0) {
-                                               if (add_64bit_unsafe == 0)
-                                                       ext_argtype[i] = "user_addr_t";
+                                               argtype[i] == "uuid_t" || match(argtype[i], "[\*]") != 0) {
+                                               ext_argtype[i] = "user_addr_t";
                                                munge32 = munge32 "w"
                                                munge32 = munge32 "w"
-                                               munge64 = munge64 "d"
                                                size32 += 4
                                        }
                                        else if (argtype[i] == "int" || argtype[i] == "u_int" ||
                                                size32 += 4
                                        }
                                        else if (argtype[i] == "int" || argtype[i] == "u_int" ||
@@ -592,14 +588,13 @@ s/\$//g
                                                         argtype[i] == "socklen_t" || argtype[i] == "uint32_t" || argtype[i] == "int32_t" ||
                                                         argtype[i] == "sigset_t" || argtype[i] == "gid_t" || argtype[i] == "unsigned int" ||
                                                         argtype[i] == "mode_t" || argtype[i] == "key_t" ||
                                                         argtype[i] == "socklen_t" || argtype[i] == "uint32_t" || argtype[i] == "int32_t" ||
                                                         argtype[i] == "sigset_t" || argtype[i] == "gid_t" || argtype[i] == "unsigned int" ||
                                                         argtype[i] == "mode_t" || argtype[i] == "key_t" ||
-                                                        argtype[i] == "mach_port_name_t") {
+                                                        argtype[i] == "mach_port_name_t" || argtype[i] == "au_asid_t" ||
+                                                        argtype[i] == "sae_associd_t" || argtype[i] == "sae_connid_t") {
                                                munge32 = munge32 "w"
                                                munge32 = munge32 "w"
-                                               munge64 = munge64 "d"
                                                size32 += 4
                                        }
                                        else if (argtype[i] == "off_t" || argtype[i] == "int64_t" || argtype[i] == "uint64_t") {
                                                munge32 = munge32 "l"
                                                size32 += 4
                                        }
                                        else if (argtype[i] == "off_t" || argtype[i] == "int64_t" || argtype[i] == "uint64_t") {
                                                munge32 = munge32 "l"
-                                               munge64 = munge64 "d"
                                                size32 += 8
                                        }
                                        else {
                                                size32 += 8
                                        }
                                        else {
@@ -631,7 +626,6 @@ s/\$//g
                if (add_sysent_entry == 0) {
                        argssize = "0"
                        munge32 = "NULL"
                if (add_sysent_entry == 0) {
                        argssize = "0"
                        munge32 = "NULL"
-                       munge64 = "NULL"
                        munge_ret = "_SYSCALL_RET_NONE"
                        if (tempname != "enosys") {
                                tempname = "nosys"
                        munge_ret = "_SYSCALL_RET_NONE"
                        if (tempname != "enosys") {
                                tempname = "nosys"
@@ -675,19 +669,24 @@ s/\$//g
                        }
                }
 
                        }
                }
 
-               if (add_64bit_unsafe == 1  && add_64bit_fakesafe == 0)
-                       my_flags = "UNSAFE_64BIT";
-
-               printf("\t{%s, %s, %s, \(sy_call_t *\)%s, %s, %s, %s, %s},", 
-                               argssize, add_resv, my_flags, tempname, munge32, munge64, munge_ret, size32) > sysent
-               linesize = length(argssize) + length(add_resv) + length(my_flags) + length(tempname) + \
-                               length(munge32) + length(munge64) + length(munge_ret) + 28
+               printf("#if CONFIG_REQUIRES_U32_MUNGING || (__arm__ && (__BIGGEST_ALIGNMENT__ > 4))\n") > sysent
+               printf("\t{ \(sy_call_t *\)%s, %s, %s, %s, %s},", 
+                               tempname, munge32, munge_ret, argssize, size32) > sysent
+               linesize = length(tempname) + length(munge32) + \
+                       length(munge_ret) + length(argssize) + length(size32) + 28
                align_comment(linesize, 88, sysent)
                printf("/* %d = %s%s*/\n", syscall_num, funcname, additional_comments) > sysent
                align_comment(linesize, 88, sysent)
                printf("/* %d = %s%s*/\n", syscall_num, funcname, additional_comments) > sysent
+               printf("#else\n") > sysent
+               printf("\t{ \(sy_call_t *\)%s, %s, %s, %s},\n", 
+                               tempname, munge_ret, argssize, size32) > sysent
+               printf("#endif\n") > sysent
                
                # output to syscalls.c
                if (add_sysnames_entry == 1) {
                        tempname = funcname
                
                # output to syscalls.c
                if (add_sysnames_entry == 1) {
                        tempname = funcname
+                       if (substr(tempname, 1, 4) == "sys_") {
+                               tempname = substr(tempname, 5)
+                       }
                        if (funcname == "nosys" || funcname == "enosys") {
                                if (syscall_num == 0)
                                        tempname = "syscall"
                        if (funcname == "nosys" || funcname == "enosys") {
                                if (syscall_num == 0)
                                        tempname = "syscall"
@@ -708,6 +707,9 @@ s/\$//g
                # output to syscalls.h
                if (add_sysheader_entry == 1) {
                        tempname = funcname
                # output to syscalls.h
                if (add_sysheader_entry == 1) {
                        tempname = funcname
+                       if (substr(tempname, 1, 4) == "sys_") {
+                               tempname = substr(tempname, 5)
+                       }
                        if (syscall_num == 0) {
                                tempname = "syscall"
                        }
                        if (syscall_num == 0) {
                                tempname = "syscall"
                        }
@@ -716,13 +718,6 @@ s/\$//g
                                linesize = length(syscallprefix) + length(tempname) + 12
                                align_comment(linesize, 30, syshdrtempfile)
                                printf("%d\n", syscall_num) > syshdrtempfile
                                linesize = length(syscallprefix) + length(tempname) + 12
                                align_comment(linesize, 30, syshdrtempfile)
                                printf("%d\n", syscall_num) > syshdrtempfile
-                               # special case for gettimeofday on ppc - cctools project uses old name
-                               if (tempname == "ppc_gettimeofday") {
-                                       printf("#define\t%s%s", syscallprefix, "gettimeofday") > syshdrtempfile
-                                       linesize = length(syscallprefix) + length(tempname) + 12
-                                       align_comment(linesize, 30, syshdrtempfile)
-                                       printf("%d\n", syscall_num) > syshdrtempfile
-                               }
                        }
                        else if (skip_for_header == 0) {
                                printf("\t\t\t/* %d %s*/\n", syscall_num, additional_comments) > syshdrtempfile
                        }
                        else if (skip_for_header == 0) {
                                printf("\t\t\t/* %d %s*/\n", syscall_num, additional_comments) > syshdrtempfile
@@ -744,7 +739,21 @@ s/\$//g
                # output to audit_kevents.c
                printf("\t%s,\t\t", auditev) > audittempfile
                printf("/* %d = %s%s*/\n", syscall_num, tempname, additional_comments) > audittempfile 
                # output to audit_kevents.c
                printf("\t%s,\t\t", auditev) > audittempfile
                printf("/* %d = %s%s*/\n", syscall_num, tempname, additional_comments) > audittempfile 
-               
+
+               tempname = funcname
+               if (skip_for_header == 0) {
+                       if (tempname == "nosys" || tempname == "enosys") {
+                               if (obs_comments == "") {
+                                       printf("0x40c%04x\tBSC_#%d%s\n", (syscall_num*4), syscall_num, obs_comments) > tracecodetempfile 
+                               } else {
+                                       printf("0x40c%04x\tBSC%s\n", (syscall_num*4), obs_comments) > tracecodetempfile 
+                               }
+                       } else {        
+                               sub(/^_+/, "", tempname)
+                               printf("0x40c%04x\tBSC_%s\n", (syscall_num*4), tempname) > tracecodetempfile 
+                       }
+               }
+
                syscall_num++
                next
        }
                syscall_num++
                next
        }
@@ -762,17 +771,21 @@ s/\$//g
                printf("\n#endif /* !%s */\n", sysproto_h) > sysprotoend
 
                printf("};\n") > sysent
                printf("\n#endif /* !%s */\n", sysproto_h) > sysprotoend
 
                printf("};\n") > sysent
-               printf("int     nsysent = sizeof(sysent) / sizeof(sysent[0]);\n") > sysent
-               printf("/* Verify that NUM_SYSENT reflects the latest syscall count */\n") > sysent
-               printf("int     nsysent_size_check[((sizeof(sysent) / sizeof(sysent[0])) == NUM_SYSENT) ? 1 : -1] __unused;\n") > sysent
+               printf("const unsigned int      nsysent = sizeof(sysent) / sizeof(sysent[0]);\n") > sysent
 
                printf("};\n") > syscallnamestempfile
                printf("#define\t%sMAXSYSCALL\t%d\n", syscallprefix, syscall_num) \
                    > syshdrtempfile
 
                printf("};\n") > syscallnamestempfile
                printf("#define\t%sMAXSYSCALL\t%d\n", syscallprefix, syscall_num) \
                    > syshdrtempfile
+               printf("#define\t%sinvalid\t%d\n", syscallprefix, 63) \
+                   > syshdrtempfile
                printf("\n#endif /* __APPLE_API_PRIVATE */\n") > syshdrtempfile
                printf("#endif /* !%s */\n", syscall_h) > syshdrtempfile
                printf("};\n\n") > audittempfile
                printf("#endif /* AUDIT */\n") > audittempfile
                printf("\n#endif /* __APPLE_API_PRIVATE */\n") > syshdrtempfile
                printf("#endif /* !%s */\n", syscall_h) > syshdrtempfile
                printf("};\n\n") > audittempfile
                printf("#endif /* AUDIT */\n") > audittempfile
+
+               printf "\tdefault:\n\t\tbreak;\n\t};\n}\n" > systraceargstempfile
+               printf "\tdefault:\n\t\tbreak;\n\t};\n\tif (p != NULL)\n\t\tstrlcpy(desc, p, descsz);\n}\n" > systraceargdesctempfile
+               printf "\tdefault:\n\t\tbreak;\n\t};\n\tif (p != NULL)\n\t\tstrlcpy(desc, p, descsz);\n}\n" > systracerettempfile
        } '
 
 # define value in syscall table file to permit redifintion because of the way
        } '
 
 # define value in syscall table file to permit redifintion because of the way
@@ -798,3 +811,18 @@ fi
 if [ $output_auditevfile -eq 1 ]; then
     cat $syslegal $audittempfile > $auditevfile
 fi
 if [ $output_auditevfile -eq 1 ]; then
     cat $syslegal $audittempfile > $auditevfile
 fi
+
+if [ $output_systrace -eq 1 ]; then
+       cat $systraceargstempfile > $systraceargsfile
+       cat $systraceargdesctempfile >> $systraceargsfile
+       cat $systracerettempfile >> $systraceargsfile
+fi
+
+if [ $output_tracecodes -eq 1 ]; then
+       if [ $use_stdout -eq 1 ]; then
+               cat $tracecodetempfile
+       else
+               cat $tracecodetempfile > $tracecodename
+       fi
+fi
+