Subversion Repositories Kolibri OS

Rev

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

Rev 1514 Rev 1519
Line 1... Line 1...
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                                 ;;
2
;;                                                                 ;;
3
;; Copyright (C) KolibriOS team 2004-2008. 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
;; DEC 21x4x driver for KolibriOS                                  ;;
6
;;  DEC 21x4x driver for KolibriOS                                 ;;
7
;;                                                                 ;;
7
;;                                                                 ;;
8
;;  Based on dec21140.Asm from Solar OS by                         ;;
8
;;  Based on dec21140.Asm from Solar OS by                         ;;
9
;;     Eugen Brasoveanu,                                           ;;
9
;;     Eugen Brasoveanu,                                           ;;
10
;;       Ontanu Bogdan Valentin                                    ;;
10
;;       Ontanu Bogdan Valentin                                    ;;
11
;;                                                                 ;;
11
;;                                                                 ;;
12
;;    Written by hidnplayr@kolibrios.org                           ;;
12
;;  Written by hidnplayr@kolibrios.org                             ;;
13
;;                                                                 ;;
13
;;                                                                 ;;
14
;;     0.1 - 5 june 2010                                           ;;
-
 
15
;;                                                                 ;;
-
 
16
;;          GNU GENERAL PUBLIC LICENSE                             ;;
14
;;          GNU GENERAL PUBLIC LICENSE                             ;;
17
;;             Version 2, June 1991                                ;;
15
;;             Version 2, June 1991                                ;;
18
;;                                                                 ;;
16
;;                                                                 ;;
19
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
17
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 20... Line 18...
20
 
18
 
Line 21... Line 19...
21
format MS COFF
19
format MS COFF
-
 
20
 
-
 
21
	API_VERSION		equ 0x01000100
-
 
22
	DRIVER_VERSION		equ 5
Line 22... Line 23...
22
 
23
 
23
	API_VERSION		equ 0x01000100
24
	MAX_DEVICES		equ 16
24
 
25
 
Line 25... Line 26...
25
	DEBUG			equ 1
26
	DEBUG			equ 1
26
	__DEBUG__		equ 1
27
	__DEBUG__		equ 1
27
	__DEBUG_LEVEL__ 	equ 1
28
	__DEBUG_LEVEL__ 	equ 1
28
 
29
 
Line 29... Line -...
29
include 'proc32.inc'
-
 
30
include 'imports.inc'
-
 
31
include 'fdo.inc'
-
 
32
include 'netdrv.inc'
-
 
33
 
30
include 'proc32.inc'
34
OS_BASE 	equ 0
31
include 'imports.inc'
35
new_app_base	equ 0x60400000
32
include 'fdo.inc'
Line 36... Line -...
36
PROC_BASE	equ OS_BASE+0x0080000
-
 
37
 
33
include 'netdrv.inc'
Line 38... Line 34...
38
public START
34
 
Line 39... Line 35...
39
public service_proc
35
public START
Line 40... Line -...
40
public version
-
 
41
 
36
public service_proc
42
 
37
public version
43
virtual at ebx
38
 
44
 
39
virtual at ebx
45
	device:
40
 
Line 61... Line 56...
61
 
56
 
Line 62... Line 57...
62
      .size = $ - device
57
	.size = $ - device
Line 63... Line -...
63
 
-
 
64
end virtual
-
 
65
 
-
 
66
 
-
 
67
 
58
 
68
MAX_DEVICES	equ 16
59
end virtual
69
 
60
 
70
;-------------------------------------------
61
;-------------------------------------------
Line 379... Line 370...
379
	cmp	byte [eax], 1				; 1 means device number and bus number (pci) are given
370
	cmp	byte [eax], 1				; 1 means device number and bus number (pci) are given
380
	jne	.fail					; other types arent supported for this card yet
371
	jne	.fail					; other types arent supported for this card yet
Line 381... Line 372...
381
 
372
 
Line 382... Line 373...
382
; check if the device is already listed
373
; check if the device is already listed
383
 
374
 
384
	mov	esi, DEVICE_LIST
375
	mov	esi, device_list
385
	mov	ecx, [devices]
376
	mov	ecx, [devices]
Line 386... Line 377...
386
	test	ecx, ecx
377
	test	ecx, ecx
Line 440... Line 431...
440
	allocate_and_clear [device.tx_p_des], TX_DES_COUNT*(DES.size+TX_BUFF_SIZE), .err
431
	allocate_and_clear [device.tx_p_des], TX_DES_COUNT*(DES.size+TX_BUFF_SIZE), .err
Line 441... Line 432...
441
 
432
 
442
; Ok, the eth_device structure is ready, let's probe the device
433
; Ok, the eth_device structure is ready, let's probe the device
443
; Because initialization fires IRQ, IRQ handler must be aware of this device
434
; Because initialization fires IRQ, IRQ handler must be aware of this device
444
	mov	eax, [devices]						; Add the device structure to our device list
435
	mov	eax, [devices]						; Add the device structure to our device list
445
	mov	[DEVICE_LIST+4*eax], ebx				; (IRQ handler uses this list to find device)
436
	mov	[device_list+4*eax], ebx				; (IRQ handler uses this list to find device)
Line 446... Line 437...
446
	inc	[devices]						;
437
	inc	[devices]						;
447
 
438
 
448
	call	probe							; this function will output in eax
439
	call	probe							; this function will output in eax
Line 769... Line 760...
769
 
760
 
770
	lea	edi, [device.bytes_tx]
761
	lea	edi, [device.bytes_tx]
771
	mov	ecx, 6
762
	mov	ecx, 6
Line -... Line 763...
-
 
763
	rep	stosd
-
 
764
 
-
 
765
; Set the mtu, kernel will be able to send now
772
	rep	stosd
766
	mov	[device.mtu], 1514
Line 773... Line 767...
773
 
767
 
Line 998... Line 992...
998
  .end:
992
  .end:
999
	status
993
	status
Line 1000... Line 994...
1000
 
994
 
1001
	DEBUGF	1,"transmit ok\n"
995
	DEBUGF	1,"transmit ok\n"
-
 
996
	xor	eax, eax
-
 
997
	call	Kernelfree
1002
	xor	eax, eax
998
	add	esp, 4
Line 1003... Line 999...
1003
	ret
999
	ret
1004
 
1000
 
1005
  .fail:
1001
  .fail:
-
 
1002
	DEBUGF	1,"transmit failed\n"
-
 
1003
	or	eax, -1
1006
	DEBUGF	1,"transmit failed\n"
1004
	call	Kernelfree
Line 1007... Line -...
1007
	or	eax, -1
-
 
1008
	ret
1005
	add	esp, 4
1009
 
1006
	ret
1010
 
1007
 
1011
 
1008
 
1012
;;;;;;;;;;;;;;;;;;;;;;;
1009
;;;;;;;;;;;;;;;;;;;;;;;
Line 1023... Line 1020...
1023
; find pointer of device wich made IRQ occur
1020
; find pointer of device wich made IRQ occur
Line 1024... Line 1021...
1024
 
1021
 
1025
	mov	ecx, [devices]
1022
	mov	ecx, [devices]
1026
	test	ecx, ecx
1023
	test	ecx, ecx
1027
	jz	.fail
1024
	jz	.fail
1028
	mov	esi, DEVICE_LIST
1025
	mov	esi, device_list
1029
  .nextdevice:
1026
  .nextdevice:
Line 1030... Line 1027...
1030
	mov	ebx, dword [esi]
1027
	mov	ebx, dword [esi]
1031
 
1028
 
Line 1699... Line 1696...
1699
 
1696
 
Line 1700... Line 1697...
1700
	ret
1697
	ret
1701
 
-
 
1702
 
1698
 
Line 1703... Line 1699...
1703
; End of code
1699
 
1704
 
1700
; End of code
1705
align 4 					; Place all initialised data here
1701
align 4 					; Place all initialised data here
Line 1706... Line 1702...
1706
 
1702
 
Line 1707... Line 1703...
1707
devices       dd 0
1703
devices       dd 0
Line 1708... Line 1704...
1708
version       dd (5 shl 16) or (API_VERSION and 0xFFFF)
1704
version       dd (DRIVER_VERSION shl 16) or (API_VERSION and 0xFFFF)