将页计数移入架构支持中(因为不同的架构分页机制不同)

This commit is contained in:
pointer-to-bios 2024-02-19 01:03:27 +08:00
parent 0613dadeaf
commit c52d9f4960
3 changed files with 52 additions and 39 deletions

View File

@ -250,4 +250,21 @@ extern void reload_pml4();
? MEMM_PAGE_SIZE_2M \
: MEMM_PAGE_SIZE_4K))
/**
* @name memm_page_counter
* @addindex
*
*
*
* @if arch == x86_64
* 使`4KB``2MB``1GB`
* @endif
*/
typedef struct __memm_page_counter
{
usize mapped_4k_page;
usize mapped_2m_page;
usize mapped_1g_page;
} memm_page_counter;
#endif

View File

@ -186,11 +186,7 @@ typedef struct __mem_manager_t
// 已经映射的页数量。若不是最小的页会被视作多个最小页计数。
usize mapped_page_amount;
#ifdef __x86_64__
usize mapped_4k_page;
usize mapped_2m_page;
usize mapped_1g_page;
#endif
memm_page_counter platformed_page_counter;
// 页地图。每个bit都表示这个页是否被映射。
u8 *page_map;

View File

@ -126,11 +126,11 @@ bool memm_map_pageframes_to(
switch (align)
{
case MEMM_PAGE_SIZE_4K:
mm->mapped_4k_page++;
mm->platformed_page_counter.mapped_4k_page++;
case MEMM_PAGE_SIZE_2M:
mm->mapped_2m_page++;
mm->platformed_page_counter.mapped_2m_page++;
case MEMM_PAGE_SIZE_1G:
mm->mapped_1g_page++;
mm->platformed_page_counter.mapped_1g_page++;
}
for (usize i = physical / MEMM_PAGE_SIZE; i < physical / MEMM_PAGE_SIZE + align; i++)
{