From: Matthias Kruk Date: Mon, 16 Sep 2019 14:14:32 +0000 (+0900) Subject: Make page frame allocations available to other kernel functions; move ALIGNED() and... X-Git-Url: https://git.corax.cc/?a=commitdiff_plain;h=d8f05c66307e19c99e19e3b13492bc0029e5b3a2;p=corax Make page frame allocations available to other kernel functions; move ALIGNED() and ALIGN() macros to paging.h --- diff --git a/kernel/arch/paging.c b/kernel/arch/paging.c index 3f191a6..2a9a206 100644 --- a/kernel/arch/paging.c +++ b/kernel/arch/paging.c @@ -42,9 +42,6 @@ static const char *_str_pg_mode[] = { "Intel64 mode" }; -#define ALIGNED(_v, _a) (!((_v) & (((_a) - 1)))) -#define ALIGN(_v, _a) (ALIGNED((_v), (_a)) ? (_v) : (((_v) & ~((_a) - 1)) + (_a))) - static void* _phys_alloc(u32_t size, u32_t align) { extern u32_t _mem_start; @@ -67,7 +64,7 @@ static void* _phys_alloc(u32_t size, u32_t align) return(addr); } -static void* _frame_alloc_start(void) +void* pg_frame_alloc_start(void) { u32_t frm; @@ -91,7 +88,7 @@ static void* _frame_alloc_start(void) return(NULL); } -static void* _frame_alloc_end(void) +void* pg_frame_alloc_end(void) { u32_t frm; diff --git a/kernel/arch/paging.h b/kernel/arch/paging.h index 0d7b5b6..963c27c 100644 --- a/kernel/arch/paging.h +++ b/kernel/arch/paging.h @@ -60,6 +60,9 @@ struct pae_page_table { u64_t ppt_entries[512]; } __attribute__((packed)); +#define ALIGNED(_v, _a) (!((_v) & (((_a) - 1)))) +#define ALIGN(_v, _a) (ALIGNED((_v), (_a)) ? (_v) : (((_v) & ~((_a) - 1)) + (_a))) + #define PDPT_ALIGN 32 #define PAGE_ALIGN 0x1000 #define ARCH_ALIGN sizeof(void*) @@ -80,6 +83,9 @@ struct pae_page_table { #define PAGE_ATTR_GLOBAL (1 << 8) #define PAGE_ATTR_NO_EXEC (1 << 63) +void* pg_frame_alloc_start(void); +void* pg_frame_alloc_end(void); + int pagedir_init(struct pagedir*); void* pagedir_map_pages(struct pagedir*); int pagedir_free(struct pagedir*);