FreeCalypso > hg > fc-magnetite
comparison src/g23m-fad/rlp/rlp_pei.c @ 174:90eb61ecd093
src/g23m-fad: initial import from TCS3.2/LoCosto
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Wed, 12 Oct 2016 05:40:46 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 173:bf64d785238a | 174:90eb61ecd093 |
|---|---|
| 1 /* | |
| 2 +----------------------------------------------------------------------------- | |
| 3 | Project : CSD (8411) | |
| 4 | Modul : Rlp_pei.c | |
| 5 +----------------------------------------------------------------------------- | |
| 6 | Copyright 2002 Texas Instruments Berlin, AG | |
| 7 | All rights reserved. | |
| 8 | | |
| 9 | This file is confidential and a trade secret of Texas | |
| 10 | Instruments Berlin, AG | |
| 11 | The receipt of or possession of this file does not convey | |
| 12 | any rights to reproduce or disclose its contents or to | |
| 13 | manufacture, use, or sell anything it may describe, in | |
| 14 | whole, or in part, without the specific written consent of | |
| 15 | Texas Instruments Berlin, AG. | |
| 16 +----------------------------------------------------------------------------- | |
| 17 | Purpose : This Modul defines the process body interface | |
| 18 | for the component Radio Link Protocol of the base station | |
| 19 +----------------------------------------------------------------------------- | |
| 20 */ | |
| 21 | |
| 22 #ifndef RLP_PEI_C | |
| 23 #define RLP_PEI_C | |
| 24 #endif | |
| 25 | |
| 26 #define ENTITY_RLP | |
| 27 | |
| 28 /*==== INCLUDES ===================================================*/ | |
| 29 | |
| 30 #include <string.h> | |
| 31 #include <stdlib.h> | |
| 32 #include "typedefs.h" | |
| 33 #include "pconst.cdg" | |
| 34 #include "vsi.h" | |
| 35 #include "custom.h" | |
| 36 #include "tools.h" | |
| 37 #include "gsm.h" | |
| 38 #include "cus_rlp.h" | |
| 39 #include "cnf_rlp.h" | |
| 40 #include "mon_rlp.h" | |
| 41 #include "prim.h" | |
| 42 #include "pei.h" | |
| 43 #include "tok.h" | |
| 44 #include "rlp.h" | |
| 45 | |
| 46 /*==== CONST ======================================================*/ | |
| 47 | |
| 48 /*==== VAR EXPORT =================================================*/ | |
| 49 | |
| 50 /*==== VAR LOCAL ==================================================*/ | |
| 51 | |
| 52 #ifdef OPTION_RELATIVE | |
| 53 LOCAL ULONG offset; | |
| 54 #endif | |
| 55 | |
| 56 LOCAL BOOL first_access = TRUE; | |
| 57 LOCAL T_MONITOR rlp_mon; | |
| 58 | |
| 59 /* | |
| 60 +------------------------------------------------------------------------------ | |
| 61 | Function : pei_not_supported | |
| 62 +------------------------------------------------------------------------------ | |
| 63 | Description : An unsupported primitive is received. | |
| 64 | |
| 65 | | |
| 66 | Parameters : data - | |
| 67 | | |
| 68 | | |
| 69 | Return : - | |
| 70 +------------------------------------------------------------------------------ | |
| 71 */ | |
| 72 | |
| 73 | |
| 74 LOCAL void pei_not_supported (void *data) | |
| 75 { | |
| 76 TRACE_FUNCTION ("pei_not_supported()"); | |
| 77 | |
| 78 PFREE (data); | |
| 79 } | |
| 80 | |
| 81 /* | |
| 82 * | |
| 83 * Use MAK_FUNC_0 for primitives which contains no SDU. | |
| 84 * | |
| 85 * Use MAK_FUNC_S for primitives which contains a SDU. | |
| 86 */ | |
| 87 | |
| 88 /* | |
| 89 * jumptable for the entity service access point. Contains | |
| 90 * the processing-function addresses and opcodes of | |
| 91 * request and response primitives. | |
| 92 * | |
| 93 */ | |
| 94 | |
| 95 LOCAL const T_FUNC rlp_table[] = { | |
| 96 MAK_FUNC_0( ker_rlp_attach_req , RLP_ATTACH_REQ ), | |
| 97 MAK_FUNC_0( ker_rlp_detach_req , RLP_DETACH_REQ ), | |
| 98 MAK_FUNC_0( ker_rlp_connect_req , RLP_CONNECT_REQ ), | |
| 99 MAK_FUNC_0( ker_rlp_connect_res , RLP_CONNECT_RES ), | |
| 100 MAK_FUNC_0( ker_rlp_disc_req , RLP_DISC_REQ ), | |
| 101 MAK_FUNC_0( ker_rlp_reset_req , RLP_RESET_REQ ), | |
| 102 MAK_FUNC_0( ker_rlp_reset_res , RLP_RESET_RES ), | |
| 103 MAK_FUNC_S( ker_rlp_data_req , RLP_DATA_REQ ), | |
| 104 MAK_FUNC_0( ker_rlp_getdata_req , RLP_GETDATA_REQ ), | |
| 105 MAK_FUNC_S( ker_rlp_ui_req , RLP_UI_REQ ), | |
| 106 MAK_FUNC_0( ker_rlp_remap_req , RLP_REMAP_REQ ), | |
| 107 MAK_FUNC_0( ker_rlp_remap_data_res , RLP_REMAP_DATA_RES) | |
| 108 }; | |
| 109 | |
| 110 /* | |
| 111 * jumptable for the service access point which are used by | |
| 112 * the entity. Contains the processing-function addresses and | |
| 113 * opcodes of indication and confirm primitives. | |
| 114 * | |
| 115 */ | |
| 116 LOCAL const T_FUNC ra_table[] = { | |
| 117 MAK_FUNC_0( rcv_ra_ready_ind , RA_READY_IND ), | |
| 118 MAK_FUNC_S( rcv_ra_data_ind , RA_DATA_IND ) | |
| 119 }; | |
| 120 | |
| 121 /* | |
| 122 +------------------------------------------------------------------------------ | |
| 123 | Function : pei_primitive | |
| 124 +------------------------------------------------------------------------------ | |
| 125 | Description : Process protocol specific primitive. | |
| 126 | | |
| 127 | Parameters : ptr - | |
| 128 | | |
| 129 | | |
| 130 | Return : PEI_OK - | |
| 131 | PEI_ERROR - | |
| 132 +------------------------------------------------------------------------------ | |
| 133 */ | |
| 134 | |
| 135 LOCAL SHORT pei_primitive (void * ptr) | |
| 136 { | |
| 137 T_PRIM * prim = ptr; | |
| 138 /* | |
| 139 * @ADAPT@ | |
| 140 * | | |
| 141 * L2R UPPER LAYER | |
| 142 * | | |
| 143 * v | |
| 144 * +-----------(rlp)----------+ | |
| 145 * | | | |
| 146 * | RLP | | |
| 147 * | | | |
| 148 * +-------------^------------+ | |
| 149 * | | |
| 150 * RA LOWER LAYER | |
| 151 * | | |
| 152 * | |
| 153 */ | |
| 154 | |
| 155 TRACE_FUNCTION ("pei_primitive()"); | |
| 156 | |
| 157 if (prim NEQ NULL) | |
| 158 { | |
| 159 ULONG opc = prim->custom.opc; | |
| 160 USHORT n; | |
| 161 const T_FUNC *table; | |
| 162 | |
| 163 VSI_PPM_REC ((T_PRIM_HEADER *)prim, __FILE__, __LINE__); | |
| 164 | |
| 165 PTRACE_IN (opc); | |
| 166 | |
| 167 rlp_data = GET_INSTANCE (prim); | |
| 168 | |
| 169 switch (SAP_NR(opc)) | |
| 170 { | |
| 171 case SAP_NR(RLP_UL): table = rlp_table; n = TAB_SIZE (rlp_table); break; | |
| 172 case SAP_NR(RA_DL ): table = ra_table; n = TAB_SIZE (ra_table); break; | |
| 173 default : table = NULL; n = 0; break; | |
| 174 } | |
| 175 | |
| 176 if (table NEQ NULL ) | |
| 177 { | |
| 178 if (PRIM_NR(opc) < n) | |
| 179 { | |
| 180 table += PRIM_NR(opc); | |
| 181 #ifdef PALLOC_TRANSITION | |
| 182 P_SDU(prim) = table->soff ? (T_sdu*) (((char*)&prim->data) + table->soff) : 0; | |
| 183 #ifndef NO_COPY_ROUTING | |
| 184 P_LEN(prim) = table->size + sizeof (T_PRIM_HEADER); | |
| 185 #endif /* NO_COPY_ROUTING */ | |
| 186 #endif /* PALLOC_TRANSITION */ | |
| 187 JUMP (table->func) (P2D(prim)); | |
| 188 } | |
| 189 else | |
| 190 { | |
| 191 pei_not_supported (P2D(prim)); | |
| 192 } | |
| 193 return PEI_OK; | |
| 194 } | |
| 195 /* | |
| 196 * Primitive is no GSM Primitive | |
| 197 * then forward to the environment | |
| 198 */ | |
| 199 | |
| 200 #ifdef GSM_ONLY | |
| 201 PFREE (P2D(prim)) | |
| 202 | |
| 203 return PEI_ERROR; | |
| 204 #else | |
| 205 if (opc & SYS_MASK) | |
| 206 vsi_c_primitive (VSI_CALLER prim); | |
| 207 else | |
| 208 { | |
| 209 PFREE (P2D(prim)); | |
| 210 return PEI_ERROR; | |
| 211 } | |
| 212 #endif | |
| 213 } | |
| 214 return PEI_OK; | |
| 215 } | |
| 216 | |
| 217 /* | |
| 218 +------------------------------------------------------------------------------ | |
| 219 | Function : pei_init | |
| 220 +------------------------------------------------------------------------------ | |
| 221 | Description : Initialize Protocol Stack Entity | |
| 222 | | |
| 223 | Parameters : handle - | |
| 224 | | |
| 225 | | |
| 226 | Return : PEI_OK - | |
| 227 | PEI_ERROR - | |
| 228 +------------------------------------------------------------------------------ | |
| 229 */ | |
| 230 | |
| 231 | |
| 232 LOCAL SHORT pei_init (T_HANDLE handle) | |
| 233 { | |
| 234 rlp_handle = handle; | |
| 235 | |
| 236 TRACE_FUNCTION ("pei_init()"); | |
| 237 | |
| 238 if (hCommL2R < VSI_OK) | |
| 239 { | |
| 240 if ((hCommL2R = vsi_c_open (VSI_CALLER L2R_NAME)) < VSI_OK) | |
| 241 return PEI_ERROR; | |
| 242 } | |
| 243 | |
| 244 #ifdef _SIMULATION_ | |
| 245 if (hCommRA < VSI_OK) | |
| 246 { | |
| 247 if ((hCommRA = vsi_c_open (VSI_CALLER RA_NAME)) < VSI_OK) | |
| 248 return PEI_ERROR; | |
| 249 } | |
| 250 #endif | |
| 251 | |
| 252 rlp_data = &rlp_data_base[0]; | |
| 253 rlp_data_magic_num = 0; /* memory is not yet initialized */ | |
| 254 | |
| 255 #ifdef _SIMULATION_ | |
| 256 /* | |
| 257 to ensure that an NULL frame can be sent | |
| 258 if RLP receives an RA_READY_INDICATION in detached state | |
| 259 */ | |
| 260 { | |
| 261 USHORT t; | |
| 262 | |
| 263 /*******************************/ | |
| 264 /* | |
| 265 * Initialize Shared Fax/Data memory | |
| 266 */ | |
| 267 | |
| 268 rlp_data = &rlp_data_base[0]; | |
| 269 memset(rlp_data, 0, sizeof (T_RLP_DATA)); | |
| 270 ker_init (); | |
| 271 snd_init (&rlp_data->snd); | |
| 272 rcv_init (); | |
| 273 rlp_data->uplink_frame_trace = FALSE; | |
| 274 rlp_data->downlink_frame_trace = FALSE; | |
| 275 rbm_reset(&rlp_data->rbm); | |
| 276 | |
| 277 for (t = 0; t < (MAX_SREJ_COUNT+5); t++) | |
| 278 { | |
| 279 TIMERSTOP (t); | |
| 280 } | |
| 281 | |
| 282 rlp_data_magic_num = RLP_DATA_MAGIC_NUM; /* memory is initialized */ | |
| 283 | |
| 284 rlp_data = &rlp_data_base[0]; | |
| 285 sig_ker_snd_set_frame_size_req (FRAME_SIZE_SHORT); | |
| 286 } | |
| 287 | |
| 288 rlp_data = &rlp_data_base[0]; | |
| 289 | |
| 290 #endif | |
| 291 | |
| 292 return PEI_OK; | |
| 293 } | |
| 294 | |
| 295 /* | |
| 296 +------------------------------------------------------------------------------ | |
| 297 | Function : pei_timeout | |
| 298 +------------------------------------------------------------------------------ | |
| 299 | Description : Process timeout | |
| 300 | | |
| 301 | Parameters : index | |
| 302 | | |
| 303 | | |
| 304 | Return : PEI_OK | |
| 305 | PEI_ERROR | |
| 306 +------------------------------------------------------------------------------ | |
| 307 */ | |
| 308 | |
| 309 LOCAL SHORT pei_timeout (USHORT index) | |
| 310 { | |
| 311 rlp_exec_timeout (index); | |
| 312 return PEI_OK; | |
| 313 } | |
| 314 | |
| 315 /* | |
| 316 +------------------------------------------------------------------------------ | |
| 317 | Function : pei_signal | |
| 318 +------------------------------------------------------------------------------ | |
| 319 | Description : Functional interface to signal a primitive. | |
| 320 | | |
| 321 | Parameters : opc - | |
| 322 | primData - | |
| 323 | | |
| 324 | | |
| 325 | Return : PEI_OK - | |
| 326 | PEI_ERROR - | |
| 327 +------------------------------------------------------------------------------ | |
| 328 */ | |
| 329 | |
| 330 LOCAL SHORT pei_signal (ULONG opc, void *primData) | |
| 331 { | |
| 332 #ifdef OPTION_SIGNAL | |
| 333 | |
| 334 if (rlp_data_magic_num NEQ RLP_DATA_MAGIC_NUM) | |
| 335 /* memory is not initialized */ | |
| 336 { | |
| 337 /* ignore received signals */ | |
| 338 return PEI_OK; | |
| 339 } | |
| 340 | |
| 341 rlp_data = GET_INSTANCE (primData); | |
| 342 | |
| 343 switch (opc) | |
| 344 { | |
| 345 case RA_DATA_IND: | |
| 346 rcv_ra_data_ind((T_RA_DATA_IND *)primData); | |
| 347 break; | |
| 348 | |
| 349 case RA_READY_IND: | |
| 350 #ifdef _SIMULATION_ | |
| 351 rcv_ra_ready_ind((T_RA_READY_IND *)primData); | |
| 352 #else | |
| 353 rcv_ra_ready_ind(); | |
| 354 #endif | |
| 355 break; | |
| 356 } | |
| 357 | |
| 358 #endif /* OPTION_SIGNAL */ | |
| 359 return PEI_OK; | |
| 360 } | |
| 361 | |
| 362 /* | |
| 363 +------------------------------------------------------------------------------ | |
| 364 | Function : pei_exit | |
| 365 +------------------------------------------------------------------------------ | |
| 366 | Description : Close Resources and terminate | |
| 367 | | |
| 368 | Parameters : - | |
| 369 | | |
| 370 | | |
| 371 | Return : - | |
| 372 +------------------------------------------------------------------------------ | |
| 373 */ | |
| 374 | |
| 375 LOCAL SHORT pei_exit (void) | |
| 376 { | |
| 377 TRACE_FUNCTION ("pei_exit()"); | |
| 378 | |
| 379 /* | |
| 380 * clean up communication | |
| 381 */ | |
| 382 | |
| 383 vsi_c_close (VSI_CALLER hCommL2R); | |
| 384 hCommL2R = VSI_ERROR; | |
| 385 | |
| 386 #ifdef _SIMULATION_ | |
| 387 vsi_c_close (VSI_CALLER hCommRA); | |
| 388 hCommRA = VSI_ERROR; | |
| 389 #endif | |
| 390 | |
| 391 return PEI_OK; | |
| 392 } | |
| 393 | |
| 394 /* | |
| 395 +------------------------------------------------------------------------------ | |
| 396 | Function : pei_config | |
| 397 +------------------------------------------------------------------------------ | |
| 398 | Description : Dynamic Configuration | |
| 399 | | |
| 400 | Parameters : inString - | |
| 401 | | |
| 402 | | |
| 403 | Return : PEI_OK - | |
| 404 | PEI_ERROR - | |
| 405 +------------------------------------------------------------------------------ | |
| 406 */ | |
| 407 | |
| 408 LOCAL SHORT pei_config (T_PEI_CONFIG inString) | |
| 409 { | |
| 410 #ifndef NCONFIG | |
| 411 | |
| 412 const T_STR_IND tmr_name_to_ind[] = | |
| 413 { | |
| 414 { "TUL_RCV", 1 }, | |
| 415 { NULL, 0 } | |
| 416 }; | |
| 417 | |
| 418 TRACE_FUNCTION ("pei_config()"); | |
| 419 | |
| 420 if (ConfigTimer(VSI_CALLER inString, tmr_name_to_ind) EQ VSI_OK) | |
| 421 { | |
| 422 TRACE_EVENT_P1("TUL_RCV now at: %02X ms", rlp_data->ker.T_ul); | |
| 423 return PEI_OK; | |
| 424 } | |
| 425 else | |
| 426 return PEI_ERROR; | |
| 427 | |
| 428 #else /* NCONFIG */ | |
| 429 | |
| 430 return PEI_OK; | |
| 431 | |
| 432 #endif | |
| 433 } | |
| 434 | |
| 435 /* | |
| 436 +------------------------------------------------------------------------------ | |
| 437 | Function : pei_monitor | |
| 438 +------------------------------------------------------------------------------ | |
| 439 | Description : Monitoring of physical Parameters | |
| 440 | | |
| 441 | Parameters : monitor - | |
| 442 | | |
| 443 | | |
| 444 | Return : PEI_OK | |
| 445 +------------------------------------------------------------------------------ | |
| 446 */ | |
| 447 | |
| 448 | |
| 449 LOCAL SHORT pei_monitor (void **monitor) | |
| 450 { | |
| 451 TRACE_FUNCTION ("pei_monitor()"); | |
| 452 | |
| 453 rlp_mon.version = VERSION_RLP; | |
| 454 | |
| 455 *monitor = &rlp_mon; | |
| 456 | |
| 457 return PEI_OK; | |
| 458 } | |
| 459 | |
| 460 /* | |
| 461 +------------------------------------------------------------------------------ | |
| 462 | Function : pei_create | |
| 463 +------------------------------------------------------------------------------ | |
| 464 | Description : Create the Protocol Stack Entity | |
| 465 | | |
| 466 | Parameters : info - | |
| 467 | | |
| 468 | | |
| 469 | Return : PEI_OK - | |
| 470 +------------------------------------------------------------------------------ | |
| 471 */ | |
| 472 | |
| 473 /*lint -e714 : Symbol not referenced */ | |
| 474 /*lint -e765 : external could be made static */ | |
| 475 GLOBAL SHORT rlp_pei_create (T_PEI_INFO const **info) | |
| 476 { | |
| 477 static const T_PEI_INFO pei_info = | |
| 478 { | |
| 479 RLP_NAME, | |
| 480 { | |
| 481 pei_init, | |
| 482 pei_exit, | |
| 483 pei_primitive, | |
| 484 pei_timeout, | |
| 485 pei_signal, | |
| 486 NULL, /* no run function */ | |
| 487 pei_config, | |
| 488 pei_monitor | |
| 489 }, | |
| 490 1024, | |
| 491 10, | |
| 492 215, | |
| 493 MAX_SREJ_COUNT+5, | |
| 494 0x03|PRIM_NO_SUSPEND | |
| 495 }; | |
| 496 | |
| 497 TRACE_FUNCTION ("pei_create()"); | |
| 498 | |
| 499 /* | |
| 500 * Close Resources if open | |
| 501 */ | |
| 502 | |
| 503 if (first_access) | |
| 504 first_access = FALSE; | |
| 505 else | |
| 506 pei_exit (); | |
| 507 | |
| 508 /* | |
| 509 * Export Startup configuration data | |
| 510 */ | |
| 511 | |
| 512 *info = &pei_info; | |
| 513 | |
| 514 return PEI_OK; | |
| 515 } | |
| 516 |
