mailbox.c 831 B

1234567891011121314151617181920212223242526272829303132
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (c) 2016, NVIDIA CORPORATION.
  4. */
  5. #include <common.h>
  6. #include <dm.h>
  7. #include <malloc.h>
  8. #include <dm/test.h>
  9. #include <asm/mbox.h>
  10. #include <test/test.h>
  11. #include <test/ut.h>
  12. static int dm_test_mailbox(struct unit_test_state *uts)
  13. {
  14. struct udevice *dev;
  15. uint32_t msg;
  16. ut_assertok(uclass_get_device_by_name(UCLASS_MISC, "mbox-test", &dev));
  17. ut_assertok(sandbox_mbox_test_get(dev));
  18. ut_asserteq(-ETIMEDOUT, sandbox_mbox_test_recv(dev, &msg));
  19. ut_assertok(sandbox_mbox_test_send(dev, 0xaaff9955UL));
  20. ut_assertok(sandbox_mbox_test_recv(dev, &msg));
  21. ut_asserteq(msg, 0xaaff9955UL ^ SANDBOX_MBOX_PING_XOR);
  22. ut_asserteq(-ETIMEDOUT, sandbox_mbox_test_recv(dev, &msg));
  23. ut_assertok(sandbox_mbox_test_free(dev));
  24. return 0;
  25. }
  26. DM_TEST(dm_test_mailbox, UT_TESTF_SCAN_FDT);