From patchwork Wed Jan 2 14:28:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Firoz Khan X-Patchwork-Id: 154646 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp238431ljp; Wed, 2 Jan 2019 06:29:51 -0800 (PST) X-Google-Smtp-Source: AFSGD/WSY4b4z9VRJ7zqmu8wdjLYliDA7kDUis5PbZmXkTD1VeNTpcQEDqCOzVKiLyHdfLKi2Whr X-Received: by 2002:a62:2c81:: with SMTP id s123mr44120723pfs.174.1546439391384; Wed, 02 Jan 2019 06:29:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546439391; cv=none; d=google.com; s=arc-20160816; b=GmNdsV79PhTC2ZK5Aml7UmCzO5+ZRfzw1zY513qSxX/omMG8rOy/x7wvc9KHMxRReb fN+hK9uxHTH5qq8xAy9jwm37gTSYnw5KoRwfb+MP+8BBB8lkqTNYD4bWOJ4zbMLez099 iFvi2QuQ6Y0ucFbJGT3c9ZKgQTB4H2qv77bQMu+FN/SH+sFTlq7RyhWRmn9hGL3x2LB6 33AgtcWGFkYUayltHm3Gi6XxNKUhaqwMuXcxPATd6cY8dVz8KNpYKKQ9m2DF+5ON6UbH CpAmjGy8pFP0nDJ9RVnTq5FbhmKPGx7w+O7jT4ISEqRVGdSYToi566FBw5eQ9dd7Ap8u o1Vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=BecXgh+kIPpPXTWVpvXLny2DUXRqtPcUA0gq4wwH7zU=; b=CqgRdpBKsnZO3qllm7n9jVYd1DD9UaepQCEA5rpaOEorqeshEtQ3zARRuzYs88BSk0 HMjdUiA+7BCUE+42Q3opLbkMT8lixV6u2EIcRNqiaaXlJzdheoxDRzxvVHXGMIAQMeyt bFjmzrTYIgX86UR9GhWpJfg9p6V0Ohmw2DYBMc/gezEl4cIODkvEU9QFvF7hOGvHwa0x ju1+dvS8jq2ypgyHzKHETWcjhbh240VD3duNEGYwuTMPCNvbukxYfJguPjhyTh+ivccl PCOkAkCKyJTN0buZ8PPgY7VpkzWCS8Fl1pzaU7soSHVT7aUqP1jY/8ZaW27WeOpX6Rqs bCSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ljcki2Bz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e16si3765020pge.364.2019.01.02.06.29.51; Wed, 02 Jan 2019 06:29:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ljcki2Bz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729468AbfABO3t (ORCPT + 31 others); Wed, 2 Jan 2019 09:29:49 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:38749 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727424AbfABO3t (ORCPT ); Wed, 2 Jan 2019 09:29:49 -0500 Received: by mail-pg1-f193.google.com with SMTP id g189so14664296pgc.5 for ; Wed, 02 Jan 2019 06:29:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=BecXgh+kIPpPXTWVpvXLny2DUXRqtPcUA0gq4wwH7zU=; b=Ljcki2Bz6dBHoXCRu7qf1OUsUWnWtpkflbcT/C48RCIStK8w6VELm8o1x07d+Si/pJ C2uE5KSq975ZqexnGmb1vhsyZry+IWM53qjgBYOCla66XluZBE0KZknVP2bqp7EwQ1/p PgJazV/uY5EGbiM1fYW4snG1iiyRVr0nyF0G0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=BecXgh+kIPpPXTWVpvXLny2DUXRqtPcUA0gq4wwH7zU=; b=o1RLrqLaQDtQ0trQoOhqG11MLr2AIBFINT1jA8qd0y9X92N5Kb7Yycp2FzI2qprqhD NbjftiX+stjLDe9joRYT38iqEpCYnaINXNmp9pGv5qMLQl7gPQ3qSUuol4QDz7xj7sxK BhGd7bisL34oqrj704zh5/one+VDsx1GfoSax5r86DL/1TshZPw65Nol6MK0Po6+IZ19 49zoDaUt1FIe58bz9d+laRPhV4qh/Bp/9Y3jyui8MMDOo6R+Kln/A4UaEyhEBTLq/2qL HCdNw/hXj3Lx9puqNV/QVHYDr/gZDhBqRrTFyk0AQouDCx/fNr2pfXuffbhZbeyZI8bT YK8A== X-Gm-Message-State: AJcUuke9LAPalR4//JCaMjURVunBSNHhgqGzJhXmpTYHczHGYaQr27TW NUX4Tmon2dTAUtKE/B3CqEclSQ== X-Received: by 2002:a63:b81a:: with SMTP id p26mr13971790pge.433.1546439388417; Wed, 02 Jan 2019 06:29:48 -0800 (PST) Received: from qualcomm-HP-ZBook-14-G2.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id z127sm82640923pfb.80.2019.01.02.06.29.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 02 Jan 2019 06:29:47 -0800 (PST) From: Firoz Khan To: Paul Burton , Greg Kroah-Hartman , Philippe Ombredanne , Thomas Gleixner , Kate Stewart Cc: y2038@lists.linaro.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, arnd@arndb.de, deepa.kernel@gmail.com, marcin.juszkiewicz@linaro.org, firoz.khan@linaro.org Subject: [PATCH] scripts: unify system call table generation scripts Date: Wed, 2 Jan 2019 19:58:51 +0530 Message-Id: <1546439331-18646-1-git-send-email-firoz.khan@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org System call table generation support is provided for alpha, ia64, m68k, microblaze, mips, parisc, powerpc, sh, sparc and xtensa architectures. The implementat- ions are almost similar across all the above archte- ctures. In order to reduce the source code across all the above architectures, create common ".sh" files and keep it in the common directory, script/. This will be a generic scripts which can use for all the above architectures. Signed-off-by: Firoz Khan --- scripts/syscallhdr.sh | 37 +++++++++++++++++++++++++++++++++++++ scripts/syscallnr.sh | 32 ++++++++++++++++++++++++++++++++ scripts/syscalltbl.sh | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 106 insertions(+) create mode 100644 scripts/syscallhdr.sh create mode 100644 scripts/syscallnr.sh create mode 100644 scripts/syscalltbl.sh -- 1.9.1 diff --git a/scripts/syscallhdr.sh b/scripts/syscallhdr.sh new file mode 100644 index 0000000..d03fe3d --- /dev/null +++ b/scripts/syscallhdr.sh @@ -0,0 +1,37 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 + +in="$1" +out="$2" +my_abis=`echo "($3)" | tr ',' '|'` +prefix="$4" +offset="$5" + +fileguard=_UAPI_ASM_`basename "$out" | sed \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \ + -e 's/[^A-Z0-9_]/_/g' -e 's/__/_/g'` +grep -E "^[0-9A-Fa-fXx]+[[:space:]]+${my_abis}" "$in" | sort -n | ( + printf "#ifndef %s\n" "${fileguard}" + printf "#define %s\n" "${fileguard}" + printf "\n" + + nxt=0 + while read nr abi name entry compat ; do + if [ -z "$offset" ]; then + printf "#define __NR_%s%s\t%s\n" \ + "${prefix}" "${name}" "${nr}" + else + printf "#define __NR_%s%s\t(%s + %s)\n" \ + "${prefix}" "${name}" "${offset}" "${nr}" + fi + nxt=$((nr+1)) + done + + printf "\n" + printf "#ifdef __KERNEL__\n" + printf "#define __NR_syscalls\t%s\n" "${nxt}" + printf "#endif\n" + printf "\n" + printf "#endif /* %s */" "${fileguard}" + printf "\n" +) > "$out" diff --git a/scripts/syscallnr.sh b/scripts/syscallnr.sh new file mode 100644 index 0000000..8cf33fa --- /dev/null +++ b/scripts/syscallnr.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 + +in="$1" +out="$2" +my_abis=`echo "($3)" | tr ',' '|'` +prefix="$4" +offset="$5" + +fileguard=_UAPI_ASM_`basename "$out" | sed \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \ + -e 's/[^A-Z0-9_]/_/g' -e 's/__/_/g'` +grep -E "^[0-9A-Fa-fXx]+[[:space:]]+${my_abis}" "$in" | sort -n | ( + printf "#ifndef %s\n" "${fileguard}" + printf "#define %s\n" "${fileguard}" + printf "\n" + + nxt=0 + while read nr abi name entry compat ; do + nxt=$((nr+1)) + done + + if [ ! -z "$prefix" ]; then + printf "#define __NR_%s_Linux_syscalls\t%s\n" "${prefix}" "${nxt}" + if [ ! -z "$offset" ]; then + printf "#define __NR_%s_Linux\t%s\n" "${prefix}" "${offset}" + fi + fi + printf "\n" + printf "#endif /* %s */" "${fileguard}" + printf "\n" +) > "$out" diff --git a/scripts/syscalltbl.sh b/scripts/syscalltbl.sh new file mode 100644 index 0000000..f60f762 --- /dev/null +++ b/scripts/syscalltbl.sh @@ -0,0 +1,37 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 + +in="$1" +out="$2" +my_abis=`echo "($3)" | tr ',' '|'` +my_abi="$4" +offset="$5" + +emit() { + t_nxt="$1" + t_nr="$2" + t_entry="$3" + + while [ $t_nxt -lt $t_nr ]; do + printf "__SYSCALL(%s,sys_ni_syscall)\n" "${t_nxt}" + t_nxt=$((t_nxt+1)) + done + printf "__SYSCALL(%s,%s)\n" "${t_nxt}" "${t_entry}" +} + +grep -E "^[0-9A-Fa-fXx]+[[:space:]]+${my_abis}" "$in" | sort -n | ( + nxt=0 + if [ -z "$offset" ]; then + offset=0 + fi + + while read nr abi name entry compat ; do + if [ "$my_abi" = "c32" -o "$my_abi" = "64_o32" ] && + [ ! -z "$compat" ]; then + emit $((nxt+offset)) $((nr+offset)) $compat + else + emit $((nxt+offset)) $((nr+offset)) $entry + fi + nxt=$((nr+1)) + done +) > "$out"