Subversion Repositories Kolibri OS

Rev

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

Rev 2220 Rev 2313
Line 1... Line 1...
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                                 ;;
2
;;                                                                 ;;
3
;; Copyright (C) KolibriOS team 2004-2010. All rights reserved.    ;;
3
;; Copyright (C) KolibriOS team 2004-2011. 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
;; i8255x (Intel eepro 100) driver for KolibriOS                   ;;
6
;; i8255x (Intel eepro 100) driver for KolibriOS                   ;;
7
;;                                                                 ;;
7
;;                                                                 ;;
8
;;    Written by hidnplayr@kolibrios.org                           ;;
8
;;    Written by hidnplayr@kolibrios.org                           ;;
Line 18... Line 18...
18
 
18
 
Line 19... Line 19...
19
 
19
 
20
format MS COFF
20
format MS COFF
Line 21... Line 21...
21
 
21
 
Line 22... Line 22...
22
	API_VERSION		equ 0x01000100
22
	API_VERSION		equ 0x01000100
23
	DRIVER_VERSION		equ 1
23
	DRIVER_VERSION		equ 5
Line 51... Line 51...
51
	.rx_buffer	dd ?
51
	.rx_buffer	dd ?
52
	.tx_buffer	dd ?
52
	.tx_buffer	dd ?
Line 53... Line 53...
53
 
53
 
Line -... Line 54...
-
 
54
	.ee_bus_width	dd ?
-
 
55
 
54
	.ee_bus_width	dd ?
56
	rb 5+8 ;;;; align
55
 
57
 
56
	rxfd:
58
	rxfd:
57
	.status 	dw ?
59
	.status 	dw ?
58
	.command	dw ?
60
	.command	dw ?
59
	.link		dd ?
61
	.link		dd ?
60
	.rx_buf_addr	dd ?
62
	.rx_buf_addr	dd ?
61
	.count		dw ?
63
	.count		dw ?
Line -... Line 64...
-
 
64
	.size		dw ?
-
 
65
	.packet 	dd ?
62
	.size		dw ?
66
 
63
	.packet 	dd ?
67
	rb 12 ;;;;
64
 
68
 
65
	txfd:
69
	txfd:
66
	.status 	dw ?
70
	.status 	dw ?
Line 176... Line 180...
176
	cmp [state], 1
180
	cmp [state], 1
177
	jne .exit
181
	jne .exit
Line 178... Line 182...
178
 
182
 
Line 179... Line 183...
179
  .entry:
183
  .entry:
180
 
184
 
181
	DEBUGF 1,"Loading I8255x driver\n"
185
	DEBUGF 1,"Loading i8255x driver\n"
Line 182... Line 186...
182
	stdcall RegService, my_service, service_proc
186
	stdcall RegService, my_service, service_proc
183
	ret
187
	ret
Line 206... Line 210...
206
;------------------------------------------------------
210
;------------------------------------------------------
Line 207... Line 211...
207
 
211
 
208
	cmp	eax, 0 ;SRV_GETVERSION
212
	cmp	eax, 0 ;SRV_GETVERSION
Line 209... Line 213...
209
	jne	@F
213
	jne	@F
210
 
214
 
211
	cmp	[edx+IOCTL.out_size], 4
215
	cmp	[IOCTL.out_size], 4
212
	jl	.fail
216
	jl	.fail
Line 213... Line 217...
213
	mov	eax, [edx+IOCTL.output]
217
	mov	eax, [IOCTL.output]
214
	mov	[eax], dword API_VERSION
218
	mov	[eax], dword API_VERSION
Line 215... Line 219...
215
 
219
 
216
	xor	eax, eax
220
	xor	eax, eax
217
	ret
221
	ret
218
 
222
 
Line 219... Line 223...
219
;------------------------------------------------------
223
;------------------------------------------------------
220
  @@:
224
  @@:
Line 221... Line 225...
221
	cmp	eax, 1 ;SRV_HOOK
225
	cmp	eax, 1 ;SRV_HOOK
222
	jne	.fail
226
	jne	.fail
223
 
227
 
Line 224... Line 228...
224
	cmp	[edx + IOCTL.inp_size], 3		; Data input must be at least 3 bytes
228
	cmp	[IOCTL.inp_size], 3		  ; Data input must be at least 3 bytes
Line 345... Line 349...
345
unload:
349
unload:
346
	; TODO: (in this particular order)
350
	; TODO: (in this particular order)
347
	;
351
	;
348
	; - Stop the device
352
	; - Stop the device
349
	; - Detach int handler
353
	; - Detach int handler
350
	; - Remove device from local list (RTL8139_LIST)
354
	; - Remove device from local list (device_list)
351
	; - call unregister function in kernel
355
	; - call unregister function in kernel
352
	; - Remove all allocated structures and buffers the card used
356
	; - Remove all allocated structures and buffers the card used
Line 353... Line 357...
353
 
357
 
Line 374... Line 378...
374
 
378
 
375
	movzx	ecx, [device.pci_bus]
379
	movzx	ecx, [device.pci_bus]
376
	movzx	edx, [device.pci_dev]
380
	movzx	edx, [device.pci_dev]
Line 377... Line 381...
377
	stdcall PciRead32, ecx ,edx ,0				      ; get device/vendor id
381
	stdcall PciRead32, ecx ,edx ,0				      ; get device/vendor id
Line 378... Line 382...
378
 
382
 
379
	DEBUGF	1,"Vendor id: 0x%x\n", ax
383
	DEBUGF	1,"Vendor_id=0x%x\n", ax
380
 
384
 
Line 381... Line 385...
381
	cmp	ax , 0x8086
385
	cmp	ax, 0x8086
Line 382... Line 386...
382
	jne	.notfound
386
	jne	.notfound
383
	shr	eax, 16
387
	shr	eax, 16
384
 
388
 
385
	DEBUGF	1,"Device id: 0x%x\n", ax
389
	DEBUGF	1,"Device_id=0x%x\n", ax
386
 
390
 
Line 387... Line 391...
387
	mov	ecx, DEVICE_IDs
391
	mov	ecx, DEVICE_IDs
388
	mov	esi, device_id_list
392
	mov	edi, device_id_list
389
	repne	scasw
393
	repne	scasw
390
	jne	.notfound
394
	jne	.notfound
Line 391... Line 395...
391
	jmp	.found
395
	jmp	.found
Line 572... Line 576...
572
 
576
 
573
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
577
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
574
;;                                         ;;
578
;;                                         ;;
575
;; Transmit                                ;;
579
;; Transmit                                ;;
576
;;                                         ;;
580
;;                                         ;;
577
;; In: buffer pointer in [esp]             ;;
581
;; In: buffer pointer in [esp+4]           ;;
578
;;     size of buffer in [esp+4]           ;;
582
;;     size of buffer in [esp+8]           ;;
579
;;     pointer to device structure in ebx  ;;
583
;;     pointer to device structure in ebx  ;;
580
;;                                         ;;
584
;;                                         ;;
Line 581... Line 585...
581
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
585
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
582
 
586
 
Line 583... Line 587...
583
align 4
587
align 4
584
transmit:
588
transmit:
585
 
589
 
586
	DEBUGF	1,"Transmitting packet, buffer:%x, size:%u\n",[esp],[esp+4]
590
	DEBUGF	1,"Transmitting packet, buffer:%x, size:%u\n",[esp+4],[esp+8]
587
	mov	eax, [esp]
591
	mov	eax, [esp+4]
588
	DEBUGF	1,"To: %x-%x-%x-%x-%x-%x From: %x-%x-%x-%x-%x-%x Type:%x%x\n",\
592
	DEBUGF	1,"To: %x-%x-%x-%x-%x-%x From: %x-%x-%x-%x-%x-%x Type:%x%x\n",\
Line 589... Line 593...
589
	[eax+00]:2,[eax+01]:2,[eax+02]:2,[eax+03]:2,[eax+04]:2,[eax+05]:2,\
593
	[eax+00]:2,[eax+01]:2,[eax+02]:2,[eax+03]:2,[eax+04]:2,[eax+05]:2,\
590
	[eax+06]:2,[eax+07]:2,[eax+08]:2,[eax+09]:2,[eax+10]:2,[eax+11]:2,\
594
	[eax+06]:2,[eax+07]:2,[eax+08]:2,[eax+09]:2,[eax+10]:2,[eax+11]:2,\
591
	[eax+13]:2,[eax+12]:2
595
	[eax+13]:2,[eax+12]:2
592
 
596
 
Line 593... Line 597...
593
	cmp	dword [esp+4], 1500
597
	cmp	dword [esp+8], 1500
594
	jg	.finish 			; packet is too long
598
	jg	.finish 			; packet is too long
595
	cmp	dword [esp+4], 60
599
	cmp	dword [esp+8], 60
Line 608... Line 612...
608
	mov	[txfd.count], 0x02208000
612
	mov	[txfd.count], 0x02208000
609
	lea	eax, [txfd.tx_buf_addr0]
613
	lea	eax, [txfd.tx_buf_addr0]
610
	GetRealAddr
614
	GetRealAddr
611
	mov	[txfd.tx_desc_addr], eax
615
	mov	[txfd.tx_desc_addr], eax
Line 612... Line -...
612
 
-
 
613
	mov	eax, [esp]
-
 
614
	mov	[txfd.tx_buf_addr0], eax
616
 
-
 
617
	mov	eax, [esp+4]
-
 
618
	mov	[txfd.tx_buf_addr0], eax
615
	mov	eax, [esp+4]
619
	mov	eax, [esp+8]
Line 616... Line 620...
616
	mov	[txfd.tx_buf_size0], eax
620
	mov	[txfd.tx_buf_size0], eax
617
 
621
 
618
	; Copy the buffer address and size in
622
	; Copy the buffer address and size in
Line 628... Line 632...
628
	set_io	reg_scb_cmd
632
	set_io	reg_scb_cmd
629
	out	dx, ax
633
	out	dx, ax
Line 630... Line 634...
630
 
634
 
Line 631... Line -...
631
	call	cmd_wait
-
 
632
 
635
	call	cmd_wait
Line 633... Line 636...
633
	set_io	0
636
 
634
	in	ax, dx
637
	in	ax, dx
635
 
638
 
Line 636... Line -...
636
  .I8t_001:
-
 
637
	cmp	[txfd.status], 0
639
  .I8t_001:
Line 638... Line 640...
638
	je	.I8t_001
640
	cmp	[txfd.status], 0
639
 
641
	je	.I8t_001
Line 640... Line 642...
640
	set_io	0
642
 
641
	in	ax, dx
643
	in	ax, dx
Line 896... Line 898...
896
	mov	esi, EE_READ shl 28
898
	mov	esi, EE_READ shl 28
897
	xor	ecx, ecx
899
	xor	ecx, ecx
Line 898... Line 900...
898
 
900
 
899
  .loop:
901
  .loop:
900
	mov	eax, EE_CS
-
 
901
	shl	esi
-
 
902
	jnc	@f
-
 
903
	or	eax, EE_DI
-
 
904
       @@:
902
	mov	eax, EE_CS
905
	out	dx , eax
903
	out	dx , eax
Line 906... Line 904...
906
	delay
904
	delay
907
 
905
 
Line 913... Line 911...
913
 
911
 
914
	in	eax, dx
912
	in	eax, dx
915
	test	eax, EE_DO
913
	test	eax, EE_DO
Line 916... Line -...
916
	jnz	.loop
-
 
917
 
-
 
918
	sub	ecx, 3
-
 
919
 
-
 
920
	DEBUGF	1,"bus width=%u\n", ecx
914
	jnz	.loop
Line 921... Line 915...
921
 
915
 
922
	mov	[device.ee_bus_width], ecx
916
	mov	[device.ee_bus_width], ecx
Line 923... Line 917...
923
 
917
 
924
;------------------------------
918
;------------------------------
925
; Now read the data from eeprom
919
; Now read the data from eeprom
926
 
920
 
927
	mov	ecx, 16
921
	mov	ecx, 16
Line 928... Line 922...
928
  .loop2:
922
  .loop2:
929
	mov	eax, EE_CS
923
	mov	eax, EE_CS + EE_SK
930
	out	dx , eax
924
	out	dx , eax
931
	delay
925
	delay
Line 932... Line 926...
932
 
926