xref: /linux/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl (revision cdd5b5a9761fd66d17586e4f4ba6588c70e640ea)
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
220d0db476STiezhu Yangcreate_sc_table()
232b588243SKim Phillips{
24*250e30baSTiezhu Yang	local sc nr max_nr
252b588243SKim Phillips
262b588243SKim Phillips	while read sc nr; do
279854e7adSHans-Peter Nilsson		printf "%s\n" "	[$nr] = \"$sc\","
28*250e30baSTiezhu Yang		max_nr=$nr
292b588243SKim Phillips	done
302b588243SKim Phillips
31*250e30baSTiezhu Yang	echo "#define SYSCALLTBL_ARM64_MAX_ID $max_nr"
322b588243SKim Phillips}
332b588243SKim Phillips
342b588243SKim Phillipscreate_table()
352b588243SKim Phillips{
369854e7adSHans-Peter Nilsson	echo "#include \"$input\""
3749f3806dSTiezhu Yang	echo "static const char *const syscalltbl_arm64[] = {"
380d0db476STiezhu Yang	create_sc_table
392b588243SKim Phillips	echo "};"
402b588243SKim Phillips}
412b588243SKim Phillips
42f95d050cSVitaly Chikunov$gcc -E -dM -x c -I $incpath/include/uapi $input \
43d6e1cc6bSTiezhu Yang	|awk '$2 ~ "__NR" && $3 !~ "__NR3264_" {
44d6e1cc6bSTiezhu Yang		sub("^#define __NR(3264)?_", "");
45d6e1cc6bSTiezhu Yang		print | "sort -k2 -n"}' \
462b588243SKim Phillips	|create_table
47