Rev 7809 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7809 | Rev 9147 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
2 | ;; ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2018. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2021. 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 | ;; i8254x driver for KolibriOS ;; |
6 | ;; i8254x driver for KolibriOS ;; |
7 | ;; ;; |
7 | ;; ;; |
8 | ;; based on i8254x.asm from baremetal os ;; |
8 | ;; based on i8254x.asm from baremetal os ;; |
Line 747... | Line 747... | ||
747 | ;; ;; |
747 | ;; ;; |
748 | ;; In: ebx = pointer to device structure ;; |
748 | ;; In: ebx = pointer to device structure ;; |
749 | ;; Out: eax = 0 on success ;; |
749 | ;; Out: eax = 0 on success ;; |
750 | ;; ;; |
750 | ;; ;; |
751 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
751 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
752 | 752 | align 16 |
|
753 | proc transmit stdcall bufferptr |
753 | proc transmit stdcall bufferptr |
Line 754... | Line 754... | ||
754 | 754 | ||
755 | pushf |
- | |
Line 756... | Line 755... | ||
756 | cli |
755 | spin_lock_irqsave |
757 | 756 | ||
758 | mov esi, [bufferptr] |
757 | mov esi, [bufferptr] |
759 | DEBUGF 1,"Transmitting packet, buffer:%x, size:%u\n", [bufferptr], [esi + NET_BUFF.length] |
758 | DEBUGF 1,"Transmitting packet, buffer:%x, size:%u\n", [bufferptr], [esi + NET_BUFF.length] |
Line 799... | Line 798... | ||
799 | add dword[ebx + device.bytes_tx], eax |
798 | add dword[ebx + device.bytes_tx], eax |
800 | adc dword[ebx + device.bytes_tx + 4], 0 |
799 | adc dword[ebx + device.bytes_tx + 4], 0 |
Line 801... | Line 800... | ||
801 | 800 | ||
Line 802... | Line 801... | ||
802 | call clean_tx |
801 | call clean_tx |
803 | 802 | ||
804 | popf |
803 | spin_unlock_irqrestore |
Line 805... | Line 804... | ||
805 | xor eax, eax |
804 | xor eax, eax |
806 | ret |
805 | ret |
Line 807... | Line 806... | ||
807 | 806 | ||
808 | .fail: |
807 | .fail: |
809 | call clean_tx |
808 | call clean_tx |
810 | 809 | ||
811 | DEBUGF 2,"Send failed\n" |
810 | DEBUGF 2,"Send failed\n" |
Line 812... | Line 811... | ||
812 | invoke NetFree, [bufferptr] |
811 | invoke NetFree, [bufferptr] |
Line 820... | Line 819... | ||
820 | ;;;;;;;;;;;;;;;;;;;;;;; |
819 | ;;;;;;;;;;;;;;;;;;;;;;; |
821 | ;; ;; |
820 | ;; ;; |
822 | ;; Interrupt handler ;; |
821 | ;; Interrupt handler ;; |
823 | ;; ;; |
822 | ;; ;; |
824 | ;;;;;;;;;;;;;;;;;;;;;;; |
823 | ;;;;;;;;;;;;;;;;;;;;;;; |
825 | - | ||
826 | align 4 |
824 | align 16 |
827 | int_handler: |
825 | int_handler: |
Line 828... | Line 826... | ||
828 | 826 | ||
Line 829... | Line 827... | ||
829 | push ebx esi edi |
827 | push ebx esi edi |
830 | 828 | ||
- | 829 | mov ebx, [esp+4*4] |
|
831 | DEBUGF 1,"INT\n" |
830 | DEBUGF 1,"INT for 0x%x\n", ebx |
Line 832... | Line -... | ||
832 | ;------------------------------------------- |
- | |
833 | ; Find pointer of device wich made IRQ occur |
- | |
834 | - | ||
835 | mov ecx, [devices] |
- | |
836 | test ecx, ecx |
- | |
837 | jz .nothing |
- | |
838 | mov esi, device_list |
831 | |
839 | .nextdevice: |
832 | ; TODO? if we are paranoid, we can check that the value from ebx is present in the current device_list |
- | 833 | ||
- | 834 | mov edi, [ebx + device.mmio_addr] |
|
840 | mov ebx, [esi] |
835 | mov eax, [edi + REG_ICR] |
841 | mov edi, [ebx + device.mmio_addr] |
836 | cmp eax, 0xffffffff ; if so, hardware is no longer present |
842 | mov eax, [edi + REG_ICR] |
- | |
843 | test eax, eax |
- | |
844 | jnz .got_it |
- | |
845 | .continue: |
- | |
846 | add esi, 4 |
- | |
847 | dec ecx |
- | |
848 | jnz .nextdevice |
- | |
849 | .nothing: |
- | |
850 | pop edi esi ebx |
- | |
Line 851... | Line -... | ||
851 | xor eax, eax |
- | |
852 | 837 | je .nothing ; |
|
Line 853... | Line 838... | ||
853 | ret |
838 | test eax, eax |
854 | 839 | jz .nothing |
|
Line 855... | Line 840... | ||
855 | .got_it: |
840 | |
Line 941... | Line 926... | ||
941 | DEBUGF 1,"Transmit done\n" |
926 | DEBUGF 1,"Transmit done\n" |
Line 942... | Line 927... | ||
942 | 927 | ||
Line 943... | Line 928... | ||
943 | ; call clean_tx |
928 | ; call clean_tx |
- | 929 | ||
944 | 930 | .no_tx: |
|
945 | .no_tx: |
931 | |
946 | pop edi esi ebx |
932 | pop edi esi ebx |
947 | xor eax, eax |
933 | xor eax, eax |
Line -... | Line 934... | ||
- | 934 | inc eax |
|
- | 935 | ret |
|
- | 936 | ||
- | 937 | .nothing: |
|
- | 938 | pop edi esi ebx |
|
- | 939 | xor eax, eax |
|
Line 948... | Line 940... | ||
948 | inc eax |
940 | |
Line 949... | Line 941... | ||
949 | ret |
941 | ret |