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

Function _install_page

components/mm/mm_page.c:1061–1125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1059}
1060
1061static void _install_page(rt_page_t mpr_head, rt_region_t region,
1062 void (*insert)(rt_page_t *ppg, rt_page_t page, rt_uint32_t size_bits))
1063{
1064 pgls_agr_t *page_list;
1065 rt_page_t *page_head;
1066 rt_region_t shadow;
1067 const rt_base_t pvoffset = PV_OFFSET;
1068
1069 _page_nr += ((region.end - region.start) >> ARCH_PAGE_SHIFT);
1070 _freed_nr += ((region.end - region.start) >> ARCH_PAGE_SHIFT);
1071
1072 shadow.start = region.start & ~shadow_mask;
1073 shadow.end = CEIL(region.end, shadow_mask + 1);
1074
1075 if (shadow.end + pvoffset > UINT32_MAX)
1076 _high_page_configured = 1;
1077
1078 rt_page_t shad_head = addr_to_page(mpr_head, (void *)shadow.start);
1079 rt_page_t shad_tail = addr_to_page(mpr_head, (void *)shadow.end);
1080 rt_page_t head = addr_to_page(mpr_head, (void *)region.start);
1081 rt_page_t tail = addr_to_page(mpr_head, (void *)region.end);
1082
1083 /* mark shadow page records not belongs to other region as illegal */
1084 _invalid_uninstalled_shadow(shad_head, head);
1085 _invalid_uninstalled_shadow(tail, shad_tail);
1086
1087 /* insert reserved pages to list */
1088 const int max_order = RT_PAGE_MAX_ORDER + ARCH_PAGE_SHIFT - 1;
1089 while (region.start != region.end)
1090 {
1091 struct rt_page *p;
1092 int align_bits;
1093 int size_bits;
1094 int page_order;
1095
1096 size_bits =
1097 ARCH_ADDRESS_WIDTH_BITS - 1 - rt_hw_clz(region.end - region.start);
1098 align_bits = rt_hw_ctz(region.start);
1099 if (align_bits < size_bits)
1100 {
1101 size_bits = align_bits;
1102 }
1103 if (size_bits > max_order)
1104 {
1105 size_bits = max_order;
1106 }
1107
1108 p = addr_to_page(mpr_head, (void *)region.start);
1109 p->size_bits = ARCH_ADDRESS_WIDTH_BITS;
1110 p->ref_cnt = 0;
1111
1112 /* insert to list */
1113 page_list = _get_page_list((void *)region.start);
1114 if (page_list == page_list_high)
1115 {
1116 _page_nr_hi += 1 << (size_bits - ARCH_PAGE_SHIFT);
1117 _freed_nr_hi += 1 << (size_bits - ARCH_PAGE_SHIFT);
1118 }

Callers 2

rt_page_initFunction · 0.85
_get_mpr_ready_n_installFunction · 0.85

Calls 6

addr_to_pageFunction · 0.85
rt_hw_clzFunction · 0.85
rt_hw_ctzFunction · 0.85
_get_page_listFunction · 0.85
_get_pgls_head_by_pageFunction · 0.85

Tested by

no test coverage detected