Skip to content

Commit 678af06

Browse files
committed
WIP amdana
Signed-off-by: Daniel Maslowski <[email protected]>
1 parent e5c648f commit 678af06

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

cmds/amdana/main.go

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package main
2+
3+
import (
4+
"encoding/json"
5+
"flag"
6+
"fmt"
7+
"io/ioutil"
8+
"log"
9+
10+
amd "github.com/linuxboot/fiano/pkg/amd/manifest"
11+
)
12+
13+
const (
14+
// This needed a look at the image; how can we fully automate it?
15+
mapping = 0xff000000
16+
)
17+
18+
// this is only for Go - would be 5 lines inline in JS, thanks...
19+
type image []byte
20+
21+
func (f image) ImageBytes() []byte {
22+
return []byte(f)
23+
}
24+
25+
func (f image) PhysAddrToOffset(physAddr uint64) uint64 {
26+
return physAddr - mapping
27+
}
28+
29+
func (f image) OffsetToPhysAddr(offset uint64) uint64 {
30+
return offset + mapping
31+
}
32+
33+
func main() {
34+
flag.Parse()
35+
args := flag.Args()
36+
37+
var path string
38+
39+
if len(args) > 0 {
40+
path = args[0]
41+
data, err := ioutil.ReadFile(path)
42+
if err != nil {
43+
log.Fatal(err)
44+
}
45+
// We could also use this, but its mapping wouldn't work with some images
46+
// FIXME: figure out those mappings
47+
// var amdfw amd.FirmwareImage = data
48+
var amdfw image = data
49+
fw, err := amd.NewAMDFirmware(amdfw)
50+
if err != nil {
51+
log.Fatal(err)
52+
}
53+
a := fw.PSPFirmware()
54+
j, err := json.MarshalIndent(a, "", " ")
55+
if err != nil {
56+
log.Fatal(err)
57+
}
58+
fmt.Printf(string(j))
59+
}
60+
}

0 commit comments

Comments
 (0)