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

Function lwp_data_get

components/lwp/lwp_user_mm.c:845–898  ·  view source on GitHub ↗

src is in lwp address space, dst is in current thread space */

Source from the content-addressed store, hash-verified

843
844/* src is in lwp address space, dst is in current thread space */
845size_t lwp_data_get(struct rt_lwp *lwp, void *dst, void *src, size_t size)
846{
847 size_t copy_len = 0;
848 char *temp_page = 0;
849 char *dst_iter, *dst_next_page;
850 char *src_copy_end, *src_iter, *src_iter_aligned;
851
852 if (!size || !dst)
853 {
854 return 0;
855 }
856 dst_iter = dst;
857 src_iter = src;
858 src_copy_end = src + size;
859 dst_next_page =
860 (char *)(((size_t)src_iter + ARCH_PAGE_SIZE) & ~(ARCH_PAGE_SIZE - 1));
861 do
862 {
863 size_t bytes_to_copy = (char *)dst_next_page - (char *)src_iter;
864 if (bytes_to_copy > size)
865 {
866 bytes_to_copy = size;
867 }
868
869 if (ALIGNED(src_iter) && bytes_to_copy == ARCH_PAGE_SIZE)
870 {
871 /* get page to kernel buffer */
872 if (rt_aspace_page_get(lwp->aspace, src_iter, dst_iter))
873 break;
874 }
875 else
876 {
877 if (!temp_page)
878 temp_page = rt_pages_alloc_ext(0, PAGE_ANY_AVAILABLE);
879 if (!temp_page)
880 break;
881
882 src_iter_aligned = (char *)((long)src_iter & ~ARCH_PAGE_MASK);
883 if (rt_aspace_page_get(lwp->aspace, src_iter_aligned, temp_page))
884 break;
885 memcpy(dst_iter, temp_page + (src_iter - src_iter_aligned), bytes_to_copy);
886 }
887
888 dst_iter = dst_iter + bytes_to_copy;
889 src_iter = src_iter + bytes_to_copy;
890 size -= bytes_to_copy;
891 dst_next_page = (void *)((char *)dst_next_page + ARCH_PAGE_SIZE);
892 copy_len += bytes_to_copy;
893 } while (src_iter < src_copy_end);
894
895 if (temp_page)
896 rt_pages_free(temp_page, 0);
897 return copy_len;
898}
899
900/* dst is in lwp address space, src is in current thread space */
901size_t lwp_data_put(struct rt_lwp *lwp, void *dst, void *src, size_t size)

Callers 7

lwp_get_envpFunction · 0.85
elf_user_dumpFunction · 0.85
lwp_get_from_userFunction · 0.85
lwp_user_strlen_extFunction · 0.85
_bt_uaddrFunction · 0.85
_bt_uaddrFunction · 0.85

Calls 3

rt_aspace_page_getFunction · 0.85
rt_pages_alloc_extFunction · 0.85
rt_pages_freeFunction · 0.85

Tested by

no test coverage detected