diff options
Diffstat (limited to 'vm/vm_page.h')
-rw-r--r-- | vm/vm_page.h | 72 |
1 files changed, 71 insertions, 1 deletions
diff --git a/vm/vm_page.h b/vm/vm_page.h index 205f3d2f..d8d022b4 100644 --- a/vm/vm_page.h +++ b/vm/vm_page.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011 Richard Braun. + * Copyright (c) 2010, 2011, 2013 Richard Braun. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -13,6 +13,9 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * + * Physical page management. */ #ifndef _VM_VM_PAGE_H @@ -35,6 +38,12 @@ #define vm_page_aligned(addr) P2ALIGNED(addr, PAGE_SIZE) /* + * True if the vm_page module is completely initialized, false otherwise + * (in which case only vm_page_bootalloc() can be used for allocations). + */ +extern int vm_page_ready; + +/* * Physical page descriptor. */ struct vm_page { @@ -51,4 +60,65 @@ vm_page_to_pa(const struct vm_page *page) return page->phys_addr; } +/* + * Load physical memory into the vm_page module at boot time. + * + * The avail_start and avail_end parameters are used to maintain a simple + * heap for bootstrap allocations. + */ +void vm_page_load(const char *name, phys_addr_t start, phys_addr_t end, + phys_addr_t avail_start, phys_addr_t avail_end, + unsigned int seg_index, unsigned int seglist_prio); + +/* + * Allocate one physical page. + * + * This function is used to allocate physical memory at boot time, before the + * vm_page module is ready, but after the physical memory has been loaded. + */ +phys_addr_t vm_page_bootalloc(void); + +/* + * Set up the vm_page module. + * + * Once this function returns, the vm_page module is ready, and normal + * allocation functions can be used. + */ +void vm_page_setup(void); + +/* + * Make the given page managed by the vm_page module. + * + * If additional memory can be made usable after the VM system is initialized, + * it should be reported through this function. + */ +void vm_page_manage(struct vm_page *page); + +/* + * Return the page descriptor for the given physical address. + */ +struct vm_page * vm_page_lookup(phys_addr_t pa); + +/* + * Allocate a block of 2^order physical pages. + */ +struct vm_page * vm_page_alloc(unsigned int order); + +/* + * Allocate physical pages from a specific segment. + * + * This function should only be called by architecture specific functions. + */ +struct vm_page * vm_page_alloc_seg(unsigned int order, unsigned int seg_index); + +/* + * Release a block of 2^order physical pages. + */ +void vm_page_free(struct vm_page *page, unsigned int order); + +/* + * Display internal information about the module. + */ +void vm_page_info(void); + #endif /* _VM_VM_PAGE_H */ |