Skip to content

Commit

Permalink
Replace function headers pagging_flags_t type with size_t
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamos82 committed Jul 30, 2023
1 parent cd1f814 commit 1ed4b1c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/include/kernel/mem/vmm.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ void vmm_init(vmm_level_t vmm_level);
void *vmm_alloc(size_t size, size_t flags);
void vmm_free(void *address);

void *map_vaddress(void *address, paging_flags_t flags);
void *map_vaddress(void *address, size_t flags);
int unmap_vaddress(void *address);

void *map_phys_to_virt_addr(void* physical_address, void* address, paging_flags_t flags);
void identity_map_phys_address(void *pyhysical_address, paging_flags_t flags);
void map_vaddress_range(void *virtual_address, paging_flags_t flags, size_t required_pages);
void *map_phys_to_virt_addr(void* physical_address, void* address, size_t flags);
void identity_map_phys_address(void *pyhysical_address, size_t flags);
void map_vaddress_range(void *virtual_address, size_t flags, size_t required_pages);
uint8_t is_phyisical_address_mapped(uintptr_t physical_address, uintptr_t virtual_address);
uint8_t check_virt_address_status(uint64_t virtual_address);
void vmm_direct_map_physical_memory();
Expand Down
13 changes: 7 additions & 6 deletions src/kernel/mem/vmm.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ extern uint64_t end_of_mapped_memory;
void vmm_init(vmm_level_t vmm_level) {
//vmm_info.higherHalfDirectMapBase is where we will the Direct Mapping of physical memory will start.
higherHalfDirectMapBase = ((uint64_t) HIGHER_HALF_ADDRESS_OFFSET + VM_KERNEL_MEMORY_PADDING);
vmm_info.vmmDataStart = align_value_to_page(higherHalfDirectMapBase + memory_size_in_bytes + VM_KERNEL_MEMORY_PADDING);
//vmm_container_root = ((uint64_t) HIGHER_HALF_ADDRESS_OFFSET + VM_KERNEL_MEMORY_PADDING);

vmm_info.vmmDataStart = align_value_to_page(higherHalfDirectMapBase + memory_size_in_bytes + VM_KERNEL_MEMORY_PADDING);

vmm_container_root = (VmmContainer *) vmm_info.vmmDataStart;
end_of_vmm_data = (uint64_t) vmm_container_root + VMM_RESERVED_SPACE_SIZE;

Expand Down Expand Up @@ -266,7 +267,7 @@ int unmap_vaddress(void *address){
return 0;
}

void identity_map_phys_address(void *physical_address, paging_flags_t flags) {
void identity_map_phys_address(void *physical_address, size_t flags) {
map_phys_to_virt_addr(physical_address, physical_address, flags);
}

Expand All @@ -279,7 +280,7 @@ void identity_map_phys_address(void *physical_address, paging_flags_t flags) {
* @param flags the flags for the mapped page.
* @return address the virtual address specified in input, or NULL in case of error.
*/
void *map_phys_to_virt_addr(void* physical_address, void* address, paging_flags_t flags){
void *map_phys_to_virt_addr(void* physical_address, void* address, size_t flags){
uint16_t pml4_e = PML4_ENTRY((uint64_t) address);
uint64_t *pml4_table = (uint64_t *) (SIGN_EXTENSION | ENTRIES_TO_ADDRESS(510l,510l,510l,510l));

Expand Down Expand Up @@ -345,13 +346,13 @@ void *map_phys_to_virt_addr(void* physical_address, void* address, paging_flags_
return address;
}

void *map_vaddress(void *virtual_address, paging_flags_t flags){
void *map_vaddress(void *virtual_address, size_t flags){
loglinef(Verbose, "(map_vaddress) address: 0x%x", virtual_address);
void *new_addr = pmm_alloc_frame();
return map_phys_to_virt_addr(new_addr, virtual_address, flags);
}

void map_vaddress_range(void *virtual_address, paging_flags_t flags, size_t required_pages) {
void map_vaddress_range(void *virtual_address, size_t flags, size_t required_pages) {
for(size_t i = 0; i < required_pages; i++) {
map_vaddress(virtual_address + (i * PAGE_SIZE_IN_BYTES), flags);
}
Expand Down

0 comments on commit 1ed4b1c

Please sign in to comment.