1*bbb1b6f9SApple OSS Distributions#!/usr/bin/env recon 2*bbb1b6f9SApple OSS Distributions 3*bbb1b6f9SApple OSS Distributionslocal cjson = require 'cjson' 4*bbb1b6f9SApple OSS Distributionslocal lpeg = require 'lpeg' 5*bbb1b6f9SApple OSS Distributionslpeg.locale(lpeg) 6*bbb1b6f9SApple OSS Distributions 7*bbb1b6f9SApple OSS Distributions-- Only certain regions of the master file should be parsed. 8*bbb1b6f9SApple OSS Distributions-- The convention is that any `#if/#else/#endif` clauses are parsed, assuming the condition is true/defined, except for `COMPAT_GETFSSTAT`. 9*bbb1b6f9SApple OSS Distributions 10*bbb1b6f9SApple OSS Distributionslocal region_state = { valid = true, } 11*bbb1b6f9SApple OSS Distributionslocal function in_valid_region(line) 12*bbb1b6f9SApple OSS Distributions -- Only C preprocessor directives can affect the region's validity. 13*bbb1b6f9SApple OSS Distributions if line:sub(1, 1) ~= '#' then 14*bbb1b6f9SApple OSS Distributions return region_state.valid 15*bbb1b6f9SApple OSS Distributions end 16*bbb1b6f9SApple OSS Distributions 17*bbb1b6f9SApple OSS Distributions -- This is the only macro definition that is assumed to be undefined. 18*bbb1b6f9SApple OSS Distributions local assume_defined = not line:match('COMPAT_GETFSSTAT') 19*bbb1b6f9SApple OSS Distributions if line:match('^#if') then 20*bbb1b6f9SApple OSS Distributions region_state.valid = assume_defined 21*bbb1b6f9SApple OSS Distributions elseif line:match('^#else') then 22*bbb1b6f9SApple OSS Distributions region_state.valid = not region_state.valid 23*bbb1b6f9SApple OSS Distributions elseif line:match('^#endif') then 24*bbb1b6f9SApple OSS Distributions region_state.valid = true 25*bbb1b6f9SApple OSS Distributions end 26*bbb1b6f9SApple OSS Distributionsend 27*bbb1b6f9SApple OSS Distributions 28*bbb1b6f9SApple OSS Distributions-- Parse a syscall declaration line from `bsd/kern/syscalls.master` into a table with `name`, `number`, `arguments`, and `old` keys. 29*bbb1b6f9SApple OSS Distributions 30*bbb1b6f9SApple OSS Distributions-- Primitive tokens. 31*bbb1b6f9SApple OSS Distributionslocal space = lpeg.S(' \t')^0 32*bbb1b6f9SApple OSS Distributionslocal identifier = (lpeg.alnum + lpeg.P('_'))^1 33*bbb1b6f9SApple OSS Distributionslocal numeric = lpeg.digit^1 / tonumber 34*bbb1b6f9SApple OSS Distributions 35*bbb1b6f9SApple OSS Distributions-- Matching the function name of the syscall declaration. 36*bbb1b6f9SApple OSS Distributionslocal function_ptn = lpeg.Cg(identifier^1, 'name') * lpeg.P('(') 37*bbb1b6f9SApple OSS Distributionslocal nosys_ptn = lpeg.P('e')^-1 * lpeg.P('nosys(') 38*bbb1b6f9SApple OSS Distributions 39*bbb1b6f9SApple OSS Distributions-- Matching an argument list. 40*bbb1b6f9SApple OSS Distributionslocal arg = lpeg.C((1 - lpeg.S(',)'))^1) 41*bbb1b6f9SApple OSS Distributionslocal args_ptn = lpeg.Ct(arg * (lpeg.P(',') * space * arg)^0) 42*bbb1b6f9SApple OSS Distributions 43*bbb1b6f9SApple OSS Distributions-- Matching a normal C-style declaration of the syscall. 44*bbb1b6f9SApple OSS Distributionslocal decl_ptn = (1 - function_ptn)^1 * (function_ptn - nosys_ptn) * 45*bbb1b6f9SApple OSS Distributions lpeg.Cg(args_ptn, 'arguments') 46*bbb1b6f9SApple OSS Distributions 47*bbb1b6f9SApple OSS Distributions-- Matching an old breadcrumb, with empty arguments table. 48*bbb1b6f9SApple OSS Distributionslocal old_ptn = lpeg.P('old') * space * lpeg.Cg(identifier^1, 'name') * 49*bbb1b6f9SApple OSS Distributions lpeg.Cg(lpeg.Cc(true), 'old') * lpeg.Cg(lpeg.Cc({}), 'arguments') 50*bbb1b6f9SApple OSS Distributionslocal old_decl_ptn = (1 - old_ptn)^1 * old_ptn 51*bbb1b6f9SApple OSS Distributions 52*bbb1b6f9SApple OSS Distributionslocal syscall_ptn = lpeg.Ct(lpeg.Cg(numeric, 'number') * 53*bbb1b6f9SApple OSS Distributions (decl_ptn + old_decl_ptn)) 54*bbb1b6f9SApple OSS Distributions 55*bbb1b6f9SApple OSS Distributionslocal bsd_syscalls = {} 56*bbb1b6f9SApple OSS Distributionsfor line in io.stdin:lines() do 57*bbb1b6f9SApple OSS Distributions if in_valid_region(line) then 58*bbb1b6f9SApple OSS Distributions bsd_syscalls[#bsd_syscalls + 1] = syscall_ptn:match(line) 59*bbb1b6f9SApple OSS Distributions end 60*bbb1b6f9SApple OSS Distributionsend 61*bbb1b6f9SApple OSS Distributions 62*bbb1b6f9SApple OSS Distributionslocal syscalls = { 63*bbb1b6f9SApple OSS Distributions bsd_syscalls = bsd_syscalls, 64*bbb1b6f9SApple OSS Distributions mach_syscalls = { 65*bbb1b6f9SApple OSS Distributions -- Duplicate the names from `mach_trap_table` here. 66*bbb1b6f9SApple OSS Distributions { number = 10, name = 'mach_vm_allocate', 67*bbb1b6f9SApple OSS Distributions arguments = { 68*bbb1b6f9SApple OSS Distributions 'mach_port_name_t target', 69*bbb1b6f9SApple OSS Distributions 'mach_vm_address_t *address', 70*bbb1b6f9SApple OSS Distributions 'mach_vm_size_t size', 71*bbb1b6f9SApple OSS Distributions 'int flags', 72*bbb1b6f9SApple OSS Distributions }, 73*bbb1b6f9SApple OSS Distributions }, 74*bbb1b6f9SApple OSS Distributions { number = 11, name = 'mach_vm_purgable_control', 75*bbb1b6f9SApple OSS Distributions arguments = { 76*bbb1b6f9SApple OSS Distributions 'mach_port_name_t target', 77*bbb1b6f9SApple OSS Distributions 'mach_vm_offset_t address', 78*bbb1b6f9SApple OSS Distributions 'vm_purgable_t control', 79*bbb1b6f9SApple OSS Distributions 'int *state', 80*bbb1b6f9SApple OSS Distributions }, 81*bbb1b6f9SApple OSS Distributions }, 82*bbb1b6f9SApple OSS Distributions { number = 12, name = 'mach_vm_deallocate', 83*bbb1b6f9SApple OSS Distributions arguments = { 84*bbb1b6f9SApple OSS Distributions 'mach_port_name_t target', 85*bbb1b6f9SApple OSS Distributions 'mach_vm_address_t address', 86*bbb1b6f9SApple OSS Distributions 'mach_vm_size_t size', 87*bbb1b6f9SApple OSS Distributions }, 88*bbb1b6f9SApple OSS Distributions }, 89*bbb1b6f9SApple OSS Distributions { number = 13, name = 'task_dyld_process_info_notify_get', 90*bbb1b6f9SApple OSS Distributions arguments = { 91*bbb1b6f9SApple OSS Distributions 'mach_port_name_array_t names_addr', 92*bbb1b6f9SApple OSS Distributions 'natural_t *names_count_addr', 93*bbb1b6f9SApple OSS Distributions }, 94*bbb1b6f9SApple OSS Distributions }, 95*bbb1b6f9SApple OSS Distributions { number = 14, name = 'mach_vm_protect', 96*bbb1b6f9SApple OSS Distributions arguments = { 97*bbb1b6f9SApple OSS Distributions 'mach_port_name_t task', 98*bbb1b6f9SApple OSS Distributions 'mach_vm_address_t address', 99*bbb1b6f9SApple OSS Distributions 'mach_vm_size_t size', 100*bbb1b6f9SApple OSS Distributions 'boolean_t set_maximum', 101*bbb1b6f9SApple OSS Distributions 'vm_prot_t new_protection', 102*bbb1b6f9SApple OSS Distributions } 103*bbb1b6f9SApple OSS Distributions }, 104*bbb1b6f9SApple OSS Distributions { number = 15, name = 'mach_vm_map', 105*bbb1b6f9SApple OSS Distributions arguments = { 106*bbb1b6f9SApple OSS Distributions 'mach_port_name_t target', 107*bbb1b6f9SApple OSS Distributions 'mach_vm_address_t *address', 108*bbb1b6f9SApple OSS Distributions 'mach_vm_size_t size', 109*bbb1b6f9SApple OSS Distributions 'mach_vm_offset_t mask', 110*bbb1b6f9SApple OSS Distributions 'int flags', 111*bbb1b6f9SApple OSS Distributions 'mem_entry_name_port_t object', 112*bbb1b6f9SApple OSS Distributions 'memory_object_offset_t offset', 113*bbb1b6f9SApple OSS Distributions 'boolean_t copy', 114*bbb1b6f9SApple OSS Distributions 'vm_prot_t cur_protection', 115*bbb1b6f9SApple OSS Distributions 'vm_prot_t max_protection', 116*bbb1b6f9SApple OSS Distributions 'vm_inherit_t inheritance', 117*bbb1b6f9SApple OSS Distributions }, 118*bbb1b6f9SApple OSS Distributions }, 119*bbb1b6f9SApple OSS Distributions { number = 16, name = 'mach_port_allocate', 120*bbb1b6f9SApple OSS Distributions arguments = { 121*bbb1b6f9SApple OSS Distributions 'mach_port_name_t target', 122*bbb1b6f9SApple OSS Distributions 'mach_port_right_t right', 123*bbb1b6f9SApple OSS Distributions 'mach_port_name_t *name', 124*bbb1b6f9SApple OSS Distributions }, 125*bbb1b6f9SApple OSS Distributions }, 126*bbb1b6f9SApple OSS Distributions 127*bbb1b6f9SApple OSS Distributions { number = 18, name = 'mach_port_deallocate', 128*bbb1b6f9SApple OSS Distributions arguments = { 129*bbb1b6f9SApple OSS Distributions 'mach_port_name_t target', 130*bbb1b6f9SApple OSS Distributions 'mach_port_name_t name', 131*bbb1b6f9SApple OSS Distributions }, 132*bbb1b6f9SApple OSS Distributions }, 133*bbb1b6f9SApple OSS Distributions { number = 19, name = 'mach_port_mod_refs', 134*bbb1b6f9SApple OSS Distributions arguments = { 135*bbb1b6f9SApple OSS Distributions 'mach_port_name_t target', 136*bbb1b6f9SApple OSS Distributions 'mach_port_name_t name', 137*bbb1b6f9SApple OSS Distributions 'mach_port_right_t right', 138*bbb1b6f9SApple OSS Distributions 'mach_port_delta_t delta', 139*bbb1b6f9SApple OSS Distributions }, 140*bbb1b6f9SApple OSS Distributions }, 141*bbb1b6f9SApple OSS Distributions { number = 20, name = 'mach_port_move_member', 142*bbb1b6f9SApple OSS Distributions arguments = { 143*bbb1b6f9SApple OSS Distributions 'mach_port_name_t target', 144*bbb1b6f9SApple OSS Distributions 'mach_port_name_t member', 145*bbb1b6f9SApple OSS Distributions 'mach_port_name_t after', 146*bbb1b6f9SApple OSS Distributions }, 147*bbb1b6f9SApple OSS Distributions }, 148*bbb1b6f9SApple OSS Distributions { number = 21, name = 'mach_port_insert_right', 149*bbb1b6f9SApple OSS Distributions arguments = { 150*bbb1b6f9SApple OSS Distributions 'mach_port_name_t target', 151*bbb1b6f9SApple OSS Distributions 'mach_port_name_t name', 152*bbb1b6f9SApple OSS Distributions 'mach_port_name_t poly', 153*bbb1b6f9SApple OSS Distributions 'mach_msg_type_name_t polyPoly', 154*bbb1b6f9SApple OSS Distributions }, 155*bbb1b6f9SApple OSS Distributions }, 156*bbb1b6f9SApple OSS Distributions { number = 22, name = 'mach_port_insert_member', 157*bbb1b6f9SApple OSS Distributions arguments = { 158*bbb1b6f9SApple OSS Distributions 'mach_port_name_t target', 159*bbb1b6f9SApple OSS Distributions 'mach_port_name_t name', 160*bbb1b6f9SApple OSS Distributions 'mach_port_name_t pset', 161*bbb1b6f9SApple OSS Distributions }, 162*bbb1b6f9SApple OSS Distributions }, 163*bbb1b6f9SApple OSS Distributions { number = 23, name = 'mach_port_extract_member', 164*bbb1b6f9SApple OSS Distributions arguments = { 165*bbb1b6f9SApple OSS Distributions 'mach_port_name_t target', 166*bbb1b6f9SApple OSS Distributions 'mach_port_name_t name', 167*bbb1b6f9SApple OSS Distributions 'mach_port_name_t pset', 168*bbb1b6f9SApple OSS Distributions }, 169*bbb1b6f9SApple OSS Distributions }, 170*bbb1b6f9SApple OSS Distributions { number = 24, name = 'mach_port_construct', 171*bbb1b6f9SApple OSS Distributions arguments = { 172*bbb1b6f9SApple OSS Distributions 'mach_port_name_t target', 173*bbb1b6f9SApple OSS Distributions 'mach_port_options_t *options', 174*bbb1b6f9SApple OSS Distributions 'uint64_t context', 175*bbb1b6f9SApple OSS Distributions 'mach_port_name_t *name', 176*bbb1b6f9SApple OSS Distributions }, 177*bbb1b6f9SApple OSS Distributions }, 178*bbb1b6f9SApple OSS Distributions { number = 25, name = 'mach_port_destruct', 179*bbb1b6f9SApple OSS Distributions arguments = { 180*bbb1b6f9SApple OSS Distributions 'mach_port_name_t target', 181*bbb1b6f9SApple OSS Distributions 'mach_port_name_t name', 182*bbb1b6f9SApple OSS Distributions 'mach_port_delta_t srdelta', 183*bbb1b6f9SApple OSS Distributions 'uint64_t guard', 184*bbb1b6f9SApple OSS Distributions }, 185*bbb1b6f9SApple OSS Distributions }, 186*bbb1b6f9SApple OSS Distributions { number = 26, name = 'mach_reply_port', 187*bbb1b6f9SApple OSS Distributions arguments = { 'void' }, 188*bbb1b6f9SApple OSS Distributions }, 189*bbb1b6f9SApple OSS Distributions { number = 27, name = 'thread_self', 190*bbb1b6f9SApple OSS Distributions arguments = { 'void' }, 191*bbb1b6f9SApple OSS Distributions }, 192*bbb1b6f9SApple OSS Distributions { number = 28, name = 'task_self', 193*bbb1b6f9SApple OSS Distributions arguments = { 'void' }, 194*bbb1b6f9SApple OSS Distributions }, 195*bbb1b6f9SApple OSS Distributions { number = 29, name = 'host_self', 196*bbb1b6f9SApple OSS Distributions arguments = { 'void' }, 197*bbb1b6f9SApple OSS Distributions }, 198*bbb1b6f9SApple OSS Distributions 199*bbb1b6f9SApple OSS Distributions { number = 31, name = 'mach_msg', 200*bbb1b6f9SApple OSS Distributions arguments = { 201*bbb1b6f9SApple OSS Distributions 'mach_msg_header_t *msg', 202*bbb1b6f9SApple OSS Distributions 'mach_msg_option_t option', 203*bbb1b6f9SApple OSS Distributions 'mach_msg_size_t send_size', 204*bbb1b6f9SApple OSS Distributions 'mach_msg_size_t rcv_size', 205*bbb1b6f9SApple OSS Distributions 'mach_port_name_t rcv_name', 206*bbb1b6f9SApple OSS Distributions 'mach_msg_timeout_t timeout', 207*bbb1b6f9SApple OSS Distributions 'mach_port_name_t notify', 208*bbb1b6f9SApple OSS Distributions }, 209*bbb1b6f9SApple OSS Distributions }, 210*bbb1b6f9SApple OSS Distributions { number = 32, name = 'mach_msg_overwrite', 211*bbb1b6f9SApple OSS Distributions arguments = { 212*bbb1b6f9SApple OSS Distributions 'mach_msg_header_t *msg', 213*bbb1b6f9SApple OSS Distributions 'mach_msg_option_t option', 214*bbb1b6f9SApple OSS Distributions 'mach_msg_size_t send_size', 215*bbb1b6f9SApple OSS Distributions 'mach_msg_size_t rcv_size', 216*bbb1b6f9SApple OSS Distributions 'mach_port_name_t rcv_name', 217*bbb1b6f9SApple OSS Distributions 'mach_msg_timeout_t timeout', 218*bbb1b6f9SApple OSS Distributions 'mach_port_name_t notify', 219*bbb1b6f9SApple OSS Distributions 'mach_msg_header_t *rcv_msg', 220*bbb1b6f9SApple OSS Distributions 'mach_msg_size_t rcv_limit', 221*bbb1b6f9SApple OSS Distributions }, 222*bbb1b6f9SApple OSS Distributions }, 223*bbb1b6f9SApple OSS Distributions { number = 33, name = 'semaphore_signal', 224*bbb1b6f9SApple OSS Distributions arguments = { 225*bbb1b6f9SApple OSS Distributions 'mach_port_name_t signal_name', 226*bbb1b6f9SApple OSS Distributions }, 227*bbb1b6f9SApple OSS Distributions }, 228*bbb1b6f9SApple OSS Distributions { number = 34, name = 'semaphore_signal_all', 229*bbb1b6f9SApple OSS Distributions arguments = { 230*bbb1b6f9SApple OSS Distributions 'mach_port_name_t signal_name', 231*bbb1b6f9SApple OSS Distributions }, 232*bbb1b6f9SApple OSS Distributions }, 233*bbb1b6f9SApple OSS Distributions { number = 35, name = 'semaphore_signal_thread', 234*bbb1b6f9SApple OSS Distributions arguments = { 235*bbb1b6f9SApple OSS Distributions 'mach_port_name_t signal_name', 236*bbb1b6f9SApple OSS Distributions 'mach_port_name_t thread_name', 237*bbb1b6f9SApple OSS Distributions }, 238*bbb1b6f9SApple OSS Distributions }, 239*bbb1b6f9SApple OSS Distributions { number = 36, name = 'semaphore_wait', 240*bbb1b6f9SApple OSS Distributions arguments = { 241*bbb1b6f9SApple OSS Distributions 'mach_port_name_t wait_name', 242*bbb1b6f9SApple OSS Distributions }, 243*bbb1b6f9SApple OSS Distributions }, 244*bbb1b6f9SApple OSS Distributions { number = 37, name = 'semaphore_wait_signal', 245*bbb1b6f9SApple OSS Distributions arguments = { 246*bbb1b6f9SApple OSS Distributions 'mach_port_name_t wait_name', 247*bbb1b6f9SApple OSS Distributions 'mach_port_name_t signal_name', 248*bbb1b6f9SApple OSS Distributions }, 249*bbb1b6f9SApple OSS Distributions }, 250*bbb1b6f9SApple OSS Distributions { number = 38, name = 'semaphore_timedwait', 251*bbb1b6f9SApple OSS Distributions arguments = { 252*bbb1b6f9SApple OSS Distributions 'mach_port_name_t wait_name', 253*bbb1b6f9SApple OSS Distributions 'unsigned int sec', 254*bbb1b6f9SApple OSS Distributions 'clock_res_t nsec', 255*bbb1b6f9SApple OSS Distributions }, 256*bbb1b6f9SApple OSS Distributions }, 257*bbb1b6f9SApple OSS Distributions { number = 39, name = 'semaphore_timedwait_signal', 258*bbb1b6f9SApple OSS Distributions arguments = { 259*bbb1b6f9SApple OSS Distributions 'mach_port_name_t wait_name', 260*bbb1b6f9SApple OSS Distributions 'mach_port_name_t signal_name', 261*bbb1b6f9SApple OSS Distributions 'unsigned int sec', 262*bbb1b6f9SApple OSS Distributions 'clock_res_t nsec', 263*bbb1b6f9SApple OSS Distributions }, 264*bbb1b6f9SApple OSS Distributions }, 265*bbb1b6f9SApple OSS Distributions { number = 40, name = 'mach_port_get_attributes', 266*bbb1b6f9SApple OSS Distributions arguments = { 267*bbb1b6f9SApple OSS Distributions 'mach_port_name_t target', 268*bbb1b6f9SApple OSS Distributions 'mach_port_name_t name', 269*bbb1b6f9SApple OSS Distributions 'mach_port_flavor_t flavor', 270*bbb1b6f9SApple OSS Distributions 'mach_port_info_t port_info_out', 271*bbb1b6f9SApple OSS Distributions 'mach_msg_type_number_t *port_info_outCnt', 272*bbb1b6f9SApple OSS Distributions }, 273*bbb1b6f9SApple OSS Distributions }, 274*bbb1b6f9SApple OSS Distributions { number = 41, name = 'mach_port_guard', 275*bbb1b6f9SApple OSS Distributions arguments = { 276*bbb1b6f9SApple OSS Distributions 'mach_port_name_t target', 277*bbb1b6f9SApple OSS Distributions 'mach_port_name_t name', 278*bbb1b6f9SApple OSS Distributions 'uint64_t guard', 279*bbb1b6f9SApple OSS Distributions 'boolean_t strict', 280*bbb1b6f9SApple OSS Distributions }, 281*bbb1b6f9SApple OSS Distributions }, 282*bbb1b6f9SApple OSS Distributions { number = 42, name = 'mach_port_unguard', 283*bbb1b6f9SApple OSS Distributions arguments = { 284*bbb1b6f9SApple OSS Distributions 'mach_port_name_t target', 285*bbb1b6f9SApple OSS Distributions 'mach_port_name_t name', 286*bbb1b6f9SApple OSS Distributions 'uint64_t guard', 287*bbb1b6f9SApple OSS Distributions }, 288*bbb1b6f9SApple OSS Distributions }, 289*bbb1b6f9SApple OSS Distributions { number = 43, name = 'mach_generate_activity_id', 290*bbb1b6f9SApple OSS Distributions arguments = { 291*bbb1b6f9SApple OSS Distributions 'mach_port_name_t target', 292*bbb1b6f9SApple OSS Distributions 'int count', 293*bbb1b6f9SApple OSS Distributions 'uint64_t *activity_id', 294*bbb1b6f9SApple OSS Distributions }, 295*bbb1b6f9SApple OSS Distributions }, 296*bbb1b6f9SApple OSS Distributions { number = 44, name = 'task_name_for_pid', 297*bbb1b6f9SApple OSS Distributions arguments = { 298*bbb1b6f9SApple OSS Distributions 'mach_port_name_t target_tport', 299*bbb1b6f9SApple OSS Distributions 'int pid', 300*bbb1b6f9SApple OSS Distributions 'mach_port_name_t *tn', 301*bbb1b6f9SApple OSS Distributions }, 302*bbb1b6f9SApple OSS Distributions }, 303*bbb1b6f9SApple OSS Distributions { number = 45, name = 'task_for_pid', 304*bbb1b6f9SApple OSS Distributions arguments = { 305*bbb1b6f9SApple OSS Distributions 'mach_port_name_t target_tport', 306*bbb1b6f9SApple OSS Distributions 'int pid', 307*bbb1b6f9SApple OSS Distributions 'mach_port_name_t *t', 308*bbb1b6f9SApple OSS Distributions }, 309*bbb1b6f9SApple OSS Distributions }, 310*bbb1b6f9SApple OSS Distributions { number = 46, name = 'pid_for_task', 311*bbb1b6f9SApple OSS Distributions arguments = { 312*bbb1b6f9SApple OSS Distributions 'mach_port_name_t t', 313*bbb1b6f9SApple OSS Distributions 'int *x', 314*bbb1b6f9SApple OSS Distributions }, 315*bbb1b6f9SApple OSS Distributions }, 316*bbb1b6f9SApple OSS Distributions { number = 47, name = 'mach_msg2', 317*bbb1b6f9SApple OSS Distributions arguments = { 318*bbb1b6f9SApple OSS Distributions 'void *data', 319*bbb1b6f9SApple OSS Distributions 'mach_msg_option64_t option64', 320*bbb1b6f9SApple OSS Distributions 'mach_msg_header_t header', 321*bbb1b6f9SApple OSS Distributions 'mach_msg_size_t send_size', 322*bbb1b6f9SApple OSS Distributions 'mach_msg_size_t rcv_size', 323*bbb1b6f9SApple OSS Distributions 'mach_port_t rcv_name', 324*bbb1b6f9SApple OSS Distributions 'uint64_t timeout', 325*bbb1b6f9SApple OSS Distributions 'uint32_t priority', 326*bbb1b6f9SApple OSS Distributions }, 327*bbb1b6f9SApple OSS Distributions }, 328*bbb1b6f9SApple OSS Distributions { number = 48, name = 'macx_swapon', 329*bbb1b6f9SApple OSS Distributions arguments = { 330*bbb1b6f9SApple OSS Distributions 'uint64_t filename', 331*bbb1b6f9SApple OSS Distributions 'int flags', 332*bbb1b6f9SApple OSS Distributions 'int size', 333*bbb1b6f9SApple OSS Distributions 'int priority', 334*bbb1b6f9SApple OSS Distributions }, 335*bbb1b6f9SApple OSS Distributions }, 336*bbb1b6f9SApple OSS Distributions { number = 49, name = 'macx_swapoff', 337*bbb1b6f9SApple OSS Distributions arguments = { 338*bbb1b6f9SApple OSS Distributions 'uint64_t filename', 339*bbb1b6f9SApple OSS Distributions 'int flags', 340*bbb1b6f9SApple OSS Distributions }, 341*bbb1b6f9SApple OSS Distributions }, 342*bbb1b6f9SApple OSS Distributions { number = 50, name = 'thread_get_special_reply_port', 343*bbb1b6f9SApple OSS Distributions arguments = { 'void' }, 344*bbb1b6f9SApple OSS Distributions }, 345*bbb1b6f9SApple OSS Distributions { number = 51, name = 'macx_triggers', 346*bbb1b6f9SApple OSS Distributions arguments = { 347*bbb1b6f9SApple OSS Distributions 'int hi_water', 348*bbb1b6f9SApple OSS Distributions 'int low_water', 349*bbb1b6f9SApple OSS Distributions 'int flags', 350*bbb1b6f9SApple OSS Distributions 'mach_port_t alert_port', 351*bbb1b6f9SApple OSS Distributions }, 352*bbb1b6f9SApple OSS Distributions }, 353*bbb1b6f9SApple OSS Distributions { number = 52, name = 'macx_backing_store_suspend', 354*bbb1b6f9SApple OSS Distributions arguments = { 355*bbb1b6f9SApple OSS Distributions 'boolean_t suspend', 356*bbb1b6f9SApple OSS Distributions }, 357*bbb1b6f9SApple OSS Distributions }, 358*bbb1b6f9SApple OSS Distributions { number = 53, name = 'macx_backing_store_recovery', 359*bbb1b6f9SApple OSS Distributions arguments = { 360*bbb1b6f9SApple OSS Distributions 'int pid', 361*bbb1b6f9SApple OSS Distributions }, 362*bbb1b6f9SApple OSS Distributions }, 363*bbb1b6f9SApple OSS Distributions 364*bbb1b6f9SApple OSS Distributions { number = 58, name = 'pfz_exit', 365*bbb1b6f9SApple OSS Distributions arguments = { 'void' }, 366*bbb1b6f9SApple OSS Distributions }, 367*bbb1b6f9SApple OSS Distributions { number = 59, name = 'swtch_pri', 368*bbb1b6f9SApple OSS Distributions arguments = { 369*bbb1b6f9SApple OSS Distributions 'int pri', 370*bbb1b6f9SApple OSS Distributions }, 371*bbb1b6f9SApple OSS Distributions }, 372*bbb1b6f9SApple OSS Distributions { number = 60, name = 'swtch', 373*bbb1b6f9SApple OSS Distributions arguments = { 'void' }, 374*bbb1b6f9SApple OSS Distributions }, 375*bbb1b6f9SApple OSS Distributions { number = 61, name = 'thread_switch', 376*bbb1b6f9SApple OSS Distributions arguments = { 377*bbb1b6f9SApple OSS Distributions 'mach_port_name_t thread_name', 378*bbb1b6f9SApple OSS Distributions 'int option', 379*bbb1b6f9SApple OSS Distributions 'mach_msg_timeout_t option_time', 380*bbb1b6f9SApple OSS Distributions }, 381*bbb1b6f9SApple OSS Distributions }, 382*bbb1b6f9SApple OSS Distributions { number = 62, name = 'clock_sleep', 383*bbb1b6f9SApple OSS Distributions arguments = { 384*bbb1b6f9SApple OSS Distributions 'mach_port_name_t clock_name', 385*bbb1b6f9SApple OSS Distributions 'sleep_type_t sleep_type', 386*bbb1b6f9SApple OSS Distributions 'int sleep_sec', 387*bbb1b6f9SApple OSS Distributions 'int sleep_nsec', 388*bbb1b6f9SApple OSS Distributions 'mach_timespec_t *wakeup_time', 389*bbb1b6f9SApple OSS Distributions }, 390*bbb1b6f9SApple OSS Distributions }, 391*bbb1b6f9SApple OSS Distributions { number = 63, name = 'mach_vm_reclaim_update_kernel_accounting_trap', 392*bbb1b6f9SApple OSS Distributions arguments = { 393*bbb1b6f9SApple OSS Distributions 'mach_port_name_t target', 394*bbb1b6f9SApple OSS Distributions 'uint64_t *bytes_reclaimed', 395*bbb1b6f9SApple OSS Distributions }, 396*bbb1b6f9SApple OSS Distributions }, 397*bbb1b6f9SApple OSS Distributions 398*bbb1b6f9SApple OSS Distributions { number = 70, name = 'host_create_mach_voucher', 399*bbb1b6f9SApple OSS Distributions arguments = { 400*bbb1b6f9SApple OSS Distributions 'mach_port_name_t host', 401*bbb1b6f9SApple OSS Distributions 'mach_voucher_attr_raw_recipe_array_t recipes', 402*bbb1b6f9SApple OSS Distributions 'int recipes_size', 403*bbb1b6f9SApple OSS Distributions 'mach_port_name_t *voucher', 404*bbb1b6f9SApple OSS Distributions }, 405*bbb1b6f9SApple OSS Distributions }, 406*bbb1b6f9SApple OSS Distributions 407*bbb1b6f9SApple OSS Distributions { number = 72, name = 'mach_voucher_extract_attr_recipe', 408*bbb1b6f9SApple OSS Distributions arguments = { 409*bbb1b6f9SApple OSS Distributions 'mach_port_name_t voucher_name', 410*bbb1b6f9SApple OSS Distributions 'mach_voucher_attr_key_t key', 411*bbb1b6f9SApple OSS Distributions 'mach_voucher_attr_raw_recipe_t recipe', 412*bbb1b6f9SApple OSS Distributions 'mach_msg_type_number_t *recipe_size', 413*bbb1b6f9SApple OSS Distributions }, 414*bbb1b6f9SApple OSS Distributions }, 415*bbb1b6f9SApple OSS Distributions 416*bbb1b6f9SApple OSS Distributions { number = 76, name = 'mach_port_type', 417*bbb1b6f9SApple OSS Distributions arguments = { 418*bbb1b6f9SApple OSS Distributions 'ipc_space_t task', 419*bbb1b6f9SApple OSS Distributions 'mach_port_name_t name', 420*bbb1b6f9SApple OSS Distributions 'mach_port_type_t *ptype', 421*bbb1b6f9SApple OSS Distributions }, 422*bbb1b6f9SApple OSS Distributions }, 423*bbb1b6f9SApple OSS Distributions { number = 77, name = 'mach_port_request_notification', 424*bbb1b6f9SApple OSS Distributions arguments = { 425*bbb1b6f9SApple OSS Distributions 'ipc_space_t task', 426*bbb1b6f9SApple OSS Distributions 'mach_port_name_t name', 427*bbb1b6f9SApple OSS Distributions 'mach_msg_id_t msgid', 428*bbb1b6f9SApple OSS Distributions 'mach_port_mscount_t sync', 429*bbb1b6f9SApple OSS Distributions 'mach_port_name_t notify', 430*bbb1b6f9SApple OSS Distributions 'mach_msg_type_name_t notifyPoly', 431*bbb1b6f9SApple OSS Distributions 'mach_port_name_t *previous', 432*bbb1b6f9SApple OSS Distributions }, 433*bbb1b6f9SApple OSS Distributions }, 434*bbb1b6f9SApple OSS Distributions { number = 88, name = 'exclaves_ctl', 435*bbb1b6f9SApple OSS Distributions arguments = { 436*bbb1b6f9SApple OSS Distributions 'mach_port_name_t name', 437*bbb1b6f9SApple OSS Distributions 'uint32_t operation_and_flags', 438*bbb1b6f9SApple OSS Distributions 'uint64_t identifier', 439*bbb1b6f9SApple OSS Distributions 'mach_vm_address_t buffer', 440*bbb1b6f9SApple OSS Distributions 'mach_vm_size_t size', 441*bbb1b6f9SApple OSS Distributions 'mach_vm_size_t size2', 442*bbb1b6f9SApple OSS Distributions 'mach_vm_size_t offset', 443*bbb1b6f9SApple OSS Distributions 'mach_vm_address_t status', 444*bbb1b6f9SApple OSS Distributions }, 445*bbb1b6f9SApple OSS Distributions }, 446*bbb1b6f9SApple OSS Distributions 447*bbb1b6f9SApple OSS Distributions { number = 89, name = 'mach_timebase_info', 448*bbb1b6f9SApple OSS Distributions arguments = { 449*bbb1b6f9SApple OSS Distributions 'mach_timebase_info_t info', 450*bbb1b6f9SApple OSS Distributions }, 451*bbb1b6f9SApple OSS Distributions }, 452*bbb1b6f9SApple OSS Distributions { number = 90, name = 'mach_wait_until', 453*bbb1b6f9SApple OSS Distributions arguments = { 454*bbb1b6f9SApple OSS Distributions 'uint64_t deadline', 455*bbb1b6f9SApple OSS Distributions }, 456*bbb1b6f9SApple OSS Distributions }, 457*bbb1b6f9SApple OSS Distributions { number = 91, name = 'mk_timer_create', 458*bbb1b6f9SApple OSS Distributions arguments = { 'void' }, 459*bbb1b6f9SApple OSS Distributions }, 460*bbb1b6f9SApple OSS Distributions { number = 92, name = 'mk_timer_destroy', 461*bbb1b6f9SApple OSS Distributions arguments = { 462*bbb1b6f9SApple OSS Distributions 'mach_port_name_t name', 463*bbb1b6f9SApple OSS Distributions }, 464*bbb1b6f9SApple OSS Distributions }, 465*bbb1b6f9SApple OSS Distributions { number = 93, name = 'mk_timer_arm', 466*bbb1b6f9SApple OSS Distributions arguments = { 467*bbb1b6f9SApple OSS Distributions 'mach_port_name_t name', 468*bbb1b6f9SApple OSS Distributions 'uint64_t expire_time', 469*bbb1b6f9SApple OSS Distributions }, 470*bbb1b6f9SApple OSS Distributions }, 471*bbb1b6f9SApple OSS Distributions { number = 94, name = 'mk_timer_cancel', 472*bbb1b6f9SApple OSS Distributions arguments = { 473*bbb1b6f9SApple OSS Distributions 'mach_port_name_t name', 474*bbb1b6f9SApple OSS Distributions 'uint64_t *result_time', 475*bbb1b6f9SApple OSS Distributions }, 476*bbb1b6f9SApple OSS Distributions }, 477*bbb1b6f9SApple OSS Distributions { number = 95, name = 'mk_timer_arm_leeway', 478*bbb1b6f9SApple OSS Distributions arguments = { 479*bbb1b6f9SApple OSS Distributions 'mach_port_name_t name', 480*bbb1b6f9SApple OSS Distributions 'uint64_t mk_timer_flags', 481*bbb1b6f9SApple OSS Distributions 'uint64_t mk_timer_expire_time', 482*bbb1b6f9SApple OSS Distributions 'uint64_t mk_timer_leeway', 483*bbb1b6f9SApple OSS Distributions }, 484*bbb1b6f9SApple OSS Distributions }, 485*bbb1b6f9SApple OSS Distributions { number = 96, name = 'debug_control_port_for_pid', 486*bbb1b6f9SApple OSS Distributions arguments = { 487*bbb1b6f9SApple OSS Distributions 'mach_port_name_t target_tport', 488*bbb1b6f9SApple OSS Distributions 'int pid', 489*bbb1b6f9SApple OSS Distributions 'mach_port_name_t *t', 490*bbb1b6f9SApple OSS Distributions }, 491*bbb1b6f9SApple OSS Distributions }, 492*bbb1b6f9SApple OSS Distributions 493*bbb1b6f9SApple OSS Distributions { number = 100, name = 'iokit_user_client', 494*bbb1b6f9SApple OSS Distributions arguments = { 495*bbb1b6f9SApple OSS Distributions 'void *userClientRef', 496*bbb1b6f9SApple OSS Distributions 'uint32_t index', 497*bbb1b6f9SApple OSS Distributions 'void *p1', 498*bbb1b6f9SApple OSS Distributions 'void *p2', 499*bbb1b6f9SApple OSS Distributions 'void *p3', 500*bbb1b6f9SApple OSS Distributions 'void *p4', 501*bbb1b6f9SApple OSS Distributions 'void *p5', 502*bbb1b6f9SApple OSS Distributions 'void *p6', 503*bbb1b6f9SApple OSS Distributions }, 504*bbb1b6f9SApple OSS Distributions }, 505*bbb1b6f9SApple OSS Distributions }, 506*bbb1b6f9SApple OSS Distributions} 507*bbb1b6f9SApple OSS Distributions 508*bbb1b6f9SApple OSS Distributions-- Basic sanity checking that the same number isn't claimed by two syscalls. 509*bbb1b6f9SApple OSS Distributionsfor type, entries in pairs(syscalls) do 510*bbb1b6f9SApple OSS Distributions local numbers_seen = {} 511*bbb1b6f9SApple OSS Distributions for _, call in ipairs(entries) do 512*bbb1b6f9SApple OSS Distributions if numbers_seen[call.number] then 513*bbb1b6f9SApple OSS Distributions io.stderr:write(('error: %s: saw %d twice: %s and %s\n'):format(type, 514*bbb1b6f9SApple OSS Distributions call.number, call.name, numbers_seen[call.number])) 515*bbb1b6f9SApple OSS Distributions os.exit(1) 516*bbb1b6f9SApple OSS Distributions end 517*bbb1b6f9SApple OSS Distributions numbers_seen[call.number] = call.name 518*bbb1b6f9SApple OSS Distributions end 519*bbb1b6f9SApple OSS Distributionsend 520*bbb1b6f9SApple OSS Distributions 521*bbb1b6f9SApple OSS Distributionsprint(cjson.encode(syscalls)) 522