Subversion Repositories Kolibri OS

Rev

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

Rev 1519 Rev 1541
Line 306... Line 306...
306
; This device doesnt have its own eth_device structure yet, lets create one
306
; This device doesnt have its own eth_device structure yet, lets create one
307
  .firstdevice:
307
  .firstdevice:
308
	cmp	[devices], MAX_DEVICES			; First check if the driver can handle one more card
308
	cmp	[devices], MAX_DEVICES			; First check if the driver can handle one more card
309
	jge	.fail
309
	jge	.fail
Line 310... Line -...
310
 
-
 
311
	push	edx
310
 
312
	stdcall KernelAlloc, device.size		; Allocate the buffer for eth_device structure
-
 
313
	pop	edx
-
 
314
	test	eax, eax
-
 
315
	jz	.fail
-
 
Line 316... Line 311...
316
	mov	ebx, eax				; ebx is always used as a pointer to the structure (in driver, but also in kernel code)
311
	allocate_and_clear ebx, device.size, .fail	; Allocate the buffer for device structure
Line 317... Line 312...
317
 
312
 
318
; Fill in the direct call addresses into the struct
313
; Fill in the direct call addresses into the struct
Line 617... Line 612...
617
 
612
 
Line 618... Line 613...
618
; set RxBuffer address, init RX buffer offset
613
; set RxBuffer address, init RX buffer offset
619
 
614
 
620
	mov	eax, [device.rx_buffer]
615
	mov	eax, [device.rx_buffer]
621
	call	GetPgAddr
616
	call	GetPgAddr
622
	set_io	0
617
;        set_io  0
Line -... Line 618...
-
 
618
	set_io	REG_RBSTART
-
 
619
	out	dx , eax
-
 
620
 
-
 
621
; Read MAC address
623
	set_io	REG_RBSTART
622
 
Line 624... Line 623...
624
	out	dx , eax
623
	call	read_mac
625
 
624
 
-
 
625
; enable interrupts
626
; enable interrupts
626
 
Line 627... Line -...
627
 
-
 
628
	mov	eax, INTERRUPT_MASK
-
 
629
	set_io	REG_IMR
-
 
630
	out	dx , ax
-
 
631
 
627
	set_io	0
632
; Read MAC address
628
	set_io	REG_IMR
Line 633... Line 629...
633
 
629
	mov	eax, INTERRUPT_MASK
Line 722... Line 718...
722
 
718
 
Line 723... Line 719...
723
	jmp	.send_packet
719
	jmp	.send_packet
724
 
720
 
725
  .fail:
721
  .fail:
726
	DEBUGF	1,"failed!\n"
722
	DEBUGF	1,"failed!\n"
Line 888... Line 884...
888
; Transmit error ?
884
; Transmit error ?
889
  @@:
885
  @@:
890
	test	ax, ISR_TER
886
	test	ax, ISR_TER
891
	jz	@f
887
	jz	@f
Line -... Line 888...
-
 
888
 
-
 
889
	DEBUGF	1,"Transmit error\n"
892
 
890
 
893
;        push    ax
891
;        push    ax
894
;        cmp     [device.curr_tx_desc], 4
892
;        cmp     [device.curr_tx_desc], 4
895
;        jz      .notxd
893
;        jz      .notxd
896
;
894
;
Line 1112... Line 1110...
1112
	DEBUGF	2,"%x-%x-%x-%x-%x-%x\n",[edi-6]:2,[edi-5]:2,[edi-4]:2,[edi-3]:2,[edi-2]:2,[edi-1]:2
1110
	DEBUGF	2,"%x-%x-%x-%x-%x-%x\n",[edi-6]:2,[edi-5]:2,[edi-4]:2,[edi-3]:2,[edi-2]:2,[edi-1]:2
Line 1113... Line 1111...
1113
 
1111
 
Line 1114... Line -...
1114
	ret
-
 
1115
 
-
 
1116
 
-
 
1117
 
-
 
1118
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
 
1119
;;                                                                      ;;
-
 
1120
;; Read eeprom (type 93c46 and 93c56)                                   ;;
-
 
1121
;;                                                                      ;;
-
 
1122
;; In: word to be read in al (6bit in case of 93c46 and 8bit otherwise) ;;
-
 
1123
;;     pointer to device structure in ebx                               ;;
-
 
1124
;;                                                                      ;;
-
 
1125
;; OUT: word read in ax                                                 ;;
-
 
1126
;;                                                                      ;;
-
 
1127
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
 
1128
 
-
 
1129
align 4
-
 
1130
read_eeprom:
-
 
1131
	DEBUGF	2,"Reading eeprom, "
-
 
1132
 
-
 
1133
	set_io	0
-
 
1134
	push	ebx
-
 
1135
	movzx	ebx, al
-
 
1136
	set_io	REG_RXCONFIG
-
 
1137
	in	al, dx
-
 
1138
	test	al, (1 shl BIT_9356SEL)
-
 
1139
	jz	.type_93c46
-
 
1140
;       and     bl, 01111111b ; don't care first bit
-
 
1141
	or	bx, EE_93C56_READ_CMD		; it contains start bit
-
 
1142
	mov	cx, EE_93C56_CMD_LENGTH-1	; cmd_loop counter
-
 
1143
	jmp	.read_eeprom
-
 
1144
.type_93c46:
-
 
1145
	and	bl, 00111111b
-
 
1146
	or	bx, EE_93C46_READ_CMD		; it contains start bit
-
 
1147
	mov	cx, EE_93C46_CMD_LENGTH-1	; cmd_loop counter
-
 
1148
.read_eeprom:
-
 
1149
	set_io	REG_9346CR
-
 
1150
;       mov     al, (1 shl BIT_93C46_EEM1)
-
 
1151
;       out     dx, al
-
 
1152
	mov	al, (1 shl BIT_93C46_EEM1) or (1 shl BIT_93C46_EECS) ; wake up the eeprom
-
 
1153
	out	dx, al
-
 
1154
.cmd_loop:
-
 
1155
	mov	al, (1 shl BIT_93C46_EEM1) or (1 shl BIT_93C46_EECS)
-
 
1156
	bt	bx, cx
-
 
1157
	jnc	.zero_bit
-
 
1158
	or	al, (1 shl BIT_93C46_EEDI)
-
 
1159
.zero_bit:
-
 
1160
	out	dx, al
-
 
1161
;       push    eax
-
 
1162
;       in      eax, dx ; eeprom delay
-
 
1163
;       pop     eax
-
 
1164
	or	al, (1 shl BIT_93C46_EESK)
-
 
1165
	out	dx, al
-
 
1166
;       in      eax, dx ; eeprom delay
-
 
1167
	dec	cx
-
 
1168
	jns	.cmd_loop
-
 
1169
;       in      eax, dx ; eeprom delay
-
 
1170
	mov	al, (1 shl BIT_93C46_EEM1) or (1 shl BIT_93C46_EECS)
-
 
1171
	out	dx, al
-
 
1172
	mov	cl, 0xf
-
 
1173
.read_loop:
-
 
1174
	shl	ebx, 1
-
 
1175
	mov	al, (1 shl BIT_93C46_EEM1) or (1 shl BIT_93C46_EECS) or (1 shl BIT_93C46_EESK)
-
 
1176
	out	dx, al
-
 
1177
;       in      eax, dx ; eeprom delay
-
 
1178
	in	al, dx
-
 
1179
	and	al, (1 shl BIT_93C46_EEDO)
-
 
1180
	jz	.dont_set
-
 
1181
	inc	ebx
-
 
1182
.dont_set:
-
 
1183
	mov	al, (1 shl BIT_93C46_EEM1) or (1 shl BIT_93C46_EECS)
-
 
1184
	out	dx, al
-
 
1185
;       in      eax, dx ; eeprom delay
-
 
1186
	dec	cl
-
 
1187
	jns	.read_loop
-
 
1188
	xor	al, al
-
 
1189
	out	dx, al
-
 
1190
	mov	ax, bx
-
 
1191
	pop	ebx
-
 
1192
 
-
 
1193
	ret
1112
	ret
Line 1194... Line 1113...
1194
 
1113
 
1195
 
1114