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