From eea83bca26b2f70882f41876e55a63d9e05116b0 Mon Sep 17 00:00:00 2001 From: Amaury Pouly Date: Tue, 3 Sep 2024 09:07:32 +0000 Subject: [PATCH] [rv_plic,dif,unittest] Add some type casts The DT commit changed the type `dif_rv_plic_irq_id_t` from `uint32_t` to an enumeration. This makes certain implicit casts in the C++ code invalid now. Signed-off-by: Amaury Pouly --- sw/device/lib/dif/dif_rv_plic_unittest.cc | 26 +++++++++++------------ 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/sw/device/lib/dif/dif_rv_plic_unittest.cc b/sw/device/lib/dif/dif_rv_plic_unittest.cc index bbc69d7b2861af..a0c4b806b807b5 100644 --- a/sw/device/lib/dif/dif_rv_plic_unittest.cc +++ b/sw/device/lib/dif/dif_rv_plic_unittest.cc @@ -146,7 +146,7 @@ constexpr std::array class IrqEnableSetTest : public IrqTest {}; TEST_F(IrqEnableSetTest, NullArgs) { - EXPECT_DIF_BADARG(dif_rv_plic_irq_set_enabled(nullptr, kFirstIrq, kTarget0, + EXPECT_DIF_BADARG(dif_rv_plic_irq_set_enabled(nullptr, (dif_rv_plic_irq_id_t)kFirstIrq, kTarget0, kDifToggleEnabled)); } @@ -156,7 +156,7 @@ TEST_F(IrqEnableSetTest, Target0Enable) { // Enable every IRQ, one at a time. for (int i = 0; i < RV_PLIC_PARAM_NUM_SRC; ++i) { EXPECT_DIF_OK( - dif_rv_plic_irq_set_enabled(&plic_, i, kTarget0, kDifToggleEnabled)); + dif_rv_plic_irq_set_enabled(&plic_, (dif_rv_plic_irq_id_t)i, kTarget0, kDifToggleEnabled)); } } @@ -166,7 +166,7 @@ TEST_F(IrqEnableSetTest, Target0Disable) { // Disable every bit, one at a time. for (int i = 0; i < RV_PLIC_PARAM_NUM_SRC; ++i) { EXPECT_DIF_OK( - dif_rv_plic_irq_set_enabled(&plic_, i, kTarget0, kDifToggleDisabled)); + dif_rv_plic_irq_set_enabled(&plic_, (dif_rv_plic_irq_id_t)i, kTarget0, kDifToggleDisabled)); } } @@ -174,11 +174,11 @@ class IrqPrioritySetTest : public PlicTest {}; TEST_F(IrqPrioritySetTest, NullArgs) { EXPECT_DIF_BADARG( - dif_rv_plic_irq_set_priority(nullptr, kFirstIrq, kDifRvPlicMaxPriority)); + dif_rv_plic_irq_set_priority(nullptr, (dif_rv_plic_irq_id_t)kFirstIrq, kDifRvPlicMaxPriority)); } TEST_F(IrqPrioritySetTest, PriorityInvalid) { - EXPECT_DIF_BADARG(dif_rv_plic_irq_set_priority(nullptr, kFirstIrq, + EXPECT_DIF_BADARG(dif_rv_plic_irq_set_priority(nullptr, (dif_rv_plic_irq_id_t)kFirstIrq, kDifRvPlicMaxPriority + 1)); } @@ -189,7 +189,7 @@ TEST_F(IrqPrioritySetTest, Success) { EXPECT_WRITE32(offset, kDifRvPlicMaxPriority); EXPECT_DIF_OK( - dif_rv_plic_irq_set_priority(&plic_, i, kDifRvPlicMaxPriority)); + dif_rv_plic_irq_set_priority(&plic_, (dif_rv_plic_irq_id_t)i, kDifRvPlicMaxPriority)); } } @@ -216,13 +216,13 @@ class IrqPendingStatusGetTest : public IrqTest {}; TEST_F(IrqPendingStatusGetTest, NullArgs) { bool status; - dif_result_t result = dif_rv_plic_irq_is_pending(nullptr, kFirstIrq, &status); + dif_result_t result = dif_rv_plic_irq_is_pending(nullptr, (dif_rv_plic_irq_id_t)kFirstIrq, &status); EXPECT_DIF_BADARG(result); - result = dif_rv_plic_irq_is_pending(&plic_, kFirstIrq, nullptr); + result = dif_rv_plic_irq_is_pending(&plic_, (dif_rv_plic_irq_id_t)kFirstIrq, nullptr); EXPECT_DIF_BADARG(result); - result = dif_rv_plic_irq_is_pending(nullptr, kFirstIrq, nullptr); + result = dif_rv_plic_irq_is_pending(nullptr, (dif_rv_plic_irq_id_t)kFirstIrq, nullptr); EXPECT_DIF_BADARG(result); } @@ -232,7 +232,7 @@ TEST_F(IrqPendingStatusGetTest, Enabled) { // Get status of every IRQ, one at a time. for (int i = 0; i < RV_PLIC_PARAM_NUM_SRC; ++i) { bool status; - dif_result_t result = dif_rv_plic_irq_is_pending(&plic_, i, &status); + dif_result_t result = dif_rv_plic_irq_is_pending(&plic_, (dif_rv_plic_irq_id_t)i, &status); EXPECT_DIF_OK(result); EXPECT_TRUE(status); } @@ -244,7 +244,7 @@ TEST_F(IrqPendingStatusGetTest, Disabled) { // Get status of every IRQ, one at a time. for (int i = 0; i < RV_PLIC_PARAM_NUM_SRC; ++i) { bool status; - dif_result_t result = dif_rv_plic_irq_is_pending(&plic_, i, &status); + dif_result_t result = dif_rv_plic_irq_is_pending(&plic_, (dif_rv_plic_irq_id_t)i, &status); EXPECT_DIF_OK(result); EXPECT_FALSE(status); } @@ -282,7 +282,7 @@ class IrqCompleteTest : public PlicTest { }; TEST_F(IrqCompleteTest, NullArgs) { - EXPECT_DIF_BADARG(dif_rv_plic_irq_complete(nullptr, kTarget0, 0)); + EXPECT_DIF_BADARG(dif_rv_plic_irq_complete(nullptr, kTarget0, (dif_rv_plic_irq_id_t)0)); } TEST_F(IrqCompleteTest, Target0Success) { @@ -293,7 +293,7 @@ TEST_F(IrqCompleteTest, Target0Success) { // Complete all of the IRQs. for (int i = 0; i < RV_PLIC_PARAM_NUM_SRC; ++i) { - EXPECT_DIF_OK(dif_rv_plic_irq_complete(&plic_, kTarget0, i)); + EXPECT_DIF_OK(dif_rv_plic_irq_complete(&plic_, kTarget0, (dif_rv_plic_irq_id_t)i)); } }