add: documentation: memory

This commit is contained in:
2024-10-30 19:05:58 +01:00
parent 5fba376e2f
commit 04211e2773
9 changed files with 134 additions and 65 deletions

View File

@ -0,0 +1,3 @@
# FRAME
Like [page](./page.md) but in physical memory space

View File

@ -0,0 +1,19 @@
# Memory Management Unit (MMU)
The MMU is a chip which translate virtual memory to physical memory. When you try to access to an address (/!\ only when you try to access) the MMU will get the physical address from the [pd](./page_directory.md).
## How translate an address ?
The address will be divid in 3 parts:
- Page Directory index (10bit (cause 1024))
- Page Table index (10bit (cause 1024 too))
- offset (12bit cause page size = 4096)
### Example
**address**: 0b000100000011101011111011101101
| Base | PD index | PT index | offset |
|--------|----------|------------|--------------|
| Binary | 00010000 | 0011101011 | 111011101101 |
| Decimal| 16 | 235 | 3821 |
So to translate this address the MMU will get the 20 first bit of the value store at the 235th PTE of the 16th PDE and will replace the 20 first bit of the virtually address.

View File

@ -0,0 +1,3 @@
# PAGE
A page is a memory space with with a specific size (default 4096byte).

View File

@ -0,0 +1,7 @@
# PAGE DIRECTORY
The page directory (or pd) is
## Indexed Size
A PD can store 1024 PT, each PT index 1024 * 4096Byte = 4MB of address, so a PD can index 1024 * 4MB = 4GB.

View File

@ -0,0 +1,12 @@
# PAGE TABLE
A page table (or PT) is an 1024 array of 32bit value(Page Table Entry (or PTE)). The address of the PT is store in the [PD](./page_directory.md).
## Page Table Entry (PTE)
The value is a 20 first bits of the [frame](./frame.md) address and the 12 last bit is for the flag.
### Not used PTE value
To say to the [MMU](./mmu.md) the page is currently not attribued to a frame you should put the (PTE index << 12)
## Indexed Size
Cause our kernel use 4096byte page and a PT can store 1024 value, each PT index 1024 * 4096Byte = 4MB of address.