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