On 3/24/23 09:43, Stefan Berger wrote:


On 3/24/23 04:24, Cédric Le Goater wrote:
Hello Ninad,


+
+/*
+ * Convert little endian byte stream into local formated
+ * unsigned integer
+ */
+static inline uint32_t tpm_i2c_le_bytes_to_uint(TPMStateI2C *i2cst)
+{
+    uint32_t data = 0;
+    int      i;
+
+    assert(i2cst->offset <= 5);  /* Including 0th register value */
+
+    if (tpm_i2c_is_little_endian()) {
+        for (i = 1; i < i2cst->offset; i++) {
+            data |= (((uint32_t)i2cst->data[i]) << (8 * (i - 1)));
+        }
+    } else {
+        for (i = 1; i < i2cst->offset; i++) {
+            data <<= 8;
+            data |= i2cst->data[i];
+        }
+    }
+
+    return data;
+}

Why is this endianess test  needed ? Something looks wrong.

Could you please explain the endianess used by the various devices and
the endianness of the MMIO ops ?

If you want to test on a BE host, simply install a debian PPC64 VM/LPAR
on a POWER9/10 box. I suppose you have access to one in IBM.

I found it's not that simple anymore since all distros moved to little endian. 
I have been using Fedora 28 for big endian tests for swtpm but I have never 
tried it with QEMU...


... Fedora 28 is still good enough to build QEMU.

   Stefan

    Stefan


Reply via email to