1 /**************************************************************************** 2 **+-----------------------------------------------------------------------+** 3 **| |** 4 **| Copyright(c) 1998 - 2008 Texas Instruments. All rights reserved. |** 5 **| All rights reserved. |** 6 **| |** 7 **| Redistribution and use in source and binary forms, with or without |** 8 **| modification, are permitted provided that the following conditions |** 9 **| are met: |** 10 **| |** 11 **| * Redistributions of source code must retain the above copyright |** 12 **| notice, this list of conditions and the following disclaimer. |** 13 **| * Redistributions in binary form must reproduce the above copyright |** 14 **| notice, this list of conditions and the following disclaimer in |** 15 **| the documentation and/or other materials provided with the |** 16 **| distribution. |** 17 **| * Neither the name Texas Instruments nor the names of its |** 18 **| contributors may be used to endorse or promote products derived |** 19 **| from this software without specific prior written permission. |** 20 **| |** 21 **| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |** 22 **| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |** 23 **| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |** 24 **| A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |** 25 **| OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |** 26 **| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |** 27 **| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |** 28 **| DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |** 29 **| THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |** 30 **| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |** 31 **| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |** 32 **| |** 33 **+-----------------------------------------------------------------------+** 34 ****************************************************************************/ 35 36 37 #ifndef TNETWARB_H 38 #define TNETWARB_H 39 40 #include "osTIType.h" 41 42 43 44 /*----------------------------------------------------------------------*/ 45 /* GKI Definitions */ 46 /*----------------------------------------------------------------------*/ 47 48 49 /* Define the total number of buffer pools supported, fixed and dynamic. 50 */ 51 #define NUM_TNETWARB_TOTAL_BUF_POOLS 3 52 53 54 /* Set this flag to non zero if you want to do buffer ownership checks. 55 ** Note that to do these checks, you should have all tasks that free 56 ** buffers as GKI tasks. 57 */ 58 #define TNETWARB_ENABLE_OWNER_CHECK 0 59 60 61 /* Set this flag to non zero if you want to do buffer corruption checks. 62 ** If set, GKI will check buffer tail corruption every time it processes 63 ** a buffer. This is very useful for debug, and is minimal overhead in 64 ** a running system. 65 */ 66 #define TNETWARB_ENABLE_BUF_CORRUPTION_CHECK 0 67 68 69 /* Set this flag to non zero if you want to do pool id checks. 70 ** If set, GKI will check if pool id exceeds the number of pools. 71 ** This is useful for debug, but not for release version. 72 */ 73 #define TNETWARB_ENABLE_POOL_ID_CHECK 0 74 75 76 /*********************************************************************** 77 ** This queue is a general purpose buffer queue, for application use. 78 *************************************************************************/ 79 typedef struct 80 { 81 void *p_first; 82 void *p_last; 83 UINT16 count; 84 } BUFFER_Q; 85 86 #define TNETWARB_IS_QUEUE_EMPTY(p_q) (p_q.count == 0) 87 88 /* Define the value that create pool will return if it fails 89 */ 90 #define TNETWARB_INVALID_POOL 0xFF 91 92 93 /********************************************************************/ 94 /** Buffer Management Data Structures **/ 95 /********************************************************************/ 96 97 typedef struct _buffer_hdr 98 { 99 struct _buffer_hdr *p_next; 100 UINT8 q_id; 101 UINT8 status; 102 103 } BUFFER_HDR_T; 104 105 106 /* Buffer related defines 107 */ 108 #define BUFFER_HDR_SIZE (sizeof(BUFFER_HDR_T)) 109 #define MAGIC_NO 0xAA55AA55 110 111 112 #define BUF_STATUS_UNLINKED 0 113 #define BUF_STATUS_FREE 1 114 #define BUF_STATUS_QUEUED 2 115 116 117 118 /*********************************************************************** 119 ** Function prototypes 120 */ 121 122 #ifdef __cplusplus 123 extern "C" { 124 #endif 125 126 127 /* To get and release buffers, change owner and get size 128 */ 129 130 void TNETWArb_buffer_init(UINT8 *pTNETWArb_Client_Array); 131 void *TNETWArb_getpoolbuf (TI_HANDLE hTNETWArb,UINT8 module_id); 132 void TNETWArb_freebuf(void *bptr); 133 134 /* User buffer queue management 135 */ 136 void TNETWArb_init_q (BUFFER_Q *p_q); 137 void TNETWArb_Enqueue (BUFFER_Q *p_q, void *p_buf); 138 void TNETWArb_Enqueue_head (BUFFER_Q *p_q, void *p_buf); 139 void *TNETWArb_Dequeue (BUFFER_Q *p_q); 140 void *TNETWArb_remove_from_queue (BUFFER_Q *p_q, void *p_buf); 141 void *TNETWArb_getfirst (BUFFER_Q *p_q); 142 void *TNETWArb_getnext (void *p_buf); 143 144 145 #ifdef __cplusplus 146 } 147 #endif /* of __cplusplus */ 148 149 150 #endif /* of GKI_H */ 151