00001 /************************************************************************************** 00002 Copyright (c) 2002 The UbixOS Project 00003 All rights reserved. 00004 00005 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 00006 00007 Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. 00008 Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors 00009 in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its 00010 contributors may be used to endorse or promote products derived from this software without specific prior written permission. 00011 00012 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 00013 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00014 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00015 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 00016 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00017 OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00018 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00019 00020 $Id$ 00021 00022 **************************************************************************************/ 00023 00024 #ifndef _KMALLOC_H 00025 #define _KMALLOC_H 00026 00027 #include <ubixos/types.h> 00028 00029 #ifdef __cplusplus 00030 extern "C" { 00031 #endif 00032 00033 #define sysMalloc -2 00034 #define sysID -2 00035 00036 struct memDescriptor { 00037 struct memDescriptor *prev; //4 00038 struct memDescriptor *next; //4 00039 void *baseAddr; //4 00040 uInt32 limit; //4 00041 uInt8 status; //1 00042 pidType pid; //4 00043 char reserved[11]; //11 00044 }; 00045 00046 void kfree(void *baseAddr); 00047 void *kmalloc(uInt32 len,pidType pid); 00048 void initMalloc(pidType pid); 00049 void *getEmptyDesc(); 00050 void insertFreeDesc(struct memDescriptor *freeDesc); 00051 void mergeMemBlocks(); 00052 void kfreeProcess(pidType pid); 00053 00054 extern struct memDescriptor *kernDesc; 00055 extern struct memDescriptor *freeKernDesc; 00056 extern struct memDescriptor *emptyKernDesc; 00057 00058 extern int mallocLock; 00059 00060 #ifdef __cplusplus 00061 } 00062 #endif 00063 00064 #endif 00065