diff options
author | Marvin Borner | 2019-09-30 22:41:39 +0200 |
---|---|---|
committer | Marvin Borner | 2019-09-30 22:42:02 +0200 |
commit | 682c47a98844ffec3f3129160e9cdb98ba129989 (patch) | |
tree | e673ace5ef65c83907cbd6575ec3a1a7e49b0fd6 /src/kernel/paging/paging.h | |
parent | 2fb0965a68dd232a70d1616bfbd7281fc65c2b0a (diff) |
Added paging and fixed several bugs
Diffstat (limited to 'src/kernel/paging/paging.h')
-rw-r--r-- | src/kernel/paging/paging.h | 59 |
1 files changed, 58 insertions, 1 deletions
diff --git a/src/kernel/paging/paging.h b/src/kernel/paging/paging.h index e8c3bf4..790dbee 100644 --- a/src/kernel/paging/paging.h +++ b/src/kernel/paging/paging.h @@ -1,6 +1,63 @@ #ifndef MELVIX_PAGING_H #define MELVIX_PAGING_H -void enable_paging(); +#define PAGE_S 0x400000 + +extern unsigned int *current_dir; +extern unsigned int *root_dir; + +typedef struct { + unsigned int present : 1; + unsigned int rw : 1; + unsigned int user : 1; + unsigned int accessed : 1; + unsigned int dirty : 1; + unsigned int unused : 7; + unsigned int frame : 20; +} page_t; + +typedef struct { + page_t pages[1024]; +} page_table_t; + +typedef struct { + page_table_t *tables[1024]; + unsigned int tables_physical[1024]; + unsigned int physical_address; +} page_directory_t; + +typedef struct { + page_table_t *tables[1024]; +} vpage_dir_t; + +extern vpage_dir_t *root_vpage_dir; + +#define EMPTY_TAB ((page_table_t*) 0x00000002) + +page_table_t *get_cr3(); + +unsigned int get_cr0(); + +void set_cr3(vpage_dir_t *dir); + +void set_cr0(unsigned int new_cr0); + +void switch_vpage_dir(vpage_dir_t *dir); + +vpage_dir_t *mk_vpage_dir(); + +page_table_t *mk_vpage_table(); + +void page_init(); + +void vpage_map(vpage_dir_t *cr3, unsigned int virt, unsigned int phys); + +void vpage_map_user(vpage_dir_t *cr3, unsigned int virt, unsigned int phys); + +void convert_vpage(vpage_dir_t *kdir); + +void dump_page(vpage_dir_t *dir, unsigned int address); + +vpage_dir_t *copy_user_dir(vpage_dir_t *dir); #endif |