yu.dong | c33b307 | 2024-08-21 23:14:49 -0700 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | * Copyright Statement: |
| 3 | * -------------------- |
| 4 | * This software is protected by Copyright and the information contained |
| 5 | * herein is confidential. The software may not be copied and the information |
| 6 | * contained herein may not be used or disclosed except with the written |
| 7 | * permission of MediaTek Inc. (C) 2011 |
| 8 | * |
| 9 | * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES |
| 10 | * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") |
| 11 | * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON |
| 12 | * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, |
| 13 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF |
| 14 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. |
| 15 | * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE |
| 16 | * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR |
| 17 | * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH |
| 18 | * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO |
| 19 | * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S |
| 20 | * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. |
| 21 | * |
| 22 | * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE |
| 23 | * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, |
| 24 | * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, |
| 25 | * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO |
| 26 | * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. |
| 27 | * |
| 28 | * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE |
| 29 | * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF |
| 30 | * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND |
| 31 | * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER |
| 32 | * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). |
| 33 | * |
| 34 | *******************************************************************************/ |
| 35 | |
| 36 | /******************************************************************************* |
| 37 | * Filename: |
| 38 | * --------- |
| 39 | * gpd_lib.h |
| 40 | * |
| 41 | * Project: |
| 42 | * -------- |
| 43 | * MAUI |
| 44 | * |
| 45 | * Description: |
| 46 | * ------------ |
| 47 | * |
| 48 | * |
| 49 | * Author: |
| 50 | * ------- |
| 51 | * ------- |
| 52 | * |
| 53 | *============================================================================== |
| 54 | * HISTORY |
| 55 | * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 56 | *------------------------------------------------------------------------------ |
| 57 | * removed! |
| 58 | * |
| 59 | * removed! |
| 60 | * removed! |
| 61 | * removed! |
| 62 | * removed! |
| 63 | * removed! |
| 64 | * removed! |
| 65 | * |
| 66 | * removed! |
| 67 | * removed! |
| 68 | * removed! |
| 69 | * |
| 70 | * removed! |
| 71 | * removed! |
| 72 | * removed! |
| 73 | * |
| 74 | * |
| 75 | * |
| 76 | *------------------------------------------------------------------------------ |
| 77 | * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 78 | *============================================================================== |
| 79 | ******************************************************************************/ |
| 80 | |
| 81 | #ifndef GPD_LIB_H |
| 82 | #define GPD_LIB_H |
| 83 | /******************************************************************************/ |
| 84 | |
| 85 | /****************************************************************************** |
| 86 | * SAMPLE CODE |
| 87 | *******************************************************************************/ |
| 88 | |
| 89 | // Basic |
| 90 | /****************************************************************************** |
| 91 | // An example of combining two gpd linked lists and poll the first 3 nodes |
| 92 | { |
| 93 | gpd_node* gpd_nodes_a; //gpd linked list A with 5 items |
| 94 | gpd_node* gpd_nodes_b; //gpd linked list B with 5 items |
| 95 | |
| 96 | gpd_nodes_a = gpd_lib_add( gpd_nodes_a, gpd_nodes_b); |
| 97 | gpd_nodes_a = gpd_lib_poll( gpd_nodes_a, 3, &gpd_node_b); |
| 98 | |
| 99 | gpd_lib_size( gpd_nodes_a); // 7 |
| 100 | gpd_lib_size( gpd_nodes_b); // 3 |
| 101 | } |
| 102 | *******************************************************************************/ |
| 103 | |
| 104 | // List |
| 105 | /****************************************************************************** |
| 106 | // An example of adding nodes to gpd_list and poll all items out |
| 107 | { |
| 108 | gpd_list node_list; //a gpd_list |
| 109 | gpd_node* gpd_nodes; //gpd linked list with 5 items |
| 110 | |
| 111 | gpd_lib_list_create ( &node_list ); // Initialize gpd_list struct |
| 112 | gpd_lib_list_add( &node_list, gpd_nodes); // add nodes into gpd_list |
| 113 | |
| 114 | gpd_lib_list_size( &node_list ); // 5 |
| 115 | |
| 116 | gpd_nodes = gpd_lib_list_pollAll( &node_list ); // Poll all gpd nodes out |
| 117 | |
| 118 | gpd_lib_size(gpd_nodes); // 5 |
| 119 | gpd_lib_list_size( &node_list ); // 0 |
| 120 | } |
| 121 | *******************************************************************************/ |
| 122 | |
| 123 | // Iterator |
| 124 | /****************************************************************************** |
| 125 | // An example of traversing a gpd linked list and remove nodes |
| 126 | { |
| 127 | gpd_node* gpd_nodes; //The gpd linked list which is going to be traversed |
| 128 | |
| 129 | gpd_itr itr; |
| 130 | gpd_node* node; |
| 131 | gpd_lib_iterator_create( &itr, &gpd_nodes ); // Create an iterator |
| 132 | while( (node = gpd_lib_iterator_next(&itr))!= NULL ) |
| 133 | { |
| 134 | if ( gpd_lib_data_size(node) > 1500 ) |
| 135 | { |
| 136 | node = gpd_lib_iterator_remove(&itr); // Remove gpd with 1500+ data length |
| 137 | } |
| 138 | } |
| 139 | } |
| 140 | *******************************************************************************/ |
| 141 | |
| 142 | // Umts GPD Header and Tail |
| 143 | /****************************************************************************** |
| 144 | // An example of adding and removing a header and a tail to an umts gpd node |
| 145 | { |
| 146 | gpd_node* umts_dl_gpd; //A umts dl gpd node |
| 147 | |
| 148 | kal_uint8 head[] = {0xAA,0xAA,0xAA}; |
| 149 | kal_uint8 tail[] = {0xBB,0xBB,0xBB}; |
| 150 | |
| 151 | // Add header and tail |
| 152 | gpd_lib_umts_addHeader( umts_dl_gpd, head, 3 ); |
| 153 | gpd_lib_umts_addTail( umts_dl_gpd, tail, 3 ); |
| 154 | |
| 155 | // Delete header and tail |
| 156 | gpd_lib_umts_delHeader( umts_dl_gpd, head, 3 ); |
| 157 | gpd_lib_umts_delTail( umts_dl_gpd, tail, 3 ); |
| 158 | } |
| 159 | *******************************************************************************/ |
| 160 | |
| 161 | // Create Umts Single GPD and BD |
| 162 | /****************************************************************************** |
| 163 | // An example of creating a single GPD with a single BD |
| 164 | { |
| 165 | gpd_node* umts_dl_gpd; |
| 166 | |
| 167 | kal_uint8 mem[1024]; |
| 168 | kal_uint8 data[] = { 1, 2, 3, 4 }; |
| 169 | |
| 170 | if( gpd_lib_umts_sizeSingleGpdBd() > 1024 ) ASSERT(0); |
| 171 | |
| 172 | umts_dl_gpd = gpd_lib_umts_createSingleGpdBd( mem, data, 4 ); |
| 173 | |
| 174 | //You get a gpd_node umts_dl_gpd |
| 175 | } |
| 176 | *******************************************************************************/ |
| 177 | |
| 178 | /******************************************************************************/ |
| 179 | |
| 180 | #include "kal_general_types.h" |
| 181 | |
| 182 | /******************************************************************************/ |
| 183 | |
| 184 | //#define __GPD_LIB_DUBUG__ |
| 185 | |
| 186 | /******************************************************************************/ |
| 187 | |
| 188 | #define GPD_LIB_GPD_RX_HEADER_SIZE (0) |
| 189 | #define GPD_LIB_GPD_RX_FOOTER_SIZE (8) |
| 190 | |
| 191 | /******************************************************************************/ |
| 192 | |
| 193 | typedef struct _gpd_node |
| 194 | { |
| 195 | struct |
| 196 | { |
| 197 | kal_uint32 hwo:1; |
| 198 | kal_uint32 bdp:1; |
| 199 | kal_uint32 reserved:6; |
| 200 | kal_uint32 checksum:8; |
| 201 | kal_uint32 allow_buff_size:16; |
| 202 | } w0; |
| 203 | union |
| 204 | { |
| 205 | kal_uint32* next_gpd_addr; |
| 206 | struct _gpd_node* next_gpd_node; |
| 207 | } w1; |
| 208 | union |
| 209 | { |
| 210 | kal_uint8* buff_addr; |
| 211 | kal_uint32* first_bd_addr; |
| 212 | } w2; |
| 213 | struct |
| 214 | { |
| 215 | kal_uint16 data_buff_size; |
| 216 | kal_uint16 reserved; |
| 217 | } w3; |
| 218 | } gpd_node; |
| 219 | |
| 220 | /******************************************************************************/ |
| 221 | |
| 222 | typedef struct _gpd_list |
| 223 | { |
| 224 | gpd_node* first; |
| 225 | gpd_node* last; |
| 226 | |
| 227 | } gpd_list; |
| 228 | |
| 229 | /******************************************************************************/ |
| 230 | |
| 231 | typedef struct _gpd_itr |
| 232 | { |
| 233 | gpd_node* ptr; |
| 234 | gpd_node* pre; |
| 235 | gpd_node** root; |
| 236 | |
| 237 | } gpd_itr; |
| 238 | |
| 239 | /******************************************************************************/ |
| 240 | |
| 241 | extern gpd_node* gpd_lib_add( gpd_node* root, gpd_node* nodes ); |
| 242 | extern gpd_node* gpd_lib_poll( gpd_node* root, kal_uint16 num, gpd_node** nodes ); |
| 243 | extern kal_uint16 gpd_lib_size( gpd_node* root ); |
| 244 | extern kal_bool gpd_lib_scan( gpd_node* root, kal_uint16* size, gpd_node** last ); |
| 245 | |
| 246 | /******************************************************************************/ |
| 247 | |
| 248 | extern gpd_list* gpd_lib_list_create( void* mem_ptr ); |
| 249 | extern void gpd_lib_list_add( gpd_list* list, gpd_node* nodes ); |
| 250 | extern gpd_node* gpd_lib_list_poll( gpd_list* list, kal_uint16 num ); |
| 251 | extern void gpd_lib_list_add_ex( gpd_list* list, gpd_node* first, gpd_node* last ); |
| 252 | extern gpd_node* gpd_lib_list_poll_ex( gpd_list* list, gpd_node** last ); |
| 253 | extern kal_uint16 gpd_lib_list_size( gpd_list* list ); |
| 254 | |
| 255 | /******************************************************************************/ |
| 256 | |
| 257 | extern gpd_itr* gpd_lib_iterator_create( void* mem_ptr, gpd_node** nodes ); |
| 258 | extern gpd_node* gpd_lib_iterator_next( gpd_itr* itr ); |
| 259 | extern kal_bool gpd_lib_iterator_hasNext( gpd_itr* itr ); |
| 260 | extern gpd_node* gpd_lib_iterator_remove( gpd_itr* itr ); |
| 261 | extern gpd_node* gpd_lib_iterator_cut( gpd_itr* itr ); |
| 262 | |
| 263 | /******************************************************************************/ |
| 264 | |
| 265 | #define gpd_lib_data_size(np) ((kal_uint16)((np)->w3.data_buff_size)) |
| 266 | #define gpd_lib_data_getAddr(np) ((kal_uint8*)((np)->w2.buff_addr)) |
| 267 | #define gpd_lib_data_setSize(np,size) ((np)->w3.data_buff_size = (kal_uint16)(size)) |
| 268 | extern kal_uint16 gpd_lib_data_totalsize( gpd_node* nodes ); |
| 269 | |
| 270 | /******************************************************************************/ |
| 271 | |
| 272 | extern void gpd_lib_umts_addHeader( gpd_node* node, kal_uint8* buff_ptr, |
| 273 | kal_uint16 buff_len ); |
| 274 | extern void gpd_lib_umts_delHeader( gpd_node* node, kal_uint8** buff_ptr ); |
| 275 | extern kal_uint8* gpd_lib_umts_peekHeader( gpd_node* node ); |
| 276 | extern void gpd_lib_umts_addTail( gpd_node* node, kal_uint8* buff_ptr, |
| 277 | kal_uint16 buff_len ); |
| 278 | extern void gpd_lib_umts_delTail( gpd_node* node, kal_uint8** buff_ptr ); |
| 279 | |
| 280 | extern kal_uint8* gpd_lib_umts_getFirstBDDataPtr( gpd_node* node ); |
| 281 | extern kal_uint32* gpd_lib_umts_getFirstBDPeerBuffPtr( gpd_node* node ); |
| 282 | extern void gpd_lib_umts_clearFirstBDPeerBuffPtr( gpd_node* node ); |
| 283 | extern kal_uint8 gpd_lib_umts_getType( gpd_node* node ); |
| 284 | extern void gpd_lib_umts_setOutputAddr( gpd_node* node, kal_uint8* addr ); |
| 285 | |
| 286 | /******************************************************************************/ |
| 287 | |
| 288 | extern void gpd_lib_sdio_tx_initGpd(gpd_node * node); |
| 289 | extern gpd_node* gpd_lib_sdio_tx_createGpd( void* mem_ptr, kal_uint8* buff_addr, |
| 290 | kal_uint16 buff_len ); |
| 291 | extern kal_uint8* gpd_lib_sdio_tx_getCCCIHeader( gpd_node* node ); |
| 292 | extern kal_uint8* gpd_lib_sdio_tx_getPayloadAddr(gpd_node * node); |
| 293 | extern kal_uint16 gpd_lib_sdio_tx_getPayloadLen( gpd_node* node ); |
| 294 | extern kal_uint16 gpd_lib_sdio_tx_sizeGpd( void ); |
| 295 | |
| 296 | /******************************************************************************/ |
| 297 | |
| 298 | #if defined(__3G_NEW_DATA_PLANE_ARCH__) && defined(__GPD_LIB_TEST__) |
| 299 | #include "uas_data_common.h" |
| 300 | |
| 301 | #define UMTSGPD_HEADER_BUFFER_SIZE 60 // used by module UPS |
| 302 | #define UMTSGPD_FOOTER_BUFFER_SIZE 4 // used by module UPS |
| 303 | |
| 304 | typedef struct _umts_dl_gpd_flc |
| 305 | { |
| 306 | umts_dl_gpd gpd; |
| 307 | |
| 308 | kal_uint32 header_buffer[(UMTSGPD_HEADER_BUFFER_SIZE+3)/4]; |
| 309 | kal_uint32 footer_buffer[(UMTSGPD_FOOTER_BUFFER_SIZE+3)/4]; |
| 310 | |
| 311 | } umts_dl_gpd_flc; |
| 312 | |
| 313 | extern void gpd_lib_umts_initBd(umts_dl_bd * bd); |
| 314 | extern void gpd_lib_umts_initGpd ( umts_dl_gpd* gpd ); |
| 315 | extern void gpd_lib_umts_initGpdFlc ( umts_dl_gpd_flc* gpd ); |
| 316 | extern void gpd_lib_umts_addBdtoGpd( umts_dl_gpd* gpd, umts_dl_bd* bd ); |
| 317 | extern gpd_node* gpd_lib_umts_createSingleGpdBd( void* mem_ptr, |
| 318 | kal_uint8* buff_addr, kal_uint16 buff_len ); |
| 319 | extern kal_uint16 gpd_lib_umts_sizeSingleGpdBd( void ); |
| 320 | #endif |
| 321 | |
| 322 | /******************************************************************************/ |
| 323 | #endif /* GPD_LIB_H */ |
| 324 | |