diff options
author | Alex Auvolat <alex.auvolat@ens.fr> | 2014-12-02 16:43:34 +0100 |
---|---|---|
committer | Alex Auvolat <alex.auvolat@ens.fr> | 2014-12-02 16:43:34 +0100 |
commit | 76795abc2f08f180b7a895aaf26e80b971caa81c (patch) | |
tree | e12017fd5856afb1cdcfd9940dbf4661017dba16 /kernel/include/sys.h | |
parent | c7bcf94b1e70721d0f7bfb5ca383d996559c2559 (diff) | |
download | kogata-76795abc2f08f180b7a895aaf26e80b971caa81c.tar.gz kogata-76795abc2f08f180b7a895aaf26e80b971caa81c.zip |
Add physical page (frame) allocator.
Diffstat (limited to 'kernel/include/sys.h')
-rw-r--r-- | kernel/include/sys.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/kernel/include/sys.h b/kernel/include/sys.h index 2304eec..a9d2d4c 100644 --- a/kernel/include/sys.h +++ b/kernel/include/sys.h @@ -29,4 +29,18 @@ void panic_assert(const char* assertion, const char* file, int line); #define BOCHS_BREAKPOINT asm volatile("xchg %bx, %bx") + +// Utility functions for memory alignment + +#define PAGE_SIZE 0x1000 +#define PAGE_MASK 0xFFFFF000 +#define PAGE_ALIGN_DOWN(x) (((size_t)x) & PAGE_MASK) +#define PAGE_ALIGN_UP(x) ((((size_t)x)&(~PAGE_MASK)) == 0 ? ((size_t)x) : (((size_t)x) & PAGE_MASK) + PAGE_SIZE) +#define PAGE_ID(x) (((size_t)x) / PAGE_SIZE) + +#define MASK4 0xFFFFFFFC +#define ALIGN4_UP(x) ((((size_t)x)&(~MASK4)) == 0 ? ((size_t)x) : (((size_t)x) & MASK4) + 4) +#define ALIGN4_DOWN(x) (((size_t)x)&MASK4) + + /* vim: set ts=4 sw=4 tw=0 noet :*/ |