xref: /linux/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl (revision 0d0db47634611bf25bb933fec801faa91702a3ab)
12b588243SKim Phillips#!/bin/sh
22b588243SKim Phillips# SPDX-License-Identifier: GPL-2.0
32b588243SKim Phillips#
42b588243SKim Phillips# Generate system call table for perf. Derived from
52b588243SKim Phillips# powerpc script.
62b588243SKim Phillips#
72b588243SKim Phillips# Copyright IBM Corp. 2017
82b588243SKim Phillips# Author(s):  Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
92b588243SKim Phillips# Changed by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
102b588243SKim Phillips# Changed by: Kim Phillips <kim.phillips@arm.com>
112b588243SKim Phillips
122b588243SKim Phillipsgcc=$1
132b588243SKim Phillipshostcc=$2
145ab1de93SKim Phillipsincpath=$3
155ab1de93SKim Phillipsinput=$4
162b588243SKim Phillips
172b588243SKim Phillipsif ! test -r $input; then
182b588243SKim Phillips	echo "Could not read input file" >&2
192b588243SKim Phillips	exit 1
202b588243SKim Phillipsfi
212b588243SKim Phillips
22*0d0db476STiezhu Yangcreate_sc_table()
232b588243SKim Phillips{
242b588243SKim Phillips	local sc nr last_sc
252b588243SKim Phillips
262b588243SKim Phillips	while read sc nr; do
279854e7adSHans-Peter Nilsson		printf "%s\n" "	[$nr] = \"$sc\","
282b588243SKim Phillips		last_sc=$sc
292b588243SKim Phillips	done
302b588243SKim Phillips
319854e7adSHans-Peter Nilsson	printf "%s\n" "#define SYSCALLTBL_ARM64_MAX_ID __NR_$last_sc"
322b588243SKim Phillips}
332b588243SKim Phillips
342b588243SKim Phillipscreate_table()
352b588243SKim Phillips{
369854e7adSHans-Peter Nilsson	echo "#include \"$input\""
3749f3806dSTiezhu Yang	echo "static const char *const syscalltbl_arm64[] = {"
38*0d0db476STiezhu Yang	create_sc_table
392b588243SKim Phillips	echo "};"
402b588243SKim Phillips}
412b588243SKim Phillips
42f95d050cSVitaly Chikunov$gcc -E -dM -x c -I $incpath/include/uapi $input \
432b588243SKim Phillips	|sed -ne 's/^#define __NR_//p' \
447e8e5e87SHans-Peter Nilsson	|sort -t' ' -k2 -n	       \
452b588243SKim Phillips	|create_table
46