Subversion Repositories Kolibri OS

Rev

Rev 261 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 ha 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                                 ;;
3
;;  ETHERNET.INC                                                   ;;
4
;;                                                                 ;;
5
;;  Ethernet network layer for Menuet OS                           ;;
6
;;                                                                 ;;
7
;;  Version 0.4  22 September 2003                                 ;;
8
;;                                                                 ;;
9
;;  This file contains the following:                              ;;
10
;;      PCI bus scanning for valid devices                         ;;
11
;;      Table of supported ethernet drivers                        ;;
12
;;      Code to identify and activate a supported driver           ;;
13
;;      ARP handler                                                ;;
14
;;      Driver interface to the IP layer                           ;;
15
;;      Gateway support                                            ;;
16
;;                                                                 ;;
17
;;  Individual driver files are included here                      ;;
18
;;                                                                 ;;
19
;;  The PCI bus scanning code was ported from the etherboot        ;;
20
;;  5.0.6 project. The copyright statement for that code is        ;;
21
;;                                                                 ;;
22
;;          GNU GENERAL PUBLIC LICENSE                             ;;
23
;;             Version 2, June 1991                                ;;
24
;;                                                                 ;;
25
;;  remaining parts Copyright 2002 Mike Hibbett                    ;;
26
;;   mikeh@oceanfree.net                                           ;;
27
;;                                                                 ;;
28
;;  See file COPYING for details                                   ;;
29
;;                                                                 ;;
30
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
31
 
32
;********************************************************************
33
;   Interface
34
;      ethernet_driver   called by stack_handler in stack.inc
35
;      eth_probe         called by app_stack_handler in stack.inc
36
;
37
;********************************************************************
38
 
302 hidnplayr 39
ETHER_IP		    equ     0x0008	; Reversed from 0800 for intel
40
ETHER_ARP		    equ     0x0608	; Reversed from 0806 for intel
41
ETHER_RARP		    equ     0x3580
261 hidnplayr 42
 
43
struc ETH_FRAME
302 hidnplayr 44
{  .DstMAC	 dp   ?  ;destination MAC-address [6 bytes]
45
   .SrcMAC	 dp   ?  ;source MAC-address [6 bytes]
46
   .Type	 dw   ?  ;type of the upper-layer protocol [2 bytes]
47
   .Data	 db   ?  ;data [46-1500 bytes]
261 hidnplayr 48
}
49
 
50
virtual at Ether_buffer
51
  ETH_FRAME ETH_FRAME
52
end virtual
53
 
54
 
1 ha 55
; Some useful information on data structures
56
 
57
;     Ethernet Packet - ARP Request example
58
;
59
;   0                   1                   2                   3
60
;   0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
61
;
62
;   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
63
;   |       Dest   H/W Address                                      |
64
;   |                    ( 14 byte header )                         |
65
;   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
66
;   |                               |     Source     H/W Address    |
67
;   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
68
;   |                                                               |
69
;   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
70
;   |    Protocol - ARP 08  06      |
71
;   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
72
 
73
;   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
74
;   |  H/W Type  00           01    |  Protocol Type   08 00        |
75
;   |                   ( ARP Request packet )                      |
76
;   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
77
;   | HLen    0x06  | PLen    0x04  |    OpCode        00   01      |
78
;   |               ( 0001 for request, 0002 for reply )            |
79
;   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
80
;   | Source Hardware Address ( MAC Address )                       |
81
;   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
82
;   |                               |  Source IP Address            |
83
;   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
84
;   |                               | Destination Hardware Address  |
85
;   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
86
;   |                                                               |
87
;   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
88
;   | Destination IP Address                                        |
89
;   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
90
 
91
; Include individual drivers source files at this point.
92
; If you create a new driver, include it below.
93
 
261 hidnplayr 94
include "drivers/rtl8029.inc"
95
include "drivers/i8255x.inc"
96
include "drivers/rtl8139.inc"
97
include "drivers/3c59x.inc"
98
include "drivers/sis900.inc"
99
include "drivers/pcnet32.inc"
1 ha 100
 
101
; PCICards
102
; ========
103
; PCI vendor and hardware types for hardware supported by the above drivers
104
; If you add a driver, ensure you update this datastructure, otherwise the
105
; card will not be probed.
106
; Each driver is defined by 4 double words. These are
107
;   PCIVendorDevice  probeFunction ResetFunction PollFunction transmitFunction
108
; The last entry must be kept at all zeros, to indicate the end of the list
109
; As a PCI driver may support more than one hardware implementation, there may
110
; be several lines which refer to the same functions.
111
; The first driver found on the PCI bus will be the one used.
112
 
302 hidnplayr 113
PCICARDS_ENTRY_SIZE	    equ     24	  ; Size of each PCICARDS entry
1 ha 114
 
115
iglobal
116
PCICards:
302 hidnplayr 117
dd  0x12098086, I8255x_probe, I8255x_reset, I8255x_poll, I8255x_transmit, 0
118
dd  0x10298086, I8255x_probe, I8255x_reset, I8255x_poll, I8255x_transmit, 0
119
dd  0x12298086, I8255x_probe, I8255x_reset, I8255x_poll, I8255x_transmit, 0
120
dd  0x10308086, I8255x_probe, I8255x_reset, I8255x_poll, I8255x_transmit, 0
121
dd  0x24498086, I8255x_probe, I8255x_reset, I8255x_poll, I8255x_transmit, 0
122
dd  0x802910ec, rtl8029_probe, rtl8029_reset, rtl8029_poll, rtl8029_transmit, 0
123
dd  0x12111113, rtl8029_probe, rtl8029_reset, rtl8029_poll, rtl8029_transmit, 0
124
 
125
dd  0x813910ec, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable
126
dd  0x813810ec, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable
127
dd  0x12111113, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable
128
dd  0x13601500, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable
129
dd  0x13604033, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable
130
dd  0x13001186, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable
131
dd  0x13401186, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable
132
dd  0xab0613d1, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable
133
dd  0xa1171259, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable
134
dd  0xa11e1259, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable
135
dd  0xab0614ea, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable
136
dd  0xab0714ea, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable
137
dd  0x123411db, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable
138
dd  0x91301432, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable
139
dd  0x101202ac, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable
140
dd  0x0106018a, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable
141
dd  0x1211126c, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable
142
dd  0x81391743, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable
143
dd  0x8139021b, rtl8139_probe, rtl8139_reset, rtl8139_poll, rtl8139_transmit, rtl8139_cable
144
 
145
dd  0x590010b7, e3c59x_probe, e3c59x_reset, e3c59x_poll, e3c59x_transmit, 0
146
dd  0x592010b7, e3c59x_probe, e3c59x_reset, e3c59x_poll, e3c59x_transmit, 0
147
dd  0x597010b7, e3c59x_probe, e3c59x_reset, e3c59x_poll, e3c59x_transmit, 0
148
dd  0x595010b7, e3c59x_probe, e3c59x_reset, e3c59x_poll, e3c59x_transmit, 0
149
dd  0x595110b7, e3c59x_probe, e3c59x_reset, e3c59x_poll, e3c59x_transmit, 0
150
dd  0x595210b7, e3c59x_probe, e3c59x_reset, e3c59x_poll, e3c59x_transmit, 0
151
dd  0x900010b7, e3c59x_probe, e3c59x_reset, e3c59x_poll, e3c59x_transmit, 0
152
dd  0x900110b7, e3c59x_probe, e3c59x_reset, e3c59x_poll, e3c59x_transmit, 0
153
dd  0x900410b7, e3c59x_probe, e3c59x_reset, e3c59x_poll, e3c59x_transmit, 0
154
dd  0x900510b7, e3c59x_probe, e3c59x_reset, e3c59x_poll, e3c59x_transmit, 0
155
dd  0x900610b7, e3c59x_probe, e3c59x_reset, e3c59x_poll, e3c59x_transmit, 0
156
dd  0x900A10b7, e3c59x_probe, e3c59x_reset, e3c59x_poll, e3c59x_transmit, 0
157
dd  0x905010b7, e3c59x_probe, e3c59x_reset, e3c59x_poll, e3c59x_transmit, 0
158
dd  0x905110b7, e3c59x_probe, e3c59x_reset, e3c59x_poll, e3c59x_transmit, 0
159
dd  0x905510b7, e3c59x_probe, e3c59x_reset, e3c59x_poll, e3c59x_transmit, 0
160
dd  0x905810b7, e3c59x_probe, e3c59x_reset, e3c59x_poll, e3c59x_transmit, 0
161
dd  0x905A10b7, e3c59x_probe, e3c59x_reset, e3c59x_poll, e3c59x_transmit, 0
162
dd  0x920010b7, e3c59x_probe, e3c59x_reset, e3c59x_poll, e3c59x_transmit, 0
163
dd  0x980010b7, e3c59x_probe, e3c59x_reset, e3c59x_poll, e3c59x_transmit, 0
164
dd  0x980510b7, e3c59x_probe, e3c59x_reset, e3c59x_poll, e3c59x_transmit, 0
165
dd  0x764610b7, e3c59x_probe, e3c59x_reset, e3c59x_poll, e3c59x_transmit, 0
166
dd  0x505510b7, e3c59x_probe, e3c59x_reset, e3c59x_poll, e3c59x_transmit, 0
167
dd  0x605510b7, e3c59x_probe, e3c59x_reset, e3c59x_poll, e3c59x_transmit, 0
168
dd  0x605610b7, e3c59x_probe, e3c59x_reset, e3c59x_poll, e3c59x_transmit, 0
169
dd  0x5b5710b7, e3c59x_probe, e3c59x_reset, e3c59x_poll, e3c59x_transmit, 0
170
dd  0x505710b7, e3c59x_probe, e3c59x_reset, e3c59x_poll, e3c59x_transmit, 0
171
dd  0x515710b7, e3c59x_probe, e3c59x_reset, e3c59x_poll, e3c59x_transmit, 0
172
dd  0x525710b7, e3c59x_probe, e3c59x_reset, e3c59x_poll, e3c59x_transmit, 0
173
dd  0x656010b7, e3c59x_probe, e3c59x_reset, e3c59x_poll, e3c59x_transmit, 0
174
dd  0x656210b7, e3c59x_probe, e3c59x_reset, e3c59x_poll, e3c59x_transmit, 0
175
dd  0x656410b7, e3c59x_probe, e3c59x_reset, e3c59x_poll, e3c59x_transmit, 0
176
dd  0x450010b7, e3c59x_probe, e3c59x_reset, e3c59x_poll, e3c59x_transmit, 0
177
 
178
dd  0x09001039, SIS900_probe, SIS900_reset, SIS900_poll, SIS900_transmit, 0
179
 
180
dd  0x20001022, pcnet32_probe, pcnet32_reset, pcnet32_poll, pcnet32_xmit, 0
181
dd  0x26251022, pcnet32_probe, pcnet32_reset, pcnet32_poll, pcnet32_xmit, 0
182
dd  0x20011022, pcnet32_probe, pcnet32_reset, pcnet32_poll, pcnet32_xmit, 0
1 ha 183
; following card is untested
302 hidnplayr 184
dd  0x70161039, SIS900_probe, SIS900_reset, SIS900_poll, SIS900_transmit, 0
185
rb PCICARDS_ENTRY_SIZE	; end of list marker, do not remove
1 ha 186
endg
187
 
188
uglobal
261 hidnplayr 189
;Net-stack's interface's settings
302 hidnplayr 190
  node_addr:	      db  0,0,0,0,0,0
191
  gateway_ip:	      dd  0
192
  dns_ip:	      dd  0
261 hidnplayr 193
 
1 ha 194
  eth_rx_data_len:    dw  0
302 hidnplayr 195
  eth_status:	      dd  0
196
  io_addr:	      dd  0
197
  hdrtype:	      db  0
1 ha 198
  vendor_device:      dd  0
302 hidnplayr 199
  pci_data:	      dd  0
200
  pci_dev:	      dd  0
201
  pci_bus:	      dd  0
1 ha 202
 
203
  ; These will hold pointers to the selected driver functions
302 hidnplayr 204
  drvr_probe:	      dd  0
205
  drvr_reset:	      dd  0
206
  drvr_poll:	      dd  0
1 ha 207
  drvr_transmit:      dd  0
302 hidnplayr 208
  drvr_cable:	      dd  0
1 ha 209
 
210
endg
211
 
212
iglobal
213
  broadcast_add:      db  0xff,0xff,0xff,0xff,0xff,0xff
302 hidnplayr 214
  subnet_mask:	      dd  0x00ffffff   ; 255.255.255.0
1 ha 215
endg
216
 
261 hidnplayr 217
include "arp.inc"    ;arp-protocol functions
218
include "pci.inc"    ;PCI bus access functions
1 ha 219
 
220
 
221
;***************************************************************************
222
;   Function
223
;      eth_tx
224
;
225
;   Description
226
;      Looks at the NET1OUT_QUEUE for data to send.
227
;      Stores that destination IP in a location used by the tx routine
228
;      Looks up the MAC address in the ARP table; stores that where
229
;      the tx routine can get it
230
;      Get the length of the data. Store that where the tx routine wants it
231
;      Call tx
232
;      Places buffer on empty queue when the tx routine finished
233
;
234
;***************************************************************************
261 hidnplayr 235
proc eth_tx stdcall uses ebx esi edi
236
local MACAddress  dp  ?  ;allocate 6 bytes in the stack
237
 
1 ha 238
    ; Look for a buffer to tx
239
    mov     eax, NET1OUT_QUEUE
240
    call    dequeue
241
    cmp     ax, NO_BUFFER
302 hidnplayr 242
    je	    .exit	     ; Exit if no buffer available
1 ha 243
 
261 hidnplayr 244
    push    eax  ;save buffer number
1 ha 245
 
246
    ; convert buffer pointer eax to the absolute address
261 hidnplayr 247
    imul    eax, IPBUFFSIZE
1 ha 248
    add     eax, IPbuffs
249
 
250
    ; Extract the destination IP
251
    ; find the destination IP in the ARP table, get MAC
252
    ; store this MAC in 'MACAddress'
302 hidnplayr 253
    mov     ebx, eax		   ; Save buffer address
254
    mov     edx, [ebx + 16]	   ; get destination address
1 ha 255
 
256
    ; If the destination address is 255.255.255.255,
257
    ; set the MACAddress to all ones ( broadcast )
261 hidnplayr 258
    cld
259
    mov     esi, broadcast_add
260
    lea     edi, [MACAddress]
261
    movsd
262
    movsw
1 ha 263
    cmp     edx, 0xffffffff
302 hidnplayr 264
    je	    .send		 ; If it is broadcast, just send
1 ha 265
 
302 hidnplayr 266
    lea     eax, [MACAddress]	 ;cause this is local variable
261 hidnplayr 267
    stdcall arp_table_manager, ARP_TABLE_IP_TO_MAC, edx, eax ;opcode,IP,MAC_ptr - Get the MAC address.
1 ha 268
 
269
    cmp     eax, ARP_VALID_MAPPING
302 hidnplayr 270
    je	    .send
1 ha 271
 
261 hidnplayr 272
    ; No valid entry. Has the request been sent, but timed out?
1 ha 273
    cmp     eax, ARP_RESPONSE_TIMEOUT
302 hidnplayr 274
    je	    .freebuf
1 ha 275
 
302 hidnplayr 276
  .wait_response:		    ;we wait arp-response
277
				    ; Re-queue the packet, and exit
1 ha 278
    pop     ebx
279
    mov     eax, NET1OUT_QUEUE
302 hidnplayr 280
    call    queue			 ; Get the buffer back
261 hidnplayr 281
    jmp     .exit
1 ha 282
 
261 hidnplayr 283
  .send:    ;if ARP_VALID_MAPPING then send the packet
302 hidnplayr 284
    lea     edi, [MACAddress]	  ; Pointer to 48 bit destination address
285
    movzx   ecx, word[ebx+2]	  ; Size of IP packet to send
286
    xchg    ch, cl		  ; because mirror byte-order
287
    mov     esi, ebx		  ; Pointer to packet data
288
    mov     bx, ETHER_IP	  ; Type of packet
261 hidnplayr 289
    call    dword [drvr_transmit] ; Call the drivers transmit function
1 ha 290
 
291
    ; OK, we have sent a packet, so increment the count
292
    inc     dword [ip_tx_count]
293
 
294
    ; And finally, return the buffer to the free queue
261 hidnplayr 295
  .freebuf:
1 ha 296
    pop     eax
297
    call    freeBuff
298
 
261 hidnplayr 299
  .exit:
1 ha 300
    ret
261 hidnplayr 301
endp
1 ha 302
 
303
;***************************************************************************
304
;   Function
305
;      ether_IP_handler
306
;
307
;   Description
308
;      Called when an IP ethernet packet is received on the ethernet
309
;      Header + Data is in Ether_buffer[]
310
;      We just need to get a buffer from the 'free' queue, and
311
;      store the packet in it, then insert the packet number into the
312
;      IPRX queue.
313
;      If no queue entry is available, the packet is silently discarded
314
;      All registers may be destroyed
315
;
316
;***************************************************************************
317
ether_IP_handler:
318
    mov     eax, EMPTY_QUEUE
319
    call    dequeue
320
    cmp     ax, NO_BUFFER
302 hidnplayr 321
    je	    eiph00x
1 ha 322
 
323
    ; convert buffer pointer eax to the absolute address
324
    push    eax
325
    mov     ecx, IPBUFFSIZE
326
    mul     ecx
327
    add     eax, IPbuffs
328
 
329
    mov     edi, eax
330
 
331
    ; get a pointer to the start of the DATA
261 hidnplayr 332
    mov     esi, ETH_FRAME.Data
1 ha 333
 
334
    ; Now store it all away
335
    mov     ecx, IPBUFFSIZE / 4     ; Copy all of the available
302 hidnplayr 336
			      ; data across - worse case
1 ha 337
    cld
338
    rep     movsd
339
 
340
    ; And finally, place the buffer in the IPRX queue
341
    pop     ebx
342
    mov     eax, IPIN_QUEUE
343
    call    queue
344
 
345
eiph00x:
346
    ret
347
 
348
;***************************************************************************
349
;   Function
261 hidnplayr 350
;      eth_probe
1 ha 351
;   Description
261 hidnplayr 352
;      Searches for an ethernet card. If found, the card is enabled and
353
;      the ethernet -> IP link established
1 ha 354
;
261 hidnplayr 355
;      This function scans the PCI bus looking for a supported device.
356
;      ISA bus is currently not supported.
1 ha 357
;
261 hidnplayr 358
;        eax is 0 if no hardware found
1 ha 359
;***************************************************************************
261 hidnplayr 360
eth_probe:
361
    ; Find a card on the PCI bus, and get it's address
302 hidnplayr 362
    call    scan_bus			; Find the ethernet cards PIC address
1 ha 363
    xor     eax, eax
261 hidnplayr 364
    cmp     [io_addr], eax
302 hidnplayr 365
    je	    ep_00x			; Return 0 in eax if no cards found
1 ha 366
 
302 hidnplayr 367
    call    dword [drvr_probe]		; Call the drivers probe function
1 ha 368
 
302 hidnplayr 369
    mov     eax, [io_addr]		; return a non zero value
1 ha 370
 
261 hidnplayr 371
ep_00x:
1 ha 372
    ret
373
 
374
;***************************************************************************
375
;   Function
261 hidnplayr 376
;      ethernet_driver
1 ha 377
;
378
;   Description
261 hidnplayr 379
;       The ethernet RX and TX handler
380
;       This is a kernel function, called by stack_handler
1 ha 381
;
382
;***************************************************************************
261 hidnplayr 383
ethernet_driver:
384
    ; Do nothing if the driver is inactive
385
    cmp     [ethernet_active], byte 0
302 hidnplayr 386
    je	    eth_exit
1 ha 387
 
261 hidnplayr 388
    call    eth_rx
389
    call    eth_tx
1 ha 390
 
261 hidnplayr 391
eth_exit:
1 ha 392
    ret
393
 
394
;***************************************************************************
395
;   Function
261 hidnplayr 396
;      eth_rx
1 ha 397
;
398
;   Description
261 hidnplayr 399
;      Polls the ethernet card for received data. Extracts if present
400
;       Depending on the Protocol within the packet:
401
;         ARP : Pass to ARP_handler. This may result in an ARP reply
402
;               being tx'ed
403
;         IP  : Store in an IP buffer
1 ha 404
;
405
;***************************************************************************
261 hidnplayr 406
eth_rx:
407
    xor     ax, ax
408
    mov     [eth_rx_data_len], ax
302 hidnplayr 409
    call    dword [drvr_poll]	    ; Call the drivers poll function
1 ha 410
 
261 hidnplayr 411
    mov     ax, [eth_rx_data_len]
412
    cmp     ax, 0
302 hidnplayr 413
    je	    .exit
1 ha 414
 
415
 
261 hidnplayr 416
    ; Check the protocol. Call appropriate handler
1 ha 417
 
261 hidnplayr 418
    mov     ax, [ETH_FRAME.Type]    ; The address of the protocol word
1 ha 419
 
261 hidnplayr 420
    cmp     ax, ETHER_IP
302 hidnplayr 421
    je	    .is_ip		     ; It's IP
1 ha 422
 
261 hidnplayr 423
    cmp     ax, ETHER_ARP
302 hidnplayr 424
    je	    .is_arp		     ; It is ARP
1 ha 425
 
302 hidnplayr 426
    jmp     .exit		; If not IP or ARP, ignore
1 ha 427
 
261 hidnplayr 428
  .is_ip:
429
    inc     dword [ip_rx_count]
430
    call    ether_IP_handler
431
    jmp     .exit
1 ha 432
 
261 hidnplayr 433
  .is_arp:
1 ha 434
 
261 hidnplayr 435
    ; At this point, the packet is still in the Ether_buffer
436
    call    arp_handler
1 ha 437
 
261 hidnplayr 438
  .exit:
302 hidnplayr 439
    ret