aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/memory/paging.h
diff options
context:
space:
mode:
authorMarvin Borner2020-02-16 17:29:19 +0100
committerMarvin Borner2020-02-16 17:29:50 +0100
commit45184af20936cb889b658e69e00a0bb3d522757f (patch)
tree4b6c3408e526fe733ccfa960726c37e70dc6f989 /src/kernel/memory/paging.h
parentf5b995586e28f7db426f4707a4348dc067df41c0 (diff)
Revert to good ol' paging
Diffstat (limited to 'src/kernel/memory/paging.h')
-rw-r--r--src/kernel/memory/paging.h77
1 files changed, 47 insertions, 30 deletions
diff --git a/src/kernel/memory/paging.h b/src/kernel/memory/paging.h
index 74d486f..ff542e3 100644
--- a/src/kernel/memory/paging.h
+++ b/src/kernel/memory/paging.h
@@ -2,46 +2,63 @@
#define MELVIX_PAGING_H
#include <stdint.h>
-#include <kernel/interrupts/interrupts.h>
-
-typedef struct page {
- uint32_t present: 1;
- uint32_t rw: 1;
- uint32_t user: 1;
- uint32_t accessed: 1;
- uint32_t dirty: 1;
- uint32_t unused: 7;
- uint32_t frame: 20;
-} page_t;
-
-typedef struct page_table {
- page_t pages[1024];
-} page_table_t;
-
-typedef struct page_directory {
- page_table_t *tables[1024];
- uint32_t tables_physical[1024];
- uint32_t physical_address;
-} page_directory_t;
-int paging_enabled;
+#define PD_PRESENT 1 << 0
+#define PD_RW 1 << 1
+#define PD_ALL_PRIV 1 << 2
+#define PD_WRITETHR 1 << 3
+#define PD_CACHE_D 1 << 4
+#define PD_ACCESSED 1 << 5
+#define PD_4M_PAGE 1 << 7
-void paging_set_frame(uint32_t frame_addr);
+#define PT_PRESENT 1 << 0
+#define PT_RW 1 << 1
+#define PT_ALL_PRIV 1 << 2
+#define PT_WRITETHR 1 << 3
+#define PT_CACHE_D 1 << 4
+#define PT_ACCESSED 1 << 5
+#define PT_DIRTY 1 << 6
+#define PT_GLOBAL 1 << 8
+#define PT_USED 1 << 9
-void paging_alloc_frame(page_t *page, int is_kernel, int is_writeable);
+int paging_enabled;
-void paging_free_frame(page_t *page);
+uint32_t *current_page_directory;
void paging_install();
-void paging_switch_directory(page_directory_t *dir);
-
void paging_enable();
void paging_disable();
-page_t *paging_get_page(uint32_t address, int make, page_directory_t *dir);
+void paging_switch_directory(int user);
+
+void paging_map(uint32_t phy, uint32_t virt, uint16_t flags);
+
+uint32_t paging_get_phys(uint32_t virt);
+
+uint16_t paging_get_flags(uint32_t virt);
+
+void paging_set_flags(uint32_t virt, uint32_t count, uint16_t flags);
+
+void paging_set_flag_up(uint32_t virt, uint32_t count, uint32_t flag);
+
+void paging_set_flag_down(uint32_t virt, uint32_t count, uint32_t flag);
+
+void paging_set_present(uint32_t virt, uint32_t count);
+
+void paging_set_absent(uint32_t virt, uint32_t count);
+
+void paging_set_used(uint32_t virt, uint32_t count);
+
+void paging_set_free(uint32_t virt, uint32_t count);
+
+void paging_set_user(uint32_t virt, uint32_t count);
+
+uint32_t paging_find_pages(uint32_t count);
+
+uint32_t paging_alloc_pages(uint32_t count);
-page_directory_t *paging_clone_directory(page_directory_t *src);
+uint32_t paging_get_used_pages();
-#endif
+#endif \ No newline at end of file