1
0
Fork 0
alistair23-linux/arch/mips/kernel/syscalls/syscalltbl.sh

37 lines
694 B
Bash
Raw Normal View History

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
2018-12-13 02:07:38 -07:00
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
in="$1"
out="$2"
my_abis=`echo "($3)" | tr ',' '|'`
my_abi="$4"
offset="$5"
emit() {
t_nxt="$1"
t_nr="$2"
t_entry="$3"
while [ $t_nxt -lt $t_nr ]; do
printf "__SYSCALL(%s,sys_ni_syscall)\n" "${t_nxt}"
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
2018-12-13 02:07:38 -07:00
t_nxt=$((t_nxt+1))
done
printf "__SYSCALL(%s,%s)\n" "${t_nxt}" "${t_entry}"
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
2018-12-13 02:07:38 -07:00
}
grep -E "^[0-9A-Fa-fXx]+[[:space:]]+${my_abis}" "$in" | sort -n | (
nxt=0
if [ -z "$offset" ]; then
offset=0
fi
while read nr abi name entry compat ; do
if [ "$my_abi" = "64_o32" ] && [ ! -z "$compat" ]; then
emit $((nxt+offset)) $((nr+offset)) $compat
else
emit $((nxt+offset)) $((nr+offset)) $entry
fi
nxt=$((nr+1))
done
) > "$out"