xref: /linux/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl (revision 49f3806d89e4cf9e330b6f2e39db1c913a8fd25a)
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
222b588243SKim Phillipscreate_table_from_c()
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\""
37*49f3806dSTiezhu Yang	echo "static const char *const syscalltbl_arm64[] = {"
382b588243SKim Phillips	create_table_from_c
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