fixed bug that mapping PAGE_DIR_SELF_REF would incorrectly allocate a new physical page
git-svn-id: svn://anubis/hos/trunk@101 5b3e749e-e535-0410-8002-a9bb6afbdfca
This commit is contained in:
parent
563758b1bd
commit
4b688a3ce0
@ -147,7 +147,8 @@ void mm_bootstrap()
|
|||||||
/* ok, now mm_early_map() should be functional */
|
/* ok, now mm_early_map() should be functional */
|
||||||
|
|
||||||
/* map in the page directory itself so we can modify it once paging is on */
|
/* map in the page directory itself so we can modify it once paging is on */
|
||||||
mm_early_map(PAGE_DIR_SELF_REF2, page_directory_phys, 0, 1);
|
(*early_page_directory_ptr)[PAGE_DIR_SELF_REF_INDEX] =
|
||||||
|
(page_directory_phys) | (0x1 << 1) | (0x1);
|
||||||
|
|
||||||
/* map in the physical page allocator pages */
|
/* map in the physical page allocator pages */
|
||||||
for (int i = 0; i <= last_page_alloc_page; i++)
|
for (int i = 0; i <= last_page_alloc_page; i++)
|
||||||
@ -250,14 +251,14 @@ int mm_early_map(u32_t virtual_address, u32_t physical_address,
|
|||||||
}
|
}
|
||||||
pagedirectory_entry_t * page_table_virt = (pagedirectory_entry_t *)
|
pagedirectory_entry_t * page_table_virt = (pagedirectory_entry_t *)
|
||||||
(page_table_phys + KERNEL_OFFSET);
|
(page_table_phys + KERNEL_OFFSET);
|
||||||
for (int i = 0; i < NUM_PAGETABLE_ENTRIES; i++)
|
for (unsigned int i = 0; i < NUM_PAGETABLE_ENTRIES; i++)
|
||||||
{
|
{
|
||||||
page_table_virt[i] = 0;
|
page_table_virt[i] = 0;
|
||||||
}
|
}
|
||||||
(*early_page_directory_ptr)[directory_index] = page_table_phys
|
(*early_page_directory_ptr)[directory_index] = page_table_phys
|
||||||
| 0x1 << 2 /* PTs can be user mode */
|
| (0x1 << 2) /* PTs can be user mode */
|
||||||
| 0x1 << 1 /* writable */
|
| (0x1 << 1) /* writable */
|
||||||
| 0x1; /* present */
|
| (0x1); /* present */
|
||||||
}
|
}
|
||||||
u32_t page_table_phys =
|
u32_t page_table_phys =
|
||||||
(*early_page_directory_ptr)[directory_index] & PAGE_HIGH_MASK;
|
(*early_page_directory_ptr)[directory_index] & PAGE_HIGH_MASK;
|
||||||
@ -266,8 +267,8 @@ int mm_early_map(u32_t virtual_address, u32_t physical_address,
|
|||||||
(pagedirectory_entry_t *) (page_table_phys + KERNEL_OFFSET);
|
(pagedirectory_entry_t *) (page_table_phys + KERNEL_OFFSET);
|
||||||
|
|
||||||
page_table[table_index] = (physical_address & PAGE_HIGH_MASK)
|
page_table[table_index] = (physical_address & PAGE_HIGH_MASK)
|
||||||
| (user_mode & 0x1) << 2
|
| ((user_mode & 0x1) << 2)
|
||||||
| (writable & 0x1) << 1
|
| ((writable & 0x1) << 1)
|
||||||
| 0x1; /* present */
|
| 0x1; /* present */
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@ -294,18 +295,23 @@ int mm_map(u32_t virtual_address, u32_t physical_address,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
*page_dir_entry = page_table_phys
|
*page_dir_entry = page_table_phys
|
||||||
| 0x1 << 2 /* PTs can be user mode */
|
| (0x1 << 2) /* PTs can be user mode */
|
||||||
| 0x1 << 1 /* writable */
|
| (0x1 << 1) /* writable */
|
||||||
| 0x1; /* present */
|
| (0x1); /* present */
|
||||||
/* FIXME pagedirectory_entry_t * page_table = */
|
pagedirectory_entry_t * page_table = (pagedirectory_entry_t *)
|
||||||
|
(PAGE_DIR_SELF_REF | (directory_index << 12));
|
||||||
|
for (unsigned int i = 0; i < NUM_PAGETABLE_ENTRIES; i++)
|
||||||
|
{
|
||||||
|
page_table[i] = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pagedirectory_entry_t * page_table_entry = (pagedirectory_entry_t *)
|
pagedirectory_entry_t * page_table_entry = (pagedirectory_entry_t *)
|
||||||
(PAGE_DIR_SELF_REF | (directory_index << 12) | (table_index << 2));
|
(PAGE_DIR_SELF_REF | (directory_index << 12) | (table_index << 2));
|
||||||
|
|
||||||
*page_table_entry = (physical_address & PAGE_HIGH_MASK)
|
*page_table_entry = (physical_address & PAGE_HIGH_MASK)
|
||||||
| (user_mode & 0x1) << 2
|
| ((user_mode & 0x1) << 2)
|
||||||
| (writable & 0x1) << 1
|
| ((writable & 0x1) << 1)
|
||||||
| 0x1; /* present */
|
| 0x1; /* present */
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user