18e2ff72aSRavi Bangoria#!/bin/sh 28e2ff72aSRavi Bangoria# SPDX-License-Identifier: GPL-2.0 38e2ff72aSRavi Bangoria# 48e2ff72aSRavi Bangoria# Generate system call table for perf. Derived from 58e2ff72aSRavi Bangoria# s390 script. 68e2ff72aSRavi Bangoria# 78e2ff72aSRavi Bangoria# Copyright IBM Corp. 2017 88e2ff72aSRavi Bangoria# Author(s): Hendrik Brueckner <brueckner@linux.vnet.ibm.com> 98e2ff72aSRavi Bangoria# Changed by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com> 108e2ff72aSRavi Bangoria 118e2ff72aSRavi Bangoriawordsize=$1 128e2ff72aSRavi Bangoriagcc=$2 138e2ff72aSRavi Bangoriainput=$3 148e2ff72aSRavi Bangoria 158e2ff72aSRavi Bangoriaif ! test -r $input; then 168e2ff72aSRavi Bangoria echo "Could not read input file" >&2 178e2ff72aSRavi Bangoria exit 1 188e2ff72aSRavi Bangoriafi 198e2ff72aSRavi Bangoria 208e2ff72aSRavi Bangoriacreate_table() 218e2ff72aSRavi Bangoria{ 228e2ff72aSRavi Bangoria local wordsize=$1 238e2ff72aSRavi Bangoria local max_nr 248e2ff72aSRavi Bangoria 258e2ff72aSRavi Bangoria echo "static const char *syscalltbl_powerpc_${wordsize}[] = {" 268e2ff72aSRavi Bangoria while read sc nr; do 278e2ff72aSRavi Bangoria printf '\t[%d] = "%s",\n' $nr $sc 288e2ff72aSRavi Bangoria max_nr=$nr 298e2ff72aSRavi Bangoria done 308e2ff72aSRavi Bangoria echo '};' 318e2ff72aSRavi Bangoria echo "#define SYSCALLTBL_POWERPC_${wordsize}_MAX_ID $max_nr" 328e2ff72aSRavi Bangoria} 338e2ff72aSRavi Bangoria 348e2ff72aSRavi Bangoria$gcc -m${wordsize} -E -dM -x c $input \ 358e2ff72aSRavi Bangoria |sed -ne 's/^#define __NR_//p' \ 368e2ff72aSRavi Bangoria |sort -t' ' -k2 -nu \ 378e2ff72aSRavi Bangoria |create_table ${wordsize} 38