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