Rev 684 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 684 | Rev 781 | ||
---|---|---|---|
Line 5... | Line 5... | ||
5 | ;; ;; |
5 | ;; ;; |
6 | ;; PCNET32.INC ;; |
6 | ;; PCNET32.INC ;; |
7 | ;; ;; |
7 | ;; ;; |
8 | ;; Ethernet driver for Menuet OS ;; |
8 | ;; Ethernet driver for Menuet OS ;; |
9 | ;; ;; |
9 | ;; ;; |
10 | ;; Version 1.0 31 July 2004 ;; |
10 | ;; - Version 1.0 31 July 2004: ;; |
- | 11 | ;; Initial release ;; |
|
- | 12 | ;; ;; |
|
- | 13 | ;; - Version 1.01 29 March 2008: ;; |
|
- | 14 | ;; Adapted to work with kolibrios flat kernel ;; |
|
- | 15 | ;; Debug info is updated, and now uses DEBUGF macro ;; |
|
- | 16 | ;; by hidnplayr@kolibrios.org ;; |
|
11 | ;; ;; |
17 | ;; ;; |
12 | ;; This driver is based on the PCNet32 driver from ;; |
18 | ;; This driver is based on the PCNet32 driver from ;; |
13 | ;; the etherboot 5.0.6 project. The copyright statement is ;; |
19 | ;; the etherboot 5.0.6 project. The copyright statement is ;; |
14 | ;; ;; |
20 | ;; ;; |
15 | ;; GNU GENERAL PUBLIC LICENSE ;; |
21 | ;; GNU GENERAL PUBLIC LICENSE ;; |
Line 20... | Line 26... | ||
20 | ;; ;; |
26 | ;; ;; |
21 | ;; See file COPYING for details ;; |
27 | ;; See file COPYING for details ;; |
22 | ;; ;; |
28 | ;; ;; |
23 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
29 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 24... | Line 30... | ||
24 | 30 | ||
Line 25... | Line -... | ||
25 | $Revision: 684 $ |
- | |
26 | - | ||
27 | - | ||
28 | ;macro PutStr X |
- | |
29 | ;{ |
- | |
30 | ; local .__xyz1 |
- | |
31 | ; local .__xyz2 |
- | |
32 | ; push esi |
- | |
33 | ; mov esi,.__xyz1 |
- | |
34 | ; call sys_msg_board_str |
- | |
35 | ; push ebx |
- | |
36 | ; mov ebx,1 |
- | |
37 | ; call delay_hs |
- | |
38 | ; pop ebx |
- | |
39 | ; jmp .__xyz2 |
- | |
40 | ;.__xyz1: |
- | |
41 | ; db X |
- | |
42 | ; db 13,10,0 |
- | |
43 | ;.__xyz2: |
31 | $Revision: 781 $ |
44 | ; pop esi |
32 | |
45 | ;} |
33 | |
46 | PCNET32_PORT_AUI equ 0x00 |
34 | PCNET32_PORT_AUI equ 0x00 |
47 | PCNET32_PORT_10BT equ 0x01 |
35 | PCNET32_PORT_10BT equ 0x01 |
48 | PCNET32_PORT_GPSI equ 0x02 |
36 | PCNET32_PORT_GPSI equ 0x02 |
49 | PCNET32_PORT_MII equ 0x03 |
37 | PCNET32_PORT_MII equ 0x03 |
50 | PCNET32_PORT_PORTSEL equ 0x03 |
38 | PCNET32_PORT_PORTSEL equ 0x03 |
51 | PCNET32_PORT_ASEL equ 0x04 |
39 | PCNET32_PORT_ASEL equ 0x04 |
- | 40 | PCNET32_PORT_100 equ 0x40 |
|
52 | PCNET32_PORT_100 equ 0x40 |
41 | PCNET32_PORT_FD equ 0x80 |
53 | PCNET32_PORT_FD equ 0x80 |
42 | PCNET32_DMA_MASK equ 0xffffffff |
- | 43 | ||
54 | PCNET32_DMA_MASK equ 0xffffffff |
44 | PCNET32_LOG_TX_BUFFERS equ 1 |
55 | PCNET32_LOG_TX_BUFFERS equ 1 |
45 | PCNET32_LOG_RX_BUFFERS equ 2 |
56 | PCNET32_LOG_RX_BUFFERS equ 2 |
46 | |
57 | PCNET32_TX_RING_SIZE equ (1 shl PCNET32_LOG_TX_BUFFERS) |
47 | PCNET32_TX_RING_SIZE equ (1 shl PCNET32_LOG_TX_BUFFERS) |
58 | PCNET32_TX_RING_MOD_MASK equ (PCNET32_TX_RING_SIZE-1) |
48 | PCNET32_TX_RING_MOD_MASK equ (PCNET32_TX_RING_SIZE-1) |
59 | PCNET32_TX_RING_LEN_BITS equ 0 |
49 | PCNET32_TX_RING_LEN_BITS equ 0 |
60 | PCNET32_RX_RING_SIZE equ (1 shl PCNET32_LOG_RX_BUFFERS) |
50 | PCNET32_RX_RING_SIZE equ (1 shl PCNET32_LOG_RX_BUFFERS) |
61 | PCNET32_RX_RING_MOD_MASK equ (PCNET32_RX_RING_SIZE-1) |
51 | PCNET32_RX_RING_MOD_MASK equ (PCNET32_RX_RING_SIZE-1) |
- | 52 | PCNET32_RX_RING_LEN_BITS equ (PCNET32_LOG_RX_BUFFERS shl 4) |
|
62 | PCNET32_RX_RING_LEN_BITS equ (PCNET32_LOG_RX_BUFFERS shl 4) |
53 | PCNET32_PKT_BUF_SZ equ 1544 |
63 | PCNET32_PKT_BUF_SZ equ 1544 |
54 | PCNET32_PKT_BUF_SZ_NEG equ 0xf9f8 |
64 | PCNET32_PKT_BUF_SZ_NEG equ 0xf9f8 |
55 | |
65 | pcnet32_txb equ (eth_data_start) |
56 | pcnet32_txb equ (eth_data_start) |
- | 57 | pcnet32_rxb equ ((pcnet32_txb+(PCNET32_PKT_BUF_SZ*PCNET32_TX_RING_SIZE)+0xf) and 0xfffffff0) |
|
66 | pcnet32_rxb equ ((pcnet32_txb+(PCNET32_PKT_BUF_SZ*PCNET32_TX_RING_SIZE)+0xf) and 0xfffffff0) |
58 | pcnet32_tx_ring equ ((pcnet32_rxb+(PCNET32_PKT_BUF_SZ*PCNET32_RX_RING_SIZE)+0xf) and 0xfffffff0) |
67 | pcnet32_tx_ring equ ((pcnet32_rxb+(PCNET32_PKT_BUF_SZ*PCNET32_RX_RING_SIZE)+0xf) and 0xfffffff0) |
59 | pcnet32_rx_ring equ ((pcnet32_tx_ring+(16*PCNET32_TX_RING_SIZE)+0xf) and 0xfffffff0) |
68 | pcnet32_rx_ring equ ((pcnet32_tx_ring+(16*PCNET32_TX_RING_SIZE)+0xf) and 0xfffffff0) |
60 | |
69 | virtual at ((pcnet32_rx_ring+(16*PCNET32_RX_RING_SIZE)+0xf) and 0xfffffff0) |
61 | virtual at ((pcnet32_rx_ring+(16*PCNET32_RX_RING_SIZE)+0xf) and 0xfffffff0) |
70 | pcnet32_private: |
62 | pcnet32_private: |
Line 87... | Line 79... | ||
87 | .ltint db ? |
79 | .ltint db ? |
88 | .dxsuflo db ? |
80 | .dxsuflo db ? |
89 | .fset db ? |
81 | .fset db ? |
90 | .fdx db ? |
82 | .fdx db ? |
91 | end virtual |
83 | end virtual |
- | 84 | ||
92 | virtual at 0 |
85 | virtual at 0 |
93 | pcnet32_rx_head: |
86 | pcnet32_rx_head: |
94 | .base dd ? |
87 | .base dd ? |
95 | .buf_length dw ? |
88 | .buf_length dw ? |
96 | .status dw ? |
89 | .status dw ? |
97 | .msg_length dd ? |
90 | .msg_length dd ? |
98 | .reserved dd ? |
91 | .reserved dd ? |
99 | end virtual |
92 | end virtual |
- | 93 | ||
100 | virtual at 0 |
94 | virtual at 0 |
101 | pcnet32_tx_head: |
95 | pcnet32_tx_head: |
102 | .base dd ? |
96 | .base dd ? |
103 | .length dw ? |
97 | .length dw ? |
104 | .status dw ? |
98 | .status dw ? |
Line 337... | Line 331... | ||
337 | dd pcnet32_dwio_read_rap |
331 | dd pcnet32_dwio_read_rap |
338 | dd pcnet32_dwio_write_rap |
332 | dd pcnet32_dwio_write_rap |
339 | dd pcnet32_dwio_reset |
333 | dd pcnet32_dwio_reset |
340 | endg |
334 | endg |
Line -... | Line 335... | ||
- | 335 | ||
- | 336 | ||
341 | 337 | ||
342 | pcnet32_init_ring: |
338 | pcnet32_init_ring: |
343 | mov [pcnet32_private.tx_full],0 |
339 | mov [pcnet32_private.tx_full],0 |
344 | mov [pcnet32_private.cur_rx],0 |
340 | mov [pcnet32_private.cur_rx],0 |
345 | mov [pcnet32_private.cur_tx],0 |
341 | mov [pcnet32_private.cur_tx],0 |
346 | mov [pcnet32_private.dirty_rx],0 |
342 | mov [pcnet32_private.dirty_rx],0 |
347 | mov [pcnet32_private.dirty_tx],0 |
343 | mov [pcnet32_private.dirty_tx],0 |
348 | mov edi,pcnet32_rx_ring |
344 | mov edi,pcnet32_rx_ring |
349 | mov ecx,PCNET32_RX_RING_SIZE |
345 | mov ecx,PCNET32_RX_RING_SIZE |
- | 346 | mov ebx,pcnet32_rxb |
|
350 | mov ebx,pcnet32_rxb |
347 | sub ebx,OS_BASE |
351 | .rx_init: |
348 | .rx_init: |
352 | mov [edi+pcnet32_rx_head.base],ebx |
349 | mov [edi+pcnet32_rx_head.base],ebx |
353 | mov [edi+pcnet32_rx_head.buf_length],word PCNET32_PKT_BUF_SZ_NEG |
350 | mov [edi+pcnet32_rx_head.buf_length],word PCNET32_PKT_BUF_SZ_NEG |
354 | mov [edi+pcnet32_rx_head.status],word 0x8000 |
351 | mov [edi+pcnet32_rx_head.status],word 0x8000 |
Line 367... | Line 364... | ||
367 | mov esi,node_addr |
364 | mov esi,node_addr |
368 | mov edi,pcnet32_private.phys_addr |
365 | mov edi,pcnet32_private.phys_addr |
369 | cld |
366 | cld |
370 | movsd |
367 | movsd |
371 | movsw |
368 | movsw |
- | 369 | mov eax,pcnet32_rx_ring |
|
- | 370 | sub eax,OS_BASE |
|
372 | mov dword [pcnet32_private.rx_ring],pcnet32_rx_ring |
371 | mov dword [pcnet32_private.rx_ring],eax |
- | 372 | ||
- | 373 | mov eax,pcnet32_tx_ring |
|
- | 374 | sub eax,OS_BASE |
|
373 | mov dword [pcnet32_private.tx_ring],pcnet32_tx_ring |
375 | mov dword [pcnet32_private.tx_ring],eax |
374 | ret |
376 | ret |
- | 377 | ||
- | 378 | ||
- | 379 | ||
375 | pcnet32_reset: |
380 | pcnet32_reset: |
376 | ; Reset PCNET32 |
381 | ; Reset PCNET32 |
377 | mov ebp,[io_addr] |
382 | mov ebp,[io_addr] |
378 | call dword [pcnet32_access.reset] |
383 | call dword [pcnet32_access.reset] |
379 | ; set 32bit mode |
384 | ; set 32bit mode |
Line 441... | Line 446... | ||
441 | jmp .L9 |
446 | jmp .L9 |
442 | .L6: |
447 | .L6: |
443 | test [pcnet32_private.options],PCNET32_PORT_ASEL |
448 | test [pcnet32_private.options],PCNET32_PORT_ASEL |
444 | jz .L9 |
449 | jz .L9 |
445 | mov ebx,32 |
450 | mov ebx,32 |
446 | ; PutStr "ASEL, enable auto-negotiation" |
451 | ; DEBUGF 1," K : ASEL, enable auto-negotiation\n" |
447 | call dword [pcnet32_access.read_bcr] |
452 | call dword [pcnet32_access.read_bcr] |
448 | and eax,not 0x98 |
453 | and eax,not 0x98 |
449 | or eax,0x20 |
454 | or eax,0x20 |
450 | call dword [pcnet32_access.write_bcr] |
455 | call dword [pcnet32_access.write_bcr] |
451 | .L9: |
456 | .L9: |
Line 463... | Line 468... | ||
463 | mov [pcnet32_private.filter],dword 0xffffffff |
468 | mov [pcnet32_private.filter],dword 0xffffffff |
464 | mov [pcnet32_private.filter+4],dword 0xffffffff |
469 | mov [pcnet32_private.filter+4],dword 0xffffffff |
465 | call pcnet32_init_ring |
470 | call pcnet32_init_ring |
466 | mov ebx,1 |
471 | mov ebx,1 |
467 | mov eax,pcnet32_private |
472 | mov eax,pcnet32_private |
- | 473 | sub eax,OS_BASE |
|
468 | and eax,0xffff |
474 | and eax,0xffff |
469 | call dword [pcnet32_access.write_csr] |
475 | call dword [pcnet32_access.write_csr] |
470 | mov eax,pcnet32_private |
476 | mov eax,pcnet32_private |
- | 477 | sub eax,OS_BASE |
|
471 | mov ebx,2 |
478 | mov ebx,2 |
472 | shr eax,16 |
479 | shr eax,16 |
473 | call dword [pcnet32_access.write_csr] |
480 | call dword [pcnet32_access.write_csr] |
474 | mov ebx,4 |
481 | mov ebx,4 |
475 | mov eax,0x0915 |
482 | mov eax,0x0915 |
Line 483... | Line 490... | ||
483 | call dword [pcnet32_access.read_csr] |
490 | call dword [pcnet32_access.read_csr] |
484 | test ax,0x100 |
491 | test ax,0x100 |
485 | jnz .L12 |
492 | jnz .L12 |
486 | loop .L11 |
493 | loop .L11 |
487 | .L12: |
494 | .L12: |
488 | ; PutStr "hardware reset" |
495 | ; DEBUGF 1," K : hardware reset\n" |
489 | xor ebx,ebx |
496 | xor ebx,ebx |
490 | mov eax,0x0002 |
497 | mov eax,0x0002 |
491 | call dword [pcnet32_access.write_csr] |
498 | call dword [pcnet32_access.write_csr] |
492 | xor ebx,ebx |
499 | xor ebx,ebx |
493 | call dword [pcnet32_access.read_csr] |
500 | call dword [pcnet32_access.read_csr] |
494 | ; PutStr "PCNET reset complete" |
501 | ; DEBUGF 1," K : PCNET reset complete\n" |
495 | ret |
502 | ret |
- | 503 | ||
- | 504 | ||
- | 505 | ||
496 | pcnet32_adjust_pci_device: |
506 | pcnet32_adjust_pci_device: |
497 | ;*******Get current setting************************ |
507 | ;*******Get current setting************************ |
498 | mov al, 2 ;read a word |
508 | mov al, 2 ;read a word |
499 | mov bh, [pci_dev] |
509 | mov bh, [pci_dev] |
500 | mov ah, [pci_bus] |
510 | mov ah, [pci_bus] |
Line 532... | Line 542... | ||
532 | ; mov bl, 0x0D ;to Lantency Timer Register |
542 | ; mov bl, 0x0D ;to Lantency Timer Register |
533 | ; call pci_write_reg |
543 | ; call pci_write_reg |
534 | ;******Check latency setting*********** |
544 | ;******Check latency setting*********** |
535 | pcnet32_adjust_pci_device_Done: |
545 | pcnet32_adjust_pci_device_Done: |
536 | ret |
546 | ret |
- | 547 | ||
- | 548 | ||
- | 549 | ||
- | 550 | ||
537 | pcnet32_probe: |
551 | pcnet32_probe: |
538 | mov ebp,[io_addr] |
552 | mov ebp,[io_addr] |
539 | call pcnet32_wio_reset |
553 | call pcnet32_wio_reset |
540 | xor ebx,ebx |
554 | xor ebx,ebx |
541 | call pcnet32_wio_read_csr |
555 | call pcnet32_wio_read_csr |
542 | cmp eax,4 |
556 | cmp eax,4 |
543 | jne .try_dwio |
557 | jne .try_dwio |
544 | call pcnet32_wio_check |
558 | call pcnet32_wio_check |
545 | and al,al |
559 | and al,al |
546 | jz .try_dwio |
560 | jz .try_dwio |
547 | ; PutStr "Using WIO" |
561 | ; DEBUGF 1," K : Using WIO\n" |
548 | mov esi,pcnet32_wio |
562 | mov esi,pcnet32_wio |
549 | jmp .L1 |
563 | jmp .L1 |
550 | .try_dwio: |
564 | .try_dwio: |
551 | call pcnet32_dwio_reset |
565 | call pcnet32_dwio_reset |
552 | xor ebx,ebx |
566 | xor ebx,ebx |
Line 554... | Line 568... | ||
554 | cmp eax,4 |
568 | cmp eax,4 |
555 | jne .no_dev |
569 | jne .no_dev |
556 | call pcnet32_dwio_check |
570 | call pcnet32_dwio_check |
557 | and al,al |
571 | and al,al |
558 | jz .no_dev |
572 | jz .no_dev |
559 | ; PutStr "Using DWIO" |
573 | ; DEBUGF 1," K : Using DWIO\n" |
560 | mov esi,pcnet32_dwio |
574 | mov esi,pcnet32_dwio |
561 | jmp .L1 |
575 | jmp .L1 |
562 | .no_dev: |
576 | .no_dev: |
563 | ; PutStr "PCNET32 not found" |
577 | DEBUGF 1," K : PCNET32 not found\n" |
564 | ret |
578 | ret |
565 | .L1: |
579 | .L1: |
566 | mov edi,pcnet32_access |
580 | mov edi,pcnet32_access |
567 | mov ecx,7 |
581 | mov ecx,7 |
568 | cld |
582 | cld |
Line 579... | Line 593... | ||
579 | cmp ecx,3 |
593 | cmp ecx,3 |
580 | jne .no_dev |
594 | jne .no_dev |
581 | shr eax,12 |
595 | shr eax,12 |
582 | and eax,0xffff |
596 | and eax,0xffff |
583 | mov [pcnet32_private.chip_version],eax |
597 | mov [pcnet32_private.chip_version],eax |
584 | ; PutStr "PCNET32 chip version OK" |
598 | ; DEBUGF 1," K : PCNET32 chip version OK\n" |
585 | mov [pcnet32_private.fdx],0 |
599 | mov [pcnet32_private.fdx],0 |
586 | mov [pcnet32_private.mii],0 |
600 | mov [pcnet32_private.mii],0 |
587 | mov [pcnet32_private.fset],0 |
601 | mov [pcnet32_private.fset],0 |
588 | mov [pcnet32_private.dxsuflo],0 |
602 | mov [pcnet32_private.dxsuflo],0 |
589 | mov [pcnet32_private.ltint],0 |
603 | mov [pcnet32_private.ltint],0 |
Line 602... | Line 616... | ||
602 | je .L7 |
616 | je .L7 |
603 | cmp eax,0x2626 |
617 | cmp eax,0x2626 |
604 | je .L8 |
618 | je .L8 |
605 | cmp eax,0x2627 |
619 | cmp eax,0x2627 |
606 | je .L9 |
620 | je .L9 |
607 | ; PutStr "Invalid chip rev" |
621 | DEBUGF 1," K : Invalid chip rev\n" |
608 | jmp .no_dev |
622 | jmp .no_dev |
609 | .L2: |
623 | .L2: |
610 | ; PutStr "PCnet/PCI 79C970" |
624 | ; DEBUGF 1," K : PCnet/PCI 79C970\n" |
611 | jmp .L10 |
625 | jmp .L10 |
612 | .L3: |
626 | .L3: |
613 | ; PutStr "PCnet/PCI 79C970" |
627 | ; DEBUGF 1," K : PCnet/PCI 79C970\n" |
614 | jmp .L10 |
628 | jmp .L10 |
615 | .L4: |
629 | .L4: |
616 | ; PutStr "PCnet/PCI II 79C970A" |
630 | ; DEBUGF 1," K : PCnet/PCI II 79C970A\n" |
617 | mov [pcnet32_private.fdx],1 |
631 | mov [pcnet32_private.fdx],1 |
618 | jmp .L10 |
632 | jmp .L10 |
619 | .L5: |
633 | .L5: |
620 | ; PutStr "PCnet/FAST 79C971" |
634 | ; DEBUGF 1," K : PCnet/FAST 79C971\n" |
621 | mov [pcnet32_private.fdx],1 |
635 | mov [pcnet32_private.fdx],1 |
622 | mov [pcnet32_private.mii],1 |
636 | mov [pcnet32_private.mii],1 |
623 | mov [pcnet32_private.fset],1 |
637 | mov [pcnet32_private.fset],1 |
624 | mov [pcnet32_private.ltint],1 |
638 | mov [pcnet32_private.ltint],1 |
625 | jmp .L10 |
639 | jmp .L10 |
626 | .L6: |
640 | .L6: |
627 | ; PutStr "PCnet/FAST+ 79C972" |
641 | ; DEBUGF 1," K : PCnet/FAST+ 79C972\n" |
628 | mov [pcnet32_private.fdx],1 |
642 | mov [pcnet32_private.fdx],1 |
629 | mov [pcnet32_private.mii],1 |
643 | mov [pcnet32_private.mii],1 |
630 | mov [pcnet32_private.fset],1 |
644 | mov [pcnet32_private.fset],1 |
631 | jmp .L10 |
645 | jmp .L10 |
632 | .L7: |
646 | .L7: |
633 | ; PutStr "PCnet/FAST III 79C973" |
647 | ; DEBUGF 1," K : PCnet/FAST III 79C973\n" |
634 | mov [pcnet32_private.fdx],1 |
648 | mov [pcnet32_private.fdx],1 |
635 | mov [pcnet32_private.mii],1 |
649 | mov [pcnet32_private.mii],1 |
636 | jmp .L10 |
650 | jmp .L10 |
637 | .L8: |
651 | .L8: |
638 | ; PutStr "PCnet/Home 79C978" |
652 | ; DEBUGF 1," K : PCnet/Home 79C978\n" |
639 | mov [pcnet32_private.fdx],1 |
653 | mov [pcnet32_private.fdx],1 |
640 | mov ebx,49 |
654 | mov ebx,49 |
641 | call dword [pcnet32_access.read_bcr] |
655 | call dword [pcnet32_access.read_bcr] |
642 | call dword [pcnet32_access.write_bcr] |
656 | call dword [pcnet32_access.write_bcr] |
643 | jmp .L10 |
657 | jmp .L10 |
644 | .L9: |
658 | .L9: |
645 | ; PutStr "PCnet/FAST III 79C975" |
659 | ; DEBUGF 1," K : PCnet/FAST III 79C975\n" |
646 | mov [pcnet32_private.fdx],1 |
660 | mov [pcnet32_private.fdx],1 |
647 | mov [pcnet32_private.mii],1 |
661 | mov [pcnet32_private.mii],1 |
648 | .L10: |
662 | .L10: |
649 | cmp [pcnet32_private.fset],1 |
663 | cmp [pcnet32_private.fset],1 |
650 | jne .L11 |
664 | jne .L11 |
Line 667... | Line 681... | ||
667 | .Lmac: |
681 | .Lmac: |
668 | in al,dx |
682 | in al,dx |
669 | stosb |
683 | stosb |
670 | inc edx |
684 | inc edx |
671 | loop .Lmac |
685 | loop .Lmac |
672 | ; PutStr "MAC read" |
686 | ; DEBUGF 1," K : MAC read\n" |
673 | call pcnet32_adjust_pci_device |
687 | call pcnet32_adjust_pci_device |
674 | ; PutStr "PCI done" |
688 | ; DEBUGF 1," K : PCI done\n" |
675 | mov eax,PCNET32_PORT_ASEL |
689 | mov eax,PCNET32_PORT_ASEL |
676 | mov [pcnet32_private.options],eax |
690 | mov [pcnet32_private.options],eax |
677 | mov [pcnet32_private.mode],word 0x0003 |
691 | mov [pcnet32_private.mode],word 0x0003 |
678 | mov [pcnet32_private.tlen_rlen],word (PCNET32_TX_RING_LEN_BITS or PCNET32_RX_RING_LEN_BITS) |
692 | mov [pcnet32_private.tlen_rlen],word (PCNET32_TX_RING_LEN_BITS or PCNET32_RX_RING_LEN_BITS) |
679 | mov esi,node_addr |
693 | mov esi,node_addr |
Line 681... | Line 695... | ||
681 | cld |
695 | cld |
682 | movsd |
696 | movsd |
683 | movsw |
697 | movsw |
684 | mov [pcnet32_private.filter],dword 0 |
698 | mov [pcnet32_private.filter],dword 0 |
685 | mov [pcnet32_private.filter+4],dword 0 |
699 | mov [pcnet32_private.filter+4],dword 0 |
- | 700 | mov eax,pcnet32_rx_ring |
|
- | 701 | sub eax,OS_BASE |
|
686 | mov dword [pcnet32_private.rx_ring],pcnet32_rx_ring |
702 | mov dword [pcnet32_private.rx_ring],eax |
- | 703 | ||
- | 704 | mov eax,pcnet32_tx_ring |
|
- | 705 | sub eax,OS_BASE |
|
687 | mov dword [pcnet32_private.tx_ring],pcnet32_tx_ring |
706 | mov dword [pcnet32_private.tx_ring],eax |
688 | ; PutStr "Switching to 32" |
707 | ; DEBUGF 1," K : Switching to 32\n" |
689 | mov ebx,20 |
708 | mov ebx,20 |
690 | mov eax,2 |
709 | mov eax,2 |
691 | call dword [pcnet32_access.write_bcr] |
710 | call dword [pcnet32_access.write_bcr] |
692 | mov ebx,1 |
711 | mov ebx,1 |
693 | mov eax,(pcnet32_private and 0xffff) |
712 | mov eax,(pcnet32_private and 0xffff) |
Line 702... | Line 721... | ||
702 | call delay_ms |
721 | call delay_ms |
703 | call pcnet32_reset |
722 | call pcnet32_reset |
704 | mov eax, [pci_data] |
723 | mov eax, [pci_data] |
705 | mov [eth_status], eax |
724 | mov [eth_status], eax |
706 | ret |
725 | ret |
- | 726 | ||
- | 727 | ||
- | 728 | ||
707 | pcnet32_poll: |
729 | pcnet32_poll: |
708 | xor eax,eax |
730 | xor ax,ax |
709 | mov [eth_rx_data_len],ax |
731 | mov [eth_rx_data_len],ax |
710 | mov eax,[pcnet32_private.cur_rx] |
732 | mov eax,[pcnet32_private.cur_rx] |
711 | and eax,PCNET32_RX_RING_MOD_MASK |
733 | and eax,PCNET32_RX_RING_MOD_MASK |
712 | mov ebx,eax |
734 | mov ebx,eax |
713 | imul esi,eax,PCNET32_PKT_BUF_SZ |
735 | imul esi,eax,PCNET32_PKT_BUF_SZ |
Line 717... | Line 739... | ||
717 | mov cx,[ebx+pcnet32_rx_head.status] |
739 | mov cx,[ebx+pcnet32_rx_head.status] |
718 | test cx,0x8000 |
740 | test cx,0x8000 |
719 | jnz .L1 |
741 | jnz .L1 |
720 | cmp ch,3 |
742 | cmp ch,3 |
721 | jne .L1 |
743 | jne .L1 |
722 | ; PutStr "PCNETRX" |
- | |
723 | mov ecx,[ebx+pcnet32_rx_head.msg_length] |
744 | mov ecx,[ebx+pcnet32_rx_head.msg_length] |
724 | and ecx,0xfff |
745 | and ecx,0xfff |
725 | sub ecx,4 |
746 | sub ecx,4 |
726 | mov [eth_rx_data_len],cx |
747 | mov [eth_rx_data_len],cx |
- | 748 | ; DEBUGF 1," K : PCNETRX: %ub\n",cx |
|
727 | push ecx |
749 | push ecx |
728 | shr ecx,2 |
750 | shr ecx,2 |
729 | mov edi,Ether_buffer |
751 | mov edi,Ether_buffer |
730 | cld |
752 | cld |
731 | rep movsd |
753 | rep movsd |
Line 735... | Line 757... | ||
735 | mov [ebx+pcnet32_rx_head.buf_length],word PCNET32_PKT_BUF_SZ_NEG |
757 | mov [ebx+pcnet32_rx_head.buf_length],word PCNET32_PKT_BUF_SZ_NEG |
736 | or [ebx+pcnet32_rx_head.status],word 0x8000 |
758 | or [ebx+pcnet32_rx_head.status],word 0x8000 |
737 | inc [pcnet32_private.cur_rx] |
759 | inc [pcnet32_private.cur_rx] |
738 | .L1: |
760 | .L1: |
739 | ret |
761 | ret |
- | 762 | ||
- | 763 | ||
- | 764 | ||
- | 765 | ||
740 | ; Pointer to 48 bit destination address in edi |
766 | ; Pointer to 48 bit destination address in edi |
741 | ; Type of packet in bx |
767 | ; Type of packet in bx |
742 | ; size of packet in ecx |
768 | ; size of packet in ecx |
743 | ; pointer to packet data in esi |
769 | ; pointer to packet data in esi |
744 | pcnet32_xmit: |
770 | pcnet32_xmit: |
745 | push edi |
771 | push edi |
746 | push esi |
772 | push esi |
747 | push ebx |
773 | push ebx |
748 | push ecx |
774 | push ecx |
749 | ; PutStr "PCNETTX" |
775 | ; DEBUGF 1," K : PCNETTX\n" |
750 | mov esi,edi |
776 | mov esi,edi |
751 | mov edi,[pcnet32_private.cur_tx] |
777 | mov edi,[pcnet32_private.cur_tx] |
752 | imul edi,PCNET32_PKT_BUF_SZ |
778 | imul edi,PCNET32_PKT_BUF_SZ |
753 | add edi,pcnet32_txb ; edi=ptxb |
779 | add edi,pcnet32_txb ; edi=ptxb |
754 | mov eax,edi |
780 | mov eax,edi |
Line 788... | Line 814... | ||
788 | mov cx,60 |
814 | mov cx,60 |
789 | .L1: |
815 | .L1: |
790 | neg cx |
816 | neg cx |
791 | mov [edi+pcnet32_tx_head.length],cx |
817 | mov [edi+pcnet32_tx_head.length],cx |
792 | mov [edi+pcnet32_tx_head.misc],dword 0 |
818 | mov [edi+pcnet32_tx_head.misc],dword 0 |
- | 819 | sub eax,OS_BASE |
|
793 | mov [edi+pcnet32_tx_head.base],eax |
820 | mov [edi+pcnet32_tx_head.base],eax |
794 | mov [edi+pcnet32_tx_head.status],word 0x8300 |
821 | mov [edi+pcnet32_tx_head.status],word 0x8300 |
795 | ; trigger an immediate send poll |
822 | ; trigger an immediate send poll |
796 | mov ebx,0 |
823 | mov ebx,0 |
797 | mov eax,0x0008 ; 0x0048 |
824 | mov eax,0x0008 ; 0x0048 |
Line 809... | Line 836... | ||
809 | jb .L4 |
836 | jb .L4 |
810 | mov esi,10 |
837 | mov esi,10 |
811 | call delay_ms |
838 | call delay_ms |
812 | jnz .L2 |
839 | jnz .L2 |
813 | .L4: |
840 | .L4: |
814 | ; PutStr "PCNET: Send timeout" |
841 | DEBUGF 1," K : PCNET: Send timeout\n" |
815 | .L3: |
842 | .L3: |
816 | mov dword [edi+pcnet32_tx_head.base],0 |
843 | mov dword [edi+pcnet32_tx_head.base],0 |
817 | pop ecx |
844 | pop ecx |
818 | pop ebx |
845 | pop ebx |
819 | pop esi |
846 | pop esi |