|
Packit Service |
c0f7c7 |
PAGE 60,132
|
|
Packit Service |
c0f7c7 |
NAME PKT_RX
|
|
Packit Service |
c0f7c7 |
|
|
Packit Service |
c0f7c7 |
ifdef ??version ; using TASM
|
|
Packit Service |
c0f7c7 |
masm
|
|
Packit Service |
c0f7c7 |
jumps
|
|
Packit Service |
c0f7c7 |
endif
|
|
Packit Service |
c0f7c7 |
|
|
Packit Service |
c0f7c7 |
PUBLIC _pktDrop, _pktRxBuf, _pktTxBuf, _pktTemp
|
|
Packit Service |
c0f7c7 |
PUBLIC _rxOutOfs, _rxInOfs, _PktReceiver, _pktRxEnd
|
|
Packit Service |
c0f7c7 |
|
|
Packit Service |
c0f7c7 |
;
|
|
Packit Service |
c0f7c7 |
; these sizes MUST be equal to the sizes in PKTDRVR.H
|
|
Packit Service |
c0f7c7 |
;
|
|
Packit Service |
c0f7c7 |
|
|
Packit Service |
c0f7c7 |
RX_BUF_SIZE = 1500 ; max message size on Ethernet
|
|
Packit Service |
c0f7c7 |
TX_BUF_SIZE = 1500
|
|
Packit Service |
c0f7c7 |
|
|
Packit Service |
c0f7c7 |
ifdef DOSX
|
|
Packit Service |
c0f7c7 |
.386
|
|
Packit Service |
c0f7c7 |
NUM_RX_BUF = 32 ; # of RX element buffers
|
|
Packit Service |
c0f7c7 |
_TEXT SEGMENT PUBLIC DWORD USE16 'CODE'
|
|
Packit Service |
c0f7c7 |
_TEXT ENDS
|
|
Packit Service |
c0f7c7 |
_DATA SEGMENT PUBLIC DWORD USE16 'CODE'
|
|
Packit Service |
c0f7c7 |
_DATA ENDS
|
|
Packit Service |
c0f7c7 |
D_SEG EQU <_TEXT SEGMENT>
|
|
Packit Service |
c0f7c7 |
D_END EQU <_TEXT ENDS>
|
|
Packit Service |
c0f7c7 |
ASSUME CS:_TEXT,DS:_TEXT
|
|
Packit Service |
c0f7c7 |
else
|
|
Packit Service |
c0f7c7 |
.286
|
|
Packit Service |
c0f7c7 |
NUM_RX_BUF = 10
|
|
Packit Service |
c0f7c7 |
_TEXT SEGMENT PUBLIC DWORD 'CODE'
|
|
Packit Service |
c0f7c7 |
_TEXT ENDS
|
|
Packit Service |
c0f7c7 |
_DATA SEGMENT PUBLIC DWORD 'DATA'
|
|
Packit Service |
c0f7c7 |
_DATA ENDS
|
|
Packit Service |
c0f7c7 |
D_SEG EQU <_DATA SEGMENT>
|
|
Packit Service |
c0f7c7 |
D_END EQU <_DATA ENDS>
|
|
Packit Service |
c0f7c7 |
ASSUME CS:_TEXT,DS:_DATA
|
|
Packit Service |
c0f7c7 |
endif
|
|
Packit Service |
c0f7c7 |
|
|
Packit Service |
c0f7c7 |
;-------------------------------------------
|
|
Packit Service |
c0f7c7 |
|
|
Packit Service |
c0f7c7 |
D_SEG
|
|
Packit Service |
c0f7c7 |
|
|
Packit Service |
c0f7c7 |
RX_ELEMENT STRUC
|
|
Packit Service |
c0f7c7 |
firstCount dw 0 ; # of bytes on 1st call
|
|
Packit Service |
c0f7c7 |
secondCount dw 0 ; # of bytes on 2nd call
|
|
Packit Service |
c0f7c7 |
handle dw 0 ; handle for upcall
|
|
Packit Service |
c0f7c7 |
destinAdr db 6 dup (0) ; packet destination address
|
|
Packit Service |
c0f7c7 |
sourceAdr db 6 dup (0) ; packet source address
|
|
Packit Service |
c0f7c7 |
protocol dw 0 ; packet protocol number
|
|
Packit Service |
c0f7c7 |
rxBuffer db RX_BUF_SIZE dup (0) ; RX buffer
|
|
Packit Service |
c0f7c7 |
ENDS
|
|
Packit Service |
c0f7c7 |
align 4
|
|
Packit Service |
c0f7c7 |
_rxOutOfs dw offset _pktRxBuf ; ring buffer offsets
|
|
Packit Service |
c0f7c7 |
_rxInOfs dw offset _pktRxBuf ; into _pktRxBuf
|
|
Packit Service |
c0f7c7 |
_pktDrop dw 0,0 ; packet drop counter
|
|
Packit Service |
c0f7c7 |
_pktTemp db 20 dup (0) ; temp work area
|
|
Packit Service |
c0f7c7 |
_pktTxBuf db (TX_BUF_SIZE+14) dup (0) ; TX buffer
|
|
Packit Service |
c0f7c7 |
_pktRxBuf RX_ELEMENT NUM_RX_BUF dup (<>) ; RX structures
|
|
Packit Service |
c0f7c7 |
LAST_OFS = offset $
|
|
Packit Service |
c0f7c7 |
|
|
Packit Service |
c0f7c7 |
screenSeg dw 0B800h
|
|
Packit Service |
c0f7c7 |
newInOffset dw 0
|
|
Packit Service |
c0f7c7 |
|
|
Packit Service |
c0f7c7 |
fanChars db '-\|/'
|
|
Packit Service |
c0f7c7 |
fanIndex dw 0
|
|
Packit Service |
c0f7c7 |
|
|
Packit Service |
c0f7c7 |
D_END
|
|
Packit Service |
c0f7c7 |
|
|
Packit Service |
c0f7c7 |
_TEXT SEGMENT
|
|
Packit Service |
c0f7c7 |
|
|
Packit Service |
c0f7c7 |
|
|
Packit Service |
c0f7c7 |
SHOW_RX MACRO
|
|
Packit Service |
c0f7c7 |
push es
|
|
Packit Service |
c0f7c7 |
push bx
|
|
Packit Service |
c0f7c7 |
mov bx, screenSeg
|
|
Packit Service |
c0f7c7 |
mov es, bx ;; r-mode segment of colour screen
|
|
Packit Service |
c0f7c7 |
mov di, 158 ;; upper right corner - 1
|
|
Packit Service |
c0f7c7 |
mov bx, fanIndex
|
|
Packit Service |
c0f7c7 |
mov al, fanChars[bx] ;; get write char
|
|
Packit Service |
c0f7c7 |
mov ah, 15 ;; and white colour
|
|
Packit Service |
c0f7c7 |
stosw ;; write to screen at ES:EDI
|
|
Packit Service |
c0f7c7 |
inc fanIndex ;; update next index
|
|
Packit Service |
c0f7c7 |
and fanIndex, 3
|
|
Packit Service |
c0f7c7 |
pop bx
|
|
Packit Service |
c0f7c7 |
pop es
|
|
Packit Service |
c0f7c7 |
ENDM
|
|
Packit Service |
c0f7c7 |
|
|
Packit Service |
c0f7c7 |
;------------------------------------------------------------------------
|
|
Packit Service |
c0f7c7 |
;
|
|
Packit Service |
c0f7c7 |
; This macro return ES:DI to tail of Rx queue
|
|
Packit Service |
c0f7c7 |
|
|
Packit Service |
c0f7c7 |
ENQUEUE MACRO
|
|
Packit Service |
c0f7c7 |
LOCAL @noWrap
|
|
Packit Service |
c0f7c7 |
mov ax, _rxInOfs ;; DI = current in-offset
|
|
Packit Service |
c0f7c7 |
add ax, SIZE RX_ELEMENT ;; point to next _pktRxBuf buffer
|
|
Packit Service |
c0f7c7 |
cmp ax, LAST_OFS ;; pointing past last ?
|
|
Packit Service |
c0f7c7 |
jb @noWrap ;; no - jump
|
|
Packit Service |
c0f7c7 |
lea ax, _pktRxBuf ;; yes, point to 1st buffer
|
|
Packit Service |
c0f7c7 |
align 4
|
|
Packit Service |
c0f7c7 |
@noWrap: cmp ax, _rxOutOfs ;; in-ofs = out-ofs ?
|
|
Packit Service |
c0f7c7 |
je @dump ;; yes, queue is full
|
|
Packit Service |
c0f7c7 |
mov di, _rxInOfs ;; ES:DI -> buffer at queue input
|
|
Packit Service |
c0f7c7 |
mov newInOffset, ax ;; remember new input offset
|
|
Packit Service |
c0f7c7 |
|
|
Packit Service |
c0f7c7 |
;; NOTE. rxInOfs is updated after the packet has been copied
|
|
Packit Service |
c0f7c7 |
;; to ES:DI (= DS:SI on 2nd call) by the packet driver
|
|
Packit Service |
c0f7c7 |
|
|
Packit Service |
c0f7c7 |
ENDM
|
|
Packit Service |
c0f7c7 |
|
|
Packit Service |
c0f7c7 |
;------------------------------------------------------------------------
|
|
Packit Service |
c0f7c7 |
;
|
|
Packit Service |
c0f7c7 |
; This routine gets called by the packet driver twice:
|
|
Packit Service |
c0f7c7 |
; 1st time (AX=0) it requests an address where to put the packet
|
|
Packit Service |
c0f7c7 |
;
|
|
Packit Service |
c0f7c7 |
; 2nd time (AX=1) the packet has been copied to this location (DS:SI)
|
|
Packit Service |
c0f7c7 |
; BX has client handle (stored in RX_ELEMENT.handle).
|
|
Packit Service |
c0f7c7 |
; CX has # of bytes in packet on both call. They should be equal.
|
|
Packit Service |
c0f7c7 |
;
|
|
Packit Service |
c0f7c7 |
; A test for equality is done by putting CX in _pktRxBuf [n].firstCount
|
|
Packit Service |
c0f7c7 |
; and _pktRxBuf[n].secondCount, and CL on first call in
|
|
Packit Service |
c0f7c7 |
; _pktRxBuf[n].rxBuffer[CX]. These values are checked in "PktReceive"
|
|
Packit Service |
c0f7c7 |
; (PKTDRVR.C)
|
|
Packit Service |
c0f7c7 |
;
|
|
Packit Service |
c0f7c7 |
;---------------------------------------------------------------------
|
|
Packit Service |
c0f7c7 |
|
|
Packit Service |
c0f7c7 |
_PktReceiver:
|
|
Packit Service |
c0f7c7 |
pushf
|
|
Packit Service |
c0f7c7 |
cli ; no distraction wanted !
|
|
Packit Service |
c0f7c7 |
push ds
|
|
Packit Service |
c0f7c7 |
push bx
|
|
Packit Service |
c0f7c7 |
ifdef DOSX
|
|
Packit Service |
c0f7c7 |
mov bx, cs
|
|
Packit Service |
c0f7c7 |
else
|
|
Packit Service |
c0f7c7 |
mov bx, SEG _DATA
|
|
Packit Service |
c0f7c7 |
endif
|
|
Packit Service |
c0f7c7 |
mov ds, bx
|
|
Packit Service |
c0f7c7 |
mov es, bx ; ES = DS = CS or seg _DATA
|
|
Packit Service |
c0f7c7 |
pop bx ; restore handle
|
|
Packit Service |
c0f7c7 |
|
|
Packit Service |
c0f7c7 |
cmp ax, 0 ; first call? (AX=0)
|
|
Packit Service |
c0f7c7 |
jne @post ; AX=1: second call, do post process
|
|
Packit Service |
c0f7c7 |
|
|
Packit Service |
c0f7c7 |
ifdef DEBUG
|
|
Packit Service |
c0f7c7 |
SHOW_RX ; show that a packet is received
|
|
Packit Service |
c0f7c7 |
endif
|
|
Packit Service |
c0f7c7 |
cmp cx, RX_BUF_SIZE+14 ; size OK ?
|
|
Packit Service |
c0f7c7 |
ja @skip ; no, packet to large for us
|
|
Packit Service |
c0f7c7 |
|
|
Packit Service |
c0f7c7 |
ENQUEUE ; ES:DI -> _pktRxBuf[n]
|
|
Packit Service |
c0f7c7 |
|
|
Packit Service |
c0f7c7 |
mov [di].firstCount, cx ; remember the first count.
|
|
Packit Service |
c0f7c7 |
mov [di].handle, bx ; remember the handle.
|
|
Packit Service |
c0f7c7 |
add di, 6 ; ES:DI -> _pktRxBuf[n].destinAdr
|
|
Packit Service |
c0f7c7 |
pop ds
|
|
Packit Service |
c0f7c7 |
popf
|
|
Packit Service |
c0f7c7 |
retf ; far return to driver with ES:DI
|
|
Packit Service |
c0f7c7 |
|
|
Packit Service |
c0f7c7 |
align 4
|
|
Packit Service |
c0f7c7 |
@dump: inc _pktDrop[0] ; discard the packet on 1st call
|
|
Packit Service |
c0f7c7 |
adc _pktDrop[2], 0 ; increment packets lost
|
|
Packit Service |
c0f7c7 |
|
|
Packit Service |
c0f7c7 |
@skip: xor di, di ; return ES:DI = NIL pointer
|
|
Packit Service |
c0f7c7 |
xor ax, ax
|
|
Packit Service |
c0f7c7 |
mov es, ax
|
|
Packit Service |
c0f7c7 |
pop ds
|
|
Packit Service |
c0f7c7 |
popf
|
|
Packit Service |
c0f7c7 |
retf
|
|
Packit Service |
c0f7c7 |
|
|
Packit Service |
c0f7c7 |
align 4
|
|
Packit Service |
c0f7c7 |
@post: or si, si ; DS:SI->_pktRxBuf[n][n].destinAdr
|
|
Packit Service |
c0f7c7 |
jz @discard ; make sure we don't use NULL-pointer
|
|
Packit Service |
c0f7c7 |
|
|
Packit Service |
c0f7c7 |
sub si, 6 ; DS:SI -> _pktRxBuf[n].destinAdr
|
|
Packit Service |
c0f7c7 |
;
|
|
Packit Service |
c0f7c7 |
; push si
|
|
Packit Service |
c0f7c7 |
; push [si].firstCount
|
|
Packit Service |
c0f7c7 |
; call bpf_filter_match ; run the filter here some day?
|
|
Packit Service |
c0f7c7 |
; add sp, 4
|
|
Packit Service |
c0f7c7 |
; cmp ax, 0
|
|
Packit Service |
c0f7c7 |
; je @discard
|
|
Packit Service |
c0f7c7 |
|
|
Packit Service |
c0f7c7 |
mov [si].secondCount, cx
|
|
Packit Service |
c0f7c7 |
mov ax, newInOffset
|
|
Packit Service |
c0f7c7 |
mov _rxInOfs, ax ; update _pktRxBuf input offset
|
|
Packit Service |
c0f7c7 |
|
|
Packit Service |
c0f7c7 |
align 4
|
|
Packit Service |
c0f7c7 |
@discard:pop ds
|
|
Packit Service |
c0f7c7 |
popf
|
|
Packit Service |
c0f7c7 |
retf
|
|
Packit Service |
c0f7c7 |
|
|
Packit Service |
c0f7c7 |
_pktRxEnd db 0 ; marker for end of r-mode code/data
|
|
Packit Service |
c0f7c7 |
|
|
Packit Service |
c0f7c7 |
_TEXT ENDS
|
|
Packit Service |
c0f7c7 |
|
|
Packit Service |
c0f7c7 |
END
|