Skip to content

Commit

Permalink
WIP: more Intel metadata utilty commands (to be discarded)
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Maslowski <[email protected]>
  • Loading branch information
orangecms committed Jan 17, 2023
1 parent 4e7b76b commit 0b5bfca
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 0 deletions.
48 changes: 48 additions & 0 deletions cmds/bginfo/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright 2017-2018 the LinuxBoot Authors. All rights reserved
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// fspinfo prints FSP header information.

package main

import (
"bytes"
"encoding/json"
"flag"
"fmt"
"os"

"github.com/linuxboot/fiano/pkg/intel/metadata/bg/bgbootpolicy"
"github.com/linuxboot/fiano/pkg/log"
)

var (
flagJSON = flag.Bool("j", false, "Output as JSON")
)

func main() {
flag.Parse()
if flag.Arg(0) == "" {
log.Fatalf("missing file name")
}
data, err := os.ReadFile(flag.Arg(0))
if err != nil {
log.Fatalf("cannot read input file: %v", err)
}
m := bgbootpolicy.Manifest{}
_, err = m.ReadFrom(bytes.NewReader(data))
if err != nil {
log.Fatalf("%v", err)
}

j, err := json.MarshalIndent(m, "", " ")
if err != nil {
log.Fatalf("cannot marshal JSON: %v", err)
}
if *flagJSON {
fmt.Println(string(j))
} else {
fmt.Print(m.PrettyString(0, true))
}
}
48 changes: 48 additions & 0 deletions cmds/km/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright 2017-2018 the LinuxBoot Authors. All rights reserved
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// fspinfo prints FSP header information.

package main

import (
"bytes"
"encoding/json"
"flag"
"fmt"
"os"

"github.com/linuxboot/fiano/pkg/intel/metadata/cbnt/cbntkey"
"github.com/linuxboot/fiano/pkg/log"
)

var (
flagJSON = flag.Bool("j", false, "Output as JSON")
)

func main() {
flag.Parse()
if flag.Arg(0) == "" {
log.Fatalf("missing file name")
}
data, err := os.ReadFile(flag.Arg(0))
if err != nil {
log.Fatalf("cannot read input file: %v", err)
}
m := cbntkey.Manifest{}
_, err = m.ReadFrom(bytes.NewReader(data))
if err != nil {
log.Fatalf("%v", err)
}

j, err := json.MarshalIndent(m, "", " ")
if err != nil {
log.Fatalf("cannot marshal JSON: %v", err)
}
if *flagJSON {
fmt.Println(string(j))
} else {
fmt.Print(m.PrettyString(0, true))
}
}

0 comments on commit 0b5bfca

Please sign in to comment.