9os

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

mkblobh (683B)


      1 #!/bin/sh
      2 
      3 set -e
      4 trap 'rm -f $$.tmp' EXIT HUP INT QUIT TERM
      5 rm -f blobs.h
      6 
      7 
      8 ./section blob $@ |
      9 awk -v type=${type=k} '
     10 NF==2	{blobaddr[$1] = $2}
     11 	{blob[$1] = 1}
     12 END	{mkblob()}
     13 
     14 function mkblob()
     15 {
     16 
     17 	printf "static Dirtab blobtab[] = {\n"
     18 	printf "\t{\"ctl\", QID(CHFILE, 0, Qblobctl), 0, O_READ},\n"
     19 	for (file in blob) {
     20 		if (blobaddr[file]) {
     21 			split(blobaddr[file], v, ",")
     22 			addr = "(void *) " v[1]
     23 			siz = v[2]
     24 		} else {
     25 			gsub(/.*\//, "", file)
     26 			addr=file
     27 			gsub(/\..*/, "", addr)
     28 			siz = "sizeof(" addr ")"
     29 		}
     30 		printf "\t{\"%s\", QID(CHFILE, 0, Qblobctl+%d), %s, O_READ, %s},\n",
     31 		        file, ++n, siz, addr
     32 	}
     33 	printf "};\n"
     34 }' > $$.tmp && mv $$.tmp blobs.h