Turnstone Operating System
|
memory paging and frame allocation interface More...
Classes | |
struct | memory_page_entry_t |
struct | memory_page_table_t |
struct | memory_page_table_context_t |
Macros | |
#define | ___MEMORY_PAGE_H 0 |
#define | MEMORY_PAGING_INDEX_COUNT 512 |
#define | MEMORY_PAGING_PAGE_SIZE 0x1000 |
#define | MEMORY_PAGING_INTERNAL_FRAMES_MAX_COUNT 0x200 |
#define | MEMORY_PAGING_PAGE_ALIGN MEMORY_PAGING_PAGE_SIZE |
#define | MEMORY_PAGING_PAGE_LENGTH_4K (1 << 12) |
#define | MEMORY_PAGING_PAGE_LENGTH_2M (1 << 21) |
#define | MEMORY_PAGING_PAGE_LENGTH_1G (1 << 30) |
#define | memory_paging_get_table() memory_paging_switch_table(NULL) |
#define | memory_paging_add_page_with_p4(pt, va, fa, t) memory_paging_add_page_ext(pt, va, fa, t) |
#define | memory_paging_add_page(va, fa, t) memory_paging_add_page_ext(NULL, va, fa, t) |
#define | memory_paging_delete_page_ext(p4, va, faptr) memory_paging_delete_page_ext_with_heap(p4, va, faptr) |
#define | memory_paging_delete_page(va, faptr) memory_paging_delete_page_ext_with_heap(NULL, va, faptr) |
#define | memory_paging_clone_pagetable() memory_paging_clone_pagetable_ext(NULL) |
#define | memory_paging_move_pagetable(h) memory_paging_clone_pagetable_ext(NULL) |
#define | memory_paging_clone_current_pagetable_to_frames_ext(h, fa) memory_paging_clone_pagetable_to_frames_ext(NULL, fa) |
#define | memory_paging_clone_current_pagetable_to_frames(fa) memory_paging_clone_pagetable_to_frames_ext(NULL, fa) |
#define | memory_paging_destroy_pagetable(p) memory_paging_destroy_pagetable_ext(p) |
#define | memory_paging_get_physical_address(va, paptr) memory_paging_get_frame_address_ext(NULL, va, paptr) |
#define | memory_paging_get_frame_address_ext(p4, va, fa) ((memory_paging_get_physical_address_ext(p4, va, fa) >> 12) << 12) |
#define | memory_paging_get_frame_address(va, faptr) memory_paging_get_frame_address_ext(NULL, va, faptr) |
#define | memory_paging_toggle_attributes(va, t) memory_paging_toggle_attributes_ext(NULL, va, t) |
#define | memory_paging_set_user_accessible(va) memory_paging_set_user_accessible_ext(NULL, va) |
#define | memory_paging_clear_page(va, t) memory_paging_clear_page_ext(NULL, va, t) |
#define | MEMORY_PT_GET_P4_INDEX(u64) ((u64 >> 39) & 0x1FF) |
#define | MEMORY_PT_GET_P3_INDEX(u64) ((u64 >> 30) & 0x1FF) |
#define | MEMORY_PT_GET_P2_INDEX(u64) ((u64 >> 21) & 0x1FF) |
#define | MEMORY_PT_GET_P1_INDEX(u64) ((u64 >> 12) & 0x1FF) |
#define | MEMORY_PAGING_GET_FA_FOR_RESERVED_VA(va) ((typeof(va))((uint64_t)(va))) |
#define | MEMORY_PAGING_GET_VA_FOR_RESERVED_FA(fa) ((typeof(fa))((uint64_t)(fa))) |
#define | memory_paging_add_va_for_frame(vas, f, t) memory_paging_add_va_for_frame_ext(NULL, vas, f, t) |
#define | memory_paging_delete_va_for_frame(vas, f) memory_paging_add_va_for_frame_ext(NULL, vas, f) |
Typedefs | |
typedef struct memory_page_entry_t | memory_page_entry_t |
short hand for struct | |
typedef struct memory_page_table_t | memory_page_table_t |
short hand for struct | |
typedef enum memory_paging_internal_frame_init_state_t | memory_paging_internal_frame_init_state_t |
typedef struct memory_page_table_context_t | memory_page_table_context_t |
short hand for struct | |
typedef enum memory_paging_page_type_e | memory_paging_page_type_t |
short hand for enum | |
typedef enum memory_paging_clear_type_t | memory_paging_clear_type_t |
Enumerations | |
enum | memory_paging_internal_frame_init_state_t { MEMORY_PAGING_INTERNAL_FRAME_INIT_STATE_UNINITIALIZED = 0 , MEMORY_PAGING_INTERNAL_FRAME_INIT_STATE_INITIALIZING = 1 , MEMORY_PAGING_INTERNAL_FRAME_INIT_STATE_INITIALIZED = 2 } |
enum | memory_paging_page_type_e { MEMORY_PAGING_PAGE_TYPE_UNKNOWN = 0 , MEMORY_PAGING_PAGE_TYPE_4K = 1 << 0 , MEMORY_PAGING_PAGE_TYPE_2M = 1 << 1 , MEMORY_PAGING_PAGE_TYPE_1G = 1 << 2 , MEMORY_PAGING_PAGE_TYPE_READONLY = 1 << 4 , MEMORY_PAGING_PAGE_TYPE_NOEXEC = 1 << 5 , MEMORY_PAGING_PAGE_TYPE_USER_ACCESSIBLE = 1 << 6 , MEMORY_PAGING_PAGE_TYPE_INTERNAL = 1 << 15 , MEMORY_PAGING_PAGE_TYPE_WILL_DELETED = 1 << 16 } |
page type enum. More... | |
enum | memory_paging_clear_type_t { MEMORY_PAGING_CLEAR_TYPE_DIRTY =1 , MEMORY_PAGING_CLEAR_TYPE_ACCESSED =2 } |
Functions | |
memory_page_table_context_t * | memory_paging_switch_table (const memory_page_table_context_t *new_table) |
switches p4 page table More... | |
int8_t | memory_paging_add_page_ext (memory_page_table_context_t *p4, uint64_t virtual_address, uint64_t frame_address, memory_paging_page_type_t type) |
creates virtual address frame mapping with adding page More... | |
int8_t | memory_paging_delete_page_ext_with_heap (memory_page_table_context_t *p4, uint64_t virtual_address, uint64_t *frame_address) |
memory_page_table_t * | memory_paging_clone_pagetable_ext (memory_page_table_context_t *table_context) |
memory_page_table_t * | memory_paging_clone_pagetable_to_frames_ext (memory_page_table_context_t *table_context, uint64_t fa) |
int8_t | memory_paging_destroy_pagetable_ext (memory_page_table_context_t *table_context) |
int8_t | memory_paging_get_physical_address_ext (memory_page_table_context_t *table_context, uint64_t virtual_address, uint64_t *physical_address) |
int8_t | memory_paging_toggle_attributes_ext (memory_page_table_context_t *table_context, uint64_t virtual_address, memory_paging_page_type_t type) |
int8_t | memory_paging_set_user_accessible_ext (memory_page_table_context_t *table_context, uint64_t virtual_address) |
int8_t | memory_paging_clear_page_ext (memory_page_table_context_t *table_context, uint64_t virtual_address, memory_paging_clear_type_t type) |
int8_t | memory_paging_add_va_for_frame_ext (memory_page_table_context_t *table_context, uint64_t va_start, frame_t *frm, memory_paging_page_type_t type) |
int8_t | memory_paging_delete_va_for_frame_ext (memory_page_table_context_t *table_context, uint64_t va_start, frame_t *frm) |
memory_page_table_context_t * | memory_paging_build_empty_table (uint64_t internal_frame_address) |
int8_t | memory_paging_reserve_current_page_table_frames (void) |
memory paging and frame allocation interface
This work is licensed under TURNSTONE OS Public License. Please read and understand latest version of Licence.
#define ___MEMORY_PAGE_H 0 |
prevent duplicate header error macro
#define memory_paging_add_page | ( | va, | |
fa, | |||
t | |||
) | memory_paging_add_page_ext(NULL, va, fa, t) |
add va and fa to defeault p4 table
#define memory_paging_add_page_with_p4 | ( | pt, | |
va, | |||
fa, | |||
t | |||
) | memory_paging_add_page_ext(pt, va, fa, t) |
add virtual address va to pt page table with frame address fa and page type t uses default heap for mallocs
#define memory_paging_get_table | ( | ) | memory_paging_switch_table(NULL) |
return p4 table
#define MEMORY_PAGING_INDEX_COUNT 512 |
how many index has a page
#define MEMORY_PAGING_PAGE_ALIGN MEMORY_PAGING_PAGE_SIZE |
memory alignment for a page (4k)
#define MEMORY_PAGING_PAGE_LENGTH_1G (1 << 30) |
page length for 1G
#define MEMORY_PAGING_PAGE_LENGTH_2M (1 << 21) |
page length for 2M
#define MEMORY_PAGING_PAGE_LENGTH_4K (1 << 12) |
page length for 4K
#define MEMORY_PAGING_PAGE_SIZE 0x1000 |
page size (4K)
#define MEMORY_PT_GET_P1_INDEX | ( | u64 | ) | ((u64 >> 12) & 0x1FF) |
gets p1 index of virtual address at long mode
#define MEMORY_PT_GET_P2_INDEX | ( | u64 | ) | ((u64 >> 21) & 0x1FF) |
gets p2 index of virtual address at long mode
#define MEMORY_PT_GET_P3_INDEX | ( | u64 | ) | ((u64 >> 30) & 0x1FF) |
gets p3 index of virtual address at long mode
#define MEMORY_PT_GET_P4_INDEX | ( | u64 | ) | ((u64 >> 39) & 0x1FF) |
gets p4 index of virtual address at long mode
page type enum.
int8_t memory_paging_add_page_ext | ( | memory_page_table_context_t * | p4, |
uint64_t | virtual_address, | ||
uint64_t | frame_address, | ||
memory_paging_page_type_t | type | ||
) |
creates virtual address frame mapping with adding page
heap | the heap where variables will be created in |
p4 | p4 page table |
virtual_address | virtual start address of page |
frame_address | frame address of page links |
type | page type, see also memory_paging_page_type_t |
if heap is NULL, the pages created in default heap
memory_page_table_context_t * memory_paging_switch_table | ( | const memory_page_table_context_t * | new_table | ) |
switches p4 page table
[in] | new_table | new p4 table |
change value of cr3 register. if new_table is NULL returns only current table