Skip to content
Snippets Groups Projects
Commit 1c15e42f authored by Matěj Kafka's avatar Matěj Kafka Committed by Michal Sojka
Browse files

nova: Add explanation for `Kalloc::phys2virt` and `virt2phys`

parent 3739b179
No related branches found
No related tags found
No related merge requests found
......@@ -38,7 +38,20 @@ class Kalloc
void * alloc_page (unsigned size, Fill fill = NOFILL);
void free_page (void *);
/**
* Even kernel can only access virtual memory, it cannot access physical memory directly.
* However, CPU and bootloader work with physical addresses, so we sometimes need to read/write
* to physical addresses.
*
* To resolve this, part of the physical memory is mapped 1:1 to a sequential block of virtual
* memory addresses at a known offset `OFFSET`, so that the physical address X is accessible
* at the virtual address OFFSET + X. This mapping is configured during kernel startup at
* `kern/src/start.S` (section `SETUP BOOT PAGE TABLE`).
*
* This method returns the virtual address that can be used to access the physical address `phys`.
*/
static void * phys2virt (mword);
/** Return the physical address that is mapped from the virtual address `virt` (opposite of `phys2virt`). */
static mword virt2phys (void *);
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment