Skip to content

Commit 9a1898c

Browse files
rihter007orangecms
authored andcommitted
Implement offsets in PSPHeader
Signed-off-by: Ilya <[email protected]>
1 parent 7495fab commit 9a1898c

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

pkg/amd/manifest/psp_header.go

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,46 @@ type PSPHeader struct {
3131
Reserved3 [156]byte
3232
}
3333

34-
// ParsePSPHeader parses
34+
// Reserved1Offset returns the offset in bytes of field Reserved1
35+
func (h *PSPHeader) Reserved1Offset() uint64 {
36+
return 0
37+
}
38+
39+
func (h *PSPHeader) Reserved1Length() uint64 {
40+
return uint64(binary.Size(h.Reserved1))
41+
}
42+
43+
// CookieOffset returns the offset in bytes of field Cookie
44+
func (h *PSPHeader) CookieOffset() uint64 {
45+
return h.Reserved1Offset() + h.Reserved1Length()
46+
}
47+
48+
// CookieLength returns the size in bytes of field Cookie
49+
func (h *PSPHeader) CookieLength() uint64 {
50+
return uint64(binary.Size(h.Cookie))
51+
}
52+
53+
// Reserved2Offset returns the offset in bytes of field Reserved2
54+
func (h *PSPHeader) Reserved2Offset() uint64 {
55+
return h.CookieOffset() + h.CookieLength()
56+
}
57+
58+
// Reserved2Length returns the size in bytes of field Reserved2
59+
func (h *PSPHeader) Reserved2Length() uint64 {
60+
return uint64(binary.Size(h.Reserved2))
61+
}
62+
63+
// VersionOffset returns the offset in bytes of field Version
64+
func (h *PSPHeader) VersionOffset() uint64 {
65+
return h.Reserved2Offset() + h.Reserved2Length()
66+
}
67+
68+
// VersionLength returns the size in bytes of field Version
69+
func (h *PSPHeader) VersionLength() uint64 {
70+
return uint64(binary.Size(h.Version))
71+
}
72+
73+
// ParsePSPHeader parses the PSP header that is supposed to be the beginning of each PSP binary
3574
func ParsePSPHeader(r io.Reader) (*PSPHeader, error) {
3675
var result PSPHeader
3776
if err := binary.Read(r, binary.LittleEndian, &result); err != nil {

0 commit comments

Comments
 (0)