aboutsummaryrefslogtreecommitdiff
path: root/tests/qtest/tpm-util.c
diff options
context:
space:
mode:
authorStefan Berger <stefanb@linux.ibm.com>2023-03-31 13:30:50 -0400
committerThomas Huth <thuth@redhat.com>2023-04-20 11:25:32 +0200
commitf8d64616932805c5a5efea1a6a5bfee630d0096b (patch)
treebcb3cfd9d46e8ba282e9164d8fc44f6a1b92a240 /tests/qtest/tpm-util.c
parenta3ebb580a21c89d22ac5f52bd70814c997f28893 (diff)
downloadqemu-f8d64616932805c5a5efea1a6a5bfee630d0096b.zip
qemu-f8d64616932805c5a5efea1a6a5bfee630d0096b.tar.gz
qemu-f8d64616932805c5a5efea1a6a5bfee630d0096b.tar.bz2
qtest: Move tpm_util_tis_transmit() into tpm-tis-utils.c and rename it
To be able to remove tpm_tis_base_addr from test cases that do not really need it move the tpm_util_tis_transmit() function into tpm-tis-utils.c and rename it to tpm_tis_transmit(). Fix a locality parameter in a test case on the way. Signed-off-by: Stefan Berger <stefanb@linux.ibm.com> Reviewed-by: Ninad Palsule <ninad@linux.ibm.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Message-Id: <20230331173051.3857801-3-stefanb@linux.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'tests/qtest/tpm-util.c')
-rw-r--r--tests/qtest/tpm-util.c45
1 files changed, 0 insertions, 45 deletions
diff --git a/tests/qtest/tpm-util.c b/tests/qtest/tpm-util.c
index a7efe2d..1c0319e 100644
--- a/tests/qtest/tpm-util.c
+++ b/tests/qtest/tpm-util.c
@@ -51,51 +51,6 @@ void tpm_util_crb_transfer(QTestState *s,
qtest_memread(s, raddr, rsp, rsp_size);
}
-void tpm_util_tis_transfer(QTestState *s,
- const unsigned char *req, size_t req_size,
- unsigned char *rsp, size_t rsp_size)
-{
- uint32_t sts;
- uint16_t bcount;
- size_t i;
-
- /* request use of locality 0 */
- qtest_writeb(s, TIS_REG(0, TPM_TIS_REG_ACCESS), TPM_TIS_ACCESS_REQUEST_USE);
- qtest_writel(s, TIS_REG(0, TPM_TIS_REG_STS), TPM_TIS_STS_COMMAND_READY);
-
- sts = qtest_readl(s, TIS_REG(0, TPM_TIS_REG_STS));
- bcount = (sts >> 8) & 0xffff;
- g_assert_cmpint(bcount, >=, req_size);
-
- /* transmit command */
- for (i = 0; i < req_size; i++) {
- qtest_writeb(s, TIS_REG(0, TPM_TIS_REG_DATA_FIFO), req[i]);
- }
-
- /* start processing */
- qtest_writeb(s, TIS_REG(0, TPM_TIS_REG_STS), TPM_TIS_STS_TPM_GO);
-
- uint64_t end_time = g_get_monotonic_time() + 50 * G_TIME_SPAN_SECOND;
- do {
- sts = qtest_readl(s, TIS_REG(0, TPM_TIS_REG_STS));
- if ((sts & TPM_TIS_STS_DATA_AVAILABLE) != 0) {
- break;
- }
- } while (g_get_monotonic_time() < end_time);
-
- sts = qtest_readl(s, TIS_REG(0, TPM_TIS_REG_STS));
- bcount = (sts >> 8) & 0xffff;
-
- memset(rsp, 0, rsp_size);
- for (i = 0; i < bcount; i++) {
- rsp[i] = qtest_readb(s, TIS_REG(0, TPM_TIS_REG_DATA_FIFO));
- }
-
- /* relinquish use of locality 0 */
- qtest_writeb(s, TIS_REG(0, TPM_TIS_REG_ACCESS),
- TPM_TIS_ACCESS_ACTIVE_LOCALITY);
-}
-
void tpm_util_startup(QTestState *s, tx_func *tx)
{
unsigned char buffer[1024];