This repository has been archived on 2023-09-28. You can view files and clone it, but cannot push or open issues or pull requests.
homepage/content/projects/noxos/docs/codebase/mm/page_frame.h.md

48 lines
2.5 KiB
Markdown
Raw Normal View History

---
title: "page_frame.h"
summary: "physical memory management"
---
# `PFRAME_SIZE` - macro
The size of one page (4KB).
# `page_frame_manager_T` - struct
| Name | Type | Description |
|-------------------|----------|------------------------------------------------------------------------------------|
| free_memory | uint64_t | The amount of free/usable memory in bytes |
| reserved_memory | uint64_t | The amount of reserved memory in bytes |
| used_memory | uint64_t | The amount of memory used by noxos in bytes |
| page_bitmap_index | uint64_t | The index to the first free page |
| page_bitmap | bitmap_T | A huge bitmap, that stores, which pages are claimable and which are already in use |
| blocked | bool | Thread safety guard |
#### `pframe_manager_init()` - function (void)
Initializes the page frame manager, needs to be called once at kernel init.
#### `pframe_reserve(address)` - function (void) [Thread Safe]
Blocks a page, so it can't be requested or anything else.
If the page is already blocked by anything else, e.g. by a request, it won't be reserved.
#### `pframe_reserve_multi(address, n)` - function (void) [Thread Safe]
Reserves the page at the given address, plus *n* pages after that page.
#### `pframe_unreserve(address)` - function (void) [Thread Safe]
Unreserves a reserved page and makes it accessible again.
#### `pframe_unreserve_multi(address, n)` - function (void) [Thread Safe]
Unreserves the page at the given address, plus *n* pages after that page.
#### `pframe_request()` - function (void*) [Thread Safe]
Returns the physical address of a page.
This is kind of the low level version of `memory_allocate`.
#### `pframe_free(address)` - function (void) [Thread Safe]
Needs a valid page address produced by [pframe_request](https://nerdcult.net/projects/noxos/docs/codebase/mm/page_frame.h/#pframe_request---function-void-thread-safe) as argument.
Invalidates the address and frees it, so it can be requested again.
This is kind of the low level version of `memory_free`.
#### `pframe_free_multi(address, n)` - function (void) [Thread Safe]
Frees the page at the given address, plus *n* pages after that page.