2 # SPDX-License-Identifier: BSD-2-Clause
4 if [ -z "$1" ] ||
[ -z "$2" ]; then
5 printf "Usage: %s <output file> \"<microcode .h files>\"\\n" "$0"
9 TMPFILE
=$
(mktemp microcode_XXXX
)
10 cat > "${TMPFILE}.c" << EOF
12 unsigned int microcode[] = {
16 if [ "${1: -4}" == ".inc" ]; then
17 sed '/^;/d' <"$1" |
awk '{gsub( /h.*$/, "", $2 ); print "0x" $2 ","; }' \
20 echo "#include \"$1\"" >> "${TMPFILE}.c"
24 for UCODE
in ${@:2}; do
25 if [ -d "$UCODE" ]; then
26 for f
in "$UCODE/"*.inc
35 cat >> "${TMPFILE}.c" << EOF
39 FILE *f = fopen("$OUTFILE", "wb");
40 fwrite(microcode, sizeof(microcode), 1, f);
46 gcc
-o "$TMPFILE" "${TMPFILE}.c"
47 [ -f "${TMPFILE}.exe" ] && mv "${TMPFILE}.exe" "$TMPFILE"
49 rm "$TMPFILE" "${TMPFILE}.c"