Back to home page

OSCL-LXR

 
 

    


0001 #!/bin/awk -f
0002 # SPDX-License-Identifier: GPL-2.0
0003 # gen-cpucaps.awk: arm64 cpucaps header generator
0004 #
0005 # Usage: awk -f gen-cpucaps.awk cpucaps.txt
0006 
0007 # Log an error and terminate
0008 function fatal(msg) {
0009   print "Error at line " NR ": " msg > "/dev/stderr"
0010   exit 1
0011 }
0012 
0013 # skip blank lines and comment lines
0014 /^$/ { next }
0015 /^#/ { next }
0016 
0017 BEGIN {
0018   print "#ifndef __ASM_CPUCAPS_H"
0019   print "#define __ASM_CPUCAPS_H"
0020   print ""
0021   print "/* Generated file - do not edit */"
0022   cap_num = 0
0023   print ""
0024 }
0025 
0026 /^[vA-Z0-9_]+$/ {
0027   printf("#define ARM64_%-30s\t%d\n", $0, cap_num++)
0028   next
0029 }
0030 
0031 END {
0032   printf("#define ARM64_NCAPS\t\t\t\t%d\n", cap_num)
0033   print ""
0034   print "#endif /* __ASM_CPUCAPS_H */"
0035 }
0036 
0037 # Any lines not handled by previous rules are unexpected
0038 {
0039   fatal("unhandled statement")
0040 }