예제 #1
0
bool vmmngr_is_page_present(virtual_addr addr)
{
	pd_entry* e = vmmngr_pdirectory_lookup_entry(vmmngr_get_directory(), addr);
	if (e == 0 || pd_entry_is_present(*e) == false)
		return false;

	ptable* table = (ptable*)pd_entry_get_frame(*e);
	if (table == 0)
		return false;

	pt_entry* page = vmmngr_ptable_lookup_entry(table, addr);
	if (page == 0 || pt_entry_is_present(*page) == false)
		return false;

	return true;
}
예제 #2
0
파일: mmngr_virtual.c 프로젝트: cjo20/cos
int vmmngr_alloc_page(virtual_addr virt)
{
	pdirectory * pd = (pdirectory *) PAGE_DIRECTORY_ADDRESS;
	pd_entry * pde = &pd->m_entries[PAGE_DIRECTORY_INDEX(virt)];

	if ((!pd) || (!pde))
	{
		return 0;
	}

	if (!pd_entry_is_present(*pde))
	{
		ptable *newpt = pmmngr_alloc_block();

		if (!newpt)
		{
			return 0;
		}

		*pde = (pd_entry) 0;

		pd_entry_add_attrib(pde, I86_PDE_PRESENT);
		pd_entry_add_attrib(pde, I86_PDE_WRITABLE);
		pd_entry_set_frame(pde, (physical_addr) newpt);

		memset(vmmngr_get_ptable_address(virt), 0, sizeof(ptable));

	}

	ptable * pt = vmmngr_get_ptable_address(virt);

	pt_entry *pte = &pt->m_entries[PAGE_TABLE_INDEX(virt)];

	if  (pt_entry_is_present(*pte))
	{
		return 1;
	}

	if (!vmmngr_commit_page(pte))
	{
		return 0;
	}

	return 1;	
}