]>
git.ipfire.org Git - thirdparty/dracut.git/blob - modules.d/99uefi-lib/uefi-lib.sh
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
=0
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
35 (( val
= b2
* 256 + b1
))
40 # Acpi(PNP0A08,0x0)/Pci(0x3,0x0)/Pci(0x0,0x0)/MAC(90E2BA265ED4,0x0)/Vlan(172)/Fibre(0x4EA06104A0CC0050,0x0)
43 data
=${1:-/sys/firmware/efi/vars/FcoeBootDevice-a0ebca23-5f9c-447a-a268-22b6c158c2ac/data}
44 [ -f "$data" ] ||
return 1
46 local IFS
= LC_CTYPE
=C res tt len
type hextype first
52 type=$
(getbyte
) ||
return 1
53 subtype
=$
(getbyte
) ||
return 1
54 len
=$
(getword
) ||
return 1
55 hextype
=$
(printf "%02x%02x" "$type" "$subtype")
56 if [[ $first == 1 ]]; then
58 elif [[ $hextype != "7fff" ]]; then
65 printf "PCI(0x%x,0x%x)" $
(($tt / 256)) $
(($tt & 255))
69 printf "Acpi(0x%x,0x%x)" $
(($
(getword
) + $
(getword
) * 65536)) $
(($
(getword
) + $
(getword
) * 65536))
75 printf "Fibre(0x%x%x%x%x%x%x%x%x,0x%x)" \
76 $
(getbyte
) $
(getbyte
) $
(getbyte
) $
(getbyte
) \
77 $
(getbyte
) $
(getbyte
) $
(getbyte
) $
(getbyte
) \
78 $
(( $
(getword
) + $
(getword
) * 65536 + 4294967296 * ( $
(getword
) + $
(getword
) * 65536 ) ))
82 printf "MAC(%02x%02x%02x%02x%02x%02x," $
(getbyte
) $
(getbyte
) $
(getbyte
) $
(getbyte
) $
(getbyte
) $
(getbyte
)
83 for((i
=0; i
<26; i
++)); do tt
=$
(getbyte
) ||
return 1; done
84 #read -r -d '' -n 26 tt || return 1
85 printf "0x%x)" $
(getbyte
)
89 printf "VLAN(%d)" $
(getword
)
97 #printf "Unknown(Type:0x%02x SubType:0x%02x len=%d)\n" "$type" "$subtype" "$len" >&2
98 for((i
=0; i
<len-4
; i
++)); do tt
=$
(getbyte
); done
105 # /home/harald/Downloads/FcoeBootDevice-80005007-4248-4e4b-8df4-93060220756f
109 data
=${1:-/sys/firmware/efi/vars/FcoeBootDevice-a0ebca23-5f9c-447a-a268-22b6c158c2ac/data}
110 [ -f "$data" ] ||
return 1
111 local IFS
= LC_CTYPE
=C tt len
type hextype
116 type=$
(getbyte
) ||
return 1
117 subtype
=$
(getbyte
) ||
return 1
118 len
=$
(getword
) ||
return 1
119 hextype
=$
(printf "%02x%02x" "$type" "$subtype")
123 printf "%02x:%02x:%02x:%02x:%02x:%02x" $
(getbyte
) $
(getbyte
) $
(getbyte
) $
(getbyte
) $
(getbyte
) $
(getbyte
)
124 for((i
=0; i
<27; i
++)); do tt
=$
(getbyte
) ||
return 1; done
131 #printf "Unknown(Type:0x%02x SubType:0x%02x len=%d)\n" "$type" "$subtype" "$len" >&2
132 for((i
=0; i
<len-4
; i
++)); do tt
=$
(getbyte
); done
141 data
=${1:-/sys/firmware/efi/vars/FcoeBootDevice-a0ebca23-5f9c-447a-a268-22b6c158c2ac/data}
142 [ -f "$data" ] ||
return 1
143 local IFS
= LC_CTYPE
=C tt len
type hextype
148 type=$
(getbyte
) ||
return 1
149 subtype
=$
(getbyte
) ||
return 1
150 len
=$
(getword
) ||
return 1
151 hextype
=$
(printf "%02x%02x" "$type" "$subtype")
155 printf "%d" $
(getword
)
162 #printf "Unknown(Type:0x%02x SubType:0x%02x len=%d)\n" "$type" "$subtype" "$len" >&2
163 for((i
=0; i
<len
; i
++)); do tt
=$
(getbyte
); done