00001 /* 00002 Copyright (C) 2006. QLogic Corporation. All Rights Reserved. 00003 00004 This program is free software; you can redistribute it and/or modify it 00005 under the terms of version 2 of the GNU General Public License as 00006 published by the Free Software Foundation. 00007 00008 This program is distributed in the hope that it would be useful, but 00009 WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00011 00012 Further, this software is distributed without any warranty that it is 00013 free of the rightful claim of any third person regarding infringement 00014 or the like. Any license provided herein, whether implied or 00015 otherwise, applies only to this software file. Patent licenses, if 00016 any, provided herein do not apply to combinations of this program with 00017 other software, or any other product whatsoever. 00018 00019 You should have received a copy of the GNU General Public License along 00020 with this program; if not, write the Free Software Foundation, Inc., 59 00021 Temple Place - Suite 330, Boston MA 02111-1307, USA. 00022 */ 00023 00024 #ifndef __GSPIN_GS_MEMPOOL_H__ 00025 #define __GSPIN_GS_MEMPOOL_H__ 00026 00027 #define GS_ARENA 0 00028 #define IB_STRING_ARENA 1 00029 #define GS_ARENA_COUNT 2 00030 00031 // represent a block of allocation of size GS_MEMBLOCK_SIZE 00032 typedef struct gs_memblock gs_memblock_t; 00033 struct gs_memblock { 00034 int block_id; // index into each block in current arena 00035 char *mem; // point to base of allocated block 00036 gs_memblock_t *next; // the next block in linked list 00037 }; 00038 00039 typedef struct gs_arena { 00040 gs_memblock_t *firstblock; // the first of the list of allocated blocks 00041 gs_memblock_t *lastblock; // the last of the list of allocated blocks where 00042 // unused memory is given out 00043 gs_count_t current_index; // not in bytes; the next available unit 00044 } gs_arena_t; 00045 00046 extern gs_arena_t gs_mempool[GS_ARENA_COUNT]; 00047 00048 extern void *__gs_mempool_alloc(unsigned int mempool_id, unsigned int count); 00049 extern void *gs_mempool_idx2address(int arena_id, int cell_index); 00050 extern long gs_mempool_address2byteofst(int arena_id, char *p); 00051 00052 #endif // __GSPIN_GS_MEMPOOL_H__
1.5.6