comparison src/cs/services/atp/atp_i.h @ 0:4e78acac3d88

src/{condat,cs,gpf,nucleus}: import from Selenite
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 16 Oct 2020 06:23:26 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4e78acac3d88
1 /*******************************************************************************
2 *
3 * File Name : atp_i.h
4 *
5 * Internal definition for ATP SW entity
6 *
7 * (C) Texas Instruments, all rights reserved
8 *
9 * Version number : 0.1 Date : 28-Feb-2000
10 *
11 * History : 0.1 - Created by E. Baissus
12 *
13 *
14 * Author : Eric Baissus : e-baissus@ti.com
15 *
16 * (C) Copyright 2000 by Texas Instruments Incorporated, All Rights Reserved
17 ******************************************************************************/
18 #ifndef ATP_I_H
19 #define ATP_I_H
20
21 #include "rv/rv_general.h"
22 #include "rvf/rvf_api.h"
23 #include "atp/atp_api.h"
24 #include "atp/atp_messages.h"
25 #include "atp/atp_config.h"
26 #include "atp/atp_cmd.h"
27
28 /* ATP trace macro */
29 #define ATP_SEND_TRACE(string,type) rvf_send_trace (string,(sizeof(string)-1),NULL_PARAM,type,ATP_USE_ID);
30
31
32
33
34 /* Structure used to store information on a registered SW entity */
35 /*---------------------------------------------------------------*/
36 typedef struct
37 {
38 T_ATP_SW_ENTITY_NAME sw_entity_name; // Sw entity name
39 UINT8 nb_open_port; // Number of port open with the SW entity
40 T_ATP_ENTITY_MODE mode; // List all the modes of the SW entity
41 T_ATP_CALLBACK return_path; // return path to send event back to the SW entity
42 } T_ATP_SW_ENTITY_STRUCT;
43
44
45 /* Structure used to store information on a port */
46 /*---------------------------------------------------------------*/
47 typedef enum
48 {
49 ATP_OPEN_PENDING,
50 ATP_CMD_MODE,
51 ATP_DATA_MODE
52 } T_ATP_PORT_STATE; // Indicate in which state is the port
53
54
55
56
57 /* Every port has 2 port_end_struct : one for each SWE concerned */
58 #define INVALID_PORT_NB (0xFF)
59
60 typedef struct t_atp_port_end_struct
61 {
62 T_ATP_SW_ENTITY_ID sw_id; // SWE ID
63 T_ATP_PORT_NB port_nb; // Port number
64 T_ATP_SIGNAL_MASK signal_mask;
65 T_ATP_NO_COPY_PORT_INFO no_copy_info;
66 T_RVF_BUFFER_Q rx_queue; // Queue used to pipe the received packet
67 //and wait for reading processing
68 UINT32 rx_data_left; // Number of data still not read by the SW entity
69 T_ATP_RING_TYPE ring_type;
70 T_ATP_PORT_SIGNAL signal; // Status of the port signal
71 T_RVF_MB_ID rx_mb; // MB to use when the SWE receives data from ATP
72 T_RVF_MB_ID tx_mb; // MB used by SWE when sending data to ATP
73 } T_ATP_PORT_END_STRUCT;
74
75 #define ATP_MAX_SW_NB (0x02)
76
77 typedef UINT8 T_ATP_SW_NB; /* Which SW_ID of a port : first/initiator (0) or second(acceptor) (1) */
78
79
80
81 /* Definition of types used for handling of commands on a port */
82 /*-------------------------------------------------------------*/
83 typedef enum { READY_FOR_NEW_CMD, WAITING_FOR_RESULT } T_ATP_CMD_STATE;
84 // Indicate if the port is ready to receive a new command
85 // or if it is waiting for the result of a command
86 typedef enum { NOT_STARTED,ON_GOING,FINISHED } T_ATP_CMD_INTERPRETATION;
87 // A string can multiplex several command. If status is NOT_STARTED, the command has not
88 // been yet interpreted at all by ATP. If ON_GOING, that means that interpretation started but
89 // is not finished (still command pending in the string)
90 typedef enum { ATP_CMD_BUFFER_IS_RDY,ATP_CMD_BUFFER_IS_NOT_RDY} T_ATP_CMD_BUFFER_RDY ;
91 // Indicate if the buffer contains a complete command that can be interpreted
92
93
94 #define ATP_CMD_INVALID_POSITION (0xFFFF);
95
96 typedef struct
97 {
98 T_ATP_CMD_STATE state; //READY_FOR_NEW_CMD or WAITING_FOR_RESULT
99 T_ATP_CMD_INTERPRETATION status; // NOT_STARTED or ON_GOING or FINISHED
100 T_ATP_TXT_CMD cmd_txt_p; // text containing the commands : Example :'ATD1274576;' Can contains several command
101 UINT16 cmd_txt_length; // length of the text in bytes
102 UINT16 next_position; // next caracter to interpret in the cmd_txt buffer
103 } T_ATP_CMD_STRUCT;
104
105
106
107 /* Internal struct used to store all the information related to a port */
108 /*---------------------------------------------------------------------*/
109 typedef struct t_atp_port_struct
110 {
111 struct t_atp_port_struct * next_p; // points on next port structure/ otherwise = NULL
112 T_ATP_PORT_STATE port_state; // ATP_OPEN_PENDING or ATP_CMD_MODE or ATP_DATA_MODE
113 T_ATP_PORT_END_STRUCT port_info[ATP_MAX_SW_NB]; //[0]=initiator side / [1]=target side
114 T_ATP_REDIRECT_MODE redirect_mode; /* Indicates if redirect flow is ON or OFF */
115 struct t_atp_port_struct * redirect_port_p; /* pointing on the port of redirection */
116 T_ATP_SW_NB redirect_port_end_nb; /* Indicates to which end of the redirecting port the flow
117 should be redirected = value = 0 or 1 */
118 T_ATP_CMD_STRUCT cmd_info; // Information related to CMD handling
119 T_ATP_DCE_INFO * dce_info_p; // Information related to DCE handling
120 T_ATP_PORT_CONFIG port_config; // Indicates what should be the ATP processing in case
121 // onE of the SWE is a transport layer. Either ATP emulates a DCE,
122 // either emulates a DTE or does not do anything (DATA_ONLY)
123 T_ATP_SW_NB port_waiting_for_mb_callback; // Wait for atp_mb_call_back to be invoked
124 } T_ATP_PORT_STRUCT;
125
126
127 typedef struct
128 {
129 UINT32 first_byte;
130 UINT32 last_byte;
131 UINT32 next_byte_to_read;
132 T_ATP_BUFFER atp_buffer_p;
133 } T_ATP_RX_PACKET;
134
135
136 /* Defines the state of the ATP SWE (cf Riviera Manager) */
137 typedef enum
138 {
139 ATP_STARTED,
140 ATP_STOPPED,
141 ATP_KILLED
142 } T_ATP_SWE_STATE;
143
144
145 /* Types of error handels by atp_error function */
146 typedef enum
147 {
148 ATP_ERROR_MB_PRIM_RED,
149 ATP_ERROR_TX_MB_RED,
150 ATP_ERROR_WRONG_CALLBACK /* The callback function of the primitive has been used where as */
151 /* Mailbox should be used */
152 } T_ATP_ERROR_REASON;
153
154
155 // Definition of return value used by atp_exit_sequence_process
156 typedef enum
157 {
158 ATP_ESCAPE_SEQUENCE_FAILED, // escape sequence is not in the current data
159 ATP_ESCAPE_SEQUENCE_SUCCESS, // escape sequence has been received
160 ATP_ESCAPE_SEQUENCE_WAIT // escape sequence may be in the data. Need to wait for next data
161 } T_ATP_ESCAPE_SEQUENCE_STATUS;
162
163
164 extern T_RVF_MB_ID atp_mb_prim; // Memory bank dedicated to internal use of ATP entity
165 // Table gathering the pointers on the different SW entity data structure. If NULL, field is free
166 extern T_ATP_PORT_STRUCT * atp_first_port_p;
167 extern T_ATP_SW_ENTITY_ID atp_nb_sw_entity;
168 extern T_ATP_SWE_STATE atp_swe_state;
169 extern T_ATP_SW_ENTITY_STRUCT * atp_sw_entity_table_p[ATP_MAX_NB_SW_ENTITY+1]; //+1 due to GSM SW entity
170
171
172 /* Registration / re-registration */
173 T_ATP_RET atp_dereg_all(void);
174 T_ATP_RET atp_init_cmd_info_struct(T_ATP_PORT_STRUCT * port_p);
175 T_ATP_RET atp_get_sw(T_ATP_SW_ENTITY_NAME name,T_ATP_SW_ENTITY_ID * sw_id_p);
176
177 /* Port handling related functions -> atp_port.c */
178 T_ATP_RET atp_create_port(T_ATP_PORT_STRUCT **port_pp);
179 T_ATP_RET atp_delete_port(T_ATP_PORT_STRUCT *port_p);
180 T_ATP_RET atp_get_port(T_ATP_SW_ENTITY_ID sw_id, T_ATP_PORT_NB port_nb,T_ATP_PORT_STRUCT ** port_found_pp,T_ATP_SW_NB * sw_nb_p);
181 T_ATP_RET atp_send_message(T_ATP_CALLBACK path,T_ATP_MESSAGE * message_p);
182 T_ATP_RET atp_delete_all_port(void);
183
184
185 /* Commands handling related functions -> atp_cmd.c */
186 T_ATP_RET atp_cmd_init_dce_info(T_ATP_DCE_INFO * dce_info_p); // initialise dce buffer */
187 T_ATP_RET atp_interpret_raw_data (T_ATP_PORT_STRUCT *port_p,
188 T_RVF_MB_ID mb_id,
189 T_ATP_CMD_TYPE *cmd_type_p,
190 T_ATP_CMD_NB *cmd_nb_p,
191 T_ATP_CMD **cmd_info_pp,
192 T_ATP_TXT_CMD *text_pp,
193 UINT16 *text_length_p);
194
195 T_ATP_RET atp_create_data_buffer_from_cmd (T_ATP_CMD_MODE cmd_mode,
196 UINT16 header,
197 UINT16 trailer,
198 T_ATP_DCE_INFO *dce_info_p,
199 T_RVF_MB_ID mb_id,
200 T_ATP_CMD_TYPE cmd_type,
201 T_ATP_CMD_NB cmd_nb,
202 T_ATP_TXT_CMD text_p,
203 T_ATP_CMD *cmd_info_p,
204 T_ATP_BUFFER *buffer_pp,
205 UINT16 *length_p);
206
207 T_ATP_RET atp_translate_cmd_to_txt (T_ATP_CMD_TYPE cmd_type,
208 T_ATP_CMD_NB cmd_nb,
209 T_ATP_CMD *cmd_info_p,
210 T_RVF_MB_ID mb_id,
211 T_ATP_TXT_CMD *text_pp,
212 UINT16 *text_length_p);
213
214 T_ATP_RET atp_translate_txt_to_cmd (T_ATP_TXT_CMD text_p,
215 T_ATP_CMD_TYPE cmd_type,
216 T_ATP_CMD_TYPE *cmd_type_p,
217 T_ATP_CMD_NB *cmd_nb_p,
218 T_RVF_MB_ID mb_id,
219 T_ATP_CMD **cmd_info_pp);
220
221 T_ATP_RET atp_copy_buffer_from_l2cap (void * l2cap_buffer_p, void * copy_buffer_p,
222 UINT32 buffer_length,UINT32 offset);
223 T_ATP_RET atp_copy_buffer (UINT8 *in_buffer_p,
224 UINT8 *out_buffer_p,
225 UINT32 data_size);
226
227 T_ATP_RET atp_update_cmd_buffer(T_ATP_PORT_STRUCT * port_p,
228 UINT8 * new_txt_cmd_buffer_p, UINT16 txt_cmd_buffer_length,
229 T_ATP_CMD_BUFFER_RDY * is_ready_p);
230 T_ATP_RET atp_free_l2cap_buffer(UINT8 * atp_buffer_p);
231
232 /* Escape sequence related functions */
233 T_ATP_RET atp_reset_escape_sequence(T_ATP_PORT_STRUCT *port_p);
234 T_ATP_RET atp_pipe_extra_character(T_ATP_PORT_STRUCT *port_p,
235 T_ATP_PORT_END_STRUCT * other_port_info_p);
236 T_ATP_ESCAPE_SEQUENCE_STATUS atp_escape_sequence_process(T_ATP_PORT_STRUCT *port_p,
237 UINT8 * atp_buffer_p,
238 UINT32 data_length,
239 T_ATP_PACKET_MODE packet_mode);
240
241
242 /* Used for test */
243 UINT8 dtoa (UINT16 decimal,
244 T_ATP_TXT_CMD ascii_p);
245
246 /* Error functions -> atp_env.c */
247 void atp_error(T_ATP_ERROR_REASON atp_error_reason);
248 T_ATP_RET atp_error_switch(T_ATP_ERROR_MAIN_REASON main_reason,
249 T_ATP_ERROR_TYPE error_type,T_RV_RETURN * return_path_p);
250
251 #endif