解决多页映射时只映射第一个页的问题

This commit is contained in:
pointer-to-bios 2024-01-15 18:20:29 +08:00
parent 2d680b011b
commit 6f049d9ca2
1 changed files with 4 additions and 2 deletions

View File

@ -110,17 +110,19 @@ bool memm_map_pageframes_to(
return false; return false;
while (size != 0) while (size != 0)
{ {
// 这是当前需要映射的页的内存对齐(或者说是当前映射的页的大小)
memm_page_size align = memm_get_page_align(physical); memm_page_size align = memm_get_page_align(physical);
if (align == MEMM_PAGE_SIZE_1G) if (align == MEMM_PAGE_SIZE_1G)
{ {
if (size < (usize)align * MEMM_PAGE_SIZE / 2) if (size < (usize)align * MEMM_PAGE_SIZE / 2)
align = MEMM_2M_ALIGN_MASK; align = MEMM_2M_ALIGN_MASK + 1;
} }
if (align == MEMM_PAGE_SIZE_2M) if (align == MEMM_PAGE_SIZE_2M)
{ {
if (size < (usize)align * MEMM_PAGE_SIZE / 2) if (size < (usize)align * MEMM_PAGE_SIZE / 2)
align = MEMM_4K_ALIGN_MASK; align = MEMM_4K_ALIGN_MASK + 1;
} }
align /= MEMM_PAGE_SIZE;
map_pageframe_to(target, physical, user, write, align); map_pageframe_to(target, physical, user, write, align);