palloc()/pfree() replace our old kmalloc()/kfree() with PAGE_SIZE granularity

This commit is contained in:
Steffen Vogel 2013-11-20 11:47:53 +01:00
parent 9018781eee
commit 7a3e77c82d

View file

@ -29,9 +29,7 @@
#ifndef __STDLIB_H__
#define __STDLIB_H__
#include <metalsvm/config.h>
#include <metalsvm/tasks_types.h>
#include <asm/stddef.h>
#include <metalsvm/stddef.h>
#ifdef __cplusplus
extern "C" {
@ -55,46 +53,42 @@ extern "C" {
void NORETURN abort(void);
/** @brief Kernel's memory allocator function.
/** @brief General page allocator function
*
* This will just call mem_allocation with
* the flags MAP_KERNEL_SPACE and MAP_HEAP.
*
* @return Pointer to the new memory range
*/
void* kmalloc(size_t);
/** @brief Kernel's more general memory allocator function.
*
* This function lets you choose flags for the newly allocated memory.
* This function allocates and maps whole pages.
* To avoid fragmentation you should use kmalloc() and kfree()!
*
* @param sz Desired size of the new memory
* @param flags Flags to specify
* @param flags Flags to for map_region(), vma_add()
*
* @return Pointer to the new memory range
*/
void* mem_allocation(size_t sz, uint32_t flags);
void* palloc(size_t sz, uint32_t flags);
/** @brief Free memory
/** @brief Free general kernel memory
*
* The kernel malloc doesn't track how
* much memory was allocated for which pointer,
* The pmalloc() doesn't track how much memory was allocated for which pointer,
* so you have to specify how much memory shall be freed.
*/
void kfree(void*, size_t);
/** @brief Create a new stack for a new task
*
* @return start address of the new stack
* @param sz The size which should freed
*/
void* create_stack(void);
void pfree(void* addr, size_t sz);
/** @brief Delete stack of a finished task
/** @brief The memory allocator function
*
* @param addr Pointer to the stack
* @return 0 on success
* This allocator uses a buddy system to manage free memory.
*
* @return Pointer to the new memory range
*/
int destroy_stack(task_t* addr);
void* kmalloc(size_t sz);
/** @brief The memory free function
*
* Releases memory allocated by malloc()
*
* @param addr The address to the memory block allocated by malloc()
*/
void kfree(void* addr);
/** @brief String to long
*