Skip to content

Commit 212caaa

Browse files
committed
cmds/intelana: rework without pkg/tools/ifd - this is faster
Signed-off-by: Daniel Maslowski <info@orangecms.org>
1 parent 41a4a14 commit 212caaa

1 file changed

Lines changed: 25 additions & 35 deletions

File tree

cmds/intelana/main.go

Lines changed: 25 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"log"
99

1010
fit "github.com/linuxboot/fiano/pkg/intel/metadata/fit"
11-
ifd "github.com/linuxboot/fiano/pkg/tools"
1211
"github.com/linuxboot/fiano/pkg/uefi"
1312
)
1413

@@ -24,43 +23,34 @@ func main() {
2423
}
2524

2625
fmt.Printf("\n== IFD ==\n")
27-
o, s, err := ifd.GetRegion(data, uefi.RegionTypeBIOS)
28-
if err != nil {
29-
fmt.Printf("BIOS region not found: %s\n", err)
30-
} else {
31-
fmt.Printf("BIOS offset %x size %x\n", o, s)
32-
}
33-
o, s, err = ifd.GetRegion(data, uefi.RegionTypeME)
34-
if err != nil {
35-
fmt.Printf("ME region not found: %s\n", err)
36-
} else {
37-
fmt.Printf("ME offset %x size %x\n", o, s)
38-
}
39-
o, s, err = ifd.GetRegion(data, uefi.RegionTypeGBE)
40-
if err != nil {
41-
fmt.Printf("GBE region not found: %s\n", err)
42-
} else {
43-
fmt.Printf("GBE offset %x size %x\n", o, s)
44-
}
45-
o, s, err = ifd.GetRegion(data, uefi.RegionTypePTT)
46-
if err != nil {
47-
fmt.Printf("PTT region not found: %s\n", err)
48-
} else {
49-
fmt.Printf("PTT offset %x size %x\n", o, s)
26+
regions := [...]uefi.FlashRegionType{
27+
uefi.RegionTypeBIOS,
28+
uefi.RegionTypeME,
29+
uefi.RegionTypeGBE,
30+
uefi.RegionTypePTT,
31+
uefi.RegionTypeEC,
32+
uefi.RegionTypeMicrocode,
5033
}
51-
o, s, err = ifd.GetRegion(data, uefi.RegionTypeEC)
52-
if err != nil {
53-
fmt.Printf("EC region not found: %s\n", err)
54-
} else {
55-
fmt.Printf("EC offset %x size %x\n", o, s)
56-
}
57-
o, s, err = ifd.GetRegion(data, uefi.RegionTypeMicrocode)
58-
if err != nil {
59-
fmt.Printf("ucode region not found: %s\n", err)
60-
} else {
61-
fmt.Printf("ucode offset %x size %x\n", o, s)
34+
35+
fi, err := uefi.NewFlashImage(data)
36+
if fi != nil {
37+
for _, r := range regions {
38+
if fi.IFD.Region.FlashRegions[r].Valid() {
39+
offset := fi.IFD.Region.FlashRegions[r].BaseOffset()
40+
size := fi.IFD.Region.FlashRegions[r].EndOffset() - offset
41+
fmt.Printf("%-5s offset %x size %x\n", r, offset, size)
42+
} else {
43+
fmt.Printf("%-5s region not found: %s\n", r, err)
44+
}
45+
}
6246
}
6347

48+
/*
49+
for _, r := range fi.IFD.Region.FlashRegions {
50+
fmt.Printf(" %#v\n", r)
51+
}
52+
*/
53+
6454
doJson := false
6555

6656
fmt.Printf("\n== FIT ==\n")

0 commit comments

Comments
 (0)