FreeCalypso > hg > fc-magnetite
comparison src/aci2/aci/cmh_pktio.c @ 3:93999a60b835
src/aci2, src/condat2: import of g23m/condat source pieces from TCS211
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 26 Sep 2016 00:29:36 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2:c41a534f33c6 | 3:93999a60b835 |
---|---|
1 /* | |
2 +------------------------------------------------------------------------------ | |
3 | File: cmh_pktio.c | |
4 +------------------------------------------------------------------------------ | |
5 | Copyright 2002 Texas Instruments Berlin, AG | |
6 | All rights reserved. | |
7 | | |
8 | This file is confidential and a trade secret of Texas | |
9 | Instruments Berlin, AG | |
10 | The receipt of or possession of this file does not convey | |
11 | any rights to reproduce or disclose its contents or to | |
12 | manufacture, use, or sell anything it may describe, in | |
13 | whole, or in part, without the specific written consent of | |
14 | Texas Instruments Berlin, AG. | |
15 +------------------------------------------------------------------------------ | |
16 | Purpose: This module defines the functions used by the command | |
17 | handler for packet I/O (PKTIO). | |
18 +------------------------------------------------------------------------------ | |
19 */ | |
20 | |
21 #if defined (GPRS ) && defined (DTI) | |
22 #ifdef FF_PKTIO | |
23 #ifndef CMH_PKTIO_C | |
24 #define CMH_PKTIO_C | |
25 #endif | |
26 | |
27 #include "aci_all.h" | |
28 /*==== INCLUDES ===================================================*/ | |
29 #include "gprs.h" | |
30 | |
31 #include "dti.h" /* functionality of the dti library */ | |
32 #include "aci_cmh.h" | |
33 #include "ati_cmd.h" | |
34 #include "aci_cmd.h" | |
35 | |
36 #include "aci.h" | |
37 #include "psa.h" | |
38 | |
39 #include "cmh.h" | |
40 | |
41 | |
42 #include "dti_conn_mng.h" | |
43 #include "dti_cntrl_mng.h" | |
44 #include "sap_dti.h" | |
45 #include "gaci.h" | |
46 #include "gaci_cmh.h" | |
47 #include "cmh_sm.h" | |
48 #include "psa_pktio.h" | |
49 #include "cmh_pktio.h" | |
50 | |
51 | |
52 /*==== CONSTANTS ==================================================*/ | |
53 #define MAX_BAUD_RATE 20 | |
54 /*==== TYPES ======================================================*/ | |
55 | |
56 /*==== EXPORT =====================================================*/ | |
57 /*==== VARIABLES ==================================================*/ | |
58 /*==== FUNCTIONS ==================================================*/ | |
59 LOCAL void set_baudrate (T_ACI_PKTIO_CAP *capabilities); | |
60 /* | |
61 +--------------------------------------------------------------------+ | |
62 | PROJECT : GPRS (8441) MODULE : CMH_PKTIO | | |
63 | STATE : finished ROUTINE : search_baudrate | | |
64 +--------------------------------------------------------------------+ | |
65 | |
66 PURPOSE : search and set the highest baudrate in DIO capabilities | |
67 to send in response PKT_CONNECT_RES | |
68 */ | |
69 LOCAL void set_baudrate (T_ACI_PKTIO_CAP * capabilities) | |
70 { | |
71 U32 baud_rate = DIO_BAUD_812500; | |
72 UBYTE i; | |
73 | |
74 for(i= 0;i<MAX_BAUD_RATE;i++) | |
75 { | |
76 if((capabilities->baud & baud_rate) EQ baud_rate) | |
77 { | |
78 capabilities->baud = baud_rate; | |
79 break; | |
80 } | |
81 else | |
82 { | |
83 baud_rate = baud_rate>>1; | |
84 } | |
85 } | |
86 } | |
87 | |
88 /* | |
89 +--------------------------------------------------------------------+ | |
90 | PROJECT : GPRS (8441) MODULE : CMH_PKTIO | | |
91 | STATE : finished ROUTINE : cmhPKT_Ind | | |
92 +--------------------------------------------------------------------+ | |
93 | |
94 PURPOSE : | |
95 */ | |
96 GLOBAL void cmhPKT_Ind (T_ACI_PKTIO *pkt_indic_msg) | |
97 { | |
98 T_ACI_PKTIO_CAP capabilities; | |
99 | |
100 TRACE_FUNCTION ("cmhPKT_Ind()"); | |
101 | |
102 /* register device to the DTI Control Manager */ | |
103 dti_cntrl_new_device ( DTI_SRC_ID_NOTPRESENT, /* ATI source ID */ | |
104 DTI_ENTITY_PKTIO, /* device ID */ | |
105 pkt_indic_msg->device_no, /* device number */ | |
106 UART_DLCI_NOT_MULTIPLEXED,/* sub-channel number */ | |
107 DTI_PORT_NUMBER_NOTPRESENT,/* ATI-RIV port number */ | |
108 pkt_indic_msg->pktio_cap.convergence,/* capabilities */ | |
109 DTI_DRIVER_ID_NOTPRESENT, | |
110 DTI_DIO_ID_NOTPRESENT); | |
111 | |
112 memset(&capabilities,0,sizeof(T_ACI_PKTIO_CAP)); | |
113 memcpy(&capabilities,&pkt_indic_msg->pktio_cap,sizeof(T_ACI_PKTIO_CAP)); | |
114 set_baudrate(&capabilities); | |
115 psaPKT_ConnectRes ( pkt_indic_msg->device_no, &capabilities); | |
116 } | |
117 | |
118 /* | |
119 +--------------------------------------------------------------------+ | |
120 | PROJECT : GPRS (8441) MODULE : CMH_PKTIO | | |
121 | STATE : finished ROUTINE : cmhPKT_OpenCnf | | |
122 +--------------------------------------------------------------------+ | |
123 | |
124 PURPOSE : | |
125 */ | |
126 GLOBAL void cmhPKT_OpenCnf (UBYTE device_number, T_DTI_CONN_RESULT result) | |
127 { | |
128 ULONG link_id; | |
129 | |
130 TRACE_FUNCTION ("cmhPKT_OpenCnf()"); | |
131 | |
132 link_id = dti_cntrl_get_link_id(DTI_ENTITY_PKTIO, device_number, | |
133 UART_DLCI_NOT_MULTIPLEXED); | |
134 dti_cntrl_entity_connected( link_id, DTI_ENTITY_PKTIO,result); | |
135 } | |
136 | |
137 /* | |
138 +--------------------------------------------------------------------+ | |
139 | PROJECT : GPRS (8441) MODULE : CMH_PKTIO | | |
140 | STATE : finished ROUTINE : cmhPKT_Close | | |
141 +--------------------------------------------------------------------+ | |
142 | |
143 PURPOSE : | |
144 */ | |
145 GLOBAL void cmhPKT_Close (UBYTE device_no, T_CMH_PKT_STATE state) | |
146 { | |
147 ULONG link_id; | |
148 SHORT cid; | |
149 | |
150 | |
151 TRACE_FUNCTION ("cmhPKT_Close()"); | |
152 | |
153 link_id = dti_cntrl_get_link_id(DTI_ENTITY_PKTIO, device_no, | |
154 UART_DLCI_NOT_MULTIPLEXED); | |
155 switch(state) | |
156 { | |
157 case DTI_CLOSE_CNF: | |
158 dti_cntrl_entity_disconnected(link_id, DTI_ENTITY_PKTIO); | |
159 break; | |
160 case DTI_CLOSE_IND: | |
161 dti_cntrl_entity_disconnected(link_id, DTI_ENTITY_PKTIO); | |
162 dti_cntrl_close_dpath_from_dti_id(EXTRACT_DTI_ID(link_id)); | |
163 break; | |
164 case DTI_DISC_IND: | |
165 return; | |
166 default: | |
167 return; | |
168 } | |
169 | |
170 cid = gaci_get_cid_over_link_id(link_id); | |
171 if( INVALID_CID NEQ cid) | |
172 { | |
173 gaci_RAT_caller(RAT_NO_CARRIER, cid, AT_CMD_CGDATA, CME_ERR_Unknown); | |
174 } | |
175 cmhSM_connection_down((UBYTE)EXTRACT_DTI_ID(link_id)); | |
176 } | |
177 | |
178 | |
179 #endif | |
180 #endif /* GPRS */ | |
181 /*==== EOF ========================================================*/ |