10c6c2d36SMark Brown#!/bin/awk -f 20c6c2d36SMark Brown# SPDX-License-Identifier: GPL-2.0 30c6c2d36SMark Brown# gen-cpucaps.awk: arm64 cpucaps header generator 40c6c2d36SMark Brown# 50c6c2d36SMark Brown# Usage: awk -f gen-cpucaps.awk cpucaps.txt 60c6c2d36SMark Brown 70c6c2d36SMark Brown# Log an error and terminate 80c6c2d36SMark Brownfunction fatal(msg) { 90c6c2d36SMark Brown print "Error at line " NR ": " msg > "/dev/stderr" 100c6c2d36SMark Brown exit 1 110c6c2d36SMark Brown} 120c6c2d36SMark Brown 130c6c2d36SMark Brown# skip blank lines and comment lines 140c6c2d36SMark Brown/^$/ { next } 150c6c2d36SMark Brown/^#/ { next } 160c6c2d36SMark Brown 170c6c2d36SMark BrownBEGIN { 18*484de085SMark Rutland print "#ifndef __ASM_CPUCAP_DEFS_H" 19*484de085SMark Rutland print "#define __ASM_CPUCAP_DEFS_H" 200c6c2d36SMark Brown print "" 210c6c2d36SMark Brown print "/* Generated file - do not edit */" 220c6c2d36SMark Brown cap_num = 0 230c6c2d36SMark Brown print "" 240c6c2d36SMark Brown} 250c6c2d36SMark Brown 260c6c2d36SMark Brown/^[vA-Z0-9_]+$/ { 2756b77ba1SPrathu Baronia printf("#define ARM64_%-40s\t%d\n", $0, cap_num++) 280c6c2d36SMark Brown next 290c6c2d36SMark Brown} 300c6c2d36SMark Brown 310c6c2d36SMark BrownEND { 3256b77ba1SPrathu Baronia printf("#define ARM64_NCAPS\t\t\t\t\t%d\n", cap_num) 330c6c2d36SMark Brown print "" 34*484de085SMark Rutland print "#endif /* __ASM_CPUCAP_DEFS_H */" 350c6c2d36SMark Brown} 360c6c2d36SMark Brown 370c6c2d36SMark Brown# Any lines not handled by previous rules are unexpected 380c6c2d36SMark Brown{ 390c6c2d36SMark Brown fatal("unhandled statement") 400c6c2d36SMark Brown} 41