]> git.proxmox.com Git - qemu.git/blame - scripts/hxtool
pcnet: Fix sign extension: make ipxe work with >2G RAM
[qemu.git] / scripts / hxtool
CommitLineData
5824d651
BS
1#!/bin/sh
2
3hxtoh()
4{
5 flag=1
fb21ced7 6 while read -r str; do
5824d651
BS
7 case $str in
8 HXCOMM*)
9 ;;
b40292e7 10 STEXI*|ETEXI*|SQMP*|EQMP*) flag=$(($flag^1))
5824d651
BS
11 ;;
12 *)
004efc96 13 test $flag -eq 1 && printf "%s\n" "$str"
5824d651
BS
14 ;;
15 esac
16 done
17}
18
19hxtotexi()
20{
21 flag=0
6c913ba5 22 line=1
fb21ced7 23 while read -r str; do
5824d651
BS
24 case "$str" in
25 HXCOMM*)
26 ;;
6c913ba5
JK
27 STEXI*)
28 if test $flag -eq 1 ; then
29 echo "line $line: syntax error: expected ETEXI, found $str" >&2
30 exit 1
31 fi
32 flag=1
33 ;;
34 ETEXI*)
35 if test $flag -ne 1 ; then
36 echo "line $line: syntax error: expected STEXI, found $str" >&2
37 exit 1
38 fi
39 flag=0
5824d651 40 ;;
b40292e7
JK
41 SQMP*|EQMP*)
42 if test $flag -eq 1 ; then
43 echo "line $line: syntax error: expected ETEXI, found $str" >&2
44 exit 1
45 fi
46 ;;
5824d651 47 DEFHEADING*)
7d69c52e 48 echo "$(expr "$str" : "DEFHEADING(\(.*\))")"
5824d651
BS
49 ;;
50 *)
7d69c52e 51 test $flag -eq 1 && echo "$str"
5824d651
BS
52 ;;
53 esac
6c913ba5 54 line=$((line+1))
5824d651
BS
55 done
56}
57
b40292e7
JK
58hxtoqmp()
59{
60 IFS=
61 flag=0
02e95918 62 line=1
b40292e7
JK
63 while read -r str; do
64 case "$str" in
65 HXCOMM*)
66 ;;
67 SQMP*)
68 if test $flag -eq 1 ; then
69 echo "line $line: syntax error: expected EQMP, found $str" >&2
70 exit 1
71 fi
72 flag=1
73 ;;
74 EQMP*)
75 if test $flag -ne 1 ; then
76 echo "line $line: syntax error: expected SQMP, found $str" >&2
77 exit 1
78 fi
79 flag=0
80 ;;
81 STEXI*|ETEXI*)
82 if test $flag -eq 1 ; then
83 echo "line $line: syntax error: expected EQMP, found $str" >&2
84 exit 1
85 fi
86 ;;
87 *)
88 test $flag -eq 1 && echo "$str"
89 ;;
90 esac
02e95918 91 line=$((line+1))
b40292e7
JK
92 done
93}
94
5824d651
BS
95case "$1" in
96"-h") hxtoh ;;
97"-t") hxtotexi ;;
b40292e7 98"-q") hxtoqmp ;;
5824d651
BS
99*) exit 1 ;;
100esac
5c2f8d2d
BS
101
102exit 0