3 # Copyright 2013 Red Hat, Inc. All rights reserved.
4 # Copyright 2013 Harald Hoyer <harald@redhat.com>
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 local IFS
= LC_CTYPE
=C res c
24 # the single quote in the argument of the printf
25 # yields the numeric value of $c (ASCII since LC_CTYPE=C)
26 [[ -n $c ]] && c
=$
(printf '%u' "'$c") || c
=0
33 b1
=$
(getbyte
) ||
return 1
34 b2
=$
(getbyte
) ||
return 1
35 (( val
= b2
* 256 + b1
))
40 # Acpi(PNP0A08,0x0)/Pci(0x3,0x0)/Pci(0x0,0x0)/MAC(90E2BA265ED4,0x0)/Vlan(172)/Fibre(0x4EA06104A0CC0050,0x0)
43 local IFS
= LC_CTYPE
=C res tt len
type hextype first
47 type=$
(getbyte
) ||
return 1
48 subtype
=$
(getbyte
) ||
return 1
49 len
=$
(getword
) ||
return 1
50 hextype
=$
(printf "%02x%02x" "$type" "$subtype")
51 if [[ $first == 1 ]]; then
53 elif [[ $hextype != "7fff" ]]; then
60 printf "PCI(0x%x,0x%x)" $
(($tt / 256)) $
(($tt & 255))
64 printf "Acpi(0x%x,0x%x)" $
(($
(getword
) + $
(getword
) * 65536)) $
(($
(getword
) + $
(getword
) * 65536))
70 printf "Fibre(0x%x%x%x%x%x%x%x%x,0x%x)" \
71 $
(getbyte
) $
(getbyte
) $
(getbyte
) $
(getbyte
) \
72 $
(getbyte
) $
(getbyte
) $
(getbyte
) $
(getbyte
) \
73 $
(( $
(getword
) + $
(getword
) * 65536 + 4294967296 * ( $
(getword
) + $
(getword
) * 65536 ) ))
77 printf "MAC(%02x%02x%02x%02x%02x%02x," $
(getbyte
) $
(getbyte
) $
(getbyte
) $
(getbyte
) $
(getbyte
) $
(getbyte
)
78 read -r -N 26 tt ||
return 1
79 printf "0x%x)" $
(getbyte
)
83 printf "VLAN(%d)" $
(getword
)
91 printf "Unknown(Type:%d SubType:%d len=%d)" "$type" "$subtype" "$len"
92 read -r -N $
(($len-4)) tt ||
return 1
100 data
=${1:-/sys/firmware/efi/vars/FcoeBootDevice-a0ebca23-5f9c-447a-a268-22b6c158c2ac/data}
101 [ -f $data ] ||
return 1
102 local IFS
= LC_CTYPE
=C tt len
type hextype
106 type=$
(getbyte
) ||
return 1
107 subtype
=$
(getbyte
) ||
return 1
108 len
=$
(getword
) ||
return 1
109 hextype
=$
(printf "%02x%02x" "$type" "$subtype")
113 printf "%02x:%02x:%02x:%02x:%02x:%02x" $
(getbyte
) $
(getbyte
) $
(getbyte
) $
(getbyte
) $
(getbyte
) $
(getbyte
)
114 read -r -N 27 tt ||
return 1
121 read -r -N $
(($len-4)) tt ||
return 1
129 data
=${1:-/sys/firmware/efi/vars/FcoeBootDevice-a0ebca23-5f9c-447a-a268-22b6c158c2ac/data}
130 [ -f $data ] ||
return 1
131 local IFS
= LC_CTYPE
=C tt len
type hextype
135 type=$
(getbyte
) ||
return 1
136 subtype
=$
(getbyte
) ||
return 1
137 len
=$
(getword
) ||
return 1
138 hextype
=$
(printf "%02x%02x" "$type" "$subtype")
142 printf "%d" $
(getword
)
149 read -r -N $
(($len-4)) tt ||
return 1