2 # SPDX-License-Identifier: GPL-2.0
4 # Generate system call table and header files
6 # Copyright IBM Corp. 2018
7 # Author(s): Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
10 # File path to the system call table definition.
11 # You can set the path with the -i option. If omitted,
12 # system call table definitions are read from standard input.
17 create_syscall_table_entries
()
19 local nr abi name entry64 entry32 _ignore
20 local temp
=$
(mktemp
${TMPDIR:-/tmp}/syscalltbl-common.XXXXXXXXX
)
24 # Initialize with 0 to create an NI_SYSCALL for 0
26 local prev_nr
=0 prev_32
=sys_ni_syscall prev_64
=sys_ni_syscall
27 while read nr abi name entry64 entry32 _ignore
; do
28 test x
$entry32 = x-
&& entry32
=sys_ni_syscall
29 test x
$entry64 = x-
&& entry64
=sys_ni_syscall
31 if test $prev_nr -eq $nr; then
33 # Same syscall but different ABI, just update
34 # the respective entry point
46 printf "%d\t%s\t%s\n" $prev_nr $prev_64 $prev_32
53 printf "%d\t%s\t%s\n" $prev_nr $prev_64 $prev_32
57 # Check for duplicate syscall numbers
59 if ! cat $temp |cut
-f1 |
uniq -d 2>&1; then
60 echo "Error: generated system call table contains duplicate entries: $temp" >&2
65 # Generate syscall table
68 while read nr entry64 entry32
; do
69 while test $prev_nr -lt $
((nr
- 1)); do
71 prev_nr
=$
((prev_nr
+ 1))
73 if test x
$entry64 = xsys_ni_syscall
&&
74 test x
$entry32 = xsys_ni_syscall
; then
77 printf "SYSCALL(%s,%s)\n" $entry64 $entry32
84 generate_syscall_table
()
87 /* SPDX-License-Identifier: GPL-2.0 */
89 * Definitions for sys_call_table, each line represents an
90 * entry in the table in the form
91 * SYSCALL(64 bit syscall, 31 bit emulated syscall)
93 * This file is meant to be included from entry.S.
96 #define NI_SYSCALL SYSCALL(sys_ni_syscall,sys_ni_syscall)
99 grep -Ev '^(#|[[:blank:]]*$)' $SYSCALL_TBL \
101 |create_syscall_table_entries
104 create_header_defines
()
106 local nr abi name _ignore
108 while read nr abi name _ignore
; do
109 printf "#define __NR_%s %d\n" $name $nr
113 normalize_fileguard
()
117 echo "$1" |
tr '[[:lower:]]' '[[:upper:]]' \
118 |
sed -e 's/[^A-Z0-9_]/_/g' -e 's/__/_/g'
121 generate_syscall_header
()
123 local abis
=$
(echo "($1)" |
tr ',' '|')
125 local fileguard suffix
127 if test "$filename"; then
128 fileguard
=$
(normalize_fileguard
"__UAPI_ASM_S390_$2")
134 fileguard
=$
(normalize_fileguard
"__UAPI_ASM_S390_SYSCALLS_$suffix")
138 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
144 grep -E "^[[:digit:]]+[[:space:]]+${abis}" $SYSCALL_TBL \
146 |create_header_defines
150 #endif /* ${fileguard} */
156 local abis
=$
(echo "($1)" |
tr ',' '|')
158 grep -E "^[[:digit:]]+[[:space:]]+${abis}" $SYSCALL_TBL \
159 |
sed -ne 's/^\([[:digit:]]*\)[[:space:]].*/\1/p' \
165 generate_syscall_nr
()
168 local max_syscall_nr num_syscalls
170 max_syscall_nr
=$
(__max_syscall_nr
"$abis")
171 num_syscalls
=$
((max_syscall_nr
+ 1))
174 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
175 #ifndef __ASM_S390_SYSCALLS_NR
176 #define __ASM_S390_SYSCALLS_NR
178 #define NR_syscalls ${num_syscalls}
180 #endif /* __ASM_S390_SYSCALLS_NR */
186 # Parse command line arguments
194 while getopts ":HNSXi:a:f:" arg
; do
200 SYSCALL_TBL
="$OPTARG"
203 filename
=${OPTARG##*/}
218 echo "Missing argument for -$OPTARG" >&2
222 echo "Invalid option specified" >&2
228 test "$do_syscall_header" && generate_syscall_header
"$abi_list" "$filename"
229 test "$do_syscall_table" && generate_syscall_table
230 test "$do_syscall_nr" && generate_syscall_nr
"$abi_list"