Updated vmm and pmm

This commit is contained in:
lucic71 2022-06-28 19:40:51 +03:00
parent aeb4561364
commit ab93ad2de1
3 changed files with 24 additions and 56 deletions

View File

@ -12,12 +12,12 @@
* pmm_init:
* Initializes the Physical Memory Manager.
*
* @param mmap_addr - Physical memory address of memory map data structure
* @param size - Size of available physical memory in KB
* @param pmmap_addr - Physical memory address of memory map data structure
* @param size - Size of available physical memory in KB
*
*/
void pmm_init(uint32_t mmap_addr, size_t size);
void pmm_init(uint32_t pmmap_addr, size_t size);
/*
* pmm_init_region:

View File

@ -1,71 +1,39 @@
#ifndef VMM_H_
#define VMM_H_
#include <stdint.h>
/*
* vmm_init:
* Initialize the Virtual Memory Manager.
* Initialize the Virtual Memory Manager. At the moment it does not
* support Higher Half Kernel. It just identity-maps the first 4MB
* of physical memory.
*
*/
void vmm_init(void);
/*
* vmm_ptable_search:
* Given a virtual address, search for its corresponding entry
* in Page Table.
*
* @param ptable - Pointer to the beginning of the Page Table
* @param virt_addr - Virtual address
*
* @return - Pointer to corresponding Page Table entry
*
*/
uint32_t *vmm_ptable_search(uint32_t *ptable, uint32_t virt_addr);
/*
* vmm_pdir_search:
* Given a virtual address, search for its corresponding entry
* in Page Directory.
*
* @param pdir - Pointer to the beginning of the Page Directory
* @param virt_addr - Virtual address
*
* @return - Pointer to corresponding Page Directory entry
*
*/
uint32_t *vmm_pdir_search(uint32_t *pdir, uint32_t virt_addr);
/*
* vmm_install_pdir:
* Install a Page Directory.
*
* @param pdir - Pointer to a Page Directory
*
*/
void vmm_install_pdir(uint32_t *pdir);
/*
* vmm_flush_tlb:
* Flush the Translation Lookaside Buffer.
*
* @param virt_tlb - Virtual address of TLB
*
*/
void vmm_flush_tlb(uint32_t virt_tlb);
/*
* vmm_map_page:
* Maps physical address to virtual address.
* Maps physical address to virtual address. This routine must be called
* only after paging was enabled (aka after vmm_init).
*
* @param phys - Physical address
* @param virt - Virtual address
*
*/
void vmm_map_addr(uint32_t phys, uint32_t virt);
int vmm_map_addr(uint32_t phys, uint32_t virt);
/*
* vmm_unmap_page:
* Unmaps a virtual address. This routine must be called only after paging
* was enabled (aka after vmm_init).
*
* @param virt - Virtual address
*
*/
void vmm_unmap_addr(uint32_t virt);
#endif

View File

@ -17,12 +17,12 @@
*
*/
void pmm_init(uint32_t mmap_addr, size_t size) {
void pmm_init(uint32_t pmmap_addr, size_t size) {
mem_size = size;
max_blocks = (mem_size * 1024) / BLOCK_SIZE;
used_blocks = max_blocks;
pmmap = (uint32_t *) mmap_addr;
pmmap = (uint32_t *) pmmap_addr;
pmmap_size = mem_size / BLOCKS_PER_BYTE;
if (mem_size % BLOCKS_PER_BYTE)