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 12 #include "common.h" 13 ioremap_tc(void)14void ioremap_tc(void) 15 { 16 const size_t bufsz = 0x1000; 17 void *paddr = (void *)rt_pages_alloc(rt_page_bits(bufsz)) + PV_OFFSET; 18 int *vaddr; 19 vaddr = rt_ioremap_cached(paddr, bufsz); 20 if (vaddr) 21 { 22 TC_ASSERT(*vaddr == *(int *)(paddr - PV_OFFSET)); 23 24 rt_iounmap(vaddr); 25 rt_pages_free(paddr - PV_OFFSET, 0); 26 } 27 } 28 utest_tc_init(void)29static rt_err_t utest_tc_init(void) 30 { 31 return RT_EOK; 32 } 33 utest_tc_cleanup(void)34static rt_err_t utest_tc_cleanup(void) 35 { 36 return RT_EOK; 37 } 38 test_main(void)39static void test_main(void) 40 { 41 CONSIST_HEAP(ioremap_tc()); 42 } 43 UTEST_TC_EXPORT(test_main, "testcases.mm.ioremap", utest_tc_init, utest_tc_cleanup, 20); 44