[SLOF] [PATCH v2 06/20] Return value of actual log in sml-get-handover-size

Stefan Berger stefanb at us.ibm.com
Wed Nov 18 04:02:22 AEDT 2015


From: Stefan Berger <stefanb at linux.vnet.ibm.com>

With the functions for calculating the actual size of the log in place,
use them to determine the exact size of the log that the firmware
API call sml-get-handover-size now returns.

Signed-off-by: Stefan Berger <stefanb at linux.vnet.ibm.com>
---
 board-qemu/slof/vtpm-sml.fs |  7 +++++++
 lib/libtpm/tcgbios.c        | 15 +++++++++++++++
 lib/libtpm/tcgbios.h        |  1 +
 lib/libtpm/tpm.code         | 10 ++++++++++
 lib/libtpm/tpm.in           |  1 +
 5 files changed, 34 insertions(+)

diff --git a/board-qemu/slof/vtpm-sml.fs b/board-qemu/slof/vtpm-sml.fs
index 5bfd629..80fa4e6 100644
--- a/board-qemu/slof/vtpm-sml.fs
+++ b/board-qemu/slof/vtpm-sml.fs
@@ -35,6 +35,13 @@ log-base LOG-SIZE tpm-set-log-parameters
     LOG-SIZE
 ;
 
+: sml-get-handover-size ( -- size )
+    tpm-get-logsize
+    vtpm-debug? IF
+        ." Call to sml-get-handover-size; size = " dup . cr
+    THEN
+;
+
 : sml-handover ( dest size -- )
     vtpm-debug? IF
         2dup
diff --git a/lib/libtpm/tcgbios.c b/lib/libtpm/tcgbios.c
index e22c550..dbc77d7 100644
--- a/lib/libtpm/tcgbios.c
+++ b/lib/libtpm/tcgbios.c
@@ -138,6 +138,21 @@ static void *get_log_area_address_next(void)
 	return log_area_address_next;
 }
 
+uint32_t tpm_get_logsize(void)
+{
+	uint8_t *log_area_start_address = get_log_base_ptr();
+	uint8_t *log_area_address_next = get_log_area_address_next();
+	uint32_t logsize;
+
+	if (log_area_address_next) {
+		logsize = log_area_address_next - log_area_start_address;
+		dprintf("log size: %u\n", logsize);
+		return logsize;
+	}
+
+	return 0;
+}
+
 /*
  * Extend the ACPI log with the given entry by copying the
  * entry data into the log.
diff --git a/lib/libtpm/tcgbios.h b/lib/libtpm/tcgbios.h
index 351f778..4e92b16 100644
--- a/lib/libtpm/tcgbios.h
+++ b/lib/libtpm/tcgbios.h
@@ -18,5 +18,6 @@
 uint32_t tpm_start(void);
 uint32_t tpm_unassert_physical_presence(void);
 void tpm_set_log_parameters(void *address, unsigned int size);
+uint32_t tpm_get_logsize(void);
 
 #endif /* TCGBIOS_H */
diff --git a/lib/libtpm/tpm.code b/lib/libtpm/tpm.code
index 4ce1739..83e175d 100644
--- a/lib/libtpm/tpm.code
+++ b/lib/libtpm/tpm.code
@@ -46,3 +46,13 @@ PRIM(tpm_X2d_set_X2d_log_X2d_parameters)
 	void *addr = TOS.a; POP;
 	tpm_set_log_parameters(addr, size);
 MIRP
+
+/************************************************/
+/* Get the size of the log                      */
+/* SLOF:   tpm-get-logsize         ( -- size )  */
+/* LIBTPM: logsize = tpm_get_logsize(void)      */
+/************************************************/
+PRIM(tpm_X2d_get_X2d_logsize)
+	PUSH;
+	TOS.n = tpm_get_logsize();
+MIRP
diff --git a/lib/libtpm/tpm.in b/lib/libtpm/tpm.in
index 06a0874..60bdf45 100644
--- a/lib/libtpm/tpm.in
+++ b/lib/libtpm/tpm.in
@@ -16,3 +16,4 @@
 cod(tpm-start)
 cod(tpm-unassert-physical-presence)
 cod(tpm-set-log-parameters)
+cod(tpm-get-logsize)
-- 
2.4.3



More information about the SLOF mailing list