Skip to content

Commit 9bcbf97

Browse files
Firoz Khanpaulburton
authored andcommitted
mips: add system call table generation support
The system call tables are in different format in all architecture and it will be difficult to manually add, modify or delete the syscall table entries in the res- pective files. To make it easy by keeping a script and which will generate the uapi header and syscall table file. This change will also help to unify the implemen- tation across all architectures. The system call table generation script is added in kernel/syscalls directory which contain the scripts to generate both uapi header file and system call table files. The syscall.tbl will be input for the scripts. syscall.tbl contains the list of available system calls along with system call number and corresponding entry point. Add a new system call in this architecture will be possible by adding new entry in the syscall.tbl file. Adding a new table entry consisting of: - System call number. - ABI. - System call name. - Entry point name. - Compat entry name, if required. syscallhdr.sh, syscallnr.sh and syscalltbl.sh will gene- rate uapi header unistd_n64/n32/o32.h, unistd_nr_n64/n32/- o32.h and syscall_table_32_o32/64_n64/64-n32/64-o32.h files respectively. All *.sh files will parse the content sys- call.tbl to generate the header and table files. unistd- _n64/n32/o32.h and unistd_nr_n64/n32/o32.h will be included by uapi/asm/unistd.h and syscall_table_32_o32/64_n64/64-n32- /64-o32.h is included by kernel/syscall_table32_o32/64- _n64/64-n32/64-o32.S - the real system call table. ARM, s390 and x86 architecuture does have similar support. I leverage their implementation to come up with a generic solution. Signed-off-by: Firoz Khan <firoz.khan@linaro.org> [paul.burton@mips.com: - Change sysnr_pfx_unistd_nr_n64 to 64.] Signed-off-by: Paul Burton <paul.burton@mips.com> Cc: linux-mips@vger.kernel.org Cc: Ralf Baechle <ralf@linux-mips.org> Cc: James Hogan <jhogan@kernel.org> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Philippe Ombredanne <pombredanne@nexb.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Kate Stewart <kstewart@linuxfoundation.org> Cc: y2038@lists.linaro.org Cc: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org Cc: arnd@arndb.de Cc: deepa.kernel@gmail.com Cc: marcin.juszkiewicz@linaro.org
1 parent 6a00cb6 commit 9bcbf97

File tree

7 files changed

+1261
-0
lines changed

7 files changed

+1261
-0
lines changed

arch/mips/kernel/syscalls/Makefile

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
kapi := arch/$(SRCARCH)/include/generated/asm
3+
uapi := arch/$(SRCARCH)/include/generated/uapi/asm
4+
5+
_dummy := $(shell [ -d '$(uapi)' ] || mkdir -p '$(uapi)') \
6+
$(shell [ -d '$(kapi)' ] || mkdir -p '$(kapi)')
7+
8+
syscalln32 := $(srctree)/$(src)/syscall_n32.tbl
9+
syscalln64 := $(srctree)/$(src)/syscall_n64.tbl
10+
syscallo32 := $(srctree)/$(src)/syscall_o32.tbl
11+
syshdr := $(srctree)/$(src)/syscallhdr.sh
12+
sysnr := $(srctree)/$(src)/syscallnr.sh
13+
systbl := $(srctree)/$(src)/syscalltbl.sh
14+
15+
quiet_cmd_syshdr = SYSHDR $@
16+
cmd_syshdr = $(CONFIG_SHELL) '$(syshdr)' '$<' '$@' \
17+
'$(syshdr_abis_$(basetarget))' \
18+
'$(syshdr_pfx_$(basetarget))' \
19+
'$(syshdr_offset_$(basetarget))'
20+
21+
quiet_cmd_sysnr = SYSNR $@
22+
cmd_sysnr = $(CONFIG_SHELL) '$(sysnr)' '$<' '$@' \
23+
'$(sysnr_abis_$(basetarget))' \
24+
'$(sysnr_pfx_$(basetarget))' \
25+
'$(sysnr_offset_$(basetarget))'
26+
27+
quiet_cmd_systbl = SYSTBL $@
28+
cmd_systbl = $(CONFIG_SHELL) '$(systbl)' '$<' '$@' \
29+
'$(systbl_abis_$(basetarget))' \
30+
'$(systbl_abi_$(basetarget))' \
31+
'$(systbl_offset_$(basetarget))'
32+
33+
syshdr_offset_unistd_n32 := __NR_Linux
34+
$(uapi)/unistd_n32.h: $(syscalln32) $(syshdr)
35+
$(call if_changed,syshdr)
36+
37+
syshdr_offset_unistd_n64 := __NR_Linux
38+
$(uapi)/unistd_n64.h: $(syscalln64) $(syshdr)
39+
$(call if_changed,syshdr)
40+
41+
syshdr_offset_unistd_o32 := __NR_Linux
42+
$(uapi)/unistd_o32.h: $(syscallo32) $(syshdr)
43+
$(call if_changed,syshdr)
44+
45+
sysnr_pfx_unistd_nr_n32 := N32
46+
sysnr_offset_unistd_nr_n32 := 6000
47+
$(uapi)/unistd_nr_n32.h: $(syscalln32) $(sysnr)
48+
$(call if_changed,sysnr)
49+
50+
sysnr_pfx_unistd_nr_n64 := 64
51+
sysnr_offset_unistd_nr_n64 := 5000
52+
$(uapi)/unistd_nr_n64.h: $(syscalln64) $(sysnr)
53+
$(call if_changed,sysnr)
54+
55+
sysnr_pfx_unistd_nr_o32 := O32
56+
sysnr_offset_unistd_nr_o32 := 4000
57+
$(uapi)/unistd_nr_o32.h: $(syscallo32) $(sysnr)
58+
$(call if_changed,sysnr)
59+
60+
systbl_abi_syscall_table_32_o32 := 32_o32
61+
systbl_offset_syscall_table_32_o32 := 4000
62+
$(kapi)/syscall_table_32_o32.h: $(syscallo32) $(systbl)
63+
$(call if_changed,systbl)
64+
65+
systbl_abi_syscall_table_64_n32 := 64_n32
66+
systbl_offset_syscall_table_64_n32 := 6000
67+
$(kapi)/syscall_table_64_n32.h: $(syscalln32) $(systbl)
68+
$(call if_changed,systbl)
69+
70+
systbl_abi_syscall_table_64_n64 := 64_n64
71+
systbl_offset_syscall_table_64_n64 := 5000
72+
$(kapi)/syscall_table_64_n64.h: $(syscalln64) $(systbl)
73+
$(call if_changed,systbl)
74+
75+
systbl_abi_syscall_table_64_o32 := 64_o32
76+
systbl_offset_syscall_table_64_o32 := 4000
77+
$(kapi)/syscall_table_64_o32.h: $(syscallo32) $(systbl)
78+
$(call if_changed,systbl)
79+
80+
uapisyshdr-y += unistd_n32.h \
81+
unistd_n64.h \
82+
unistd_o32.h \
83+
unistd_nr_n32.h \
84+
unistd_nr_n64.h \
85+
unistd_nr_o32.h
86+
kapisyshdr-y += syscall_table_32_o32.h \
87+
syscall_table_64_n32.h \
88+
syscall_table_64_n64.h \
89+
syscall_table_64_o32.h
90+
91+
targets += $(uapisyshdr-y) $(kapisyshdr-y)
92+
93+
PHONY += all
94+
all: $(addprefix $(uapi)/,$(uapisyshdr-y))
95+
all: $(addprefix $(kapi)/,$(kapisyshdr-y))
96+
@:

0 commit comments

Comments
 (0)