aboutsummaryrefslogtreecommitdiff
path: root/libstb
diff options
context:
space:
mode:
authorClaudio Carvalho <cclaudio@linux.vnet.ibm.com>2016-10-25 16:58:21 +1100
committerStewart Smith <stewart@linux.vnet.ibm.com>2016-10-25 16:58:21 +1100
commit7b0d3155c9dd71cd8d7afcec9dbbeebc22bd77bf (patch)
treef816cb23d682239618a033edcc6cd4e955aaa8b9 /libstb
parent8652ced003f7977e1126149b8011c184b88fe24e (diff)
downloadskiboot-7b0d3155c9dd71cd8d7afcec9dbbeebc22bd77bf.zip
skiboot-7b0d3155c9dd71cd8d7afcec9dbbeebc22bd77bf.tar.gz
skiboot-7b0d3155c9dd71cd8d7afcec9dbbeebc22bd77bf.tar.bz2
libstb/container: add function for getting sw payload size
Add a function to get the software payload size from a STB container. (originally from patch from Claudio, but I pulled out just this bit here) Extracted-from-a-patch-by: Claudio Carvalho <cclaudio@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'libstb')
-rw-r--r--libstb/container.c10
-rw-r--r--libstb/container.h1
2 files changed, 11 insertions, 0 deletions
diff --git a/libstb/container.c b/libstb/container.c
index 19df556..a720fbb 100644
--- a/libstb/container.c
+++ b/libstb/container.c
@@ -38,6 +38,16 @@ uint32_t stb_payload_magic(const void *buf, size_t size)
return be32_to_cpu(*(uint32_t*)(p+SECURE_BOOT_HEADERS_SIZE));
}
+uint64_t stb_sw_payload_size(const void *buf, size_t size)
+{
+ struct parsed_stb_container c;
+ if (!stb_is_container(buf, size))
+ return 0;
+ if (parse_stb_container(buf, size, &c) != 0)
+ return 0;
+ return be64_to_cpu(c.sh->payload_size);
+}
+
int parse_stb_container(const void* data, size_t len, struct parsed_stb_container *c)
{
const size_t prefix_data_min_size = 3 * (EC_COORDBYTES * 2);
diff --git a/libstb/container.h b/libstb/container.h
index f65615a..f8965d4 100644
--- a/libstb/container.h
+++ b/libstb/container.h
@@ -143,6 +143,7 @@ bool stb_is_container(const void* buf, size_t size);
/* Get the pointer for the sw-payload-hash field of the container header */
const uint8_t* stb_sw_payload_hash(const void* buf, size_t size);
+uint64_t stb_sw_payload_size(const void *buf, size_t size);
int parse_stb_container(const void* data, size_t len, struct parsed_stb_container *c);