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 27*9854e7adSHans-Peter Nilsson printf "%s\n" " [$nr] = \"$sc\"," 282b588243SKim Phillips last_sc=$sc 292b588243SKim Phillips done 302b588243SKim Phillips 31*9854e7adSHans-Peter Nilsson printf "%s\n" "#define SYSCALLTBL_ARM64_MAX_ID __NR_$last_sc" 322b588243SKim Phillips} 332b588243SKim Phillips 342b588243SKim Phillipscreate_table() 352b588243SKim Phillips{ 36*9854e7adSHans-Peter Nilsson echo "#include \"$input\"" 372b588243SKim Phillips echo "static const char *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