|
| 1 | +package main |
| 2 | + |
| 3 | +import ( |
| 4 | + "encoding/json" |
| 5 | + "flag" |
| 6 | + "fmt" |
| 7 | + "io/ioutil" |
| 8 | + "log" |
| 9 | + "os" |
| 10 | + |
| 11 | + fit "github.com/linuxboot/fiano/pkg/intel/metadata/fit" |
| 12 | + ifd "github.com/linuxboot/fiano/pkg/tools" |
| 13 | + "github.com/linuxboot/fiano/pkg/uefi" |
| 14 | +) |
| 15 | + |
| 16 | +func main() { |
| 17 | + flag.Parse() |
| 18 | + args := flag.Args() |
| 19 | + |
| 20 | + var path string |
| 21 | + |
| 22 | + if len(args) > 0 { |
| 23 | + path = args[0] |
| 24 | + data, err := ioutil.ReadFile(path) |
| 25 | + if err != nil { |
| 26 | + log.Fatal(err) |
| 27 | + } |
| 28 | + fmt.Printf("\n== IFD ==\n") |
| 29 | + a, b, err := ifd.GetRegion(data, uefi.RegionTypeBIOS) |
| 30 | + fmt.Printf("BIOS offset %x size %x\n", a, b) |
| 31 | + a, b, err = ifd.GetRegion(data, uefi.RegionTypeME) |
| 32 | + fmt.Printf("ME offset %x size %x\n", a, b) |
| 33 | + a, b, err = ifd.GetRegion(data, uefi.RegionTypeGBE) |
| 34 | + fmt.Printf("GBE offset %x size %x\n", a, b) |
| 35 | + a, b, err = ifd.GetRegion(data, uefi.RegionTypePTT) |
| 36 | + fmt.Printf("PTT offset %x size %x\n", a, b) |
| 37 | + a, b, err = ifd.GetRegion(data, uefi.RegionTypeEC) |
| 38 | + fmt.Printf("EC offset %x size %x\n", a, b) |
| 39 | + a, b, err = ifd.GetRegion(data, uefi.RegionTypeMicrocode) |
| 40 | + fmt.Printf("ucode offset %x size %x\n", a, b) |
| 41 | + fmt.Printf("\n== FIT ==\n") |
| 42 | + file, err := os.Open(path) |
| 43 | + headers, err := fit.ParseEntryHeadersFrom(file) |
| 44 | + j, err := json.MarshalIndent(headers, "", " ") |
| 45 | + if err != nil { |
| 46 | + log.Fatal(err) |
| 47 | + } |
| 48 | + fmt.Printf(string(j)) |
| 49 | + } |
| 50 | +} |
0 commit comments