Rev 4470 | Rev 5363 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4470 | Rev 5006 | ||
---|---|---|---|
Line 21... | Line 21... | ||
21 | ;; Updates: ;; |
21 | ;; Updates: ;; |
22 | ;; Revision Look up table and SIS635 Mac Address by Jarek Pelczar ;; |
22 | ;; Revision Look up table and SIS635 Mac Address by Jarek Pelczar ;; |
23 | ;; ;; |
23 | ;; ;; |
24 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
24 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 25... | Line 25... | ||
25 | 25 | ||
- | 26 | format PE DLL native |
|
- | 27 | entry START |
|
- | 28 | ||
- | 29 | CURRENT_API = 0x0200 |
|
- | 30 | COMPATIBLE_API = 0x0100 |
|
Line 26... | Line 31... | ||
26 | format MS COFF |
31 | API_VERSION = (COMPATIBLE_API shl 16) + CURRENT_API |
27 | 32 | ||
28 | NUM_RX_DESC = 4 ; Number of RX descriptors |
33 | NUM_RX_DESC = 4 ; Number of RX descriptors |
29 | NUM_TX_DESC = 4 ; Number of TX descriptors |
- | |
30 | RX_BUFF_SZ = 1520 ; Buffer size for each Rx buffer |
- | |
31 | TX_BUFF_SZ = 1516 ; Buffer size for each Tx buffer |
- | |
32 | MAX_ETH_FRAME_SIZE = 1516 |
- | |
33 | - | ||
Line 34... | Line 34... | ||
34 | API_VERSION = 0x01000100 |
34 | NUM_TX_DESC = 4 ; Number of TX descriptors |
Line 35... | Line -... | ||
35 | DRIVER_VERSION = 5 |
- | |
36 | 35 | RX_BUFF_SZ = 1520 ; Buffer size for each Rx buffer |
|
37 | MAX_DEVICES = 16 |
36 | |
Line 38... | Line 37... | ||
38 | 37 | MAX_DEVICES = 16 |
|
39 | DEBUG = 1 |
38 | |
40 | __DEBUG__ = 1 |
39 | __DEBUG__ = 1 |
Line 195... | Line 194... | ||
195 | ; For SiS962 or SiS963, request the eeprom software access |
194 | ; For SiS962 or SiS963, request the eeprom software access |
196 | EEREQ = 0x00000400 |
195 | EEREQ = 0x00000400 |
197 | EEDONE = 0x00000200 |
196 | EEDONE = 0x00000200 |
198 | EEGNT = 0x00000100 |
197 | EEGNT = 0x00000100 |
Line -... | Line 198... | ||
- | 198 | ||
- | 199 | section '.flat' readable writable executable |
|
- | 200 | ||
199 | 201 | include '../proc32.inc' |
|
200 | include '../struct.inc' |
202 | include '../struct.inc' |
201 | include '../macros.inc' |
- | |
202 | include '../proc32.inc' |
- | |
203 | include '../imports.inc' |
203 | include '../macros.inc' |
204 | include '../fdo.inc' |
204 | include '../fdo.inc' |
205 | include '../netdrv.inc' |
- | |
206 | - | ||
207 | public START |
- | |
208 | public version |
- | |
209 | - | ||
210 | - | ||
211 | virtual at ebx |
- | |
Line 212... | Line -... | ||
212 | device: |
- | |
Line 213... | Line -... | ||
213 | - | ||
214 | ETH_DEVICE |
- | |
215 | - | ||
216 | .io_addr dd ? |
- | |
217 | .pci_bus dd ? |
205 | include '../netdrv_pe.inc' |
218 | .pci_dev dd ? |
- | |
219 | .irq_line db ? |
- | |
220 | .cur_rx db ? |
- | |
221 | .cur_tx db ? |
- | |
222 | .last_tx db ? |
- | |
Line -... | Line 206... | ||
- | 206 | ||
- | 207 | ||
- | 208 | struct device ETH_DEVICE |
|
- | 209 | ||
- | 210 | io_addr dd ? |
|
- | 211 | pci_bus dd ? |
|
- | 212 | pci_dev dd ? |
|
- | 213 | irq_line db ? |
|
- | 214 | cur_rx db ? |
|
- | 215 | cur_tx db ? |
|
- | 216 | last_tx db ? |
|
223 | .pci_revision db ? |
217 | pci_revision db ? |
224 | .table_entries db ? |
218 | table_entries db ? |
Line 225... | Line -... | ||
225 | rb 2 ; alignment |
- | |
226 | - | ||
227 | .txd rd (4 * NUM_TX_DESC) |
219 | |
Line 228... | Line 220... | ||
228 | .rxd rd (4 * NUM_RX_DESC) |
220 | rb 0x100 - ($ and 0xff) ; align 256 |
229 | 221 | txd rd (4 * NUM_TX_DESC) |
|
230 | .size = $ - device |
222 | rxd rd (4 * NUM_RX_DESC) |
231 | 223 | ||
Line 244... | Line 236... | ||
244 | in eax, dx |
236 | in eax, dx |
245 | in eax, dx |
237 | in eax, dx |
246 | pop eax |
238 | pop eax |
247 | } |
239 | } |
Line 248... | Line -... | ||
248 | - | ||
- | 240 | ||
- | 241 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|
- | 242 | ;; ;; |
|
- | 243 | ;; proc START ;; |
|
249 | 244 | ;; ;; |
|
- | 245 | ;; (standard driver proc) ;; |
|
Line 250... | Line 246... | ||
250 | section '.flat' code readable align 16 |
246 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
251 | 247 | ||
- | 248 | ; Driver entry point - register our service when the driver is loading. |
|
- | 249 | ; TODO: add needed operations when unloading |
|
252 | ; Driver entry point - register our service when the driver is loading. |
250 | |
253 | ; TODO: add needed operations when unloading |
251 | proc START c, reason:dword, cmdline:dword |
254 | START: |
252 | |
- | 253 | cmp [reason], DRV_ENTRY |
|
- | 254 | jne .fail |
|
255 | cmp dword [esp+4], 1 |
255 | |
256 | jne .exit |
256 | DEBUGF 2,"Loading driver\n" |
- | 257 | invoke RegService, my_service, service_proc |
|
257 | stdcall RegService, my_service, service_proc |
258 | ret |
258 | ret 4 |
259 | |
259 | .exit: |
260 | .fail: |
- | 261 | xor eax, eax |
|
- | 262 | ret |
|
- | 263 | ||
- | 264 | endp |
|
- | 265 | ||
- | 266 | ||
- | 267 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|
- | 268 | ;; ;; |
|
- | 269 | ;; proc SERVICE_PROC ;; |
|
- | 270 | ;; ;; |
|
Line 260... | Line 271... | ||
260 | xor eax, eax |
271 | ;; (standard driver proc) ;; |
261 | ret 4 |
272 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
262 | 273 | ||
263 | ; Service procedure for the driver - handle all I/O requests for the driver. |
274 | ; Service procedure for the driver - handle all I/O requests for the driver. |
Line 305... | Line 316... | ||
305 | 316 | ||
306 | ; mov eax, [edx + IOCTL.input] ; get the pci bus and device numbers |
317 | ; mov eax, [edx + IOCTL.input] ; get the pci bus and device numbers |
307 | mov ax, [eax+1] ; |
318 | mov ax, [eax+1] ; |
308 | .nextdevice: |
319 | .nextdevice: |
309 | mov ebx, [esi] |
320 | mov ebx, [esi] |
310 | cmp al, byte[device.pci_bus] |
321 | cmp al, byte[ebx + device.pci_bus] |
311 | jne @f |
322 | jne @f |
312 | cmp ah, byte[device.pci_dev] |
323 | cmp ah, byte[ebx + device.pci_dev] |
313 | je .find_devicenum ; Device is already loaded, let's find it's device number |
324 | je .find_devicenum ; Device is already loaded, let's find it's device number |
314 | @@: |
325 | @@: |
315 | add esi, 4 |
326 | add esi, 4 |
316 | loop .nextdevice |
327 | loop .nextdevice |
Line 319... | Line 330... | ||
319 | ; 4f. Check that we have place for new device. |
330 | ; 4f. Check that we have place for new device. |
320 | cmp [devices], MAX_DEVICES |
331 | cmp [devices], MAX_DEVICES |
321 | jae .fail |
332 | jae .fail |
322 | ; 4g. Allocate memory for device descriptor and receive+transmit buffers. |
333 | ; 4g. Allocate memory for device descriptor and receive+transmit buffers. |
323 | ; 4h. Zero the structure. |
334 | ; 4h. Zero the structure. |
324 | allocate_and_clear ebx, device.size, .fail |
335 | allocate_and_clear ebx, sizeof.device, .fail |
325 | ; 4i. Save PCI coordinates |
336 | ; 4i. Save PCI coordinates |
326 | mov eax, [edx + IOCTL.input] |
337 | mov eax, [edx + IOCTL.input] |
327 | movzx ecx, byte[eax+1] |
338 | movzx ecx, byte[eax+1] |
328 | mov [device.pci_bus], ecx |
339 | mov [ebx + device.pci_bus], ecx |
329 | movzx ecx, byte[eax+2] |
340 | movzx ecx, byte[eax+2] |
330 | mov [device.pci_dev], ecx |
341 | mov [ebx + device.pci_dev], ecx |
331 | ; 4j. Fill in the direct call addresses into the struct. |
342 | ; 4j. Fill in the direct call addresses into the struct. |
332 | mov [device.reset], reset |
343 | mov [ebx + device.reset], reset |
333 | mov [device.transmit], transmit |
344 | mov [ebx + device.transmit], transmit |
334 | mov [device.unload], unload |
345 | mov [ebx + device.unload], unload |
335 | mov [device.name], my_service |
346 | mov [ebx + device.name], my_service |
Line 336... | Line 347... | ||
336 | 347 | ||
337 | ; 4k. Now, it's time to find the base io addres of the PCI device |
348 | ; 4k. Now, it's time to find the base io addres of the PCI device |
Line 338... | Line 349... | ||
338 | ; TODO: implement check if bus and dev exist on this machine |
349 | ; TODO: implement check if bus and dev exist on this machine |
- | 350 | ||
339 | 351 | ; Now, it's time to find the base io addres of the PCI device |
|
Line 340... | Line 352... | ||
340 | ; Now, it's time to find the base io addres of the PCI device |
352 | stdcall PCI_find_io, [ebx + device.pci_bus], [ebx + device.pci_dev] |
- | 353 | mov [ebx + device.io_addr], eax |
|
- | 354 | ||
341 | PCI_find_io |
355 | ; We've found the io address, find IRQ now |
Line 342... | Line 356... | ||
342 | 356 | ||
343 | ; We've found the io address, find IRQ now |
357 | invoke PciRead8, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header00.interrupt_line |
344 | PCI_find_irq |
358 | mov [ebx + device.irq_line], al |
345 | 359 | ||
Line 352... | Line 366... | ||
352 | call probe |
366 | call probe |
353 | test eax, eax |
367 | test eax, eax |
354 | jnz .destroy |
368 | jnz .destroy |
355 | ; 4n. If device was successfully initialized, register it for the kernel. |
369 | ; 4n. If device was successfully initialized, register it for the kernel. |
Line 356... | Line 370... | ||
356 | 370 | ||
357 | mov [device.type], NET_TYPE_ETH |
371 | mov [ebx + device.type], NET_TYPE_ETH |
Line 358... | Line 372... | ||
358 | call NetRegDev |
372 | invoke NetRegDev |
359 | 373 | ||
Line 360... | Line 374... | ||
360 | cmp eax, -1 |
374 | cmp eax, -1 |
Line 361... | Line 375... | ||
361 | je .destroy |
375 | je .destroy |
Line 362... | Line 376... | ||
362 | 376 | ||
363 | ret 4 |
377 | ret 4 |
364 | 378 | ||
365 | ; 5. If the device was already loaded, find the device number and return it in eax |
379 | ; 5. If the device was already loaded, find the device number and return it in eax |
366 | 380 | ||
Line 367... | Line 381... | ||
367 | .find_devicenum: |
381 | .find_devicenum: |
Line 375... | Line 389... | ||
375 | .destroy: |
389 | .destroy: |
376 | dec [devices] |
390 | dec [devices] |
377 | ; todo: reset device into virgin state |
391 | ; todo: reset device into virgin state |
Line 378... | Line 392... | ||
378 | 392 | ||
379 | .err: |
393 | .err: |
Line 380... | Line 394... | ||
380 | stdcall KernelFree, ebx |
394 | invoke KernelFree, ebx |
381 | 395 | ||
382 | .fail: |
396 | .fail: |
Line 414... | Line 428... | ||
414 | ;*************************************************************************** |
428 | ;*************************************************************************** |
415 | align 4 |
429 | align 4 |
416 | probe: |
430 | probe: |
417 | DEBUGF 1, "Probe\n" |
431 | DEBUGF 1, "Probe\n" |
Line 418... | Line 432... | ||
418 | 432 | ||
- | 433 | ; wake up device |
|
419 | ; wake up device CHECKME |
434 | ; TODO: check capabilities pointer instead of using hardcoded offset. |
420 | stdcall PciWrite8, [device.pci_bus], [device.pci_dev], 0x40, 0 |
435 | invoke PciWrite8, [ebx + device.pci_bus], [ebx + device.pci_dev], 0x40, 0 |
421 | 436 | ||
- | 437 | ; Make the device a bus master |
|
- | 438 | invoke PciRead32, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header00.command |
|
- | 439 | or al, PCI_CMD_MASTER |
|
422 | PCI_make_bus_master |
440 | invoke PciWrite32, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header00.command, eax |
- | 441 | ||
- | 442 | ; Adjust PCI latency to be at least 64 |
|
- | 443 | invoke PciRead8, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header00.max_latency |
|
- | 444 | cmp al, 64 |
|
423 | 445 | jae @f |
|
- | 446 | mov al, 64 |
|
- | 447 | invoke PciWrite8, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header00.max_latency, eax |
|
Line 424... | Line 448... | ||
424 | PCI_adjust_latency 64 |
448 | @@: |
425 | 449 | ||
426 | ; Get Card Revision |
450 | ; Get Card Revision |
Line 427... | Line 451... | ||
427 | stdcall PciRead8, [device.pci_bus], [device.pci_dev], 0x08 |
451 | invoke PciRead8, [ebx + device.pci_bus], [ebx + device.pci_dev], 0x08 |
428 | mov [device.pci_revision], al ; save the revision for later use |
452 | mov [ebx + device.pci_revision], al ; save the revision for later use |
429 | 453 | ||
430 | ; Look up through the specific_table |
454 | ; Look up through the specific_table |
431 | mov esi, specific_table |
455 | mov esi, specific_table |
432 | .tableloop: |
456 | .tableloop: |
433 | cmp dword [esi], 0 ; Check if we reached end of the list |
457 | cmp dword[esi], 0 ; Check if we reached end of the list |
434 | je .notsupported |
458 | je .notsupported |
435 | cmp al, [esi] ; Check if revision is OK |
459 | cmp al, [esi] ; Check if revision is OK |
436 | je .ok |
- | |
437 | add esi, 12 ; Advance to next entry |
460 | je .ok |
438 | jmp .tableloop |
- | |
439 | 461 | add esi, 12 ; Advance to next entry |
|
Line 440... | Line 462... | ||
440 | .ok: |
462 | jmp .tableloop |
441 | 463 | .ok: |
|
442 | call dword[esi + 4] ; "get MAC" function |
464 | call dword[esi + 4] ; "get MAC" function |
443 | 465 | ||
444 | ; Set table entries |
466 | ; Set table entries |
445 | mov [device.table_entries], 16 |
467 | mov [ebx + device.table_entries], 16 |
446 | cmp [device.pci_revision], SIS635A_900_REV |
468 | cmp [ebx + device.pci_revision], SIS635A_900_REV |
447 | jae @f |
469 | jae @f |
Line 448... | Line 470... | ||
448 | cmp [device.pci_revision], SIS900B_900_REV |
470 | cmp [ebx + device.pci_revision], SIS900B_900_REV |
449 | je @f |
- | |
450 | mov [device.table_entries], 8 |
471 | je @f |
Line 451... | Line 472... | ||
451 | @@: |
472 | mov [ebx + device.table_entries], 8 |
452 | 473 | @@: |
|
453 | ; TODO: Probe for mii transceiver |
474 | |
Line 454... | Line 475... | ||
454 | 475 | ; TODO: Probe for mii transceiver |
|
Line 455... | Line 476... | ||
455 | jmp reset |
476 | jmp reset |
Line 456... | Line 477... | ||
456 | 477 | ||
Line 457... | Line 478... | ||
457 | .notsupported: |
478 | .notsupported: |
458 | DEBUGF 1, "Device not supported\n" |
479 | DEBUGF 2, "Device not supported\n" |
- | 480 | or eax, -1 |
|
- | 481 | ||
- | 482 | ret |
|
- | 483 | ||
- | 484 | reset: |
|
- | 485 | ||
Line 459... | Line 486... | ||
459 | or eax, -1 |
486 | DEBUGF 1, "reset\n" |
460 | 487 | ||
Line 461... | Line 488... | ||
461 | ret |
488 | movzx eax, [ebx + device.irq_line] |
462 | 489 | invoke AttachIntHandler, eax, int_handler, ebx |
|
463 | reset: |
490 | test eax, eax |
464 | 491 | jnz @f |
|
Line 465... | Line 492... | ||
465 | DEBUGF 1, "reset\n" |
492 | DEBUGF 2,"Could not attach int handler!\n" |
466 | 493 | or eax, -1 |
|
Line 467... | Line 494... | ||
467 | movzx eax, [device.irq_line] |
494 | ret |
468 | stdcall AttachIntHandler, eax, int_handler, 0 |
495 | @@: |
Line 469... | Line 496... | ||
469 | 496 | ||
470 | ;-------------------------------------------- |
497 | ;-------------------------------------------- |
Line 471... | Line 498... | ||
471 | ; Disable Interrupts and reset Receive Filter |
498 | ; Disable Interrupts and reset Receive Filter |
472 | 499 | ||
473 | set_io 0 |
500 | set_io [ebx + device.io_addr], 0 |
474 | set_io ier |
501 | set_io [ebx + device.io_addr], ier |
Line 475... | Line 502... | ||
475 | xor eax, eax |
502 | xor eax, eax |
476 | out dx, eax |
503 | out dx, eax |
Line 477... | Line 504... | ||
477 | 504 | ||
478 | set_io imr |
505 | set_io [ebx + device.io_addr], imr |
479 | out dx, eax |
506 | out dx, eax |
480 | 507 | ||
481 | set_io rfcr |
508 | set_io [ebx + device.io_addr], rfcr |
482 | out dx, eax |
509 | out dx, eax |
Line 503... | Line 530... | ||
503 | DEBUGF 1, "status=%x\n", eax |
530 | DEBUGF 1, "status=%x\n", eax |
Line 504... | Line 531... | ||
504 | 531 | ||
505 | ;------------------------------------------------------ |
532 | ;------------------------------------------------------ |
Line 506... | Line 533... | ||
506 | ; Set Configuration Register depending on Card Revision |
533 | ; Set Configuration Register depending on Card Revision |
507 | 534 | ||
508 | set_io cfg |
535 | set_io [ebx + device.io_addr], cfg |
509 | mov eax, PESEL ; Configuration Register Bit |
536 | mov eax, PESEL ; Configuration Register Bit |
510 | cmp [device.pci_revision], SIS635A_900_REV |
537 | cmp [ebx + device.pci_revision], SIS635A_900_REV |
511 | je .match |
538 | je .match |
512 | cmp [device.pci_revision], SIS900B_900_REV ; Check card revision |
539 | cmp [ebx + device.pci_revision], SIS900B_900_REV ; Check card revision |
513 | jne .done |
540 | jne .done |
514 | .match: ; Revision match |
541 | .match: ; Revision match |
515 | or eax, RND_CNT ; Configuration Register Bit |
542 | or eax, RND_CNT ; Configuration Register Bit |
Line 516... | Line 543... | ||
516 | .done: |
543 | .done: |
Line 517... | Line 544... | ||
517 | out dx, eax |
544 | out dx, eax |
518 | 545 | ||
519 | DEBUGF 1, "Initialising RX Filter\n" |
546 | DEBUGF 1, "Initialising RX Filter\n" |
520 | 547 | ||
Line 521... | Line 548... | ||
521 | ; Get Receive Filter Control Register |
548 | ; Get Receive Filter Control Register |
522 | set_io rfcr |
549 | set_io [ebx + device.io_addr], rfcr |
Line 529... | Line 556... | ||
529 | 556 | ||
530 | ; load MAC addr to filter data register |
557 | ; load MAC addr to filter data register |
531 | xor ecx, ecx |
558 | xor ecx, ecx |
532 | .macloop: |
559 | .macloop: |
533 | mov eax, ecx |
560 | mov eax, ecx |
534 | set_io 0 |
561 | set_io [ebx + device.io_addr], 0 |
535 | set_io rfcr |
562 | set_io [ebx + device.io_addr], rfcr |
536 | shl eax, 16 ; high word of eax tells card which mac byte to write |
563 | shl eax, 16 ; high word of eax tells card which mac byte to write |
537 | out dx, eax ; |
564 | out dx, eax ; |
538 | set_io rfdr |
565 | set_io [ebx + device.io_addr], rfdr |
539 | mov ax, word [device.mac + ecx*2] ; Get Mac ID word |
566 | mov ax, word [ebx + device.mac + ecx*2] ; Get Mac ID word |
540 | out dx, ax ; Send Mac ID |
567 | out dx, ax ; Send Mac ID |
541 | inc cl ; send next word |
568 | inc cl ; send next word |
542 | cmp cl, 3 ; more to send? |
569 | cmp cl, 3 ; more to send? |
Line 543... | Line 570... | ||
543 | jne .macloop |
570 | jne .macloop |
544 | 571 | ||
545 | ; enable packet filtering |
572 | ; enable packet filtering |
546 | pop eax ; old register value |
573 | pop eax ; old register value |
547 | set_io rfcr |
574 | set_io [ebx + device.io_addr], rfcr |
Line 548... | Line 575... | ||
548 | or eax, RFEN ; enable filtering |
575 | or eax, RFEN ; enable filtering |
Line 549... | Line 576... | ||
549 | out dx, eax ; set register |
576 | out dx, eax ; set register |
550 | 577 | ||
551 | DEBUGF 1, "Initialising TX Descriptors\n" |
578 | DEBUGF 1, "Initialising TX Descriptors\n" |
552 | 579 | ||
553 | mov ecx, NUM_TX_DESC |
580 | mov ecx, NUM_TX_DESC |
554 | lea esi, [device.txd] |
581 | lea esi, [ebx + device.txd] |
555 | .txdescloop: |
582 | .txdescloop: |
556 | lea eax, [esi + 16] ; next ptr |
583 | lea eax, [esi + 16] ; next ptr |
557 | GetRealAddr |
584 | invoke GetPhysAddr |
558 | mov dword [esi], eax ; link to next desc |
585 | mov dword[esi], eax ; link to next desc |
559 | mov dword [esi + 4], 0 ; status field |
586 | mov dword[esi + 4], 0 ; status field |
Line 560... | Line 587... | ||
560 | mov dword [esi + 8], 0 ; ptr to buffer |
587 | mov dword[esi + 8], 0 ; ptr to buffer |
561 | add esi, 16 |
588 | add esi, 16 |
562 | dec ecx |
589 | dec ecx |
Line 563... | Line 590... | ||
563 | jnz .txdescloop |
590 | jnz .txdescloop |
564 | 591 | ||
565 | lea eax, [device.txd] |
592 | lea eax, [ebx + device.txd] |
566 | GetRealAddr |
593 | invoke GetPhysAddr |
Line 567... | Line 594... | ||
567 | mov dword [esi - 16], eax ; correct last descriptor link ptr |
594 | mov dword[esi - 16], eax ; correct last descriptor link ptr |
568 | 595 | ||
Line 569... | Line 596... | ||
569 | set_io txdp ; TX Descriptor Pointer |
596 | set_io [ebx + device.io_addr], txdp ; TX Descriptor Pointer |
Line 570... | Line 597... | ||
570 | ; lea eax, [device.txd] |
597 | ; lea eax, [ebx + device.txd] |
571 | ; GetRealAddr |
598 | ; invoke GetPhysAddr |
572 | out dx, eax |
599 | out dx, eax |
573 | 600 | ||
574 | mov [device.cur_tx], 0 ; Set current tx descriptor to 0 |
601 | mov [ebx + device.cur_tx], 0 ; Set current tx descriptor to 0 |
575 | mov [device.last_tx], 0 |
602 | mov [ebx + device.last_tx], 0 |
576 | 603 | ||
Line 577... | Line 604... | ||
577 | DEBUGF 1, "Initialising RX Descriptors\n" |
604 | DEBUGF 1, "Initialising RX Descriptors\n" |
578 | 605 | ||
579 | mov ecx, NUM_RX_DESC |
606 | mov ecx, NUM_RX_DESC |
580 | lea esi, [device.rxd] |
607 | lea esi, [ebx + device.rxd] |
581 | .rxdescloop: |
608 | .rxdescloop: |
582 | lea eax, [esi + 16] ; next ptr |
609 | lea eax, [esi + 16] ; next ptr |
583 | GetRealAddr |
610 | invoke GetPhysAddr |
584 | mov dword [esi], eax |
611 | mov dword [esi], eax |
585 | mov dword [esi + 4], RX_BUFF_SZ ; size |
612 | mov dword [esi + 4], RX_BUFF_SZ ; size |
586 | 613 | ||
587 | push ecx esi |
614 | push ecx esi |
Line 588... | Line 615... | ||
588 | stdcall KernelAlloc, RX_BUFF_SZ |
615 | invoke KernelAlloc, RX_BUFF_SZ |
589 | pop esi ecx |
616 | pop esi ecx |
590 | test eax, eax |
617 | test eax, eax |
Line 591... | Line 618... | ||
591 | jz .fail |
618 | jz .fail |
592 | mov dword [esi + 12], eax ; address |
619 | mov dword [esi + 12], eax ; address |
593 | GetRealAddr |
620 | invoke GetPhysAddr |
594 | mov dword [esi + 8], eax ; real address |
621 | mov dword [esi + 8], eax ; real address |
595 | add esi, 16 |
622 | add esi, 16 |
Line 596... | Line 623... | ||
596 | dec ecx |
623 | dec ecx |
Line 597... | Line 624... | ||
597 | jnz .rxdescloop |
624 | jnz .rxdescloop |
Line 598... | Line 625... | ||
598 | 625 | ||
599 | lea eax, [device.rxd] |
626 | lea eax, [ebx + device.rxd] |
600 | GetRealAddr |
627 | invoke GetPhysAddr |
601 | mov dword [esi - 16], eax ; correct last descriptor link ptr |
628 | mov dword [esi - 16], eax ; correct last descriptor link ptr |
602 | 629 | ||
603 | set_io 0 |
630 | set_io [ebx + device.io_addr], 0 |
604 | set_io rxdp |
631 | set_io [ebx + device.io_addr], rxdp |
605 | ; lea eax, [device.rxd] |
632 | ; lea eax, [ebx + device.rxd] |
Line 606... | Line 633... | ||
606 | ; GetRealAddr |
633 | ; invoke GetPhysAddr |
607 | out dx, eax |
634 | out dx, eax |
608 | 635 | ||
Line 609... | Line 636... | ||
609 | mov [device.cur_rx], 0 ; Set current rx descriptor to 0 |
636 | mov [ebx + device.cur_rx], 0 ; Set current rx descriptor to 0 |
610 | 637 | ||
611 | DEBUGF 1, "setting RX mode\n" |
638 | DEBUGF 1, "setting RX mode\n" |
Line 612... | Line 639... | ||
612 | 639 | ||
613 | xor cl, cl |
640 | xor cl, cl |
614 | .rxfilterloop: |
641 | .rxfilterloop: |
Line 615... | Line 642... | ||
615 | set_io 0 |
642 | set_io [ebx + device.io_addr], 0 |
616 | set_io rfcr ; Receive Filter Control Reg offset |
643 | set_io [ebx + device.io_addr], rfcr ; Receive Filter Control Reg offset |
617 | mov eax, 4 ; determine table entry |
644 | mov eax, 4 ; determine table entry |
Line 618... | Line 645... | ||
618 | add al, cl |
645 | add al, cl |
Line 619... | Line 646... | ||
619 | shl eax, 16 |
646 | shl eax, 16 |
620 | out dx, eax ; tell card which entry to modify |
- | |
621 | 647 | out dx, eax ; tell card which entry to modify |
|
622 | set_io rfdr ; Receive Filter Control Reg offset |
648 | |
623 | mov eax, 0xffff ; entry value |
649 | set_io [ebx + device.io_addr], rfdr ; Receive Filter Control Reg offset |
Line 624... | Line 650... | ||
624 | out dx, ax ; write value to table in card |
650 | mov eax, 0xffff ; entry value |
Line 625... | Line 651... | ||
625 | 651 | out dx, ax ; write value to table in card |
|
626 | inc cl ; next entry |
652 | |
627 | cmp cl, [device.table_entries] |
653 | inc cl ; next entry |
Line 628... | Line 654... | ||
628 | jb .rxfilterloop |
654 | cmp cl, [ebx + device.table_entries] |
629 | 655 | jb .rxfilterloop |
|
630 | set_io rfcr ; Receive Filter Control Register offset |
656 | |
631 | mov eax, RFAAB + RFAAM + RFAAP + RFEN |
657 | set_io [ebx + device.io_addr], rfcr ; Receive Filter Control Register offset |
Line 632... | Line 658... | ||
632 | out dx, eax |
658 | mov eax, RFAAB + RFAAM + RFAAP + RFEN |
633 | 659 | out dx, eax |
|
634 | set_io rxcfg ; Receive Config Register offset |
660 | |
Line 635... | Line 661... | ||
635 | mov eax, ATX + RX_DMA + 2 ; 0x2 : RX Drain Threshold = 8*8=64 bytes |
661 | set_io [ebx + device.io_addr], rxcfg ; Receive Config Register offset |
Line 636... | Line 662... | ||
636 | out dx, eax |
662 | mov eax, ATX + RX_DMA + 2 ; 0x2 : RX Drain Threshold = 8*8=64 bytes |
637 | 663 | out dx, eax |
|
Line 638... | Line 664... | ||
638 | DEBUGF 1, "setting TX mode\n" |
664 | |
639 | 665 | DEBUGF 1, "setting TX mode\n" |
|
Line 640... | Line 666... | ||
640 | set_io txcfg ; Transmit config Register offset |
666 | |
641 | mov eax, ATP + HBI + CSI + TX_DMA + 0x120 |
667 | set_io [ebx + device.io_addr], txcfg ; Transmit config Register offset |
642 | ; TX Fill threshold = 0x100 |
668 | mov eax, ATP + HBI + CSI + TX_DMA + 0x120 ; TX Fill threshold = 0x100 |
Line 643... | Line 669... | ||
643 | ; TX Drain Threshold = 0x20 |
669 | ; TX Drain Threshold = 0x20 |
Line 689... | Line 715... | ||
689 | ; Return 0 is EAX = failure |
715 | ; Return 0 is EAX = failure |
690 | ; |
716 | ; |
691 | ;*************************************************************************** |
717 | ;*************************************************************************** |
692 | align 4 |
718 | align 4 |
693 | SIS960_get_mac_addr: |
719 | SIS960_get_mac_addr: |
694 | DEBUGF 1, "SIS960 - get mac: " |
720 | DEBUGF 1, "SIS960 - get mac:\n" |
Line 695... | Line 721... | ||
695 | 721 | ||
696 | ;------------------------------- |
722 | ;------------------------------- |
Line 697... | Line 723... | ||
697 | ; Send Request for eeprom access |
723 | ; Send Request for eeprom access |
698 | 724 | ||
699 | set_io 0 |
725 | set_io [ebx + device.io_addr], 0 |
700 | set_io mear ; Eeprom access register |
726 | set_io [ebx + device.io_addr], mear ; Eeprom access register |
Line 701... | Line 727... | ||
701 | mov eax, EEREQ ; Request access to eeprom |
727 | mov eax, EEREQ ; Request access to eeprom |
702 | out dx, eax ; Send request |
728 | out dx, eax ; Send request |
Line 709... | Line 735... | ||
709 | in eax, dx ; get eeprom status |
735 | in eax, dx ; get eeprom status |
710 | test eax, EEGNT ; see if eeprom access granted flag is set |
736 | test eax, EEGNT ; see if eeprom access granted flag is set |
711 | jnz .got_access ; if it is, go access the eeprom |
737 | jnz .got_access ; if it is, go access the eeprom |
712 | loop .loop ; else keep waiting |
738 | loop .loop ; else keep waiting |
Line 713... | Line 739... | ||
713 | 739 | ||
Line 714... | Line 740... | ||
714 | DEBUGF 1, "Access to EEprom failed!\n", 0 |
740 | DEBUGF 2, "Access to EEprom failed!\n", 0 |
715 | 741 | ||
716 | set_io mear ; Eeprom access register |
742 | set_io [ebx + device.io_addr], mear ; Eeprom access register |
Line 717... | Line 743... | ||
717 | mov eax, EEDONE ; tell eeprom we are done |
743 | mov eax, EEDONE ; tell eeprom we are done |
718 | out dx, eax |
744 | out dx, eax |
Line 732... | Line 758... | ||
732 | mov eax, EEPROMMACAddr ; Base Mac Address |
758 | mov eax, EEPROMMACAddr ; Base Mac Address |
733 | add eax, ecx ; Current Mac Byte Offset |
759 | add eax, ecx ; Current Mac Byte Offset |
734 | push ecx |
760 | push ecx |
735 | call read_eeprom ; try to read 16 bits |
761 | call read_eeprom ; try to read 16 bits |
736 | pop ecx |
762 | pop ecx |
737 | mov word [device.mac+ecx*2], ax ; save 16 bits to the MAC ID varible |
763 | mov word [ebx + device.mac+ecx*2], ax ; save 16 bits to the MAC ID varible |
738 | dec ecx ; one less word to read |
764 | dec ecx ; one less word to read |
739 | jns .read_loop ; if more read more |
765 | jns .read_loop ; if more read more |
740 | mov eax, 1 ; return non-zero indicating success |
766 | mov eax, 1 ; return non-zero indicating success |
Line -... | Line 767... | ||
- | 767 | ||
741 | 768 | DEBUGF 1,"%x-%x-%x-%x-%x-%x\n",\ |
|
Line 742... | Line 769... | ||
742 | DEBUGF 2,"%x-%x-%x-%x-%x-%x\n",[device.mac]:2,[device.mac+1]:2,[device.mac+2]:2,[device.mac+3]:2,[device.mac+4]:2,[device.mac+5]:2 |
769 | [ebx + device.mac]:2,[ebx + device.mac+1]:2,[ebx + device.mac+2]:2,[ebx + device.mac+3]:2,[ebx + device.mac+4]:2,[ebx + device.mac+5]:2 |
743 | 770 | ||
Line 744... | Line 771... | ||
744 | ;------------------------------------- |
771 | ;------------------------------------- |
745 | ; Tell EEPROM We are Done Accessing It |
772 | ; Tell EEPROM We are Done Accessing It |
746 | 773 | ||
747 | .done: |
774 | .done: |
748 | set_io 0 |
775 | set_io [ebx + device.io_addr], 0 |
Line 749... | Line 776... | ||
749 | set_io mear ; Eeprom access register |
776 | set_io [ebx + device.io_addr], mear ; Eeprom access register |
750 | mov eax, EEDONE ; tell eeprom we are done |
777 | mov eax, EEDONE ; tell eeprom we are done |
Line 763... | Line 790... | ||
763 | ; Older SiS900 and friends, use EEPROM to store MAC address. |
790 | ; Older SiS900 and friends, use EEPROM to store MAC address. |
764 | ; |
791 | ; |
765 | ;*************************************************************************** |
792 | ;*************************************************************************** |
766 | align 4 |
793 | align 4 |
767 | SIS900_get_mac_addr: |
794 | SIS900_get_mac_addr: |
768 | DEBUGF 1, "SIS900 - get mac: " |
795 | DEBUGF 1, "SIS900 - get mac:\n" |
Line 769... | Line 796... | ||
769 | 796 | ||
770 | ;------------------------------------ |
797 | ;------------------------------------ |
Line 771... | Line 798... | ||
771 | ; check to see if we have sane EEPROM |
798 | ; check to see if we have sane EEPROM |
Line 787... | Line 814... | ||
787 | mov eax, EEPROMMACAddr ; Base Mac Address |
814 | mov eax, EEPROMMACAddr ; Base Mac Address |
788 | add eax, ecx ; Current Mac Byte Offset |
815 | add eax, ecx ; Current Mac Byte Offset |
789 | push ecx |
816 | push ecx |
790 | call read_eeprom ; try to read 16 bits |
817 | call read_eeprom ; try to read 16 bits |
791 | pop ecx |
818 | pop ecx |
792 | mov word [device.mac+ecx*2], ax ; save 16 bits to the MAC ID storage |
819 | mov word [ebx + device.mac+ecx*2], ax ; save 16 bits to the MAC ID storage |
793 | dec ecx ; one less word to read |
820 | dec ecx ; one less word to read |
794 | jns .loop ; if more read more |
821 | jns .loop ; if more read more |
Line -... | Line 822... | ||
- | 822 | ||
795 | 823 | DEBUGF 1,"%x-%x-%x-%x-%x-%x\n",\ |
|
Line 796... | Line 824... | ||
796 | DEBUGF 2,"%x-%x-%x-%x-%x-%x\n",[device.mac]:2,[device.mac+1]:2,[device.mac+2]:2,[device.mac+3]:2,[device.mac+4]:2,[device.mac+5]:2 |
824 | [ebx + device.mac]:2,[ebx + device.mac+1]:2,[ebx + device.mac+2]:2,[ebx + device.mac+3]:2,[ebx + device.mac+4]:2,[ebx + device.mac+5]:2 |
797 | 825 | ||
Line 811... | Line 839... | ||
811 | ; Get_Mac_SIS635_900_REV: - Get MAC address for model 635 |
839 | ; Get_Mac_SIS635_900_REV: - Get MAC address for model 635 |
812 | ; |
840 | ; |
813 | ;*************************************************************************** |
841 | ;*************************************************************************** |
814 | align 4 |
842 | align 4 |
815 | Get_Mac_SIS635_900_REV: |
843 | Get_Mac_SIS635_900_REV: |
816 | DEBUGF 1, "SIS635 - get mac: " |
844 | DEBUGF 1, "SIS635 - get mac:\n" |
Line 817... | Line 845... | ||
817 | 845 | ||
818 | set_io 0 |
846 | set_io [ebx + device.io_addr], 0 |
819 | set_io rfcr |
847 | set_io [ebx + device.io_addr], rfcr |
820 | in eax, dx |
848 | in eax, dx |
Line 821... | Line 849... | ||
821 | mov esi, eax |
849 | mov esi, eax |
822 | 850 | ||
823 | set_io cr |
851 | set_io [ebx + device.io_addr], cr |
Line 824... | Line 852... | ||
824 | or eax, RELOAD |
852 | or eax, RELOAD |
825 | out dx, eax |
853 | out dx, eax |
Line 826... | Line 854... | ||
826 | 854 | ||
827 | xor eax, eax |
855 | xor eax, eax |
Line 828... | Line 856... | ||
828 | out dx, eax |
856 | out dx, eax |
829 | 857 | ||
830 | ;----------------------------------------------- |
858 | ;----------------------------------------------- |
831 | ; Disable packet filtering before setting filter |
859 | ; Disable packet filtering before setting filter |
Line 832... | Line 860... | ||
832 | 860 | ||
833 | set_io rfcr |
861 | set_io [ebx + device.io_addr], rfcr |
Line 834... | Line 862... | ||
834 | mov eax, esi |
862 | mov eax, esi |
835 | and eax, not RFEN |
863 | and eax, not RFEN |
836 | out dx, eax |
864 | out dx, eax |
837 | 865 | ||
838 | ;--------------------------------- |
866 | ;--------------------------------- |
839 | ; Load MAC to filter data register |
867 | ; Load MAC to filter data register |
840 | 868 | ||
841 | xor ecx, ecx |
869 | xor ecx, ecx |
Line 842... | Line 870... | ||
842 | lea edi, [device.mac] |
870 | lea edi, [ebx + device.mac] |
843 | .loop: |
871 | .loop: |
844 | set_io 0 |
872 | set_io [ebx + device.io_addr], 0 |
845 | set_io rfcr |
873 | set_io [ebx + device.io_addr], rfcr |
846 | mov eax, ecx |
874 | mov eax, ecx |
847 | shl eax, RFADDR_shift |
875 | shl eax, RFADDR_shift |
Line 848... | Line 876... | ||
848 | out dx, eax |
876 | out dx, eax |
849 | 877 | ||
Line 850... | Line 878... | ||
850 | set_io rfdr |
878 | set_io [ebx + device.io_addr], rfdr |
851 | in ax, dx |
879 | in ax, dx |
852 | stosw |
880 | stosw |
853 | inc ecx |
881 | inc ecx |
Line -... | Line 882... | ||
- | 882 | cmp ecx, 3 |
|
854 | cmp ecx, 3 |
883 | jb .loop |
Line 855... | Line 884... | ||
855 | jb .loop |
884 | |
856 | 885 | ;------------------------ |
|
Line 857... | Line 886... | ||
857 | ;------------------------ |
886 | ; Enable packet filtering |
Line 878... | Line 907... | ||
878 | ; |
907 | ; |
879 | ;*************************************************************************** |
908 | ;*************************************************************************** |
880 | align 4 |
909 | align 4 |
881 | read_eeprom: |
910 | read_eeprom: |
Line 882... | Line 911... | ||
882 | 911 | ||
883 | set_io 0 |
912 | set_io [ebx + device.io_addr], 0 |
Line 884... | Line 913... | ||
884 | set_io mear |
913 | set_io [ebx + device.io_addr], mear |
885 | 914 | ||
886 | xor eax, eax ; start send |
915 | xor eax, eax ; start send |
Line 956... | Line 985... | ||
956 | 985 | ||
957 | 986 | ||
958 | 987 | ||
959 | align 4 |
988 | align 4 |
960 | write_mac: |
989 | write_mac: |
Line 974... | Line 1003... | ||
974 | ; size of buffer in [esp+8] |
1003 | ; size of buffer in [esp+8] |
975 | ; pointer to device structure in ebx |
1004 | ; pointer to device structure in ebx |
976 | ; |
1005 | ; |
977 | ;*************************************************************************** |
1006 | ;*************************************************************************** |
978 | align 4 |
1007 | align 4 |
- | 1008 | ||
- | 1009 | proc transmit stdcall bufferptr, buffersize |
|
- | 1010 | ||
- | 1011 | pushf |
|
979 | transmit: |
1012 | cli |
- | 1013 | ||
980 | DEBUGF 1,"Transmitting packet, buffer:%x, size:%u\n",[esp+4],[esp+8] |
1014 | DEBUGF 1,"Transmitting packet, buffer:%x, size:%u\n", [bufferptr], [buffersize] |
981 | mov eax, [esp+4] |
1015 | mov eax, [bufferptr] |
982 | DEBUGF 1,"To: %x-%x-%x-%x-%x-%x From: %x-%x-%x-%x-%x-%x Type:%x%x\n",\ |
1016 | DEBUGF 1,"To: %x-%x-%x-%x-%x-%x From: %x-%x-%x-%x-%x-%x Type:%x%x\n",\ |
983 | [eax+00]:2,[eax+01]:2,[eax+02]:2,[eax+03]:2,[eax+04]:2,[eax+05]:2,\ |
1017 | [eax+00]:2,[eax+01]:2,[eax+02]:2,[eax+03]:2,[eax+04]:2,[eax+05]:2,\ |
984 | [eax+06]:2,[eax+07]:2,[eax+08]:2,[eax+09]:2,[eax+10]:2,[eax+11]:2,\ |
1018 | [eax+06]:2,[eax+07]:2,[eax+08]:2,[eax+09]:2,[eax+10]:2,[eax+11]:2,\ |
985 | [eax+13]:2,[eax+12]:2 |
1019 | [eax+13]:2,[eax+12]:2 |
Line 986... | Line 1020... | ||
986 | 1020 | ||
987 | cmp dword [esp + 8], MAX_ETH_FRAME_SIZE |
1021 | cmp [buffersize], 1514 |
988 | ja .error |
1022 | ja .fail |
989 | cmp dword [esp + 8], 60 |
1023 | cmp [buffersize], 60 |
Line 990... | Line 1024... | ||
990 | jb .error |
1024 | jb .fail |
991 | 1025 | ||
992 | movzx ecx, [device.cur_tx] |
1026 | movzx ecx, [ebx + device.cur_tx] |
Line 993... | Line 1027... | ||
993 | shl ecx, 4 ; *16 |
1027 | shl ecx, 4 ; *16 |
994 | lea ecx, [device.txd + ecx] |
1028 | lea ecx, [ebx + device.txd + ecx] |
Line 995... | Line 1029... | ||
995 | 1029 | ||
996 | test dword [ecx + 4], 0x80000000 ; card owns descriptor ? |
1030 | test dword[ecx + 4], 0x80000000 ; card owns descriptor ? |
997 | jnz .error |
1031 | jnz .fail |
998 | 1032 | ||
Line 999... | Line 1033... | ||
999 | mov eax, [esp + 4] |
1033 | mov eax, [bufferptr] |
1000 | mov dword [ecx + 12], eax |
1034 | mov dword[ecx + 12], eax |
1001 | GetRealAddr |
1035 | invoke GetPhysAddr |
1002 | mov dword [ecx + 8], eax ; buffer address |
1036 | mov dword[ecx + 8], eax ; buffer address |
Line 1003... | Line 1037... | ||
1003 | 1037 | ||
1004 | mov eax, [esp + 8] |
1038 | mov eax, [buffersize] |
1005 | and eax, DSIZE |
1039 | and eax, DSIZE |
1006 | or eax, 0x80000000 ; card owns descriptor |
1040 | or eax, 0x80000000 ; card owns descriptor |
1007 | mov dword [ecx + 4], eax ; status field |
1041 | mov dword[ecx + 4], eax ; status field |
Line 1008... | Line 1042... | ||
1008 | 1042 | ||
1009 | set_io 0 |
1043 | set_io [ebx + device.io_addr], 0 |
Line 1010... | Line 1044... | ||
1010 | set_io cr |
1044 | set_io [ebx + device.io_addr], cr |
1011 | in eax, dx |
1045 | in eax, dx |
1012 | or eax, TxENA ; Enable the transmit state machine |
1046 | or eax, TxENA ; Enable the transmit state machine |
1013 | out dx, eax |
1047 | out dx, eax |
1014 | 1048 | ||
Line 1015... | Line -... | ||
1015 | inc [device.cur_tx] |
- | |
1016 | and [device.cur_tx], NUM_TX_DESC-1 |
1049 | inc [ebx + device.cur_tx] |
- | 1050 | and [ebx + device.cur_tx], NUM_TX_DESC-1 |
|
1017 | 1051 | ||
1018 | ; update stats |
1052 | ; update stats |
Line 1019... | Line 1053... | ||
1019 | mov ecx, [esp + 8] |
1053 | mov ecx, [buffersize] |
1020 | inc [device.packets_tx] |
1054 | inc [ebx + device.packets_tx] |
1021 | add dword [device.bytes_tx], ecx |
1055 | add dword [ebx + device.bytes_tx], ecx |
- | 1056 | adc dword [ebx + device.bytes_tx + 4], 0 |
|
1022 | adc dword [device.bytes_tx + 4], 0 |
1057 | |
1023 | 1058 | DEBUGF 1,"Transmit OK\n" |
|
- | 1059 | popf |
|
- | 1060 | xor eax, eax |
|
Line 1024... | Line 1061... | ||
1024 | .finish: |
1061 | ret |
1025 | DEBUGF 1,"Packet sent!\n" |
1062 | |
1026 | xor eax, eax |
1063 | .fail: |
Line 1047... | Line 1084... | ||
1047 | align 4 |
1084 | align 4 |
1048 | int_handler: |
1085 | int_handler: |
Line 1049... | Line 1086... | ||
1049 | 1086 | ||
Line 1050... | Line 1087... | ||
1050 | push ebx esi edi |
1087 | push ebx esi edi |
Line 1051... | Line 1088... | ||
1051 | 1088 | ||
Line 1052... | Line 1089... | ||
1052 | DEBUGF 1,"\n%s int\n", my_service |
1089 | DEBUGF 1,"INT\n" |
1053 | 1090 | ||
1054 | ; find pointer of device which made IRQ occur |
1091 | ; find pointer of device which made IRQ occur |
1055 | 1092 | ||
1056 | mov ecx, [devices] |
1093 | mov ecx, [devices] |
1057 | test ecx, ecx |
1094 | test ecx, ecx |
Line 1058... | Line 1095... | ||
1058 | jz .nothing |
1095 | jz .nothing |
1059 | mov esi, device_list |
1096 | mov esi, device_list |
1060 | .nextdevice: |
1097 | .nextdevice: |
1061 | mov ebx, [esi] |
1098 | mov ebx, [esi] |
1062 | 1099 | ||
1063 | set_io 0 |
1100 | set_io [ebx + device.io_addr], 0 |
1064 | set_io isr |
1101 | set_io [ebx + device.io_addr], isr |
Line 1075... | Line 1112... | ||
1075 | 1112 | ||
Line 1076... | Line 1113... | ||
1076 | ret |
1113 | ret |
Line 1077... | Line 1114... | ||
1077 | 1114 | ||
Line 1078... | Line 1115... | ||
1078 | .got_it: |
1115 | .got_it: |
1079 | 1116 | ||
Line 1080... | Line 1117... | ||
1080 | DEBUGF 1,"Device: %x Status: %x ", ebx, ax |
1117 | DEBUGF 1,"Device: %x Status: %x\n", ebx, ax |
Line 1081... | Line 1118... | ||
1081 | 1118 | ||
Line 1082... | Line 1119... | ||
1082 | test ax, RxOK |
1119 | test ax, RxOK |
1083 | jz .no_rx_ |
1120 | jz .no_rx_ |
1084 | 1121 | ||
1085 | push ax |
1122 | push ax |
1086 | 1123 | ||
Line 1087... | Line 1124... | ||
1087 | .rx_loop: |
1124 | .rx_loop: |
1088 | 1125 | ||
1089 | ;----------- |
1126 | ;----------- |
1090 | ; Get Status |
1127 | ; Get Status |
Line 1107... | Line 1144... | ||
1107 | and ecx, DSIZE ; get packet size minus CRC |
1144 | and ecx, DSIZE ; get packet size minus CRC |
1108 | sub ecx, CRC_SIZE ; make sure packet contains data |
1145 | sub ecx, CRC_SIZE ; make sure packet contains data |
1109 | jbe .error_size |
1146 | jbe .error_size |
Line 1110... | Line 1147... | ||
1110 | 1147 | ||
1111 | ; update statistics |
1148 | ; update statistics |
1112 | inc dword [device.packets_rx] |
1149 | inc dword [ebx + device.packets_rx] |
1113 | add dword [device.bytes_rx], ecx |
1150 | add dword [ebx + device.bytes_rx], ecx |
Line 1114... | Line 1151... | ||
1114 | adc dword [device.bytes_rx + 4], 0 |
1151 | adc dword [ebx + device.bytes_rx + 4], 0 |
1115 | 1152 | ||
1116 | push ebx |
1153 | push ebx |
1117 | push .return |
1154 | push .return |
1118 | push ecx ; packet size |
1155 | push ecx ; packet size |
1119 | pushd [device.rxd + eax + 12] ; packet ptr |
1156 | pushd [ebx + device.rxd + eax + 12] ; packet ptr |
1120 | DEBUGF 1, "Packet received OK\n" |
1157 | DEBUGF 1, "Packet received OK\n" |
1121 | jmp Eth_input |
1158 | jmp [Eth_input] |
Line 1122... | Line 1159... | ||
1122 | .return: |
1159 | .return: |
1123 | pop ebx |
1160 | pop ebx |
1124 | 1161 | ||
1125 | ; Reset status, allow ethernet card access to descriptor |
1162 | ; Reset status, allow ethernet card access to descriptor |
1126 | stdcall KernelAlloc, RX_BUFF_SZ |
1163 | invoke KernelAlloc, RX_BUFF_SZ |
1127 | test eax, eax |
1164 | test eax, eax |
1128 | jz .fail |
1165 | jz .fail |
1129 | movzx ecx, [device.cur_rx] |
1166 | movzx ecx, [ebx + device.cur_rx] |
1130 | shl ecx, 4 ; *16 |
1167 | shl ecx, 4 ; *16 |
1131 | lea ecx, [device.rxd + ecx] |
1168 | lea ecx, [ebx + device.rxd + ecx] |
1132 | mov dword [ecx + 12], eax |
1169 | mov dword [ecx + 12], eax |
Line 1133... | Line 1170... | ||
1133 | GetRealAddr |
1170 | invoke GetPhysAddr |
1134 | mov dword [ecx + 8], eax |
1171 | mov dword [ecx + 8], eax |
Line 1135... | Line 1172... | ||
1135 | mov dword [ecx + 4], RX_BUFF_SZ |
1172 | mov dword [ecx + 4], RX_BUFF_SZ |
Line 1136... | Line 1173... | ||
1136 | 1173 | ||
1137 | inc [device.cur_rx] ; get next descriptor |
1174 | inc [ebx + device.cur_rx] ; get next descriptor |
1138 | and [device.cur_rx], NUM_RX_DESC-1 ; only 4 descriptors 0-3 |
1175 | and [ebx + device.cur_rx], NUM_RX_DESC-1 ; only 4 descriptors 0-3 |
1139 | 1176 | ||
1140 | jmp .rx_loop |
1177 | jmp .rx_loop |
1141 | 1178 | ||
Line 1142... | Line 1179... | ||
1142 | .no_rx: |
1179 | .no_rx: |
Line 1153... | Line 1190... | ||
1153 | jz .no_tx |
1190 | jz .no_tx |
Line 1154... | Line 1191... | ||
1154 | 1191 | ||
Line 1155... | Line 1192... | ||
1155 | DEBUGF 1, "TX ok!\n" |
1192 | DEBUGF 1, "TX ok!\n" |
1156 | 1193 | ||
1157 | .tx_loop: |
1194 | .tx_loop: |
1158 | movzx ecx, [device.last_tx] |
1195 | movzx ecx, [ebx + device.last_tx] |
Line 1159... | Line 1196... | ||
1159 | shl ecx, 4 ; *16 |
1196 | shl ecx, 4 ; *16 |
1160 | lea ecx, [device.txd + ecx] |
1197 | lea ecx, [ebx + device.txd + ecx] |
1161 | 1198 | ||
1162 | test dword [ecx + 4], 0x80000000 ; card owns descr |
1199 | test dword[ecx + 4], 0x80000000 ; card owns descr |
Line 1163... | Line 1200... | ||
1163 | jnz .no_tx |
1200 | jnz .no_tx |
1164 | cmp dword [ecx + 12], 0 |
1201 | cmp dword[ecx + 12], 0 |
1165 | je .no_tx |
1202 | je .no_tx |
1166 | 1203 | ||
Line 1167... | Line 1204... | ||
1167 | DEBUGF 1, "Freeing packet = %x\n", [ecx + 12]:8 |
1204 | DEBUGF 1, "Freeing packet = %x\n", [ecx + 12]:8 |
1168 | push dword [ecx + 12] |
1205 | push dword[ecx + 12] |
1169 | mov dword [ecx + 12], 0 |
1206 | mov dword[ecx + 12], 0 |
Line 1170... | Line 1207... | ||
1170 | call KernelFree |
1207 | invoke KernelFree |
1171 | 1208 | ||
1172 | inc [device.last_tx] |
1209 | inc [ebx + device.last_tx] |
Line 1182... | Line 1219... | ||
1182 | ret |
1219 | ret |
Line 1183... | Line 1220... | ||
1183 | 1220 | ||
Line 1184... | Line 1221... | ||
1184 | ret |
1221 | ret |
1185 | 1222 | ||
1186 | .error_status: |
1223 | .error_status: |
Line 1187... | Line 1224... | ||
1187 | DEBUGF 1, "Packet error: %x\n", ecx |
1224 | DEBUGF 2, "Packet error: %x\n", ecx |
1188 | jmp .fail |
1225 | jmp .fail |
1189 | 1226 | ||
Line 1190... | Line 1227... | ||
1190 | .error_size: |
1227 | .error_size: |
Line -... | Line 1228... | ||
- | 1228 | DEBUGF 2, "Packet too large/small\n" |
|
1191 | DEBUGF 1, "Packet too large/small\n" |
1229 | jmp .fail |
Line 1192... | Line 1230... | ||
1192 | jmp .fail |
1230 | |
- | 1231 | ||
- | 1232 | ||
Line 1193... | Line 1233... | ||
1193 | 1233 | ||
1194 | 1234 | ||
1195 | 1235 | ; End of code |
|
1196 | 1236 | ||
Line 1210... | Line 1250... | ||
1210 | dd SIS635A_900_REV, Get_Mac_SIS635_900_REV, 0 |
1250 | dd SIS635A_900_REV, Get_Mac_SIS635_900_REV, 0 |
1211 | dd SIS900_960_REV, SIS960_get_mac_addr, 0 |
1251 | dd SIS900_960_REV, SIS960_get_mac_addr, 0 |
1212 | dd SIS900B_900_REV, SIS900_get_mac_addr, 0 |
1252 | dd SIS900B_900_REV, SIS900_get_mac_addr, 0 |
1213 | dd 0 ; end of list |
1253 | dd 0 ; end of list |
Line 1214... | Line -... | ||
1214 | - | ||
1215 | version dd (DRIVER_VERSION shl 16) or (API_VERSION and 0xFFFF) |
- | |
1216 | my_service db 'SIS900',0 ; max 16 chars include zero |
- | |
1217 | 1254 | ||
Line 1218... | Line -... | ||
1218 | include_debug_strings ; All data wich FDO uses will be included here |
- | |
1219 | 1255 | include_debug_strings ; All data wich FDO uses will be included here |
|
- | 1256 | ||
1220 | section '.data' data readable writable align 16; place all uninitialized data place here |
1257 | align 4 |