versadac  1
versadac - Scalable Recorder Firmware
pool.h
1 /*---------------------------------------------------------------------------*/
2 /* Copyright (C) 2006 Woodhead Software & Electonics. All rights reserved. */
3 /*---------------------------------------------------------------------------*/
4 /* This program is protected by international copyright. */
5 /* */
6 /* The use of this software including but not limited to its Source Code */
7 /* is subject to restrictions as agreed in the license agreement between */
8 /* you and Woodhead. */
9 /* Copying or distribution is not allowed unless expressly permitted */
10 /* according to your license agreement with Woodhead. */
11 /*---------------------------------------------------------------------------*/
12 /* */
13 /* Project : STACK PROFINET Controller */
14 /* Component : Tools */
15 /* $Workfile:: pool.h $*/
16 /* $Revision:: 2 $*/
17 /* $Date:: 9/22/09 6:01p $*/
18 /* */
19 /*---------------------------------------------------------------------------*/
20 /* */
21 /* D e s c r i p t i o n : */
22 /* manage a pool of ethernet frame */
23 /* - All ressources allocated in init */
24 /* - Allow to do a resrvation of 1 resources (lock) */
25 /*---------------------------------------------------------------------------*/
26 
27 #ifndef __ETH_FRAME_DLIST_H__
28 #define __ETH_FRAME_DLIST_H__
29 
30 #include "os_pck.h"
31 
32 typedef struct _pool{
33  /*ST_QUEUE stFreeBloc; Don't use ST_QUEUE*/
34  APP_LPVOID lpFirstElement; /* First element of the queue. APP_NULL If queue is empty */
35  APP_LPVOID lpLastElement; /* Last element of the queue. APP_NULL If queue is empty */
36 
37  APP_WORD wSize;
38  APP_WORD wSizeElt;
39  APP_WORD wMaxElt;
40 } PACK_ALIGNEMENT(ST_POOL),APP_FAR *LPST_POOL;
41 #include "os_unpck.h"
42 
43 /* ------------- Public Interface -------------------- */
44 APP_WORD pool_init (LPST_POOL pPool,APP_WORD wMaxElt,APP_WORD wSizeElt);
45 APP_VOID pool_destroy(LPST_POOL pPool);
46 
47 APP_WORD pool_lock_elt (LPST_POOL pPool, APP_LPBYTE APP_FAR * ppvData);
48 APP_WORD pool_unlock_elt (LPST_POOL pPool, APP_LPBYTE pvData);
49 APP_WORD pool_unlock_elt_at_end(LPST_POOL lpPool, APP_LPBYTE lpbyData);
50 
51 #define pool_nbfree(pPool) ((pPool)->wSize)
52 #define pool_nbused(pPool) ((pPool)->wMaxElt-(pPool)->wSize)
53 #define pool_sizeelt(pPool) ((pPool)->wSizeElt)
54 #define pool_maxframe(pPool) ((pPool)->wMaxElt)
55 #define pool_isfree(pPool) ((( (pPool)->wSize)) != 0)
56 
57 #endif
58 
Definition: pool.h:32