On 02/27/2018 02:17 PM, Stephen Douthit wrote:
Signed-off-by: Stephen Douthit <steph...@silicom-usa.com>
Tested-by: Stephen Douthit <steph...@silicom-usa.com>

Reviewed-by: Stefan Berger <stef...@linux.vnet.ibm.com>

---
  src/hw/tpm_drivers.c | 80 ++++++++++++++++++++++------------------------------
  1 file changed, 33 insertions(+), 47 deletions(-)

diff --git a/src/hw/tpm_drivers.c b/src/hw/tpm_drivers.c
index 1fd05e1..13ad821 100644
--- a/src/hw/tpm_drivers.c
+++ b/src/hw/tpm_drivers.c
@@ -63,6 +63,39 @@ static void *crb_cmd;
  static u32 crb_resp_size;
  static void *crb_resp;

+static u32 wait_reg8(u8* reg, u32 time, u8 mask, u8 expect)
+{
+    if (!CONFIG_TCGBIOS)
+        return 0;
+
+    u32 rc = 1;
+    u32 end = timer_calc_usec(time);
+
+    for (;;) {
+        u8 value = readl(reg);
+        if ((value & mask) == expect) {
+            rc = 0;
+            break;
+        }
+        if (timer_check(end)) {
+            warn_timeout();
+            break;
+        }
+        yield();
+    }
+    return rc;
+}
+
+static u32 tis_wait_sts(u8 locty, u32 time, u8 mask, u8 expect)
+{
+    return wait_reg8(TIS_REG(locty, TIS_REG_STS), time, mask, expect);
+}
+
+static u32 crb_wait_reg(u8 locty, u16 reg, u32 time, u8 mask, u8 expect)
+{
+    return wait_reg8(CRB_REG(locty, reg), time, mask, expect);
+}
+
  /* if device is not there, return '0', '1' otherwise */
  static u32 tis_probe(void)
  {
@@ -152,30 +185,6 @@ static void set_timeouts(u32 timeouts[4], u32 durations[3])
          memcpy(dus, durations, 3 * sizeof(u32));
  }

-
-static u32 tis_wait_sts(u8 locty, u32 time, u8 mask, u8 expect)
-{
-    if (!CONFIG_TCGBIOS)
-        return 0;
-
-    u32 rc = 1;
-    u32 end = timer_calc_usec(time);
-
-    for (;;) {
-        u8 sts = readb(TIS_REG(locty, TIS_REG_STS));
-        if ((sts & mask) == expect) {
-            rc = 0;
-            break;
-        }
-        if (timer_check(end)) {
-            warn_timeout();
-            break;
-        }
-        yield();
-    }
-    return rc;
-}
-
  static u32 tis_activate(u8 locty)
  {
      if (!CONFIG_TCGBIOS)
@@ -399,29 +408,6 @@ static u32 crb_init(void)
      return 0;
  }

-static u32 crb_wait_reg(u8 locty, u8 reg, u32 time, u8 mask, u8 expect)
-{
-    if (!CONFIG_TCGBIOS)
-        return 0;
-
-    u32 rc = 1;
-    u32 end = timer_calc_usec(time);
-
-    for (;;) {
-        u8 sts = readl(CRB_REG(locty, reg));
-        if ((sts & mask) == expect) {
-            rc = 0;
-            break;
-        }
-        if (timer_check(end)) {
-            warn_timeout();
-            break;
-        }
-        yield();
-    }
-    return rc;
-}
-
  static u32 crb_activate(u8 locty)
  {
      if (!CONFIG_TCGBIOS)



_______________________________________________
SeaBIOS mailing list
SeaBIOS@seabios.org
https://mail.coreboot.org/mailman/listinfo/seabios

Reply via email to