00001 /*! \file include/kernel/kmalloc.h 00002 * \brief Headers for the kernel memory allocators. 00003 * \author Andrea Righi <drizzt@inwind.it> 00004 * \date 2003-10-24 00005 * \note Copyright (C) 2003 Andrea Righi 00006 */ 00007 00008 #ifndef KMALLOC_H 00009 #define KMALLOC_H 00010 00011 // Constants // 00012 00013 /** \ingroup Memory 00014 * \defgroup KMemoryAlloc Kernel Memory Allocator 00015 * The memory operators for the kernel. 00016 * @{ 00017 */ 00018 00019 //! Magic number to identify a memory block. 00020 #define M_MAGIC ((dword)"$MB$") 00021 //! Free block. 00022 #define M_FREE 0 00023 //! Allocated block. 00024 #define M_ALLOC 1 00025 00026 //! A memory block structure. 00027 typedef struct MEM_BLOCK 00028 { 00029 dword magic, 00030 flags, 00031 size, 00032 owner; 00033 } mem_block_t; 00034 00035 void kmalloc_init(); 00036 void *kmalloc(dword size); 00037 void kfree(void *ptr); 00038 int mem_sizeof(void *ptr); 00039 00040 void *kmemalign(size_t alignment, size_t size); 00041 00042 /** @} */ // end of KMemoryAlloc 00043 00044 /** \ingroup Memory 00045 * \defgroup DebugMemoryAlloc Debug Routines for Memory Allocator 00046 * Functions to debug the kernel memory area allocator. 00047 * @{ 00048 */ 00049 void dump_memory_map(); 00050 /** @} */ // end of DebugMemoryAlloc 00051 00052 #endif