rt_ioremap.c 946 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Copyright (c) 2006-2023, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2022-12-14 WangXiaoyao the first version
  9. * 2023-03-20 WangXiaoyao Format & add more testcases for API under mm_aspace.h
  10. */
  11. #include "common.h"
  12. void ioremap_tc(void)
  13. {
  14. const size_t bufsz = 0x1000;
  15. void *paddr = (void *)rt_pages_alloc(rt_page_bits(bufsz)) + PV_OFFSET;
  16. int *vaddr;
  17. vaddr = rt_ioremap_cached(paddr, bufsz);
  18. if (vaddr)
  19. {
  20. TC_ASSERT(*vaddr == *(int *)(paddr - PV_OFFSET));
  21. rt_iounmap(vaddr);
  22. rt_pages_free(paddr - PV_OFFSET, 0);
  23. }
  24. }
  25. static rt_err_t utest_tc_init(void)
  26. {
  27. return RT_EOK;
  28. }
  29. static rt_err_t utest_tc_cleanup(void)
  30. {
  31. return RT_EOK;
  32. }
  33. static void test_main(void)
  34. {
  35. CONSIST_HEAP(ioremap_tc());
  36. }
  37. UTEST_TC_EXPORT(test_main, "testcases.mm.ioremap", utest_tc_init, utest_tc_cleanup, 20);