将页计数移入架构支持中(因为不同的架构分页机制不同)
This commit is contained in:
parent
0613dadeaf
commit
c52d9f4960
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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++)
|
||||
{
|
||||
|
|
Reference in New Issue