|
| bool | mmu_init (void) |
| | Initialize the MMU's paging system. More...
|
| |
| paddr_t | mmu_new (void) |
| | Allocate and initialize a new page directory. More...
|
| |
| void | mmu_destroy (paddr_t mmu) |
| | Release the MMU's page_directory. More...
|
| |
|
void | mmu_clone (paddr_t destination) |
| | Clone the current MMU inside another one.
|
| |
|
error_t | mmu_copy_on_write (vaddr_t) |
| | Try to remap a potential copy-on-write mapping.
|
| |
| void | mmu_load (paddr_t mmu) |
| | Replace the current page directory. More...
|
| |
| bool | mmu_map (vaddr_t virt, paddr_t physical, int prot) |
| | Map a virtual address to a physical one. More...
|
| |
| bool | mmu_map_range (vaddr_t virt, paddr_t physical, size_t size, int prot) |
| | Map a range of virtual addresses to physical ones. More...
|
| |
| paddr_t | mmu_unmap (vaddr_t virt) |
| | Unmap a virtual address. More...
|
| |
| void | mmu_unmap_range (vaddr_t start, vaddr_t end) |
| | Unmap a range of virtual addresses. More...
|
| |
| void | mmu_identity_map (paddr_t start, paddr_t end, int prot) |
| | Perform identity mapping inside a given virtual address range. More...
|
| |
| paddr_t | mmu_find_physical (vaddr_t) |
| | Find the physical mapping of a virtual address. More...
|
| |
| static bool | mmu_is_mapped (vaddr_t addr) |
| |
Memory Managerment Unit (MMU)
Interface with the CPU's hardware MMU.
The MMU automatically translates virtual addresses into physical ones. These physical addresses should be pages, allocated using the PMM. This whole translation process is called paging.
This includes:
- Enabling/Disabling paging
- Updating the underlying structures
TODO: It should ideally be possible to modify the content of another MMU. We have no efficient way of accessing an arbitrary physical address without having to go through the VMM to find an address.
◆ mmu_prot
| Enumerator |
|---|
| PROT_NONE | Pages may not be accessed
|
| PROT_EXEC | Pages may be executed
|
| PROT_READ | Pages may be read
|
| PROT_WRITE | Pages may be written
|
| PROT_KERNEL | Pages should be accessible only from the kernel
|
◆ mmu_destroy()
| void mmu_destroy |
( |
paddr_t |
mmu | ) |
|
- Note
- This function does not release all the memory that was potentially mapped by the MMU. This should be done separately by the caller.
◆ mmu_find_physical()
| paddr_t mmu_find_physical |
( |
vaddr_t |
virtual | ) |
|
- Returns
- -E_INVAL if error, a physical address if none
◆ mmu_identity_map()
| void mmu_identity_map |
( |
paddr_t |
start, |
|
|
paddr_t |
end, |
|
|
int |
prot |
|
) |
| |
Identity mapping is the process of mapping a virtual address to the same physical address.
Both start and end addresses will be included inside the range.
- Parameters
-
| start | the starting page of the address range |
| end | the ending address of the address range |
| prot | Protection rule in use for this page. A combination of mmu_prot flags. |
◆ mmu_init()
This function is responsible for setting any required bit inside the CPU's register.
It is also responsible of remapping the kernel's code and addresses before enabling paging.
- Warning
- After calling this function, each and every address will automatically be translated into its physical equivalent using the paging mechanism. Be sure to remap known addresses to avoid raising exceptions.
◆ mmu_is_mapped()
| static bool mmu_is_mapped |
( |
vaddr_t |
addr | ) |
|
|
inlinestatic |
- Returns
- Whether the current MMU contains a mapping for a virtual address.
◆ mmu_load()
| void mmu_load |
( |
paddr_t |
mmu | ) |
|
- Parameters
-
| page_directory | The physical address of the page directory |
◆ mmu_map()
| bool mmu_map |
( |
vaddr_t |
virt, |
|
|
paddr_t |
physical, |
|
|
int |
prot |
|
) |
| |
- Parameters
-
| virt | The virtual address |
| physical | Its physical equivalent |
| prot | Protection rule in use for this page. A combination of mmu_prot flags. |
- Returns
- False if the address was already mapped before
◆ mmu_map_range()
| bool mmu_map_range |
( |
vaddr_t |
virt, |
|
|
paddr_t |
physical, |
|
|
size_t |
size, |
|
|
int |
prot |
|
) |
| |
- Parameters
-
| virt | The start of the virtual address range |
| physical | Its physical equivalent |
| size | The size of the region to map |
| prot | Protection rule in use for this page. A combination of mmu_prot flags. |
- Returns
- False if the address was already mapped before
◆ mmu_new()
- Returns
- The physical address of the new page_directory, 0 if error.
Allocate and initialize a new page directory.
- Returns
- The physical address of the new page_directory, 0 if error.
◆ mmu_unmap()
| paddr_t mmu_unmap |
( |
vaddr_t |
virt | ) |
|
- Warning
- After calling this, referencing the given virtual address may cause the CPU to raise an exception.
- Parameters
-
- Returns
- The physical pageframe associated with the unmapped address
◆ mmu_unmap_range()
| void mmu_unmap_range |
( |
vaddr_t |
start, |
|
|
vaddr_t |
end |
|
) |
| |
- Parameters
-
| start | The start of the virtual address |
| end | The end of the virtual address |