File tree Expand file tree Collapse file tree 1 file changed +60
-0
lines changed Expand file tree Collapse file tree 1 file changed +60
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments