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 26389373d3SHongxu Jia create_table_exe=`mktemp ${TMPDIR:-/tmp}/create-table-XXXXXX` 272b588243SKim Phillips 282b588243SKim Phillips { 292b588243SKim Phillips 302b588243SKim Phillips cat <<-_EoHEADER 312b588243SKim Phillips #include <stdio.h> 322b588243SKim Phillips #include "$input" 332b588243SKim Phillips int main(int argc, char *argv[]) 342b588243SKim Phillips { 352b588243SKim Phillips _EoHEADER 362b588243SKim Phillips 372b588243SKim Phillips while read sc nr; do 382b588243SKim Phillips printf "%s\n" " printf(\"\\t[%d] = \\\"$sc\\\",\\n\", __NR_$sc);" 392b588243SKim Phillips last_sc=$sc 402b588243SKim Phillips done 412b588243SKim Phillips 422b588243SKim Phillips printf "%s\n" " printf(\"#define SYSCALLTBL_ARM64_MAX_ID %d\\n\", __NR_$last_sc);" 432b588243SKim Phillips printf "}\n" 442b588243SKim Phillips 455ab1de93SKim Phillips } | $hostcc -I $incpath/include/uapi -o $create_table_exe -x c - 462b588243SKim Phillips 472b588243SKim Phillips $create_table_exe 482b588243SKim Phillips 492b588243SKim Phillips rm -f $create_table_exe 502b588243SKim Phillips} 512b588243SKim Phillips 522b588243SKim Phillipscreate_table() 532b588243SKim Phillips{ 542b588243SKim Phillips echo "static const char *syscalltbl_arm64[] = {" 552b588243SKim Phillips create_table_from_c 562b588243SKim Phillips echo "};" 572b588243SKim Phillips} 582b588243SKim Phillips 59f95d050cSVitaly Chikunov$gcc -E -dM -x c -I $incpath/include/uapi $input \ 602b588243SKim Phillips |sed -ne 's/^#define __NR_//p' \ 61*7e8e5e87SHans-Peter Nilsson |sort -t' ' -k2 -n \ 622b588243SKim Phillips |create_table 63