Subversion Repositories Kolibri OS

Rev

Rev 1635 | Rev 2465 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1635 Rev 2434
Line 17... Line 17...
17
;;                                                              ;;
17
;;                                                              ;;
18
;;10.01.2007 Bugfix for checksum function from Paolo Franchetti ;;
18
;;10.01.2007 Bugfix for checksum function from Paolo Franchetti ;;
19
;;                                                              ;;
19
;;                                                              ;;
20
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
20
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 21... Line 21...
21
 
21
 
Line 22... Line 22...
22
$Revision: 1369 $
22
$Revision: 2434 $
23
 
23
 
24
 
24
 
Line 34... Line 34...
34
;*******************************************************************
34
;*******************************************************************
Line 35... Line 35...
35
 
35
 
36
uglobal
36
uglobal
37
StackCounters:
37
StackCounters:
-
 
38
  dumped_rx_count     dd  0
38
  dumped_rx_count     dd  0
39
  arp_tx_count:
-
 
40
                      dd  0
39
  arp_tx_count:       dd  0
41
  arp_rx_count:
-
 
42
                      dd  0
40
  arp_rx_count:       dd  0
43
  ip_rx_count:
-
 
44
                      dd  0
41
  ip_rx_count:        dd  0
45
  ip_tx_count:
42
  ip_tx_count:        dd  0
46
                      dd  0
Line 43... Line 47...
43
endg
47
endg
44
 
48
 
45
; socket buffers
49
; socket buffers
Line 139... Line 143...
139
macro _memset_dw adr,value,amount
143
macro _memset_dw adr,value,amount
140
{
144
{
141
        mov     edi, adr
145
        mov     edi, adr
142
        mov     ecx, amount
146
        mov     ecx, amount
143
        if value = 0
147
        if value = 0
144
                xor     eax, eax
148
        xor     eax, eax
145
        else
149
        else
146
                mov     eax, value
150
        mov     eax, value
147
        end if
151
        end if
148
        cld
152
        cld
149
        rep     stosd
153
        rep stosd
150
}
154
}
Line 151... Line 155...
151
 
155
 
152
 
156
 
Line 183... Line 187...
183
        ; The following block sets up the 1s timer
187
        ; The following block sets up the 1s timer
184
        mov     al, 0x0
188
        mov     al, 0x0
185
        out     0x70, al
189
        out     0x70, al
186
        in      al, 0x71
190
        in      al, 0x71
187
        mov     [last_1sTick], al
191
        mov     [last_1sTick], al
188
ret
192
        ret
Line 189... Line 193...
189
 
193
 
190
 
194
 
Line 199... Line 203...
199
;
203
;
200
;***************************************************************************
204
;***************************************************************************
201
align 4
205
align 4
202
stack_handler:
206
stack_handler:
Line 203... Line 207...
203
 
207
 
204
    call    ethernet_driver
208
        call    ethernet_driver
Line 205... Line 209...
205
    call    ip_rx
209
        call    ip_rx
206
 
210
 
207
 
211
 
208
    ; Test for 10ms tick, call tcp timer
212
    ; Test for 10ms tick, call tcp timer
Line 209... Line 213...
209
    mov     eax, [timer_ticks] ;[0xfdf0]
213
        mov     eax, [timer_ticks];[0xfdf0]
210
    cmp     eax, [last_1hsTick]
214
        cmp     eax, [last_1hsTick]
Line 211... Line 215...
211
    je      sh_001
215
        je      sh_001
Line 212... Line 216...
212
 
216
 
213
    mov     [last_1hsTick], eax
217
        mov     [last_1hsTick], eax
214
    call    tcp_tx_handler
218
        call    tcp_tx_handler
215
 
219
 
216
sh_001:
220
sh_001:
217
 
221
 
Line 218... Line 222...
218
    ; Test for 1 second event, call 1s timer functions
222
    ; Test for 1 second event, call 1s timer functions
Line 219... Line 223...
219
    mov     al, 0x0   ;second
223
        mov     al, 0x0;second
220
    out     0x70, al
224
        out     0x70, al
Line 221... Line 225...
221
    in      al, 0x71
225
        in      al, 0x71
222
    cmp     al, [last_1sTick]
226
        cmp     al, [last_1sTick]
Line 223... Line 227...
223
    je      sh_exit
227
        je      sh_exit
224
 
228
 
225
    mov     [last_1sTick], al
229
        mov     [last_1sTick], al
226
 
230
 
Line 240... Line 244...
240
;;              Saves all used registers
244
;;              Saves all used registers
241
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
245
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
242
proc checksum_jb stdcall uses ebx esi ecx,\
246
proc checksum_jb stdcall uses ebx esi ecx,\
243
     buf_ptr:DWORD, buf_size:DWORD
247
     buf_ptr:DWORD, buf_size:DWORD
Line 244... Line 248...
244
 
248
 
245
    xor     eax, eax
249
        xor     eax, eax
246
    xor     ebx, ebx  ;accumulator
250
        xor     ebx, ebx;accumulator
247
    mov     esi, dword[buf_ptr]
251
        mov     esi, dword[buf_ptr]
248
    mov     ecx, dword[buf_size]
252
        mov     ecx, dword[buf_size]
249
    shr     ecx, 1  ; ecx=ecx/2
253
        shr     ecx, 1; ecx=ecx/2
250
    jnc     @f      ; if CF==0 then size is even number
254
        jnc     @f  ; if CF==0 then size is even number
251
    mov     bh, byte[esi + ecx*2]
255
        mov     bh, byte[esi + ecx*2]
252
  @@:
256
  @@:
Line 253... Line 257...
253
    cld
257
        cld
254
 
258
 
255
  .loop:
259
  .loop:
256
    lodsw   ;eax=word[esi],esi=esi+2
260
        lodsw   ;eax=word[esi],esi=esi+2
257
    xchg    ah,al    ;cause must be a net byte-order
261
        xchg    ah, al;cause must be a net byte-order
258
    add     ebx, eax
262
        add     ebx, eax
259
    loop    .loop
263
        loop    .loop
260
 
264
 
261
    mov     eax, ebx
265
        mov     eax, ebx
262
    shr     eax, 16
266
        shr     eax, 16
Line 263... Line 267...
263
    add     ax, bx
267
        add     ax, bx
264
    not     ax
268
        not     ax
Line 265... Line 269...
265
 
269
 
266
    ret
270
        ret
267
endp
271
endp
Line 278... Line 282...
278
;
282
;
279
;***************************************************************************
283
;***************************************************************************
Line 280... Line 284...
280
 
284
 
281
 
285
 
282
checksum:
286
checksum:
283
    pusha
287
        pusha
284
    mov     eax, [checkAdd1]
288
        mov     eax, [checkAdd1]
285
    xor     edx, edx                  ; edx is the accumulative checksum
289
        xor     edx, edx              ; edx is the accumulative checksum
286
    xor     ebx, ebx
290
        xor     ebx, ebx
287
    mov     cx, [checkSize1]
291
        mov     cx, [checkSize1]
Line 288... Line 292...
288
    shr     cx, 1
292
        shr     cx, 1
289
    jz      cs1_1
293
        jz      cs1_1
290
 
294
 
Line 291... Line 295...
291
cs1:
295
cs1:
292
    mov     bh, [eax]
296
        mov     bh, [eax]
Line 293... Line 297...
293
    mov     bl, [eax + 1]
297
        mov     bl, [eax + 1]
Line 294... Line 298...
294
 
298
 
295
    add     eax, 2
299
        add     eax, 2
296
    add     edx, ebx
300
        add     edx, ebx
Line 297... Line 301...
297
 
301
 
298
    loopw   cs1
302
        loopw   cs1
Line 299... Line 303...
299
 
303
 
Line 300... Line 304...
300
cs1_1:
304
cs1_1:
301
    and     word [checkSize1], 0x01
305
        and     word [checkSize1], 0x01
302
    jz      cs_test2
306
        jz      cs_test2
303
 
307
 
Line 304... Line 308...
304
    mov     bh, [eax]
308
        mov     bh, [eax]
Line 305... Line 309...
305
    xor     bl, bl
309
        xor     bl, bl
306
 
310
 
Line 307... Line 311...
307
    add     edx, ebx
311
        add     edx, ebx
308
 
312
 
309
cs_test2:
313
cs_test2:
Line 310... Line 314...
310
    mov     cx, [checkSize2]
314
        mov     cx, [checkSize2]
311
    cmp     cx, 0
315
        cmp     cx, 0
Line 312... Line 316...
312
    jz      cs_exit                     ; Finished if no 2nd buffer
316
        jz      cs_exit                 ; Finished if no 2nd buffer
Line 313... Line 317...
313
 
317
 
314
    mov     eax, [checkAdd2]
318
        mov     eax, [checkAdd2]
315
 
319
 
Line 316... Line 320...
316
    shr     cx, 1
320
        shr     cx, 1
317
    jz      cs2_1
321
        jz      cs2_1
Line 318... Line 322...
318
 
322
 
Line 319... Line 323...
319
cs2:
323
cs2:
320
    mov     bh, [eax]
324
        mov     bh, [eax]
-
 
325
        mov     bl, [eax + 1]
-
 
326
 
-
 
327
        add     eax, 2
-
 
328
        add     edx, ebx
-
 
329
 
-
 
330
        loopw   cs2
-
 
331
 
-
 
332
cs2_1:
Line 321... Line -...
321
    mov     bl, [eax + 1]
-
 
322
 
-
 
323
    add     eax, 2
-
 
324
    add     edx, ebx
-
 
325
 
-
 
326
    loopw   cs2
-
 
327
 
-
 
328
cs2_1:
-
 
329
    and     word [checkSize2], 0x01
333
        and     word [checkSize2], 0x01
330
    jz      cs_exit
334
        jz      cs_exit
331
 
335
 
Line 332... Line 336...
332
    mov     bh, [eax]
336
        mov     bh, [eax]
Line 362... Line 366...
362
;
366
;
363
;***************************************************************************
367
;***************************************************************************
364
iglobal
368
iglobal
365
align 4
369
align 4
366
f52call:
370
f52call:
367
	dd	app_stack_handler.00
371
        dd      app_stack_handler.00
368
	dd	app_stack_handler.01
372
        dd      app_stack_handler.01
369
	dd	app_stack_handler.02
373
        dd      app_stack_handler.02
370
	dd	app_stack_handler.03
374
        dd      app_stack_handler.03
371
	dd	app_stack_handler.fail	;04
375
        dd      app_stack_handler.fail  ;04
372
	dd	app_stack_handler.fail	;05
376
        dd      app_stack_handler.fail  ;05
373
	dd	stack_insert_packet	;app_stack_handler.06
377
        dd      stack_insert_packet     ;app_stack_handler.06
374
	dd	app_stack_handler.fail	;07
378
        dd      app_stack_handler.fail  ;07
375
	dd	stack_get_packet	;app_stack_handler.08
379
        dd      stack_get_packet        ;app_stack_handler.08
376
	dd	app_stack_handler.09
380
        dd      app_stack_handler.09
377
	dd	app_stack_handler.10
381
        dd      app_stack_handler.10
378
	dd	app_stack_handler.11
382
        dd      app_stack_handler.11
379
	dd	app_stack_handler.12
383
        dd      app_stack_handler.12
380
	dd	app_stack_handler.13
384
        dd      app_stack_handler.13
381
	dd	app_stack_handler.14
385
        dd      app_stack_handler.14
382
	dd	app_stack_handler.15
386
        dd      app_stack_handler.15
383
endg
387
endg
384
app_stack_handler:
388
app_stack_handler:
385
;in ebx,ecx
389
;in ebx,ecx
386
;out eax
390
;out eax
387
	cmp	ebx,15
391
        cmp     ebx, 15
388
	ja	.fail			;if more than 15 then exit
392
        ja      .fail                   ;if more than 15 then exit
Line 389... Line 393...
389
 
393
 
Line 390... Line 394...
390
	jmp	dword [f52call+ebx*4]
394
        jmp     dword [f52call+ebx*4]
391
 
395
 
392
 
396
 
393
.00:
397
.00:
Line 394... Line 398...
394
; Read the configuration word
398
; Read the configuration word
395
	mov	eax, [stack_config]
399
        mov     eax, [stack_config]
396
	ret
400
        ret
397
 
401
 
Line 398... Line 402...
398
.01:
402
.01:
399
; read the IP address
403
; read the IP address
400
	mov     eax, [stack_ip]
404
        mov     eax, [stack_ip]
Line 401... Line 405...
401
	ret
405
        ret
402
 
406
 
403
.02:
407
.02:
404
; write the configuration word
408
; write the configuration word
405
	mov     [stack_config], ecx
409
        mov     [stack_config], ecx
406
 
410
 
Line 407... Line 411...
407
; 
411
; 
408
; If ethernet now enabled, probe for the card, reset it and empty
412
; If ethernet now enabled, probe for the card, reset it and empty
409
; the packet buffer
413
; the packet buffer
410
; If all successfull, enable the card.
414
; If all successfull, enable the card.
411
; If ethernet now disabled, set it as disabled. Should really
415
; If ethernet now disabled, set it as disabled. Should really
412
; empty the tcpip data area too.
416
; empty the tcpip data area too.
413
 
417
 
Line 414... Line 418...
414
; ethernet interface is '3' in ls 7 bits
418
; ethernet interface is '3' in ls 7 bits
415
	and     cl, 0x7f
419
        and     cl, 0x7f
416
	cmp     cl, 3
420
        cmp     cl, 3
417
	je      ash_eth_enable
421
        je      ash_eth_enable
418
; Ethernet isn't enabled, so make sure that the card is disabled
422
; Ethernet isn't enabled, so make sure that the card is disabled
419
	mov     [ethernet_active], byte 0
423
        mov     [ethernet_active], byte 0
420
	ret
424
        ret
421
 
425
 
422
.03:
426
.03:
Line 423... Line 427...
423
; write the IP Address
427
; write the IP Address
Line 424... Line 428...
424
	mov     [stack_ip], ecx
428
        mov     [stack_ip], ecx
425
	ret
429
        ret
426
;old functions was deleted
430
;old functions was deleted
427
;.06:
431
;.06:
Line 428... Line 432...
428
; Insert an IP packet into the stacks received packet queue
432
; Insert an IP packet into the stacks received packet queue
429
;	call    stack_insert_packet
433
;       call    stack_insert_packet
430
;	ret
434
;       ret
431
 
435
 
Line 432... Line 436...
432
; Test for any packets queued for transmission over the network
436
; Test for any packets queued for transmission over the network
433
 
437
 
434
;.08:
438
;.08:
435
;	call    stack_get_packet
439
;       call    stack_get_packet
436
; Extract a packet queued for transmission by the network
440
; Extract a packet queued for transmission by the network
437
;	ret
441
;       ret
438
 
442
 
439
.09:
443
.09:
Line 440... Line 444...
440
; read the gateway IP address
444
; read the gateway IP address
441
	mov     eax, [gateway_ip]
445
        mov     eax, [gateway_ip]
442
	ret
446
        ret
443
 
447
 
Line 444... Line 448...
444
.10:
448
.10:
445
; read the subnet mask
449
; read the subnet mask
446
	mov     eax, [subnet_mask]
450
        mov     eax, [subnet_mask]
447
	ret
451
        ret
Line 448... Line 452...
448
.11:
452
.11:
449
; write the gateway IP Address
453
; write the gateway IP Address
450
	mov     [gateway_ip], ecx
454
        mov     [gateway_ip], ecx
451
	ret
455
        ret
Line 452... Line 456...
452
 
456
 
453
.12:
457
.12:
454
; write the subnet mask
458
; write the subnet mask
455
	mov     [subnet_mask], ecx
459
        mov     [subnet_mask], ecx
456
	ret
460
        ret
457
 
461
 
Line 458... Line 462...
458
.13:
462
.13:
459
; read the dns
463
; read the dns
460
	mov     eax, [dns_ip]
464
        mov     eax, [dns_ip]
Line 461... Line 465...
461
	ret
465
        ret
462
 
466
 
463
.14:
467
.14:
Line 464... Line 468...
464
; write the dns IP Address
468
; write the dns IP Address
465
	mov     [dns_ip], ecx
469
        mov     [dns_ip], ecx
466
	ret
470
        ret
467
 
471
 
468
.15:
472
.15:
469
;
473
;
Line 470... Line 474...
470
; in ecx we need 4 to read the last 2 bytes
474
; in ecx we need 4 to read the last 2 bytes
471
; or we need 0 to read the first 4 bytes
475
; or we need 0 to read the first 4 bytes
472
	cmp     ecx,4
476
        cmp     ecx, 4
473
        ja	.param_error
477
        ja      .param_error
474
 
478
 
Line 475... Line 479...
475
; read MAC, returned (in mirrored byte order) in eax
479
; read MAC, returned (in mirrored byte order) in eax
476
        mov     eax, [node_addr + ecx]
480
        mov     eax, [node_addr + ecx]
Line 523... Line 527...
523
; modified by [smb]
527
; modified by [smb]
Line 524... Line 528...
524
 
528
 
525
;
529
;
526
; ARPTable manager interface
530
; ARPTable manager interface
527
    ;see "proc arp_table_manager" for more details
531
    ;see "proc arp_table_manager" for more details
528
    stdcall arp_table_manager,ecx,edx,esi  ;Opcode,Index,Extra
532
        stdcall arp_table_manager, ecx, edx, esi;Opcode,Index,Extra
529
    ret
533
        ret
Line 530... Line 534...
530
;
534
;
531
 
535
 
532
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
536
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
533
ash_eth_enable:
537
ash_eth_enable:
534
; Probe for the card. This will reset it and enable the interface
538
; Probe for the card. This will reset it and enable the interface
535
; if found
539
; if found
536
	call	eth_probe
540
        call    eth_probe
Line 537... Line 541...
537
	test	eax,eax
541
        test    eax, eax
538
	jz	ash_eth_done            ; Abort if no hardware found
542
        jz      ash_eth_done            ; Abort if no hardware found
539
 
543
 
540
	mov     [ethernet_active], byte 1
544
        mov     [ethernet_active], byte 1
541
ash_eth_done:
545
ash_eth_done:
542
	ret
546
        ret
543
;***************************************************************************
547
;***************************************************************************
544
;   Function
548
;   Function
Line 551... Line 555...
551
;
555
;
552
;***************************************************************************
556
;***************************************************************************
553
iglobal
557
iglobal
554
align 4
558
align 4
555
f53call:
559
f53call:
556
	dd	socket_open			;00
560
        dd      socket_open                     ;00
557
	dd	socket_close			;01
561
        dd      socket_close                    ;01
558
	dd	socket_poll			;02
562
        dd      socket_poll                     ;02
559
	dd	socket_read			;03
563
        dd      socket_read                     ;03
560
	dd	socket_write			;04
564
        dd      socket_write                    ;04
561
	dd	socket_open_tcp			;05
565
        dd      socket_open_tcp                 ;05
562
	dd	socket_status			;06
566
        dd      socket_status                   ;06
563
	dd	socket_write_tcp		;07
567
        dd      socket_write_tcp                ;07
564
	dd	socket_close_tcp		;08
568
        dd      socket_close_tcp                ;08
565
	dd	is_localport_unused		;09
569
        dd      is_localport_unused             ;09
566
	dd	app_socket_handler.10
570
        dd      app_socket_handler.10
567
	dd	socket_read_packet		;11
571
        dd      socket_read_packet              ;11
568
endg
572
endg
Line 569... Line 573...
569
 
573
 
570
app_socket_handler:
574
app_socket_handler:
571
;in ebx,ecx,edx,wsi
575
;in ebx,ecx,edx,wsi
572
;out eax
576
;out eax
573
	cmp	eax,255
577
        cmp     eax, 255
Line 574... Line 578...
574
	je	stack_internal_status
578
        je      stack_internal_status
575
 
579
 
Line 576... Line 580...
576
	cmp	eax,11
580
        cmp     eax, 11
Line 577... Line 581...
577
	ja	.fail			;if more than 15 then exit
581
        ja      .fail                   ;if more than 15 then exit
578
 
582
 
579
	jmp	dword [f53call+eax*4]
583
        jmp     dword [f53call+eax*4]
580
 
584
 
581
.10:
585
.10:
582
	mov     eax,dword[drvr_cable]
586
        mov     eax, dword[drvr_cable]
583
	test    eax,eax
587
        test    eax, eax
584
	jnz     @f                	; if function is not implented, return -1
588
        jnz     @f                      ; if function is not implented, return -1
Line 585... Line 589...
585
	or      al,-1
589
        or      al, -1
586
	ret
590
        ret
587
@@:
591
@@:
588
	jmp    dword[drvr_cable]
592
        jmp     dword[drvr_cable]
589
 
593
 
590
.fail:
594
.fail:
591
	or	eax,-1
595
        or      eax, -1
Line 630... Line 634...
630
;  6 : return status of packet driver
634
;  6 : return status of packet driver
631
;  ( 0 == not active, FFFFFFFF = successful )
635
;  ( 0 == not active, FFFFFFFF = successful )
Line 632... Line 636...
632
 
636
 
633
 
637
 
634
stack_internal_status:
638
stack_internal_status:
Line 635... Line 639...
635
    cmp     ebx, 100
639
        cmp     ebx, 100
636
    jnz     notsis100
640
        jnz     notsis100
637
 
641
 
638
    ;  100 : return length of EMPTY QUEUE
642
    ;  100 : return length of EMPTY QUEUE
Line 639... Line 643...
639
    mov     ebx, EMPTY_QUEUE
643
        mov     ebx, EMPTY_QUEUE
640
    call    queueSize
644
        call    queueSize
641
    ret
645
        ret
Line 642... Line 646...
642
 
646
 
643
notsis100:
647
notsis100:
644
    cmp     ebx, 101
648
        cmp     ebx, 101
645
    jnz     notsis101
649
        jnz     notsis101
Line 646... Line 650...
646
 
650
 
647
    ;  101 : return length of IPOUT QUEUE
651
    ;  101 : return length of IPOUT QUEUE
648
    mov     ebx, IPOUT_QUEUE
652
        mov     ebx, IPOUT_QUEUE
Line 649... Line 653...
649
    call    queueSize                       
653
        call    queueSize
650
    ret
654
        ret
651
 
655
 
652
notsis101:
656
notsis101:
Line 653... Line 657...
653
    cmp     ebx, 102
657
        cmp     ebx, 102
654
    jnz     notsis102
658
        jnz     notsis102
655
 
659
 
Line 656... Line 660...
656
    ;  102 : return length of IPIN QUEUE
660
    ;  102 : return length of IPIN QUEUE
657
    mov     ebx, IPIN_QUEUE
661
        mov     ebx, IPIN_QUEUE
658
    call    queueSize
662
        call    queueSize
659
    ret
663
        ret
Line 660... Line 664...
660
 
664
 
661
notsis102:
665
notsis102:
662
    cmp     ebx, 103
666
        cmp     ebx, 103
Line 663... Line 667...
663
    jnz     notsis103
667
        jnz     notsis103
664
 
668
 
665
    ;  103 : return length of NET1OUT QUEUE
669
    ;  103 : return length of NET1OUT QUEUE
Line 666... Line 670...
666
    mov     ebx, NET1OUT_QUEUE
670
        mov     ebx, NET1OUT_QUEUE
667
    call    queueSize
671
        call    queueSize
668
    ret
672
        ret
Line 669... Line 673...
669
 
673
 
670
notsis103:
674
notsis103:
671
    cmp     ebx, 200
675
        cmp     ebx, 200
Line 672... Line 676...
672
    jnz     notsis200
676
        jnz     notsis200
673
 
677
 
674
    ; 200 : return num entries in arp table
678
    ; 200 : return num entries in arp table
Line 675... Line 679...
675
    movzx   eax, byte [NumARP]
679
        movzx   eax, byte [NumARP]
676
    ret
680
        ret
677
 
681
 
Line 678... Line 682...
678
notsis200:
682
notsis200:
679
    cmp     ebx, 201
683
        cmp     ebx, 201
680
    jnz     notsis201
684
        jnz     notsis201
681
 
685
 
682
    ; 201 : return arp table size
686
    ; 201 : return arp table size
683
    mov     eax, 20 ; ARP_TABLE_SIZE
687
        mov     eax, 20; ARP_TABLE_SIZE
684
    ret
688
        ret
685
 
689
 
686
notsis201:
690
notsis201:
687
    cmp     ebx, 202
691
        cmp     ebx, 202
688
    jnz     notsis202
692
        jnz     notsis202
689
 
693
 
690
    ; 202 - read the requested table entry
694
    ; 202 - read the requested table entry
Line 691... Line 695...
691
    ; into a temporary buffer
695
    ; into a temporary buffer
692
    ; ecx holds the entry number
696
    ; ecx holds the entry number
693
 
697
 
Line 694... Line 698...
694
    mov     eax, ecx
698
        mov     eax, ecx
695
    mov     ecx, 14 ; ARP_ENTRY_SIZE
699
        mov     ecx, 14; ARP_ENTRY_SIZE
696
    mul     ecx
700
        mul     ecx
Line 697... Line 701...
697
 
701
 
698
    mov     ecx, [eax + ARPTable]
702
        mov     ecx, [eax + ARPTable]
699
    mov     [ARPTmp], ecx
703
        mov     [ARPTmp], ecx
Line 700... Line 704...
700
    mov     ecx, [eax + ARPTable+4]
704
        mov     ecx, [eax + ARPTable+4]
701
    mov     [ARPTmp+4], ecx
705
        mov     [ARPTmp+4], ecx
702
    mov     ecx, [eax + ARPTable+8]
706
        mov     ecx, [eax + ARPTable+8]
Line 703... Line 707...
703
    mov     [ARPTmp+8], ecx
707
        mov     [ARPTmp+8], ecx
704
    mov     cx, [eax + ARPTable+12]
708
        mov     cx, [eax + ARPTable+12]
705
    mov     [ARPTmp+12], cx
709
        mov     [ARPTmp+12], cx
Line 706... Line 710...
706
    ret
710
        ret
707
 
711
 
708
notsis202:
712
notsis202:
Line 709... Line 713...
709
    cmp     ebx, 203
713
        cmp     ebx, 203
710
    jnz     notsis203
714
        jnz     notsis203
711
 
715
 
Line 712... Line 716...
712
    ; 203 - return IP address
716
    ; 203 - return IP address
713
    mov     eax, [ARPTmp]
717
        mov     eax, [ARPTmp]
714
    ret
718
        ret
Line 715... Line 719...
715
 
719
 
716
notsis203:
720
notsis203:
717
    cmp     ebx, 204
721
        cmp     ebx, 204
Line 718... Line 722...
718
    jnz     notsis204
722
        jnz     notsis204
719
 
723
 
720
    ; 204 - return MAC high dword
724
    ; 204 - return MAC high dword
Line 721... Line 725...
721
    mov     eax, [ARPTmp+4]
725
        mov     eax, [ARPTmp+4]
722
    ret
726
        ret
723
 
727
 
Line 724... Line 728...
724
notsis204:
728
notsis204:
725
    cmp     ebx, 205
729
        cmp     ebx, 205
726
    jnz     notsis205
730
        jnz     notsis205
Line 727... Line 731...
727
 
731
 
728
    ; 205 - return MAC ls word
732
    ; 205 - return MAC ls word
729
    movzx   eax, word [ARPTmp+8]
733
        movzx   eax, word [ARPTmp+8]
Line 730... Line 734...
730
    ret
734
        ret
731
 
735
 
732
notsis205:
736
notsis205:
Line 733... Line 737...
733
    cmp     ebx, 206
737
        cmp     ebx, 206
734
    jnz     notsis206
738
        jnz     notsis206
735
 
739
 
Line 736... Line 740...
736
    ; 206 - return status word
740
    ; 206 - return status word
737
    movzx   eax, word [ARPTmp+10]
741
        movzx   eax, word [ARPTmp+10]
738
    ret
742
        ret
Line 739... Line 743...
739
 
743
 
740
notsis206:
744
notsis206:
741
    cmp     ebx, 207
745
        cmp     ebx, 207
Line 742... Line 746...
742
    jnz     notsis207
746
        jnz     notsis207
743
 
747
 
744
    ; 207 - return ttl word
748
    ; 207 - return ttl word
Line 745... Line 749...
745
    movzx   eax, word [ARPTmp+12]
749
        movzx   eax, word [ARPTmp+12]
746
    ret
750
        ret
747
 
751
 
Line 748... Line 752...
748
notsis207:
752
notsis207:
749
    cmp     ebx, 2
753
        cmp     ebx, 2
750
    jnz     notsis2
754
        jnz     notsis2
751
 
755
 
Line 752... Line 756...
752
    ;  2 : return number of IP packets received
756
    ;  2 : return number of IP packets received
753
    mov     eax, [ip_rx_count]
757
        mov     eax, [ip_rx_count]
754
    ret
758
        ret
Line 755... Line 759...
755
 
759
 
756
notsis2:
760
notsis2:
Line 803... Line 807...
803
;       returns number of bytes read in eax
807
;       returns number of bytes read in eax
804
;
808
;
805
;***************************************************************************
809
;***************************************************************************
806
stack_get_packet:
810
stack_get_packet:
807
    ; Look for a buffer to tx
811
    ; Look for a buffer to tx
808
    mov     eax, NET1OUT_QUEUE
812
        mov     eax, NET1OUT_QUEUE
809
    call    dequeue
813
        call    dequeue
810
    cmp     ax, NO_BUFFER
814
        cmp     ax, NO_BUFFER
811
    je      sgp_non_exit            ; Exit if no buffer available
815
        je      sgp_non_exit        ; Exit if no buffer available
Line 812... Line 816...
812
 
816
 
Line 813... Line 817...
813
    push    eax                     ; Save buffer number for freeing at end
817
        push    eax                 ; Save buffer number for freeing at end
814
 
818
 
815
    push    edx
819
        push    edx
816
    ; convert buffer pointer eax to the absolute address
820
    ; convert buffer pointer eax to the absolute address
817
    mov     ecx, IPBUFFSIZE
821
        mov     ecx, IPBUFFSIZE
818
    mul     ecx
822
        mul     ecx
Line 819... Line 823...
819
    add     eax, IPbuffs
823
        add     eax, IPbuffs
820
    pop     edx
824
        pop     edx
821
 
825
 
822
    push    eax                     ; save address of IP data
826
        push    eax                 ; save address of IP data
823
    ; Get the address of the callers data
827
    ; Get the address of the callers data
824
    mov     edi,[TASK_BASE]
828
        mov     edi, [TASK_BASE]
825
    add     edi,TASKDATA.mem_start
829
        add     edi, TASKDATA.mem_start
826
    add     edx,[edi]
830
        add     edx, [edi]
827
    mov     edi, edx
831
        mov     edi, edx
828
    pop     eax
832
        pop     eax
829
 
833
 
830
    mov     ecx, 1500           ; should get the actual number of bytes to write
834
        mov     ecx, 1500       ; should get the actual number of bytes to write
Line 831... Line 835...
831
    mov     esi, eax
835
        mov     esi, eax
832
    cld
836
        cld
833
    rep     movsb               ; copy the data across
837
        rep movsb               ; copy the data across
Line 834... Line 838...
834
 
838
 
835
    ; And finally, return the buffer to the free queue
839
    ; And finally, return the buffer to the free queue
Line 836... Line 840...
836
    pop     eax
840
        pop     eax
837
    call    freeBuff
841
        call    freeBuff
838
 
842
 
Line 839... Line 843...
839
    mov     eax, 1500
843
        mov     eax, 1500
840
    ret
844
        ret
Line 856... Line 860...
856
;       returns 0 in eax ok, -1 == failed
860
;       returns 0 in eax ok, -1 == failed
857
;
861
;
858
;***************************************************************************
862
;***************************************************************************
859
stack_insert_packet:
863
stack_insert_packet:
Line 860... Line 864...
860
 
864
 
861
    mov     eax, EMPTY_QUEUE
865
        mov     eax, EMPTY_QUEUE
862
    call    dequeue
866
        call    dequeue
863
    cmp     ax, NO_BUFFER
867
        cmp     ax, NO_BUFFER
Line 864... Line 868...
864
    je      sip_err_exit
868
        je      sip_err_exit
Line 865... Line 869...
865
 
869
 
866
    push    eax
870
        push    eax
867
 
871
 
Line 868... Line 872...
868
    ; save the pointers to the data buffer & size
872
    ; save the pointers to the data buffer & size
869
    push    edx
873
        push    edx
870
    push    ecx
874
        push    ecx
871
 
875
 
Line 872... Line 876...
872
    ; convert buffer pointer eax to the absolute address
876
    ; convert buffer pointer eax to the absolute address
Line 873... Line 877...
873
    mov     ecx, IPBUFFSIZE
877
        mov     ecx, IPBUFFSIZE
Line 874... Line 878...
874
    mul     ecx
878
        mul     ecx
875
    add     eax, IPbuffs
879
        add     eax, IPbuffs
876
 
880
 
Line 877... Line 881...
877
    mov     edx, eax
881
        mov     edx, eax
878
 
882
 
879
    ; So, edx holds the IPbuffer ptr
883
    ; So, edx holds the IPbuffer ptr
880
 
884
 
881
    pop     ecx                     ; count of bytes to send
885
        pop     ecx                 ; count of bytes to send
Line 882... Line 886...
882
    mov     ebx, ecx                ; need the length later
886
        mov     ebx, ecx            ; need the length later
883
    pop     eax                     ; get callers ptr to data to send
887
        pop     eax                 ; get callers ptr to data to send
884
 
888
 
Line 885... Line 889...
885
    ; Get the address of the callers data
889
    ; Get the address of the callers data
Line 886... Line 890...
886
    mov     edi,[TASK_BASE]
890
        mov     edi, [TASK_BASE]
887
    add     edi,TASKDATA.mem_start
891
        add     edi, TASKDATA.mem_start
Line 888... Line 892...
888
    add     eax,[edi]
892
        add     eax, [edi]
Line 889... Line 893...
889
    mov     esi, eax
893
        mov     esi, eax
890
 
894
 
Line 891... Line 895...
891
    mov     edi, edx
895
        mov     edi, edx
892
    cld
896
        cld
893
    rep     movsb               ; copy the data across
897
        rep movsb               ; copy the data across