annotate src/g23m-aci/gdd_dio/gdd_dio_dtxf.c @ 189:d78986760e92

LICENSE: new terms
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 14 Apr 2020 20:26:40 +0000
parents d393cd9bb723
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 +-----------------------------------------------------------------------------
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 | File : gdd_dio_txf.c
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 +-----------------------------------------------------------------------------
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 | Copyright 2002 Texas Instruments Berlin, AG
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 | All rights reserved.
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 |
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 | This file is confidential and a trade secret of Texas
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 | Instruments Berlin, AG
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 | The receipt of or possession of this file does not convey
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 | any rights to reproduce or disclose its contents or to
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 | manufacture, use, or sell anything it may describe, in
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 | whole, or in part, without the specific written consent of
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 | Texas Instruments Berlin, AG.
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 +-----------------------------------------------------------------------------
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 | Purpose : This modul is part of the entity gdd_dio and implements the
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 | dtx service functions.
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 +-----------------------------------------------------------------------------
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 */
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 #define ENTITY_GDD_DIO
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 /*==== INCLUDES =============================================================*/
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 #include "typedefs.h" /* to get Condat data types */
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 #include "vsi.h" /* to get a lot of macros */
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 /* GDD stuff */
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 #include "gdd_dio.h" /* to get the global entity definitions */
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 #include "gdd_dio_con_mgr.h"
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 #include "gdd_dio_dtxf.h"
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 #include "gdd_dio_rxf.h"
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 #include "gdd_dio_drxf.h" /* Needed for allocate_gdd_desc_list() etc */
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 #include "gdd_dio_queue.h"
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 /*==== CONST ================================================================*/
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 /*==== LOCAL VARS ===========================================================*/
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 /*==== PRIVATE FUNCTIONS ====================================================*/
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 /*==== PUBLIC FUNCTIONS =====================================================*/
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 GLOBAL GDD_RESULT gdd_dio_dtx_get_send_buffer
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 (
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 T_GDD_CON_HANDLE con_handle,
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 T_GDD_BUF ** send_buf,
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 U16 data_size
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 )
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 {
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 T_GDD_INST_ID inst;
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 T_GDD_DIO_DATA * gdd_dio_data;
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 T_GDD_DIO_CON_DATA * con_data;
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 T_dio_buffer * dio_buf;
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 TRACE_USER_CLASS(TC_FUNC_DATA_FLOW, "[GDD] gdd_dio_dtx_get_send_buffer()");
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 inst = (T_GDD_INST_ID)inst_num_from_dev_id(con_handle);
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 /**
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 * Do the necessary checks.
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 */
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 if(inst < 0)
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 {
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 TRACE_ERROR("[GDD] Invalid connection handle");
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 return GDD_INVALID_PARAMS;
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 }
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 if(inst >= GDD_NUM_INSTS)
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 {
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 TRACE_ERROR("[GDD] inst id out of bounds");
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 return GDD_INTERNAL_ERROR;
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 }
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 gdd_dio_data = &gdd_dio_data_base[inst];
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 if(gdd_dio_init_flag[inst] EQ FALSE)
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 {
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 TRACE_ERROR("[GDD] Instance not initialized");
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 return GDD_INVALID_PARAMS;
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 }
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 if (gdd_dio_data->ker.state NEQ GDD_DIO_KER_READY)
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 {
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 TRACE_ERROR("[GDD] DIO driver not initialized");
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 return GDD_INTERNAL_ERROR;
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 }
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 con_data = get_con_data(gdd_dio_data, con_handle);
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 if(con_data EQ NULL)
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 {
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 TRACE_ERROR("[GDD] Invalid connection handle");
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 return GDD_INVALID_PARAMS;
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 }
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 if(data_size EQ 0 || data_size > con_data->dio_cap.mtu_data)
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 {
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 TRACE_ERROR("[GDD] requested data_size (MTU size) out of range");
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 return GDD_INVALID_PARAMS;
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 }
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 if( con_data->con_state EQ GDD_DIO_CON_CONNECT ||
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 con_data->con_state EQ GDD_DIO_CON_SENDING ||
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 gdd_dio_queue_peek_next_for_dequeue(&con_data->rx_queue, &dio_buf) EQ FALSE)
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 {
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 /* Set the flag indicating the somebody (the client) is waiting for a send
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 buffer. As a consequence, the signal GDD_SIGTYPE_SEND_BUF_AVAILABLE
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 will be sent as soon as we receive a new RX buffer from PSI. */
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 char * reason;
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113 if(con_data->con_state EQ GDD_DIO_CON_CONNECT)
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 reason = "con_state=GDD_DIO_CON_CONNECT";
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115 else if(con_data->con_state EQ GDD_DIO_CON_SENDING)
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 reason = "con_state=GDD_DIO_CON_SENDING";
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117 else
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118 reason = "no buffer available in RX queue";
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120 con_data->wait_send_buf = TRUE;
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122 TRACE_EVENT_P2("[GDD] Cannot return buffer [con_handle=0x%4x: %s]",
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
123 con_handle, reason);
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
124
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
125 return GDD_NO_BUF_AVAILABLE;
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
126 }
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127 else
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128 {
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129 /* Make sure that buffer can hold what is requested.
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130 We must take into account that the first 2-byte segment holding
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
131 the protocol ID which is not part of the pay-load */
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132 if(data_size > (dio_buf->length-2))
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133 {
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 TRACE_ERROR("[GDD] Requested buffer size too large");
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135 return GDD_REQ_BUF_TOO_LARGE;
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136 }
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137 else
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138 {
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139 /* Setup current descriptor list and pass it back to the client */
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
140 (*send_buf) = (T_GDD_BUF *)dio_buf;
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
141
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
142 con_data->con_state = GDD_DIO_CON_SENDING;
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
143
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
144 return GDD_OK;
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
145 }
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
146 }
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
147 }
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
148
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
149
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
150 GLOBAL GDD_RESULT gdd_dio_dtx_send_buffer(T_GDD_CON_HANDLE con_handle, T_GDD_BUF * buf)
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
151 {
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
152 #ifdef GDD_MAKE_DTX_CONTEXT_SWITCH
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
153 U32 signal = GDD_DIO_SIGNAL_SEND_DATA | (U32)con_handle;
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
154 #endif /* GDD_MAKE_DTX_CONTEXT_SWITCH */
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
155 T_GDD_INST_ID inst;
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
156 T_GDD_DIO_DATA * gdd_dio_data;
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
157 T_GDD_DIO_CON_DATA * con_data;
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
158 T_dio_buffer * dio_buf;
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
159
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
160 TRACE_USER_CLASS(TC_FUNC_DATA_FLOW, "[GDD] gdd_dio_dtx_send_buffer()");
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
161
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
162 inst = (T_GDD_INST_ID)inst_num_from_dev_id(con_handle);
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
163
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
164 /**
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
165 * Do the necessary checks.
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
166 */
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
167 if(inst < 0)
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
168 {
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
169 TRACE_ERROR("[GDD] Invalid connection handle");
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
170 return GDD_INVALID_PARAMS;
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
171 }
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
172 else if(inst >= GDD_NUM_INSTS)
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
173 {
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
174 TRACE_ERROR("[GDD] inst id out of bounds");
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
175 return GDD_INTERNAL_ERROR;
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
176 }
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
177 gdd_dio_data = &gdd_dio_data_base[inst];
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
178
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
179 if(gdd_dio_init_flag[inst] EQ FALSE)
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
180 {
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
181 TRACE_ERROR("[GDD] Instance not initialized");
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
182 return GDD_ALREADY_INITIALIZED;
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
183 }
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
184
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
185 if (gdd_dio_data->ker.state NEQ GDD_DIO_KER_READY)
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
186 {
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
187 TRACE_ERROR("[GDD] DIO driver not initialized");
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
188 return GDD_INTERNAL_ERROR;
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
189 }
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
190
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
191 con_data = get_con_data(gdd_dio_data, con_handle);
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
192 if(con_data EQ NULL)
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
193 {
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
194 TRACE_ERROR("[GDD] Invalid connection handle");
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
195 return GDD_INVALID_PARAMS;
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
196 }
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
197
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
198 /* The pointer which is next for dequeue must be the one which
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
199 corresponds to the buffer for sending ! */
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
200 if(gdd_dio_queue_peek_next_for_dequeue(&con_data->rx_queue, &dio_buf) EQ FALSE)
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
201 {
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
202 return GDD_INTERNAL_ERROR;
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
203 }
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
204 #ifdef GDD_MAKE_DTX_CONTEXT_SWITCH
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
205 #ifdef MEMORY_SUPERVISION
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
206 vsi_c_ssend(hCommGDD_DIO, signal, (T_VOID_STRUCT*)dio_buf, sizeof(T_VOID_STRUCT*), __FILE__, __LINE__);
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
207 #else
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
208 vsi_c_ssend(hCommGDD_DIO, signal, (T_VOID_STRUCT*)dio_buf, sizeof(T_VOID_STRUCT*));
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
209 #endif
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
210 return GDD_OK;
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
211 #else /* GDD_MAKE_DTX_CONTEXT_SWITCH */
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
212 /* Call the corresponding RX function directly instead of sending signal */
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
213 gdd_dio_rx_sig_send_data(con_handle, dio_buf);
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
214 return GDD_OK;
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
215 #endif /* GDD_MAKE_DTX_CONTEXT_SWITCH */
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
216
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
217
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
218 }
d393cd9bb723 src/g23m-*: initial import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
219