9os

Experimental kernel using plan9 ideas for embedded device
git clone git://git.simple-cc.org/9os
Log | Files | Refs | README | LICENSE

mksysreg (605B)


      1 #/bin/sh
      2 
      3 set -e
      4 trap 'rm -f $$.tmp' EXIT HUP INT QUIT TERM
      5 
      6 for i
      7 do
      8 	case $i in
      9 	-h)
     10 		shift
     11 		awk 'BEGIN   {print "enum sysreg {"}
     12 		     NF == 2 {printf "\t%s,\n", $1}
     13 		     END     {print "};"}' $@ > $$.tmp &&
     14 		mv $$.tmp sysreg.h
     15 		;;
     16 	-s)
     17 		shift
     18 		cat <<EOF > $$.tmp && mv $$.tmp sysreg.s
     19 	.FILE	"sysreg.s"
     20 
     21 	.TEXT
     22 	.GLOBL	sysrd
     23 sysrd:
     24 	ADR	X1,1f
     25 	LSL	X0,X0,#3
     26 	ADD	X1,X1,X0
     27 	BR	X1
     28 1:
     29 $(awk 'NF == 2  {printf "\tMRS\tX0,%s\n\tret\n\n", $2}' $@)
     30 
     31 	.GLOBL	syswr
     32 syswr:
     33 	ADR	X2,1f
     34 	LSL	X0,X0,#3
     35 	ADD	X2,X2,X0
     36 	BR	X2
     37 1:
     38 $(awk 'NF == 2  {printf "\tMSR\t%s,X1\n\tRET\n\n", $2}' $@)
     39 EOF
     40 		;;
     41 	esac
     42 done