Skip to content

Commit 345e4f7

Browse files
committed
pkg/amd/manifest: marshal PSP entry type names
Signed-off-by: Daniel Maslowski <info@orangecms.org>
1 parent 3a583d6 commit 345e4f7

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

go.mod

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module github.com/linuxboot/fiano
33
go 1.16
44

55
require (
6+
github.com/orangecms/PSP-Entry-Types v1.0.1 // indirect
67
github.com/spf13/pflag v1.0.5
78
github.com/u-root/u-root v0.0.0-20210724144310-637617c480d4
89
github.com/ulikunitz/xz v0.5.10

go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ
8686
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
8787
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
8888
github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
89+
github.com/orangecms/PSP-Entry-Types v1.0.1 h1:CTJ/+esmVshvkpNbOAcdZGf/I/hUh3fo6PUwtBwxmpA=
90+
github.com/orangecms/PSP-Entry-Types v1.0.1/go.mod h1:gveQh8FM6402D5v+xtvRHYwecihTLmxPQDZJTFjpqSo=
8991
github.com/orangecms/go-framebuffer v0.0.0-20200613202404-a0700d90c330/go.mod h1:3Myb/UszJY32F2G7yGkUtcW/ejHpjlGfYLim7cv2uKA=
9092
github.com/pborman/getopt/v2 v2.1.0/go.mod h1:4NtW75ny4eBw9fO1bhtNdYTlZKYX5/tBLtsOpwKIKd0=
9193
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=

pkg/amd/manifest/marshal_json.go

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package manifest
2+
3+
import (
4+
"encoding/json"
5+
"fmt"
6+
7+
pspentries "github.com/orangecms/PSP-Entry-Types"
8+
)
9+
10+
var knownTypes = pspentries.Types()
11+
12+
func (t BIOSDirectoryTableEntryType) MarshalJSON() ([]byte, error) {
13+
for _, knownType := range knownTypes {
14+
if knownType.Type == uint32(t) {
15+
name := knownType.Name
16+
if name == "" {
17+
name = knownType.ProposedName
18+
}
19+
if name == "" {
20+
return json.Marshal(fmt.Sprintf("0x%x", t))
21+
}
22+
return json.Marshal(name)
23+
}
24+
}
25+
return json.Marshal(fmt.Sprintf("0x%x", t))
26+
}
27+
28+
/*
29+
TODO: extend information, also for PSPDirectoryTableEntry
30+
func (e BIOSDirectoryTableEntry) MarshalJSON() json.RawMessage {
31+
info := TypeInfo{
32+
Name: name,
33+
Comment: knownType.Comment,
34+
}
35+
entry.TypeInfo = &info
36+
}
37+
*/
38+
39+
func (t PSPDirectoryTableEntryType) MarshalJSON() ([]byte, error) {
40+
for _, knownType := range knownTypes {
41+
if knownType.Type == uint32(t) {
42+
name := knownType.Name
43+
if name == "" {
44+
name = knownType.ProposedName
45+
}
46+
if name == "" {
47+
return json.Marshal(fmt.Sprintf("0x%x", t))
48+
}
49+
return json.Marshal(name)
50+
}
51+
}
52+
return json.Marshal(fmt.Sprintf("0x%x", t))
53+
}

0 commit comments

Comments
 (0)