1#!/usr/libexec/flua 2-- 3-- SPDX-License-Identifier: BSD-2-Clause 4-- 5-- Copyright (c) 2024 Tyler Baxter <agge@FreeBSD.org> 6-- Copyright (c) 2023 Warner Losh <imp@bsdimp.com> 7-- Copyright (c) 2019 Kyle Evans <kevans@FreeBSD.org> 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). 14if arg[0]:match("/") then 15 local path = arg[0]:gsub("/[^/]+.lua$", "") 16 package.path = package.path .. ";" .. path .. "/?.lua" 17end 18 19-- Common config file management. 20local config = require("config") 21-- FreeBSDSyscall generates a table of system calls from syscalls.master. 22local FreeBSDSyscall = require("core.freebsd-syscall") 23 24-- Modules for each file: 25local init_sysent = require("scripts.init_sysent") 26local libsys_h = require("scripts.libsys_h") 27local syscall_h = require("scripts.syscall_h") 28local syscall_mk = require("scripts.syscall_mk") 29local syscalls = require("scripts.syscalls") 30local syscalls_map = require("scripts.syscalls_map") 31local sysproto_h = require("scripts.sysproto_h") 32local systrace_args = require("scripts.systrace_args") 33 34-- Entry: 35if #arg < 1 or #arg > 2 then 36 error("usage: " .. arg[0] .. " syscall.master") 37end 38 39local sysfile, configfile = arg[1], arg[2] 40 41config.merge(configfile) 42config.mergeCompat() 43 44local tbl = FreeBSDSyscall:new{sysfile = sysfile, config = config} 45 46-- Output files: 47init_sysent.file = config.syssw 48libsys_h.file = config.libsys_h 49syscall_h.file = config.syshdr 50syscall_mk.file = config.sysmk 51syscalls.file = config.sysnames 52syscalls_map.file = config.libsysmap 53sysproto_h.file = config.sysproto 54systrace_args.file = config.systrace 55 56init_sysent.generate(tbl, config, init_sysent.file) 57libsys_h.generate(tbl, config, libsys_h.file) 58syscall_h.generate(tbl, config, syscall_h.file) 59syscall_mk.generate(tbl, config, syscall_mk.file) 60syscalls.generate(tbl, config, syscalls.file) 61syscalls_map.generate(tbl, config, syscalls_map.file) 62sysproto_h.generate(tbl, config, sysproto_h.file) 63systrace_args.generate(tbl, config, systrace_args.file) 64