18c2ecf20Sopenharmony_ci#!/bin/sh
28c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0
38c2ecf20Sopenharmony_ci#
48c2ecf20Sopenharmony_ci# Generate system call table for perf
58c2ecf20Sopenharmony_ci#
68c2ecf20Sopenharmony_ci# Copyright IBM Corp. 2017, 2018
78c2ecf20Sopenharmony_ci# Author(s):  Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
88c2ecf20Sopenharmony_ci#
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ciSYSCALL_TBL=$1
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ciif ! test -r $SYSCALL_TBL; then
138c2ecf20Sopenharmony_ci	echo "Could not read input file" >&2
148c2ecf20Sopenharmony_ci	exit 1
158c2ecf20Sopenharmony_cifi
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_cicreate_table()
188c2ecf20Sopenharmony_ci{
198c2ecf20Sopenharmony_ci	local max_nr nr abi sc discard
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci	echo 'static const char *syscalltbl_s390_64[] = {'
228c2ecf20Sopenharmony_ci	while read nr abi sc discard; do
238c2ecf20Sopenharmony_ci		printf '\t[%d] = "%s",\n' $nr $sc
248c2ecf20Sopenharmony_ci		max_nr=$nr
258c2ecf20Sopenharmony_ci	done
268c2ecf20Sopenharmony_ci	echo '};'
278c2ecf20Sopenharmony_ci	echo "#define SYSCALLTBL_S390_64_MAX_ID $max_nr"
288c2ecf20Sopenharmony_ci}
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_cigrep -E "^[[:digit:]]+[[:space:]]+(common|64)" $SYSCALL_TBL	\
318c2ecf20Sopenharmony_ci	|sort -k1 -n					\
328c2ecf20Sopenharmony_ci	|create_table
33