#define ET_TEST_IMPL #include "../test.h" #include et_test_status test_exi_readwrite(struct et_test_plan *plan, void *data, size_t data_sz, et_test_error base, struct et_next_state *next_state) { struct et_test_plan_entry *cur = test_current(plan); int chan = plan->exi_channel; et_test_status status = TEST_PASS; s32 exi_res; if ((exi_res = EXI_Lock(chan, EXI_DEVICE_0, NULL)) <= 0) { status = TEST_ERROR(base); test_plan_entry_set_error(cur, "failed to lock EXI channel: %" PRId32, exi_res); goto fail_lock; } if ((exi_res = EXI_Select(chan, EXI_DEVICE_0, EXI_SPEED32MHZ)) <= 0) { status = TEST_ERROR(base + 1); test_plan_entry_set_error(cur, "failed to select EXI channel: %" PRId32, exi_res); goto fail_select; } if ((exi_res = EXI_Imm(chan, data, data_sz, EXI_READWRITE, NULL)) <= 0) { status = TEST_ERROR(base + 2); test_plan_entry_set_error(cur, "failed to send EXI data: %" PRId32, exi_res); goto fail_data; } if ((exi_res = EXI_Sync(chan)) <= 0) { status = TEST_ERROR(base + 3); test_plan_entry_set_error(cur, "failed to complete transfer: %" PRId32, exi_res); goto fail_data; } fail_data: EXI_Deselect(chan); fail_select: EXI_Unlock(chan); fail_lock: cur->status = status; return status; } static int check_id_tick(const struct et_state *state, void *data, struct et_next_state *next_state) { struct et_test_state_private_base *priv = data; struct et_test_plan *test_plan = priv->plan; struct et_test_plan_entry *cur = test_current(test_plan); et_test_status status = TEST_PASS; u16 command = 0x9000; if ((status = test_exi_readwrite(test_plan, &command, sizeof(command), TEST_EPRIV_BASE, next_state)) != TEST_PASS) { return test_next(test_plan, next_state); } if (command != 0x0470) { test_plan_entry_set_error(cur, "bad identifier from gecko: expected 0x0470, got 0x%04" PRIx16, command); status = TEST_FAIL; } cur->status = TEST_PASS; return test_next(test_plan, next_state); } TEST_DEF(check_id, "Identify Gecko (0x09)", TEST_PAUSE_ON_ERROR, NULL, check_id_tick, NULL, struct et_test_state_private_base);