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