qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3 3/3] New I2C: Add support for TPM devices over I2C bus


From: Stefan Berger
Subject: Re: [PATCH v3 3/3] New I2C: Add support for TPM devices over I2C bus
Date: Fri, 24 Mar 2023 15:42:52 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0



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

[Prev in Thread] Current Thread [Next in Thread]