| 1 |
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ |
| 2 |
|
| 3 |
File: octapi_llman_private.h |
| 4 |
|
| 5 |
Copyright (c) 2001 Octasic Inc. All rights reserved. |
| 6 |
|
| 7 |
Description: |
| 8 |
|
| 9 |
Library used to manage allocation tables and linked lists. The library is |
| 10 |
made such that only a block of contiguous memory is needed for the |
| 11 |
management of the linked list/allocation table. |
| 12 |
|
| 13 |
|
| 14 |
This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is |
| 15 |
free software; you can redistribute it and/or modify it under the terms of |
| 16 |
the GNU General Public License as published by the Free Software Foundation; |
| 17 |
either version 2 of the License, or (at your option) any later version. |
| 18 |
|
| 19 |
The OCT6100 GPL API is distributed in the hope that it will be useful, but |
| 20 |
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 21 |
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 22 |
for more details. |
| 23 |
|
| 24 |
You should have received a copy of the GNU General Public License |
| 25 |
along with the OCT6100 GPL API; if not, write to the Free Software |
| 26 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 27 |
|
| 28 |
$Octasic_Release: OCT612xAPI-01.00-PR49 $ |
| 29 |
|
| 30 |
$Octasic_Revision: 13 $ |
| 31 |
|
| 32 |
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ |
| 33 |
#ifndef __OCTAPI_LLMAN_PRIVATE_H__ |
| 34 |
#define __OCTAPI_LLMAN_PRIVATE_H__ |
| 35 |
|
| 36 |
#include "octdef.h" |
| 37 |
|
| 38 |
|
| 39 |
/**************************************** llm_alloc section **********************************************/ |
| 40 |
|
| 41 |
|
| 42 |
/* Most basic linked list model. |
| 43 |
LLM_STR contains a list of "number_of_items" that |
| 44 |
are each "unassigned" or "assigned". When requesting |
| 45 |
a new element, llm_alloc must choose an "unassigned" |
| 46 |
element. An element that is deallocated will be last |
| 47 |
to be allocated. |
| 48 |
*/ |
| 49 |
|
| 50 |
typedef struct _LLM_ALLOC |
| 51 |
{ |
| 52 |
UINT32 *linked_list; /* Each item is either used (0xFFFFFFFE)*/ |
| 53 |
/* or unused (pointer to next unused item, 0xFFFFFFFF means last item reached).*/ |
| 54 |
UINT32 next_avail_num; /* Points to the next available item in linked list. (0xFFFFFFFF means none available)*/ |
| 55 |
UINT32 number_of_items; /* Total number of items in linked list.*/ |
| 56 |
UINT32 allocated_items; /* Allocated items in linked list.*/ |
| 57 |
|
| 58 |
} LLM_ALLOC; |
| 59 |
|
| 60 |
typedef struct _TLLM_ALLOC_NODE_ |
| 61 |
{ |
| 62 |
UINT32 value; /* Each item is either used (0xFFFFFFFE)*/ |
| 63 |
/* or unused (pointer to next unused item, 0xFFFFFFFF means last item reached).*/ |
| 64 |
UINT32 timeout[2]; /* Timeout value that must be exceeded for the node to be considered free again.*/ |
| 65 |
|
| 66 |
} TLLM_ALLOC_NODE; |
| 67 |
|
| 68 |
|
| 69 |
typedef struct _TLLM_ALLOC_ |
| 70 |
{ |
| 71 |
TLLM_ALLOC_NODE *linked_list; /* List of nodes used by the link list.*/ |
| 72 |
|
| 73 |
UINT32 next_avail_num; /* Points to the next available item in linked list. (0xFFFFFFFF means none available)*/ |
| 74 |
UINT32 number_of_items; /* Total number of items in linked list.*/ |
| 75 |
UINT32 allocated_items; /* Allocated items in linked list.*/ |
| 76 |
|
| 77 |
UINT32 number_of_timeout; /* Number of block currently in timeout.*/ |
| 78 |
UINT32 next_timeout_num; /* Points to the next block currently in timeout.*/ |
| 79 |
UINT32 last_timeout_num; /* Last node of the timeout list.*/ |
| 80 |
|
| 81 |
UINT32 last_known_time[2]; /* last known time.*/ |
| 82 |
|
| 83 |
} TLLM_ALLOC; |
| 84 |
|
| 85 |
/* |
| 86 |
void octapi_llm_alloc_build_structure(void *l, LLM_ALLOC ** ls); |
| 87 |
*/ |
| 88 |
/**************************************** llm_alloc section **********************************************/ |
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
/**************************************** llm_list section **********************************************/ |
| 93 |
/* This section contains memory structures and functions used |
| 94 |
to maintain a variable number of lists (FIFOs) that each |
| 95 |
have a variable amount of items. A total amount of items |
| 96 |
can be assigned through-out all the lists. Each item in |
| 97 |
each list contains a UINT32 specified by the software using |
| 98 |
the lists. Each used item in the list is accessible through |
| 99 |
it's position in the list. */ |
| 100 |
|
| 101 |
typedef struct _LLM_LIST_HEAD |
| 102 |
{ |
| 103 |
UINT32 list_length; /* Current number of items in the list.*/ |
| 104 |
/* 0xFFFFFFFF means that the list is not used.*/ |
| 105 |
UINT32 head_pointer; /* Number of the item in the item pool that is the first of this list.*/ |
| 106 |
/* 0xFFFFFFFF indicates end-of-list link.*/ |
| 107 |
UINT32 tail_pointer; /* Number of the item in the item pool that is the last of this list.*/ |
| 108 |
|
| 109 |
/* Item cache (pointer within the list of the last accessed item):*/ |
| 110 |
UINT32 cache_item_number; /* Number of the last accessed item in the list. 0xFFFFFFFF indicates invalid cache.*/ |
| 111 |
UINT32 cache_item_pointer; /* Number of the last accessed item in the item pool.*/ |
| 112 |
} LLM_LIST_HEAD; |
| 113 |
|
| 114 |
typedef struct _LLM_LIST_ITEM |
| 115 |
{ |
| 116 |
UINT32 forward_link; /* Number of the item in the item pool that is next in this list.*/ |
| 117 |
/* 0xFFFFFFFF indicates end-of-list link.*/ |
| 118 |
|
| 119 |
/* User item info (variable size)*/ |
| 120 |
UINT32 user_info[1]; |
| 121 |
} LLM_LIST_ITEM; |
| 122 |
|
| 123 |
typedef struct _LLM_LIST |
| 124 |
{ |
| 125 |
UINT32 user_info_bytes; /* In bytes, size of the user info in a single item.*/ |
| 126 |
UINT32 user_info_size; /* In bytes, size of the user info in a single item.*/ |
| 127 |
UINT32 item_size; |
| 128 |
|
| 129 |
UINT32 head_alloc_size; |
| 130 |
UINT32 total_items; |
| 131 |
UINT32 assigned_items; |
| 132 |
|
| 133 |
UINT32 total_lists; |
| 134 |
UINT32 assigned_lists; |
| 135 |
|
| 136 |
UINT32 next_empty_item; /* Contains a pointer to the next empty item in the*/ |
| 137 |
/* item pool.*/ |
| 138 |
|
| 139 |
/* Table of all the possible list heads:*/ |
| 140 |
LLM_LIST_HEAD * lh; |
| 141 |
void * list_head_alloc; /* LLM_ALLOC structure used for list head allocation!*/ |
| 142 |
|
| 143 |
/* Table of the list items:*/ |
| 144 |
LLM_LIST_ITEM * li; |
| 145 |
} LLM_LIST; |
| 146 |
|
| 147 |
|
| 148 |
/**********************************************************************************/ |
| 149 |
/* These structures are are used by the Llm2 functions to creates lists of ordered |
| 150 |
items based on a key given by the user when a new node is inserted in a list. */ |
| 151 |
typedef struct _LLM2_LIST_HEAD |
| 152 |
{ |
| 153 |
UINT32 list_length; /* Current number of items in the list.*/ |
| 154 |
/* 0xFFFFFFFF means that the list is not used.*/ |
| 155 |
UINT32 head_pointer; /* Number of the item in the item pool that is the first of this list.*/ |
| 156 |
/* 0xFFFFFFFF indicates end-of-list link.*/ |
| 157 |
UINT32 tail_pointer; /* Number of the item in the item pool that is the last of this list.*/ |
| 158 |
|
| 159 |
} LLM2_LIST_HEAD; |
| 160 |
|
| 161 |
typedef struct _LLM2_LIST_ITEM |
| 162 |
{ |
| 163 |
UINT32 forward_link; /* Number of the item in the item pool that is next in this list.*/ |
| 164 |
/* 0xFFFFFFFF indicates end-of-list link.*/ |
| 165 |
UINT32 key; /* Key used to order the entries.*/ |
| 166 |
|
| 167 |
/* User item info (variable size)*/ |
| 168 |
UINT32 user_info[1]; |
| 169 |
} LLM2_LIST_ITEM; |
| 170 |
|
| 171 |
typedef struct _LLM2_LIST |
| 172 |
{ |
| 173 |
UINT32 user_info_bytes; /* In bytes, size of the user info in a single item.*/ |
| 174 |
UINT32 user_info_size; /* In bytes, size of the user info in a single item.*/ |
| 175 |
UINT32 item_size; |
| 176 |
|
| 177 |
UINT32 head_alloc_size; |
| 178 |
UINT32 total_items; |
| 179 |
UINT32 assigned_items; |
| 180 |
|
| 181 |
UINT32 total_lists; |
| 182 |
UINT32 assigned_lists; |
| 183 |
|
| 184 |
UINT32 next_empty_item; /* Contains a pointer to the next empty item in the*/ |
| 185 |
/* item pool.*/ |
| 186 |
|
| 187 |
/* Table of all the possible list heads:*/ |
| 188 |
LLM2_LIST_HEAD * lh; |
| 189 |
void * list_head_alloc; /* LLM_ALLOC structure used for list head allocation!*/ |
| 190 |
|
| 191 |
/* Table of the list items:*/ |
| 192 |
LLM2_LIST_ITEM * li; |
| 193 |
} LLM2_LIST; |
| 194 |
|
| 195 |
/*void octapi_llm_list_build_structure(void *l, LLM_LIST ** ls);*/ |
| 196 |
LLM_LIST_ITEM * OctApiLlmListGetItemPointer( LLM_LIST * ls, UINT32 item_number ); |
| 197 |
LLM2_LIST_ITEM * OctApiLlm2ListGetItemPointer( LLM2_LIST * ls, UINT32 item_number ); |
| 198 |
UINT32 OctApiTllmCheckTimeoutList( TLLM_ALLOC *ls, UINT32 current_time[2] ); |
| 199 |
VOID * OctApiLlmMemCpy( VOID *f_pvDestination, const VOID * f_pvSource, UINT32 f_ulSize ); |
| 200 |
/**************************************** llm_list section **********************************************/ |
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
#endif /*__OCTAPI_LLMAN_PRIVATE_H__*/ |