Subversion Repositories Kolibri OS

Rev

Rev 1473 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1473 Rev 1514
Line 1... Line 1...
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                                 ;;
2
;;                                                                 ;;
3
;; Copyright (C) KolibriOS team 2004-2009. All rights reserved.    ;;
3
;; Copyright (C) KolibriOS team 2004-2010. All rights reserved.    ;;
4
;; Distributed under terms of the GNU General Public License       ;;
4
;; Distributed under terms of the GNU General Public License       ;;
5
;;                                                                 ;;
5
;;                                                                 ;;
6
;;  ETHERNET.INC                                                   ;;
6
;;  ETHERNET.INC                                                   ;;
7
;;                                                                 ;;
7
;;                                                                 ;;
8
;;  Ethernet network layer for KolibriOS                           ;;
8
;;  Ethernet network layer for KolibriOS                           ;;
Line 12... Line 12...
12
;;          GNU GENERAL PUBLIC LICENSE                             ;;
12
;;          GNU GENERAL PUBLIC LICENSE                             ;;
13
;;             Version 2, June 1991                                ;;
13
;;             Version 2, June 1991                                ;;
14
;;                                                                 ;;
14
;;                                                                 ;;
15
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 16... Line 16...
16
 
16
 
Line 17... Line -...
17
$Revision: 1473 $
-
 
18
 
17
$Revision: 1514 $
Line 19... Line 18...
19
MAX_ETH_DEVICES 	equ MAX_NET_DEVICES
18
 
20
ETH_QUEUE_SIZE		equ 16
19
ETH_QUEUE_SIZE		equ 16
21
 
20
 
22
struct	ETH_FRAME
21
struct	ETH_FRAME
23
	.DstMAC 	dp  ?  ; destination MAC-address [6 bytes]
22
	.DstMAC 	dp  ?  ; destination MAC-address
24
	.SrcMAC 	dp  ?  ; source MAC-address [6 bytes]
23
	.SrcMAC 	dp  ?  ; source MAC-address
Line -... Line 24...
-
 
24
	.Type		dw  ?  ; type of the upper-layer protocol
-
 
25
	.Data:		       ; data (46-1500 bytes for a normal packet)
25
	.Type		dw  ?  ; type of the upper-layer protocol [2 bytes]
26
ends
26
	.Data:		       ; data [46-1500 bytes]
27
 
27
ends
28
virtual at NET_DEVICE.end
28
 
29
 
29
struct	ETH_DEVICE
30
	ETH_DEVICE:
30
	.unload 	dd ?
31
	.unload 	dd ?
Line 37... Line 38...
37
 
38
 
38
	.bytes_tx	dq ?
39
	.bytes_tx	dq ?
39
	.bytes_rx	dq ?
40
	.bytes_rx	dq ?
40
	.packets_tx	dd ?
41
	.packets_tx	dd ?
41
	.packets_rx	dd ?
42
	.packets_rx	dd ?
42
	.mode		dd ?  ; This dword contains cable status (10mbit/100mbit, full/half duplex, auto negotiation or not,..)
43
	.mode		dd ?
43
	.name		dd ?
44
	.name		dd ?
44
	.mac		dp ?
-
 
45
ends			      ; the rest of the device struct depends on the type of device
-
 
46
 
-
 
47
struct	eth_queue_entry
-
 
48
	.owner		dd ?
-
 
49
	.data_ptr	dd ?
-
 
50
	.data_size	dd ?
-
 
51
	.size:
-
 
Line -... Line 45...
-
 
45
	.mac		dp ?
Line 52... Line 46...
52
ends
46
 
53
 
47
end virtual
Line 54... Line 48...
54
 
48
 
55
align 4
49
align 4
Line 56... Line 50...
56
iglobal
50
iglobal
57
 
51
 
58
	ETH_BROADCAST	dp  0xffffffffffff
-
 
59
endg
52
	ETH_BROADCAST	dp  0xffffffffffff
60
 
-
 
61
align 4
-
 
62
uglobal
-
 
63
 
-
 
64
	ETH_RUNNING	dd  ?
-
 
65
	ETH_DRV_LIST	rd  MAX_ETH_DEVICES
53
endg
Line 66... Line 54...
66
	ETH_IN_QUEUE	rd  3*ETH_QUEUE_SIZE+3
54
 
67
if QUEUE_BEFORE_SENDING
55
align 4
Line 81... Line 69...
81
;
69
;
82
;-----------------------------------------------------------------
70
;-----------------------------------------------------------------
83
align 4
71
align 4
84
ETH_init:
72
ETH_init:
Line 85... Line -...
85
 
-
 
86
	xor	eax, eax
-
 
87
	mov	edi, ETH_RUNNING
-
 
88
	mov	ecx, (1+MAX_ETH_DEVICES)
-
 
89
	rep	stosd
-
 
90
 
-
 
91
	init_queue ETH_IN_QUEUE
-
 
92
 
-
 
93
if QUEUE_BEFORE_SENDING
-
 
94
	init_queue ETH_OUT_QUEUE
-
 
95
end if
-
 
96
 
-
 
97
	ret
-
 
98
 
-
 
99
 
-
 
100
;-----------------------------------------------------------------
-
 
101
;
-
 
102
; ETH_Add_Device:
-
 
103
;
-
 
104
;  This function is called by ethernet drivers,
-
 
105
;  to register each running ethernet device to the kernel
-
 
106
;
-
 
107
;  IN:  Pointer to device structure in ebx
-
 
108
;  OUT: Device num in eax, -1 on error
-
 
109
;
-
 
110
;-----------------------------------------------------------------
-
 
111
align 4
-
 
112
ETH_add_device:
-
 
113
 
-
 
114
	DEBUGF	1,"ETH_Add_Device: %x ", ebx
-
 
115
 
73
 
116
	mov	eax, [ETH_RUNNING]
-
 
117
	cmp	eax, MAX_ETH_DEVICES
-
 
118
	jge	.error
-
 
119
 
-
 
120
	test	eax, eax
-
 
121
	jnz	.notfirst
-
 
122
	mov	dword [ETH_IN_QUEUE], eax
-
 
123
if QUEUE_BEFORE_SENDING
-
 
124
	mov	dword [ETH_OUT_QUEUE], eax
-
 
125
end if
-
 
126
      .notfirst:
-
 
127
 
-
 
128
	mov	eax, ebx
-
 
129
	mov	ecx, MAX_ETH_DEVICES	  ; We need to check whole list because a device may be removed without re-organizing list
-
 
130
	mov	edi, ETH_DRV_LIST
-
 
131
 
-
 
132
	repne	scasd			  ; See if device is already in the list
-
 
133
	jz	.error
-
 
134
 
-
 
135
	xor	eax, eax
-
 
136
	mov	ecx, MAX_ETH_DEVICES
-
 
137
	mov	edi, ETH_DRV_LIST
-
 
138
 
-
 
139
	repne	scasd			  ; Find empty spot in the list
-
 
Line 140... Line -...
140
	jnz	.error
-
 
141
 
-
 
142
	sub	edi, 4
-
 
143
	mov	[edi], ebx		  ; add device to list
-
 
144
 
-
 
145
	sub	edi, ETH_DRV_LIST	  ; edi = 4*device num       Calculate device number in eax
-
 
146
	mov	eax, edi		  ; edx = 4*device num
-
 
147
	shr	eax, 2
-
 
148
 
-
 
149
	inc	[ETH_RUNNING]		  ; Indicate that one more ethernet device is up and running
-
 
150
 
74
	mov	[ETH_RUNNING], 0
Line 151... Line -...
151
	DEBUGF	1,"- succes: %u\n",eax
-
 
152
	ret
-
 
153
 
-
 
154
       .error:
-
 
155
	or	eax, -1
-
 
156
	DEBUGF	2,"Adding ETH device failed\n"
-
 
157
	ret
-
 
158
 
-
 
159
 
-
 
160
 
-
 
161
 
-
 
162
;-----------------------------------------------------------------
-
 
163
;
-
 
164
; ETH_Remove_Device:
-
 
165
;
-
 
166
;  This function is called by ethernet drivers,
-
 
167
;  to unregister ethernet devices from the kernel
-
 
168
;
-
 
169
;  IN:  Pointer to device structure in ebx
-
 
170
;  OUT: eax: -1 on error
-
 
171
;
-
 
172
;-----------------------------------------------------------------
-
 
173
align 4
-
 
174
ETH_remove_device:
-
 
175
 
-
 
176
	cmp	[ETH_RUNNING], 0
-
 
177
	je	.error
-
 
178
 
-
 
179
	mov	eax, ebx
-
 
180
	mov	ecx, MAX_ETH_DEVICES
-
 
181
	mov	edi, ETH_DRV_LIST
-
 
182
 
-
 
183
	repne	scasd
-
 
184
	jnz	.error
-
 
185
 
-
 
186
	xor	eax, eax
-
 
187
	mov	dword [edi-4], eax
-
 
188
 
-
 
189
	dec	[ETH_RUNNING]
-
 
190
	jnz	.notlast
-
 
191
 
-
 
192
	mov	dword [ETH_IN_QUEUE], ETH_QUEUE_SIZE
-
 
193
if QUEUE_BEFORE_SENDING
-
 
194
	mov	dword [ETH_OUT_QUEUE], ETH_QUEUE_SIZE
-
 
195
end if
-
 
196
 
-
 
197
  .notlast:
-
 
198
	ret
-
 
199
 
-
 
200
  .error:
-
 
201
	or	eax, -1
-
 
Line 202... Line 75...
202
	ret
75
 
203
 
76
	ret
204
 
77
 
205
 
78
 
Line 216... Line 89...
216
;  OUT: /
89
;  OUT: /
217
;
90
;
218
;-----------------------------------------------------------------
91
;-----------------------------------------------------------------
219
align 4
92
align 4
220
ETH_receiver:
93
ETH_receiver:
221
 
-
 
222
;        DEBUGF  1,"ETH_Receiver: "
-
 
223
;        push    ebx
-
 
224
;        mov     esi, esp
-
 
225
;        add_to_queue ETH_IN_QUEUE, ETH_QUEUE_SIZE, eth_queue_entry.size, .fail
-
 
226
;        DEBUGF  1,"Queued packet successfully\n"
-
 
227
;        add     esp, 4*3
-
 
228
;
-
 
229
;        ret
-
 
230
;
-
 
231
;  .fail:
-
 
232
;        DEBUGF  1,"ETH_IN_QUEUE is full!\n"
-
 
233
;        add     esp, 4
-
 
234
;        call    kernel_free
-
 
235
;        add     esp, 4
-
 
236
;
-
 
237
;        ret
-
 
238
;
-
 
239
;
-
 
240
;
-
 
241
;;-----------------------------------------------------------------
-
 
242
;;
-
 
243
;; ETH_Handler:
-
 
244
;;
-
 
245
;;  Handles all queued eth packets (called from kernel's main_loop)
-
 
246
;;
-
 
247
;;  IN:  /
-
 
248
;;  OUT: /
-
 
249
;;
-
 
250
;;-----------------------------------------------------------------
-
 
251
;align 4
-
 
252
;ETH_handler:
-
 
253
;
-
 
254
;        get_from_queue ETH_IN_QUEUE, ETH_QUEUE_SIZE, eth_queue_entry.size, .gohome
-
 
255
;
-
 
256
;        push    ETH_handler
-
 
257
;
-
 
258
;        lodsd
-
 
259
;        mov     ebx, eax
-
 
260
;        lodsd
-
 
261
;        mov     ecx, eax
-
 
262
;        lodsd
-
 
263
;        xchg    eax, ecx
-
 
264
;        push    ecx
-
 
265
;        push    eax
-
 
266
 
-
 
267
 
-
 
268
;-----------------------------
-
 
269
	mov	eax, [esp]
94
	mov	eax, [esp]
270
	mov	ecx, [esp+4]
95
	mov	ecx, [esp+4]
271
;-----------------------------
-
 
Line 272... Line 96...
272
 
96
 
273
	DEBUGF	1,"ETH_Handler - size: %u\n", ecx
97
	DEBUGF	1,"ETH_Handler - size: %u\n", ecx
274
	cmp	ecx, 60    ; check packet length
98
	cmp	ecx, 60    ; check packet length
275
	jl	.dump
99
	jl	.dump
Line 288... Line 112...
288
 
112
 
289
  .dump:
113
  .dump:
290
	DEBUGF	2,"ETH_Handler - dumping\n"
114
	DEBUGF	2,"ETH_Handler - dumping\n"
291
	call	kernel_free
115
	call	kernel_free
292
	add	esp, 4
-
 
293
 
-
 
294
  .gohome:
-
 
295
	ret				; return to get more from queue / to caller
-
 
296
 
-
 
297
 
-
 
298
 
-
 
299
 
-
 
300
align 4
-
 
301
ETH_handler:
-
 
302
ret
-
 
303
 
-
 
304
 
-
 
305
;-----------------------------------------------------------------
-
 
306
;
-
 
307
; ETH_sender:
-
 
308
;
-
 
309
;  This function sends an ethernet packet to the correct driver.
-
 
310
;
-
 
311
;  IN:  Pointer to buffer in [esp]
-
 
312
;       size of buffer in [esp+4]
-
 
313
;       pointer to device struct in ebx
-
 
314
;  OUT: /
-
 
315
;
-
 
316
;-----------------------------------------------------------------
-
 
317
align 4
-
 
318
ETH_sender:
-
 
319
if QUEUE_BEFORE_SENDING
-
 
320
	DEBUGF	1,"ETH_Sender: queuing for device: %x, %u bytes\n", [esp], [esp + 4]
-
 
321
 
-
 
322
	push	ebx
-
 
323
	mov	esi, esp
-
 
324
	add_to_queue ETH_OUT_QUEUE, ETH_QUEUE_SIZE, eth_queue_entry.size, .fail
-
 
325
	DEBUGF	1,"Queued packet successfully\n"
-
 
326
	add	esp, 3*4
-
 
327
 
-
 
328
	ret
-
 
329
 
-
 
330
  .fail:
-
 
331
	DEBUGF	1,"ETH_OUT_QUEUE is full!\n"
-
 
332
	add	esp, 4
-
 
333
	call	kernel_free
-
 
334
	add	esp, 4
-
 
335
 
116
	add	esp, 4
Line 336... Line -...
336
	ret
-
 
337
 
-
 
338
 
-
 
339
 
-
 
340
;-----------------------------------------------------------------
-
 
341
;
-
 
342
; ETH_send_queued:
-
 
343
;
-
 
344
;  IN:  /
-
 
345
;  OUT: /
-
 
346
;
-
 
347
;-----------------------------------------------------------------
-
 
348
align 4
-
 
349
ETH_send_queued:
-
 
350
 
-
 
351
	get_from_queue ETH_OUT_QUEUE, ETH_QUEUE_SIZE, eth_queue_entry.size, .gohome
-
 
352
 
-
 
353
	push	ETH_send_queued 		; this will cause the procedure to check for more packets
-
 
354
						; when a single packet is handled
-
 
355
 
-
 
356
	mov	ebx, [esi]
-
 
357
	pushd	[esi + 8]
-
 
358
	pushd	[esi + 4]
-
 
359
 
-
 
360
	DEBUGF	1,"dequeued packet for device %x\n", ebx
-
 
361
end if
-
 
362
	call	[ebx+ETH_DEVICE.transmit]	; we will return to get_from_queue macro after transmitting packet
-
 
363
	call	kernel_free
-
 
364
	add	esp, 4 ; pop (balance stack)
-
 
365
 
-
 
366
  .gohome:
-
 
367
	ret
-
 
368
 
-
 
369
 
-
 
370
;-----------------------------------------------------------------
-
 
371
;
-
 
372
; ETH_struc2dev
-
 
373
;
-
 
374
; IN: pointer to device struct in ebx
-
 
375
;
-
 
376
; OUT: edi is -1 on error, device number otherwise
-
 
377
;
-
 
378
;-----------------------------------------------------------------
-
 
379
align 4
-
 
380
ETH_struc2dev:
-
 
381
	push	ecx
-
 
382
 
-
 
383
	mov	ecx, MAX_ETH_DEVICES
-
 
384
	mov	edi, ETH_DRV_LIST
-
 
385
 
-
 
386
 
-
 
387
  .loop:
-
 
388
	cmp	ebx, [edi]
-
 
389
	jz	.found
-
 
390
	add	edi, 4
-
 
391
	dec	ecx
-
 
392
	jnz	.loop
-
 
393
 
-
 
394
	or	edi, -1
-
 
395
 
-
 
396
	pop	ecx
-
 
397
	ret
-
 
398
 
-
 
399
  .found:
-
 
400
	sub	edi, ETH_DRV_LIST
-
 
401
	shr	edi, 2
-
 
402
 
-
 
403
	pop	ecx
-
 
404
	ret
-
 
405
 
117
	ret
406
 
118
 
407
;-----------------------------------------------------------------
119
;-----------------------------------------------------------------
408
;
120
;
409
; ETH_create_packet
121
; ETH_create_packet
410
;
122
;
411
; IN: pointer to source mac in eax
123
; IN: eax = pointer to source mac
412
;     pointer to destination mac in ebx
124
;     ebx = pointer to destination mac
413
;     packet size in ecx
125
;     ecx = packet size
414
;     device number in edx
126
;     edx = device number
415
;     protocol in di
127
;      di = protocol
416
;
128
;
417
; OUT: edi is -1 on error, pointer to buffer otherwise
129
; OUT: edi = 0 on error, pointer to buffer otherwise
418
;      eax points to buffer start
130
;      eax = buffer start
419
;      ebx is pointer to device structure
131
;      ebx = to device structure
420
;      ecx is unchanged (packet size of embedded data)
-
 
421
;      edx is size of complete buffer
132
;      ecx = unchanged (packet size of embedded data)
422
;      esi points to procedure wich needs to be called to send packet
133
;      edx = size of complete buffer
423
;
134
;
424
;-----------------------------------------------------------------
135
;-----------------------------------------------------------------
Line 425... Line 136...
425
align 4
136
align 4
Line 426... Line 137...
426
ETH_create_packet:
137
ETH_create_packet:
427
 
138
 
Line 428... Line 139...
428
	DEBUGF	1,"Creating Ethernet Packet (size=%u): \n", ecx
139
	DEBUGF	1,"Creating Ethernet Packet (size=%u): \n", ecx
Line 429... Line 140...
429
 
140
 
430
	cmp	ecx, 1500
141
	cmp	ecx, 1500 ;;;
431
	jg	.exit
142
	jg	.exit
432
 
143
 
-
 
144
	push	ecx di eax ebx edx
433
	push	ecx di eax ebx edx
145
 
434
 
146
	add	ecx, ETH_FRAME.Data
Line 435... Line 147...
435
	add	ecx, ETH_FRAME.Data
147
	push	ecx
436
	push	ecx
148
	push	ecx
Line 437... Line -...
437
	push	ecx
-
 
438
	call	kernel_alloc
149
	call	kernel_alloc
439
	test	eax, eax
150
	mov	edi, eax
440
	jz	.pop_exit
151
	test	edi, edi
441
 
152
	jz	.pop_exit
442
	pop	ecx
153
 
Line 453... Line 164...
453
	stosw
164
	stosw
Line 454... Line 165...
454
 
165
 
455
	lea	eax, [edi - ETH_FRAME.Data]  ; Set eax to buffer start
166
	lea	eax, [edi - ETH_FRAME.Data]  ; Set eax to buffer start
456
	mov	edx, ecx		     ; Set ebx to complete buffer size
167
	mov	edx, ecx		     ; Set ebx to complete buffer size
457
	pop	ecx
-
 
Line 458... Line 168...
458
	mov	esi, ETH_sender
168
	pop	ecx
459
 
169
 
Line 460... Line 170...
460
	xor	ebx, ebx			;;;; TODO: Fixme
170
	xor	ebx, ebx			;;;; TODO: Fixme
461
	mov	ebx, [ETH_DRV_LIST + ebx]
171
	mov	ebx, [NET_DRV_LIST + ebx]
462
 
172
 
463
	cmp	edx, 46 + ETH_FRAME.Data    ; If data size is less then 46, add padding bytes
173
	cmp	edx, 46 + ETH_FRAME.Data    ; If data size is less then 46, add padding bytes
Line 469... Line 179...
469
	ret
179
	ret
Line 470... Line 180...
470
 
180
 
471
  .pop_exit:
181
  .pop_exit:
472
	DEBUGF	2,"Out of ram space!!\n"
182
	DEBUGF	2,"Out of ram space!!\n"
473
	add	esp, 18
183
	add	esp, 18
474
	or	edi,-1
184
	and	edi, 0
Line 475... Line 185...
475
	ret
185
	ret
476
 
186
 
477
  .exit:
187
  .exit:
478
	DEBUGF	2,"Packet too large!\n"
188
	DEBUGF	2,"Packet too large!\n"
Line 479... Line 189...
479
	or	edi, -1
189
	and	edi, 0
Line 495... Line 205...
495
;
205
;
496
;-----------------------------------------------------------------
206
;-----------------------------------------------------------------
497
align 4
207
align 4
498
ETH_API:
208
ETH_API:
Line -... Line 209...
-
 
209
 
-
 
210
	cmp	bh, MAX_NET_DEVICES
499
 
211
	jg	.error
500
	movzx	eax, bh
212
	movzx	eax, bh
Line -... Line 213...
-
 
213
	shl	eax, 2
-
 
214
 
-
 
215
	cmp	bl, 7
-
 
216
	jz	.out_queue
-
 
217
	cmp	bl, 6
-
 
218
	jz	.in_queue
-
 
219
 
-
 
220
	mov	eax, dword [NET_DRV_LIST + eax]
-
 
221
	cmp	[eax + NET_DEVICE.type], NET_TYPE_ETH
501
	shl	eax, 2
222
	jne	.error
502
 
223
 
503
	test	bl, bl
224
	test	bl, bl
504
	jz	.packets_tx	; 0
225
	jz	.packets_tx	; 0
505
	dec	bl
226
	dec	bl
Line 510... Line 231...
510
	jz	.bytes_rx	; 3
231
	jz	.bytes_rx	; 3
511
	dec	bl
232
	dec	bl
512
	jz	.read_mac	; 4
233
	jz	.read_mac	; 4
513
	dec	bl
234
	dec	bl
514
	jz	.write_mac	; 5
235
	jz	.write_mac	; 5
515
	dec	bl
-
 
516
	jz	.in_queue	; 6
-
 
517
	dec	bl
-
 
518
	jz	.out_queue	; 7
-
 
Line 519... Line 236...
519
 
236
 
-
 
237
  .error:
520
.error:
238
	DEBUGF	2,"Device is not ethernet type\n"
521
	mov	eax, -1
239
	or	eax, -1
Line 522... Line 240...
522
	ret
240
	ret
523
 
-
 
524
.packets_tx:
-
 
525
	add	eax, ETH_DRV_LIST
241
 
Line 526... Line 242...
526
	mov	eax, dword [eax]
242
.packets_tx:
Line 527... Line 243...
527
	mov	eax, dword [eax + ETH_DEVICE.packets_tx]
243
	mov	eax, dword [eax + ETH_DEVICE.packets_tx]
528
 
-
 
529
	ret
-
 
530
 
244
 
531
.packets_rx:
245
	ret
Line 532... Line 246...
532
	add	eax, ETH_DRV_LIST
246
 
533
	mov	eax, dword [eax]
-
 
534
	mov	eax, dword [eax + ETH_DEVICE.packets_rx]
-
 
535
	ret
247
.packets_rx:
536
 
248
	mov	eax, dword [eax + ETH_DEVICE.packets_rx]
537
.bytes_tx:
249
	ret
538
	add	eax, ETH_DRV_LIST
250
 
Line 539... Line 251...
539
	mov	eax, dword [eax]
251
.bytes_tx:
540
	mov	ebx, dword [eax + ETH_DEVICE.bytes_tx + 4]
-
 
541
	mov	eax, dword [eax + ETH_DEVICE.bytes_tx]
-
 
542
	mov	[esp+20+4], ebx 			; TODO: fix this ugly code
252
	mov	ebx, dword [eax + ETH_DEVICE.bytes_tx + 4]
543
	ret
253
	mov	eax, dword [eax + ETH_DEVICE.bytes_tx]
544
 
254
	mov	[esp+20+4], ebx 			; TODO: fix this ugly code
545
.bytes_rx:
255
	ret
Line 546... Line 256...
546
	add	eax, ETH_DRV_LIST
256
 
547
	mov	eax, dword [eax]
-
 
548
	mov	ebx, dword [eax + ETH_DEVICE.bytes_rx + 4]
-
 
549
	mov	eax, dword [eax + ETH_DEVICE.bytes_rx]
-
 
550
	mov	[esp+20+4], ebx 			; TODO: fix this ugly code
-
 
551
	ret
-
 
552
 
257
.bytes_rx:
553
 
258
	mov	ebx, dword [eax + ETH_DEVICE.bytes_rx + 4]
554
.read_mac:
259
	mov	eax, dword [eax + ETH_DEVICE.bytes_rx]
555
	add	eax, ETH_DRV_LIST
260
	mov	[esp+20+4], ebx 			; TODO: fix this ugly code
Line 556... Line 261...
556
	mov	eax, [eax]
261
	ret
557
;        push    eax
262
 
558
;        call    dword [eax + ETH_DEVICE.get_MAC]
263
 
559
;        pop     eax
-
 
560
	movzx	ebx, word [eax + ETH_DEVICE.mac]
-
 
561
	mov	eax, dword [eax + ETH_DEVICE.mac + 2]
264
.read_mac:
562
	mov	[esp+20+4], ebx 			; TODO: fix this ugly code
265
	movzx	ebx, word [eax + ETH_DEVICE.mac]
563
	ret
266
	mov	eax, dword [eax + ETH_DEVICE.mac + 2]
Line 564... Line 267...
564
 
267
	mov	[esp+20+4], ebx 			; TODO: fix this ugly code
-
 
268
	ret
565
.write_mac:
269
 
566
	push	ecx
270
.write_mac:
-
 
271
	push	ecx
-
 
272
	push	dx
-
 
273
	mov	eax, [eax + ETH_DEVICE.set_MAC]
567
	push	dx
274
	call	eax
Line 568... Line 275...
568
	add	eax, ETH_DRV_LIST
275
	ret
569
	mov	eax, [eax]
276
 
570
	mov	eax, dword [eax + ETH_DEVICE.set_MAC]
277
.in_queue:
571
	call	eax
278
   if ETH_QUEUE
572
	ret
279
	add	eax, ETH_IN_QUEUE
573
 
280
	mov	eax, [eax + queue.size]
574
.in_queue:
281
   else
575
	add	eax, ETH_IN_QUEUE
282
	or	eax, -1
576
	mov	eax, [eax + queue.size]
283
   end if