[PATCH 04/16] Add initial support for logging
Stefan Berger
stefanb at linux.vnet.ibm.com
Sat Aug 8 11:54:53 AEST 2015
This patch adds initial support for the logging that will be done
following measurements done by further code added to SLOF.
Signed-off-by: Stefan Berger <stefanb at linux.vnet.ibm.com>
Reviewed-by: Nikunj A Dadhania <nikunj at linux.vnet.ibm.com>
---
board-qemu/slof/vtpm-sml.fs | 3 +++
lib/libtpm/tcgbios.c | 30 ++++++++++++++++++++++++++++++
lib/libtpm/tcgbios.h | 1 +
lib/libtpm/tpm.code | 11 +++++++++++
lib/libtpm/tpm.in | 1 +
5 files changed, 46 insertions(+)
diff --git a/board-qemu/slof/vtpm-sml.fs b/board-qemu/slof/vtpm-sml.fs
index 72edac0..741a953 100644
--- a/board-qemu/slof/vtpm-sml.fs
+++ b/board-qemu/slof/vtpm-sml.fs
@@ -25,6 +25,9 @@ LOG-SIZE alloc-mem to log-base
\ create /ibm,vtpm
s" ibm,vtpm" 2dup device-name device-type
+\ convey logbase and size to the C driver
+log-base LOG-SIZE tpm-set-log-parameters
+
: sml-get-allocated-size ( -- buffer-size)
vtpm-debug? IF
." Call to sml-get-allocated-size; size = " LOG-SIZE . cr
diff --git a/lib/libtpm/tcgbios.c b/lib/libtpm/tcgbios.c
index efa4cdf..afbaede 100644
--- a/lib/libtpm/tcgbios.c
+++ b/lib/libtpm/tcgbios.c
@@ -77,10 +77,40 @@ static struct tpm_state tpm_state = {
extern struct tpm_driver tpm_drivers[];
+static void *log_base;
+static uint32_t log_area_size;
+
/********************************************************
Extensions for TCG-enabled BIOS
*******************************************************/
+void tpm_set_log_parameters(void *addr, unsigned int size)
+{
+ dprintf("Log is at 0x%llx; size is %u bytes\n",
+ (uint64_t)addr, size);
+ log_base = addr;
+ log_area_size = size;
+}
+
+static uint8_t *get_log_base_ptr(void)
+{
+ return log_base;
+}
+
+static uint32_t get_log_area_size(void)
+{
+ return log_area_size;
+}
+
+/* clear the OpenFirmware device tree log */
+static void reset_ofdt_log(void)
+{
+ uint8_t *log_area_start_address = get_log_base_ptr();
+
+ if (log_area_start_address)
+ memset(log_area_start_address, 0, get_log_area_size());
+}
+
static bool is_tpm_present(void)
{
bool rc = false;
diff --git a/lib/libtpm/tcgbios.h b/lib/libtpm/tcgbios.h
index c4c462e..9b51826 100644
--- a/lib/libtpm/tcgbios.h
+++ b/lib/libtpm/tcgbios.h
@@ -17,5 +17,6 @@
uint32_t tpm_start(void);
uint32_t tpm_unassert_pp(void);
+void tpm_set_log_parameters(void *address, unsigned int size);
#endif /* TCGBIOS_H */
diff --git a/lib/libtpm/tpm.code b/lib/libtpm/tpm.code
index 567b384..a6b66a8 100644
--- a/lib/libtpm/tpm.code
+++ b/lib/libtpm/tpm.code
@@ -35,3 +35,14 @@ PRIM(tpm_X2d_unassert_X2d_pp)
PUSH;
TOS.n = tpm_unassert_pp();
MIRP
+
+/*************************************************************/
+/* Convey log address and size */
+/* SLOF: tpm-set-log-parameters ( addr size -- ) */
+/* LIBTPM: tpm_set_log_parameters(void *addr, uint64_t size) */
+/*************************************************************/
+PRIM(tpm_X2d_set_X2d_log_X2d_parameters)
+ int size = TOS.u; POP;
+ void *addr = TOS.a; POP;
+ tpm_set_log_parameters(addr, size);
+MIRP
diff --git a/lib/libtpm/tpm.in b/lib/libtpm/tpm.in
index 266439e..a2f7cb9 100644
--- a/lib/libtpm/tpm.in
+++ b/lib/libtpm/tpm.in
@@ -15,3 +15,4 @@
cod(tpm-start)
cod(tpm-unassert-pp)
+cod(tpm-set-log-parameters)
--
1.9.3
More information about the Linuxppc-dev
mailing list