MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / _mm_aspace_map_phy

Function _mm_aspace_map_phy

components/mm/mm_aspace.c:752–806  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

750}
751
752int _mm_aspace_map_phy(rt_aspace_t aspace, rt_varea_t varea,
753 rt_mm_va_hint_t hint, rt_size_t attr, rt_size_t pa_off,
754 void **ret_va)
755{
756 int err;
757 void *vaddr;
758
759 if (!aspace || !hint || !hint->limit_range_size || !hint->map_size)
760 {
761 LOG_W("%s: Invalid input", __func__);
762 err = -RT_EINVAL;
763 }
764 else if (_not_align(hint->prefer, hint->map_size, ARCH_PAGE_MASK))
765 {
766 LOG_W("%s: not aligned", __func__);
767 err = -RT_EINVAL;
768 }
769 else if (_not_in_range(hint->flags, hint->limit_start, hint->limit_range_size, aspace->start,
770 aspace->size) ||
771 _not_in_range(hint->flags, hint->prefer, hint->map_size, aspace->start,
772 aspace->size))
773 {
774 LOG_W("%s: not in range", __func__);
775 err = -RT_EINVAL;
776 }
777 else
778 {
779 struct _mapping_property prop = INIT_PROP(0, pa_off, hint->flags, attr);
780
781 WR_LOCK(aspace);
782 err = _varea_install(aspace, &varea, hint, &prop, &vaddr);
783 if (err == RT_EOK)
784 {
785 err = _do_named_map(aspace, varea, varea->start, varea->size,
786 (rt_size_t)pa_off, attr);
787
788 if (err != RT_EOK)
789 {
790 _varea_uninstall_locked(varea);
791 }
792 }
793
794 WR_UNLOCK(aspace);
795 }
796
797 if (ret_va)
798 {
799 if (err == RT_EOK)
800 *ret_va = vaddr;
801 else
802 *ret_va = RT_NULL;
803 }
804
805 return err;
806}
807
808int rt_aspace_map_phy(rt_aspace_t aspace, rt_mm_va_hint_t hint, rt_size_t attr,
809 rt_size_t pa_off, void **ret_va)

Callers 2

rt_aspace_map_phyFunction · 0.85
rt_aspace_map_phy_staticFunction · 0.85

Calls 5

_not_alignFunction · 0.85
_not_in_rangeFunction · 0.85
_varea_installFunction · 0.85
_do_named_mapFunction · 0.85
_varea_uninstall_lockedFunction · 0.85

Tested by

no test coverage detected