Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

include/sys/mm.h

Go to the documentation of this file.
00001 
00006 /*
00007  *  The contents of this file are subject to the Mozilla Public License
00008  *  Version 1.0 (the "License"); you may not use this file except in
00009  *  compliance with the License. You may obtain a copy of the License
00010  *  at http://www.mozilla.org/MPL/
00011  *
00012  *  Software distributed under the License is distributed on an "AS IS"
00013  *  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00014  *  the License for the specific language governing rights and
00015  *  limitations under the License.
00016  *
00017  *  The Original Code is legOS code, released October 17, 1999.
00018  *
00019  *  The Initial Developer of the Original Code is Markus L. Noga.
00020  *  Portions created by Markus L. Noga are Copyright (C) 1999
00021  *  Markus L. Noga. All Rights Reserved.
00022  *
00023  *  Contributor(s): Markus L. Noga <markus@noga.de>
00024  */
00025 
00026 #ifndef __sys_mm_h__
00027 #define __sys_mm_h__
00028 
00029 #ifdef  __cplusplus
00030 extern "C" {
00031 #endif
00032 
00033 #include <config.h>
00034 
00035 #ifdef CONF_MM
00036 
00037 #include <mem.h>
00038 #include <stdlib.h>
00039 
00040 
00042 //
00043 // Definitions
00044 //
00046 
00047 #define MM_FREE         0x0000                  
00048 #define MM_RESERVED     0xffff                  
00049 
00050 // as data generally nees to be word aligned, 1 unit ^= 2 bytes
00051 //
00052 
00053 #define MM_HEADER_SIZE  2                       
00054 #define MM_SPLIT_THRESH (MM_HEADER_SIZE+8)      
00055 
00056 extern size_t mm_start;                         
00057 
00058 extern size_t* mm_first_free;                   
00059 
00060 // Macros for mm_init()
00061 // Always alternate FREE and RESERVED.
00062 //
00063 
00065 
00068 #define MM_BLOCK_FREE(addr)                                     \
00069         next=(size_t*)(addr);                                   \
00070         *current=((((size_t)next)-(size_t)current)-2)>>1;       \
00071         *(next++)=MM_FREE;                                      \
00072         current=next;
00073 
00074 
00076 
00079 #define MM_BLOCK_RESERVED(addr)                                 \
00080         next=(size_t*)(((size_t)addr)-4);                       \
00081         *current=((((size_t)next)-(size_t)current)-2)>>1;       \
00082         *(next++)=MM_RESERVED;                                  \
00083         current=next;
00084 
00085 
00087 //
00088 // Functions
00089 //
00091 
00093 extern void mm_init();
00094 
00096 extern void mm_reaper();
00097 
00099 extern int mm_free_mem(void);
00100 
00101 #endif  // CONF_MM
00102 
00103 #ifdef  __cplusplus
00104 }
00105 #endif
00106 
00107 #endif  // __sys_mm_h__

brickOS is released under the Mozilla Public License.
Original code copyright 1998-2002 by the authors.

Generated on Mon Feb 16 21:02:10 2004 for brickOS Kernel Developer by doxygen 1.3.5