@@ -97,9 +97,10 @@ static char peer[256];
97
97
static int address ;
98
98
static uint16 ch11_csr ;
99
99
static int rx_count ;
100
+ static int rx_pos ;
100
101
static int tx_count ;
101
- static uint8 rx_buffer [512 + 100 ];
102
- static uint8 tx_buffer [512 + 100 ];
102
+ static uint8 rx_buffer [514 + 100 ];
103
+ static uint8 tx_buffer [514 + 100 ];
103
104
104
105
TMLN ch11_lines [1 ] = { {0 } };
105
106
TMXR ch11_tmxr = { 1 , NULL , 0 , ch11_lines };
@@ -111,6 +112,7 @@ UNIT ch11_unit[] = {
111
112
REG ch11_reg [] = {
112
113
{ ORDATA (CSR , ch11_csr , 16 )},
113
114
{ GRDATAD (RXCNT , rx_count , 16 , 16 , 0 , "Receive word count" ), REG_FIT |REG_RO },
115
+ { GRDATAD (RXPOS , rx_pos , 16 , 16 , 0 , "Receive Position" ), REG_FIT |REG_RO },
114
116
{ GRDATAD (TXCNT , tx_count , 16 , 16 , 0 , "Transmit word count" ), REG_FIT |REG_RO },
115
117
{ BRDATAD (RXBUF , rx_buffer , 16 , 8 , sizeof rx_buffer , "Receive packet buffer" ), REG_FIT },
116
118
{ BRDATAD (TXBUF , tx_buffer , 16 , 8 , sizeof tx_buffer , "Transmit packet buffer" ), REG_FIT },
@@ -179,6 +181,7 @@ ch11_write(DEVICE *dptr, t_addr addr, uint16 data, int32 access)
179
181
sim_debug (DBG_REG , & ch11_dev , "Clear RX\n" );
180
182
ch11_csr &= ~CSR_RDN ;
181
183
rx_count = 0 ;
184
+ rx_pos = 0 ;
182
185
ch11_lines [0 ].rcve = TRUE;
183
186
uba_clr_irq (dibp , dibp -> uba_vect );
184
187
}
219
222
ch11_read (DEVICE * dptr , t_addr addr , uint16 * data , int32 access )
220
223
{
221
224
struct pdp_dib * dibp = (DIB * )dptr -> ctxt ;
222
- int i ;
223
225
224
226
addr &= dibp -> uba_mask ;
225
227
* data = 0 ;
@@ -237,19 +239,19 @@ ch11_read(DEVICE *dptr, t_addr addr, uint16 *data, int32 access)
237
239
* data = 0 ;
238
240
sim_debug (DBG_ERR , & ch11_dev , "Read empty buffer\n" );
239
241
} else {
240
- i = 512 - rx_count ;
241
242
ch11_csr &= ~CSR_RDN ;
242
243
uba_clr_irq (dibp , dibp -> uba_vect );
243
- * data = ((uint64 )(rx_buffer [i ]) & 0xff ) << 8 ;
244
- * data |= ((uint64 )(rx_buffer [i + 1 ]) & 0xff );
245
- rx_count -= 2 ;
244
+ * data = ((uint64 )(rx_buffer [rx_pos ]) & 0xff ) << 8 ;
245
+ * data |= ((uint64 )(rx_buffer [rx_pos + 1 ]) & 0xff );
246
246
sim_debug (DBG_DAT , & ch11_dev , "Read buffer word %d:%02x %02x %06o %06o\n" ,
247
- rx_count , rx_buffer [i ], rx_buffer [i + 1 ], * data , ch11_csr );
247
+ rx_count , rx_buffer [rx_pos ], rx_buffer [rx_pos + 1 ], * data , ch11_csr );
248
+ rx_count -= 2 ;
249
+ rx_pos += 2 ;
248
250
}
249
251
break ;
250
252
251
253
case 006 : /* Bit count */
252
- * data = ((512 - rx_count ) - 1 ) & 07777 ;
254
+ * data = ((rx_count * 8 ) - 1 ) & 07777 ;
253
255
break ;
254
256
case 012 : /* Start transmission */
255
257
sim_debug (DBG_REG , & ch11_dev , "XMIT TX\n" );
@@ -340,7 +342,7 @@ ch11_transmit (struct pdp_dib *dibp)
340
342
len = CHUDP_HEADER + (size_t )tx_count ;
341
343
r = tmxr_put_packet_ln (& ch11_lines [0 ], (const uint8 * )& tx_buffer , len );
342
344
if (r == SCPE_OK ) {
343
- sim_debug (DBG_PKT , & ch11_dev , "Sent UDP packet, %d bytes.\n" , (int )len );
345
+ sim_debug (DBG_PKT , & ch11_dev , "Sent UDP packet, %d bytes. %04x checksum. \n" , (int )len , chk );
344
346
tmxr_poll_tx (& ch11_tmxr );
345
347
} else {
346
348
sim_debug (DBG_ERR , & ch11_dev , "Sending UDP failed: %d.\n" , r );
@@ -372,9 +374,10 @@ ch11_receive (struct pdp_dib *dibp)
372
374
return ;
373
375
374
376
if ((CSR_RDN & ch11_csr ) == 0 ) {
375
- count = (count + 1 ) & 0776 ;
376
- memcpy (rx_buffer + (512 - count ), p , count );
377
- rx_count = count ;
377
+ count = (count + 1 ) & 01776 ;
378
+ memcpy (rx_buffer , p + CHUDP_HEADER , count );
379
+ rx_count = count - CHUDP_HEADER ;
380
+ rx_pos = 0 ;
378
381
sim_debug (DBG_TRC , & ch11_dev , "Rx count, %d\n" , rx_count );
379
382
ch11_validate (p + CHUDP_HEADER , count - CHUDP_HEADER );
380
383
ch11_csr |= CSR_RDN ;
@@ -397,6 +400,7 @@ ch11_clear (struct pdp_dib *dibp)
397
400
ch11_csr = CSR_TDN ;
398
401
rx_count = 0 ;
399
402
tx_count = 0 ;
403
+ rx_pos = 0 ;
400
404
401
405
tx_buffer [0 ] = 1 ; /* CHUDP header */
402
406
tx_buffer [1 ] = 1 ;
0 commit comments