1#!/bin/sh 2# SPDX-License-Identifier: GPL-2.0 3# 4# Generate system call table for perf. Derived from 5# powerpc script. 6# 7# Copyright IBM Corp. 2017 8# Author(s): Hendrik Brueckner <brueckner@linux.vnet.ibm.com> 9# Changed by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com> 10# Changed by: Kim Phillips <kim.phillips@arm.com> 11# Changed by: Björn Töpel <bjorn@rivosinc.com> 12 13gcc=$1 14hostcc=$2 15incpath=$3 16input=$4 17 18if ! test -r $input; then 19 echo "Could not read input file" >&2 20 exit 1 21fi 22 23create_sc_table() 24{ 25 local sc nr max_nr 26 27 while read sc nr; do 28 printf "%s\n" " [$nr] = \"$sc\"," 29 max_nr=$nr 30 done 31 32 echo "#define SYSCALLTBL_RISCV_MAX_ID $max_nr" 33} 34 35create_table() 36{ 37 echo "#include \"$input\"" 38 echo "static const char *const syscalltbl_riscv[] = {" 39 create_sc_table 40 echo "};" 41} 42 43$gcc -E -dM -x c -I $incpath/include/uapi $input \ 44 |awk '$2 ~ "__NR" && $3 !~ "__NR3264_" { 45 sub("^#define __NR(3264)?_", ""); 46 print | "sort -k2 -n"}' \ 47 |create_table 48