add helper function to map a page frame into the boot page table
This commit is contained in:
parent
2e75a39295
commit
211fa113f0
2 changed files with 26 additions and 7 deletions
|
@ -112,9 +112,18 @@ size_t page_virt_to_phys(size_t vir);
|
|||
* Before calling page_init(), the bootstrap tables contain a simple identity
|
||||
* paging. Which is replaced by more specific mappings.
|
||||
*/
|
||||
int page_init();
|
||||
int page_init(void);
|
||||
|
||||
/** @brief Map a continious region of pages
|
||||
/** @brief Map one page into the boot page table
|
||||
*
|
||||
* @param viraddr
|
||||
* @param phyaddr
|
||||
* @param bits
|
||||
* @return
|
||||
*/
|
||||
int page_map_bootmap(size_t viraddr, size_t phyaddr, size_t bits);
|
||||
|
||||
/** @brief Map a continuous region of pages
|
||||
*
|
||||
* @param viraddr
|
||||
* @param phyaddr
|
||||
|
@ -124,7 +133,7 @@ int page_init();
|
|||
*/
|
||||
int page_map(size_t viraddr, size_t phyaddr, size_t npages, size_t bits);
|
||||
|
||||
/** @brief Unmap a continious region of pages
|
||||
/** @brief Unmap a continuous region of pages
|
||||
*
|
||||
* @param viraddr
|
||||
* @param npages
|
||||
|
@ -141,6 +150,6 @@ int page_unmap(size_t viraddr, size_t npages);
|
|||
int page_map_copy(task_t *dest);
|
||||
|
||||
/** @brief Free a whole page map tree */
|
||||
int page_map_drop();
|
||||
int page_map_drop(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -53,7 +53,7 @@ extern const void kernel_end;
|
|||
static spinlock_t kslock = SPINLOCK_INIT;
|
||||
|
||||
/** This PGD table is initialized in entry.asm */
|
||||
extern size_t boot_map[PAGE_MAP_ENTRIES];
|
||||
extern size_t* boot_map;
|
||||
|
||||
/** A self-reference enables direct access to all page tables */
|
||||
static size_t* self[PAGE_LEVELS] = {
|
||||
|
@ -77,6 +77,16 @@ size_t page_virt_to_phys(size_t addr)
|
|||
return phy | off;
|
||||
}
|
||||
|
||||
int page_map_bootmap(size_t viraddr, size_t phyaddr, size_t bits)
|
||||
{
|
||||
if (BUILTIN_EXPECT(viraddr >= PAGE_MAP_ENTRIES*PAGE_SIZE, 0))
|
||||
return -EINVAL;
|
||||
|
||||
boot_map[PAGE_MAP_ENTRIES + (viraddr >> PAGE_BITS)] = phyaddr | bits | PG_PRESENT;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int page_map(size_t viraddr, size_t phyaddr, size_t npages, size_t bits)
|
||||
{
|
||||
int lvl, ret = -ENOMEM;
|
||||
|
@ -160,7 +170,7 @@ int page_unmap(size_t viraddr, size_t npages)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int page_map_drop()
|
||||
int page_map_drop(void)
|
||||
{
|
||||
void traverse(int lvl, long vpn) {
|
||||
long stop;
|
||||
|
@ -248,7 +258,7 @@ void page_fault_handler(struct state *s)
|
|||
while(1) HALT;
|
||||
}
|
||||
|
||||
int page_init()
|
||||
int page_init(void)
|
||||
{
|
||||
size_t addr, npages;
|
||||
int i;
|
||||
|
|
Loading…
Add table
Reference in a new issue