Skip to content

Commit 22c1f88

Browse files
committed
WIP intelana
Signed-off-by: Daniel Maslowski <info@orangecms.org>
1 parent 978160d commit 22c1f88

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

cmds/intelana/main.go

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package main
2+
3+
import (
4+
"encoding/json"
5+
"flag"
6+
"fmt"
7+
"io/ioutil"
8+
"log"
9+
10+
fit "github.com/linuxboot/fiano/pkg/intel/metadata/fit"
11+
"github.com/linuxboot/fiano/pkg/uefi"
12+
)
13+
14+
func main() {
15+
flag.Parse()
16+
args := flag.Args()
17+
18+
if len(args) > 0 {
19+
path := args[0]
20+
data, err := ioutil.ReadFile(path)
21+
if err != nil {
22+
log.Fatal(err)
23+
}
24+
25+
fmt.Printf("\n== IFD ==\n")
26+
regions := [...]uefi.FlashRegionType{
27+
uefi.RegionTypeBIOS,
28+
uefi.RegionTypeME,
29+
uefi.RegionTypeGBE,
30+
uefi.RegionTypePTT,
31+
uefi.RegionTypeEC,
32+
uefi.RegionTypeMicrocode,
33+
}
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("%-9s offset %x size %x\n", r, offset, size)
42+
} else {
43+
fmt.Printf("%-9s region not found/invalid\n", r)
44+
}
45+
}
46+
}
47+
48+
fmt.Printf("\n== FIT ==\n")
49+
table, err := fit.GetTable(data)
50+
doJson := false
51+
if doJson {
52+
j, err := json.MarshalIndent(table, "", " ")
53+
if err != nil {
54+
log.Fatal(err)
55+
}
56+
fmt.Printf(string(j))
57+
} else {
58+
fmt.Printf("\n%s", table)
59+
}
60+
}
61+
}

0 commit comments

Comments
 (0)