Skip to content

Commit

Permalink
WIP amdana
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Maslowski <[email protected]>
  • Loading branch information
orangecms committed Jan 10, 2022
1 parent 1195aea commit 239087c
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions cmds/amdana/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package main

import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"log"

amd "github.com/linuxboot/fiano/pkg/amd/manifest"
)

const (
// This needed a look at the image; how can we fully automate it?
mapping = 0xff000000
)

// this is only for Go - would be 5 lines inline in JS, thanks...
type dummyFirmware struct {
image []byte
}

func (f dummyFirmware) ImageBytes() []byte {
return f.image
}

func (f dummyFirmware) PhysAddrToOffset(physAddr uint64) uint64 {
return physAddr - mapping
}

func (f dummyFirmware) OffsetToPhysAddr(offset uint64) uint64 {
return offset + mapping
}

func main() {
flag.Parse()
args := flag.Args()

var path string
var amdfw dummyFirmware

if len(args) > 0 {
path = args[0]
data, err := ioutil.ReadFile(path)
if err != nil {
log.Fatal(err)
}
amdfw.image = data
fw, err := amd.NewAMDFirmware(amdfw)
if err != nil {
log.Fatal(err)
}
a := fw.PSPFirmware()
j, err := json.MarshalIndent(a, "", " ")
if err != nil {
log.Fatal(err)
}
fmt.Printf(string(j))
}
}

0 comments on commit 239087c

Please sign in to comment.