4 Copyright (c) Eicon Networks, 2002.
6 This source file is supplied for the use with
7 Eicon Networks range of DIVA Server Adapters.
9 Eicon File Revision : 2.1
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2, or (at your option)
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY
18 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 See the GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 #if defined(DIVA_ISTREAM) /* { */
33 #if !defined USE_EXTENDED_DEBUGS
39 int diva_istream_write (void* context,
46 int diva_istream_read (void* context,
53 /* -------------------------------------------------------------------
54 Does provide iStream interface to the client
55 ------------------------------------------------------------------- */
56 void diva_xdi_provide_istream_info (ADAPTER* a,
57 diva_xdi_stream_interface_t* pi) {
58 pi->provided_service = 0;
60 /* ------------------------------------------------------------------
61 Does write the data from caller's buffer to the card's
63 If synchronous service was requested, then function
64 does return amount of data written to stream.
65 'final' does indicate that pice of data to be written is
66 final part of frame (necessary only by structured datatransfer)
67 return 0 if zero lengh packet was written
68 return -1 if stream is full
69 ------------------------------------------------------------------ */
70 int diva_istream_write (void* context,
77 ADAPTER* a = (ADAPTER*)context;
78 int written = 0, to_write = -1;
80 byte* data_ptr = (byte*)data;
83 #ifdef PLATFORM_GT_32BIT
84 ULongToPtr(a->tx_stream[Id] + a->tx_pos[Id]),
86 (void*)(a->tx_stream[Id] + a->tx_pos[Id]),
90 if (tmp[0] & DIVA_DFIFO_READY) { /* No free blocks more */
92 return (-1); /* was not able to write */
93 break; /* only part of message was written */
95 to_write = min(length, DIVA_DFIFO_DATA_SZ);
98 #ifdef PLATFORM_GT_32BIT
99 ULongToPtr(a->tx_stream[Id] + a->tx_pos[Id]+4),
101 (void*)(a->tx_stream[Id] + a->tx_pos[Id] + 4),
107 data_ptr += to_write;
109 tmp[1] = (char)to_write;
110 tmp[0] = (tmp[0] & DIVA_DFIFO_WRAP) |
112 ((!length && final) ? DIVA_DFIFO_LAST : 0);
113 if (tmp[0] & DIVA_DFIFO_LAST) {
118 #ifdef PLATFORM_GT_32BIT
119 ULongToPtr(a->tx_stream[Id] + a->tx_pos[Id]),
121 (void*)(a->tx_stream[Id] + a->tx_pos[Id]),
125 if (tmp[0] & DIVA_DFIFO_WRAP) {
128 a->tx_pos[Id] += DIVA_DFIFO_STEP;
136 /* -------------------------------------------------------------------
137 In case of SYNCRONOUS service:
138 Does write data from stream in caller's buffer.
139 Does return amount of data written to buffer
140 Final flag is set on return if last part of structured frame
142 return 0 if zero packet was received
143 return -1 if stream is empty
144 return -2 if read buffer does not profide sufficient space
145 to accommodate entire segment
146 max_length should be at least 68 bytes
147 ------------------------------------------------------------------- */
148 int diva_istream_read (void* context,
155 ADAPTER* a = (ADAPTER*)context;
156 int read = 0, to_read = -1;
158 byte* data_ptr = (byte*)data;
162 #ifdef PLATFORM_GT_32BIT
163 ULongToPtr(a->rx_stream[Id] + a->rx_pos[Id]),
165 (void*)(a->rx_stream[Id] + a->rx_pos[Id]),
169 if (tmp[1] > max_length) {
171 return (-2); /* was not able to read */
174 if (!(tmp[0] & DIVA_DFIFO_READY)) {
176 return (-1); /* was not able to read */
179 to_read = min(max_length, (int)tmp[1]);
182 #ifdef PLATFORM_GT_32BIT
183 ULongToPtr(a->rx_stream[Id] + a->rx_pos[Id] + 4),
185 (void*)(a->rx_stream[Id] + a->rx_pos[Id] + 4),
189 max_length -= to_read;
193 if (tmp[0] & DIVA_DFIFO_LAST) {
196 tmp[0] &= DIVA_DFIFO_WRAP;
198 #ifdef PLATFORM_GT_32BIT
199 ULongToPtr(a->rx_stream[Id] + a->rx_pos[Id]),
201 (void*)(a->rx_stream[Id] + a->rx_pos[Id]),
205 if (tmp[0] & DIVA_DFIFO_WRAP) {
208 a->rx_pos[Id] += DIVA_DFIFO_STEP;
220 /* ---------------------------------------------------------------------
221 Does check if one of streams had caused interrupt and does
222 wake up corresponding application
223 --------------------------------------------------------------------- */
224 void pr_stream (ADAPTER * a) {