[Skiboot] [PATCH 3/4] libstb/container: add function for getting sw payload size

Stewart Smith stewart at linux.vnet.ibm.com
Tue Oct 25 18:15:01 AEDT 2016


From: Claudio Carvalho <cclaudio at linux.vnet.ibm.com>

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 at linux.vnet.ibm.com>
Signed-off-by: Stewart Smith <stewart at linux.vnet.ibm.com>
---
 libstb/container.c | 10 ++++++++++
 libstb/container.h |  1 +
 2 files changed, 11 insertions(+)

diff --git a/libstb/container.c b/libstb/container.c
index 19df55640509..a720fbbf1e8b 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 f65615a1db45..f8965d40f52b 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);
 
-- 
2.1.4



More information about the Skiboot mailing list