page: use new ptr align macros
This commit is contained in:
parent
ebce7b8e83
commit
5877697e64
2 changed files with 10 additions and 8 deletions
|
@ -143,7 +143,9 @@ int pages_init(void);
|
||||||
* @param flags
|
* @param flags
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
void *get_pages(usize count, enum mm_flags flags) __malloc_like;
|
void *get_pages(usize count, enum mflags flags) __malloc_like;
|
||||||
|
#define GET_PAGE_LEVELS (HUGEPAGE_SHIFT - PAGE_SHIFT + 1)
|
||||||
|
#define GET_PAGE_MAXCOUNT (1 << (HUGEPAGE_SHIFT - PAGE_SHIFT))
|
||||||
|
|
||||||
void free_pages(void *ptr);
|
void free_pages(void *ptr);
|
||||||
|
|
||||||
|
|
|
@ -41,11 +41,11 @@
|
||||||
# if CFG_DEBUG_PAGE_ALLOCS_NOISY
|
# if CFG_DEBUG_PAGE_ALLOCS_NOISY
|
||||||
# define page_debug_noisy(msg, ...) kprintf("[page] " msg, ##__VA_ARGS__)
|
# define page_debug_noisy(msg, ...) kprintf("[page] " msg, ##__VA_ARGS__)
|
||||||
# else
|
# else
|
||||||
# define page_debug_noisy(msg, ...)
|
# define page_debug_noisy(msg, ...) ({})
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
# define page_debug(msg, ...)
|
# define page_debug(msg, ...) ({})
|
||||||
# define page_debug_noisy(msg, ...)
|
# define page_debug_noisy(msg, ...) ({})
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -54,7 +54,7 @@
|
||||||
* the one below it, starting at one page per entry. The effective result is
|
* the one below it, starting at one page per entry. The effective result is
|
||||||
* that a single entry in the cache on level L covers `(1 << L)` pages.
|
* that a single entry in the cache on level L covers `(1 << L)` pages.
|
||||||
*/
|
*/
|
||||||
#define CACHE_LEVELS (HUGEPAGE_SHIFT - PAGE_SHIFT + 1)
|
#define CACHE_LEVELS GET_PAGE_LEVELS
|
||||||
|
|
||||||
#define LEVEL_SHIFT(level) (PAGE_SHIFT + (level))
|
#define LEVEL_SHIFT(level) (PAGE_SHIFT + (level))
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ struct cache_pool {
|
||||||
usize free_entries;
|
usize free_entries;
|
||||||
};
|
};
|
||||||
static struct cache_pool caches[CACHE_LEVELS];
|
static struct cache_pool caches[CACHE_LEVELS];
|
||||||
MTX(caches_lock);
|
static MTX(caches_lock);
|
||||||
|
|
||||||
#define LONG_BIT_MASK (~(LONG_BIT - 1))
|
#define LONG_BIT_MASK (~(LONG_BIT - 1))
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ int pages_init(void)
|
||||||
vm_flush();
|
vm_flush();
|
||||||
|
|
||||||
/* phys_end gets aligned, as promised by the comment in kmalloc_init() */
|
/* phys_end gets aligned, as promised by the comment in kmalloc_init() */
|
||||||
phys_end = uintptr_align(phys_end, -HUGEPAGE_SHIFT);
|
phys_end = align_floor(phys_end, HUGEPAGE_SIZE);
|
||||||
usize phys_size = phys_end - phys_start;
|
usize phys_size = phys_end - phys_start;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -187,7 +187,7 @@ int pages_init(void)
|
||||||
|
|
||||||
/* kheap_start and kheap_end are globals */
|
/* kheap_start and kheap_end are globals */
|
||||||
kheap_start = __v(phys_start);
|
kheap_start = __v(phys_start);
|
||||||
kheap_end = ptr_align(bitmap_start, -HUGEPAGE_SHIFT);
|
kheap_end = align_floor(bitmap_start, HUGEPAGE_SIZE);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* populate the freelist on the highest level, all levels beneath it
|
* populate the freelist on the highest level, all levels beneath it
|
||||||
|
|
Loading…
Reference in a new issue