Skip to content

Commit

Permalink
pkg/amd/manifest: marshal PSP entry type names
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Maslowski <[email protected]>
  • Loading branch information
orangecms committed Dec 14, 2021
1 parent 9a1898c commit 74d2c53
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/linuxboot/fiano
go 1.16

require (
github.com/orangecms/PSP-Entry-Types v1.0.1 // indirect
github.com/u-root/u-root v0.0.0-20210724144310-637617c480d4
github.com/ulikunitz/xz v0.5.10
golang.org/x/text v0.3.6
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
github.com/orangecms/PSP-Entry-Types v1.0.1 h1:CTJ/+esmVshvkpNbOAcdZGf/I/hUh3fo6PUwtBwxmpA=
github.com/orangecms/PSP-Entry-Types v1.0.1/go.mod h1:gveQh8FM6402D5v+xtvRHYwecihTLmxPQDZJTFjpqSo=
github.com/orangecms/go-framebuffer v0.0.0-20200613202404-a0700d90c330/go.mod h1:3Myb/UszJY32F2G7yGkUtcW/ejHpjlGfYLim7cv2uKA=
github.com/pborman/getopt/v2 v2.1.0/go.mod h1:4NtW75ny4eBw9fO1bhtNdYTlZKYX5/tBLtsOpwKIKd0=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
Expand Down
53 changes: 53 additions & 0 deletions pkg/amd/manifest/marshal_json.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package manifest

import (
"encoding/json"
"fmt"

pspentries "github.com/orangecms/PSP-Entry-Types"
)

var knownTypes = pspentries.Types()

func (t BIOSDirectoryTableEntryType) MarshalJSON() ([]byte, error) {
for _, knownType := range knownTypes {
if knownType.Type == uint32(t) {
name := knownType.Name
if name == "" {
name = knownType.ProposedName
}
if name == "" {
return json.Marshal(fmt.Sprintf("0x%x", t))
}
return json.Marshal(name)
}
}
return json.Marshal(fmt.Sprintf("0x%x", t))
}

/*
TODO: extend information, also for PSPDirectoryTableEntry
func (e BIOSDirectoryTableEntry) MarshalJSON() json.RawMessage {
info := TypeInfo{
Name: name,
Comment: knownType.Comment,
}
entry.TypeInfo = &info
}
*/

func (t PSPDirectoryTableEntryType) MarshalJSON() ([]byte, error) {
for _, knownType := range knownTypes {
if knownType.Type == uint32(t) {
name := knownType.Name
if name == "" {
name = knownType.ProposedName
}
if name == "" {
return json.Marshal(fmt.Sprintf("0x%x", t))
}
return json.Marshal(name)
}
}
return json.Marshal(fmt.Sprintf("0x%x", t))
}

0 comments on commit 74d2c53

Please sign in to comment.