Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/sys/tools/syscalls/main.lua
39530 views
1
#!/usr/libexec/flua
2
--
3
-- SPDX-License-Identifier: BSD-2-Clause
4
--
5
-- Copyright (c) 2024 Tyler Baxter <[email protected]>
6
-- Copyright (c) 2023 Warner Losh <[email protected]>
7
-- Copyright (c) 2019 Kyle Evans <[email protected]>
8
--
9
-- Thanks to Kyle Evans for his makesyscall.lua in FreeBSD which served as
10
-- inspiration for this, and as a source of code at times.
11
--
12
13
-- When we have a path, add it to the package.path (. is already in the list).
14
if arg[0]:match("/") then
15
local path = arg[0]:gsub("/[^/]+.lua$", "")
16
package.path = package.path .. ";" .. path .. "/?.lua"
17
end
18
19
-- Common config file management.
20
local config = require("config")
21
-- FreeBSDSyscall generates a table of system calls from syscalls.master.
22
local FreeBSDSyscall = require("core.freebsd-syscall")
23
24
-- Modules for each file:
25
local init_sysent = require("scripts.init_sysent")
26
local libsys_h = require("scripts.libsys_h")
27
local syscall_h = require("scripts.syscall_h")
28
local syscall_mk = require("scripts.syscall_mk")
29
local syscalls = require("scripts.syscalls")
30
local syscalls_map = require("scripts.syscalls_map")
31
local sysproto_h = require("scripts.sysproto_h")
32
local systrace_args = require("scripts.systrace_args")
33
34
-- Entry:
35
if #arg < 1 or #arg > 2 then
36
error("usage: " .. arg[0] .. " syscall.master")
37
end
38
39
local sysfile, configfile = arg[1], arg[2]
40
41
config.merge(configfile)
42
config.mergeCompat()
43
44
local tbl = FreeBSDSyscall:new{sysfile = sysfile, config = config}
45
46
-- Output files:
47
init_sysent.file = config.syssw
48
libsys_h.file = config.libsys_h
49
syscall_h.file = config.syshdr
50
syscall_mk.file = config.sysmk
51
syscalls.file = config.sysnames
52
syscalls_map.file = config.libsysmap
53
sysproto_h.file = config.sysproto
54
systrace_args.file = config.systrace
55
56
init_sysent.generate(tbl, config, init_sysent.file)
57
libsys_h.generate(tbl, config, libsys_h.file)
58
syscall_h.generate(tbl, config, syscall_h.file)
59
syscall_mk.generate(tbl, config, syscall_mk.file)
60
syscalls.generate(tbl, config, syscalls.file)
61
syscalls_map.generate(tbl, config, syscalls_map.file)
62
sysproto_h.generate(tbl, config, sysproto_h.file)
63
systrace_args.generate(tbl, config, systrace_args.file)
64
65