Rev 465 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 465 | Rev 562 | ||
---|---|---|---|
Line 14... | Line 14... | ||
14 | API_VERSION equ 0x01000100 |
14 | API_VERSION equ 0x01000100 |
Line 15... | Line 15... | ||
15 | 15 | ||
Line 16... | Line 16... | ||
16 | DEBUG equ 1 |
16 | DEBUG equ 1 |
- | 17 | ||
Line 17... | Line 18... | ||
17 | 18 | REMAP_IRQ equ 0 |
|
18 | REMAP_IRQ equ 0 |
19 | IRQ_LINE equ 0 |
19 | 20 | ||
20 | ;irq 0,1,2,8,12,13 íåäîñòóïíû |
21 | ;irq 0,1,2,8,12,13 íåäîñòóïíû |
Line 21... | Line -... | ||
21 | ; FEDCBA9876543210 |
- | |
Line 22... | Line 22... | ||
22 | VALID_IRQ equ 1100111011111000b |
22 | ; FEDCBA9876543210 |
Line 23... | Line 23... | ||
23 | ATTCH_IRQ equ 0000111010101000b |
23 | VALID_IRQ equ 1100111011111000b |
24 | 24 | ATTCH_IRQ equ 0000111010101000b |
|
Line 280... | Line 280... | ||
280 | IOCTL IOCTL |
280 | IOCTL IOCTL |
281 | end virtual |
281 | end virtual |
Line 282... | Line 282... | ||
282 | 282 | ||
Line 283... | Line -... | ||
283 | EVENT_NOTIFY equ 0x00000200 |
- | |
284 | - | ||
285 | OS_BASE equ 0x80000000 |
- | |
286 | SLOT_BASE equ OS_BASE+0x0080000 |
283 | EVENT_NOTIFY equ 0x00000200 |
287 | 284 | ||
288 | public START |
285 | public START |
Line 289... | Line 286... | ||
289 | public service_proc |
286 | public service_proc |
Line 315... | Line 312... | ||
315 | 312 | ||
316 | call init_controller |
313 | call init_controller |
317 | test eax, eax |
314 | test eax, eax |
Line 318... | Line 315... | ||
318 | jz .fail |
315 | jz .fail |
319 | 316 | ||
320 | if DEBUG |
317 | ; if DEBUG |
321 | mov esi, msgInitCodec |
318 | ; mov esi, msgInitCodec |
Line 322... | Line 319... | ||
322 | call SysMsgBoardStr |
319 | ; call SysMsgBoardStr |
323 | end if |
320 | ; end if |
324 | 321 | ||
Line 325... | Line -... | ||
325 | call init_codec |
- | |
326 | test eax, eax |
- | |
327 | jz .fail |
- | |
328 | - | ||
329 | if DEBUG |
- | |
330 | mov esi, [codec.ac_vendor_ids] |
- | |
331 | call SysMsgBoardStr |
- | |
332 | - | ||
333 | mov esi, [codec.chip_ids] |
322 | call init_codec |
334 | call SysMsgBoardStr |
323 | test eax, eax |
Line 335... | Line 324... | ||
335 | end if |
324 | jz .fail |
336 | 325 | ||
Line 675... | Line 664... | ||
675 | mov ebx, [edi+4] |
664 | mov ebx, [edi+4] |
676 | mov [ctrl.ctrl_ids], ebx |
665 | mov [ctrl.ctrl_ids], ebx |
677 | mov esi, [edi+8] |
666 | mov esi, [edi+8] |
678 | mov [ctrl.ctrl_setup], esi |
667 | mov [ctrl.ctrl_setup], esi |
Line 679... | Line 668... | ||
679 | 668 | ||
680 | cmp ebx, VID_INTEL |
669 | cmp edx, VID_INTEL |
681 | jne @F |
670 | jne @F |
682 | mov [ctrl.vendor_ids], msg_Intel |
671 | mov [ctrl.vendor_ids], msg_Intel |
683 | ret |
672 | ret |
684 | @@: |
673 | @@: |
685 | cmp ebx, VID_NVIDIA |
674 | cmp edx, VID_NVIDIA |
686 | jne @F |
675 | jne @F |
687 | mov [ctrl.vendor_ids], msg_NVidia |
- | |
688 | @@: |
- | |
689 | mov [ctrl.vendor_ids], 0 ;something wrong ? |
676 | mov [ctrl.vendor_ids], msg_NVidia |
- | 677 | ret |
|
690 | ret |
678 | @@: |
691 | .err: |
679 | .err: |
- | 680 | xor eax, eax |
|
692 | xor eax, eax |
681 | mov [ctrl.vendor_ids], eax ;something wrong ? |
693 | ret |
682 | ret |
Line 694... | Line 683... | ||
694 | endp |
683 | endp |
695 | 684 | ||
Line 740... | Line 729... | ||
740 | and eax, 0xFFFF |
729 | and eax, 0xFFFF |
741 | mov [ctrl.pci_cmd], eax |
730 | mov [ctrl.pci_cmd], eax |
742 | shr ebx, 16 |
731 | shr ebx, 16 |
743 | mov [ctrl.pci_stat], ebx |
732 | mov [ctrl.pci_stat], ebx |
Line -... | Line 733... | ||
- | 733 | ||
- | 734 | mov esi, msgPciCmd |
|
- | 735 | call SysMsgBoardStr |
|
- | 736 | call dword2str |
|
- | 737 | call SysMsgBoardStr |
|
- | 738 | ||
- | 739 | mov esi, msgPciStat |
|
- | 740 | call SysMsgBoardStr |
|
- | 741 | mov eax, [ctrl.pci_stat] |
|
- | 742 | call dword2str |
|
- | 743 | call SysMsgBoardStr |
|
- | 744 | ||
- | 745 | mov esi, msgMixIsaIo |
|
- | 746 | call SysMsgBoardStr |
|
744 | 747 | ||
- | 748 | stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10 |
|
- | 749 | ||
- | 750 | call dword2str |
|
- | 751 | call SysMsgBoardStr |
|
745 | stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10 |
752 | |
746 | and eax,0xFFFE |
753 | and eax,0xFFFE |
Line -... | Line 754... | ||
- | 754 | mov [ctrl.codec_io_base], eax |
|
- | 755 | ||
- | 756 | mov esi, msgCtrlIsaIo |
|
747 | mov [ctrl.codec_io_base], eax |
757 | call SysMsgBoardStr |
- | 758 | ||
- | 759 | stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x14 |
|
- | 760 | ||
- | 761 | call dword2str |
|
748 | 762 | call SysMsgBoardStr |
|
749 | stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x14 |
763 | |
Line -... | Line 764... | ||
- | 764 | and eax, 0xFFC0 |
|
- | 765 | mov [ctrl.ctrl_io_base], eax |
|
- | 766 | ||
750 | and eax, 0xFFC0 |
767 | mov esi, msgMixMMIo |
751 | mov [ctrl.ctrl_io_base], eax |
768 | call SysMsgBoardStr |
Line -... | Line 769... | ||
- | 769 | ||
- | 770 | stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x18 |
|
- | 771 | mov [ctrl.codec_mem_base], eax |
|
- | 772 | ||
- | 773 | call dword2str |
|
- | 774 | call SysMsgBoardStr |
|
752 | 775 | ||
753 | stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x18 |
776 | mov esi, msgCtrlMMIo |
Line -... | Line 777... | ||
- | 777 | call SysMsgBoardStr |
|
- | 778 | ||
- | 779 | stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x1C |
|
754 | mov [ctrl.codec_mem_base], eax |
780 | mov [ctrl.ctrl_mem_base], eax |
755 | 781 | ||
756 | stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x1C |
782 | call dword2str |
Line 757... | Line 783... | ||
757 | mov [ctrl.ctrl_mem_base], eax |
783 | call SysMsgBoardStr |
Line 853... | Line 879... | ||
853 | mov esi, msgStatus |
879 | mov esi, msgStatus |
854 | call SysMsgBoardStr |
880 | call SysMsgBoardStr |
Line 855... | Line 881... | ||
855 | 881 | ||
856 | mov edx, CTRL_STAT |
882 | mov edx, CTRL_STAT |
857 | call [ctrl.ctrl_read32] |
- | |
- | 883 | call [ctrl.ctrl_read32] |
|
858 | 884 | push eax |
|
859 | call dword2str |
885 | call dword2str |
- | 886 | call SysMsgBoardStr |
|
- | 887 | pop eax |
|
- | 888 | cmp eax, 0xFFFFFFFF |
|
Line 860... | Line 889... | ||
860 | call SysMsgBoardStr |
889 | je .err |
861 | 890 | ||
Line 862... | Line 891... | ||
862 | test eax, CTRL_ST_CREADY |
891 | test eax, CTRL_ST_CREADY |
863 | jnz .ready |
892 | jnz .ready |
864 | 893 | ||
Line -... | Line 894... | ||
- | 894 | call reset_codec |
|
865 | call reset_codec |
895 | test eax, eax |
866 | and eax, eax |
896 | jz .err |
Line 867... | Line 897... | ||
867 | jz .err |
897 | |
868 | 898 | .ready: |
|
869 | xor edx, edx ;ac_reg_0 |
899 | xor edx, edx ;ac_reg_0 |
Line 870... | Line 900... | ||
870 | call [ctrl.codec_write16] |
900 | call [ctrl.codec_write16] |
871 | 901 | ||
- | 902 | xor eax, eax |
|
- | 903 | mov edx, CODEC_REG_POWERDOWN |
|
- | 904 | call [ctrl.codec_write16] |
|
872 | xor eax, eax |
905 | |
873 | mov edx, CODEC_REG_POWERDOWN |
906 | mov [counter], 200 ; total 200*5 ms = 1s |
874 | call [ctrl.codec_write16] |
907 | .wait: |
875 | 908 | mov eax, 5000 ; wait 5 ms |
|
876 | mov [counter], 200 ; total 200*5 ms = 1s |
909 | call StallExec |
Line 877... | Line -... | ||
877 | .wait: |
- | |
878 | mov edx, CODEC_REG_POWERDOWN |
- | |
879 | call [ctrl.codec_read16] |
910 | |
880 | and eax, 0x0F |
911 | mov edx, CODEC_REG_POWERDOWN |
881 | cmp eax, 0x0F |
912 | call [ctrl.codec_read16] |
882 | jz .ready |
913 | and eax, 0x0F |
883 | 914 | cmp eax, 0x0F |
|
884 | mov eax, 5000 ; wait 5 ms |
915 | jz .done |
885 | call StallExec |
916 | |
886 | sub [counter] , 1 |
917 | sub [counter] , 1 |
887 | jnz .wait |
918 | jnz .wait |
888 | .err: |
919 | .err: |
889 | xor eax, eax ; timeout error |
920 | xor eax, eax ; timeout error |
Line 951... | Line 982... | ||
951 | mov [counter], 10 ; total 10*100 ms = 1s |
982 | mov [counter], 10 ; total 10*100 ms = 1s |
952 | .wait: |
983 | .wait: |
953 | mov eax, 100000 ; wait 100 ms |
984 | mov eax, 100000 ; wait 100 ms |
954 | call StallExec |
985 | call StallExec |
Line 955... | Line 986... | ||
955 | 986 | ||
956 | mov edx, GLOB_CTRL |
987 | mov edx, CTRL_STAT |
957 | call [ctrl.ctrl_read32] |
988 | call [ctrl.ctrl_read32] |
958 | test eax, 4 |
989 | test eax, CTRL_ST_CREADY |
- | 990 | jnz .ok |
|
959 | jz .ok |
991 | |
960 | sub [counter], 1 |
992 | dec [counter] |
Line 961... | Line 993... | ||
961 | jnz .wait |
993 | jnz .wait |
962 | 994 | ||
963 | if DEBUG |
995 | if DEBUG |
964 | mov esi, msgWRFail |
996 | mov esi, msgWRFail |
965 | call SysMsgBoardStr |
997 | call SysMsgBoardStr |
966 | end if |
998 | end if |
967 | 999 | .fail: |
|
968 | stc |
1000 | stc |
969 | ret |
- | |
970 | .ok: |
- | |
971 | mov edx, CTRL_STAT |
- | |
972 | call [ctrl.ctrl_read32] |
- | |
973 | and eax, CTRL_ST_CREADY |
1001 | ret |
974 | jz .fail |
1002 | .ok: |
975 | clc |
- | |
976 | ret |
- | |
977 | .fail: |
- | |
978 | stc |
1003 | clc |
Line 979... | Line 1004... | ||
979 | ret |
1004 | ret |
980 | endp |
1005 | endp |
981 | 1006 | ||
982 | align 4 |
1007 | align 4 |
983 | proc cold_reset |
1008 | proc cold_reset |
Line 984... | Line 1009... | ||
984 | locals |
1009 | locals |
985 | counter dd ? |
1010 | counter dd ? |
986 | endl |
1011 | endl |
Line 987... | Line 1012... | ||
987 | 1012 | ||
988 | xor eax, eax |
1013 | mov eax, 0x02 |
989 | mov edx, GLOB_CTRL |
1014 | mov edx, GLOB_CTRL |
990 | call [ctrl.ctrl_write32] |
1015 | call [ctrl.ctrl_write32] |
Line 991... | Line 1016... | ||
991 | 1016 | ||
992 | if DEBUG |
1017 | if DEBUG |
Line 993... | Line -... | ||
993 | mov esi, msgCold |
- | |
994 | call SysMsgBoardStr |
- | |
995 | end if |
- | |
996 | - | ||
997 | mov eax, 1000000 ; wait 1 s |
1018 | mov esi, msgCold |
998 | call StallExec |
1019 | call SysMsgBoardStr |
- | 1020 | end if |
|
- | 1021 | ||
- | 1022 | mov eax, 400000 ; wait 400 ms |
|
- | 1023 | call StallExec |
|
- | 1024 | ||
- | 1025 | mov [counter], 16 ; total 20*100 ms = 2s |
|
999 | 1026 | .wait: |
|
1000 | mov eax, 2 |
1027 | |
Line 1001... | Line -... | ||
1001 | mov edx, GLOB_CTRL |
- | |
1002 | call [ctrl.ctrl_write32] |
- | |
1003 | - | ||
1004 | mov [counter], 10 ; total 10*100 ms = 1s |
- | |
1005 | .wait: |
1028 | mov edx, CTRL_STAT |
1006 | mov eax, 100000 ; wait 100 ms |
1029 | call [ctrl.ctrl_read32] |
Line 1007... | Line 1030... | ||
1007 | call StallExec |
1030 | test eax, CTRL_ST_CREADY |
1008 | 1031 | jnz .ok |
|
1009 | mov edx, GLOB_CTRL |
1032 | |
1010 | call [ctrl.ctrl_read32] |
1033 | mov eax, 100000 ; wait 100 ms |
- | 1034 | call StallExec |
|
- | 1035 | ||
1011 | test eax, 4 |
1036 | dec [counter] |
1012 | jz .ok |
1037 | jnz .wait |
1013 | sub [counter], 1 |
1038 | |
- | 1039 | if DEBUG |
|
- | 1040 | mov esi, msgCRFail |
|
- | 1041 | call SysMsgBoardStr |
|
- | 1042 | end if |
|
- | 1043 | ||
- | 1044 | .fail: |
|
- | 1045 | stc |
|
- | 1046 | ret |
|
- | 1047 | .ok: |
|
- | 1048 | mov esi, msgControl |
|
- | 1049 | call SysMsgBoardStr |
|
1014 | jnz .wait |
1050 | |
1015 | 1051 | mov edx, GLOB_CTRL |
|
- | 1052 | call [ctrl.ctrl_read32] |
|
- | 1053 | call dword2str |
|
- | 1054 | call SysMsgBoardStr |
|
- | 1055 | ||
- | 1056 | mov esi, msgStatus |
|
1016 | if DEBUG |
1057 | call SysMsgBoardStr |
1017 | mov esi, msgCRFail |
1058 | |
1018 | call SysMsgBoardStr |
1059 | mov edx, CTRL_STAT |
1019 | end if |
1060 | call [ctrl.ctrl_read32] |
1020 | stc |
- | |
1021 | ret |
- | |
1022 | .ok: |
- | |
1023 | mov edx, CTRL_STAT |
1061 | push eax |
Line 1024... | Line 1062... | ||
1024 | call [ctrl.ctrl_read32] |
1062 | call dword2str |
1025 | and eax, CTRL_ST_CREADY |
1063 | call SysMsgBoardStr |
1026 | jz .fail |
1064 | pop eax |
Line 1381... | Line 1419... | ||
1381 | dd 0 ;terminator |
1419 | dd 0 ;terminator |
Line 1382... | Line 1420... | ||
1382 | 1420 | ||
Line 1383... | Line 1421... | ||
1383 | 1421 | ||
1384 | version dd (5 shl 16) or (API_VERSION and 0xFFFF) |
1422 | version dd (5 shl 16) or (API_VERSION and 0xFFFF) |
1385 | 1423 | ||
1386 | msg_ICH db 'Intel ICH', 13,10, 0 |
1424 | msg_ICH db '802801AA (ICH)', 13,10, 0 |
1387 | msg_ICH0 db 'Intel ICH0', 13,10, 0 |
1425 | msg_ICH0 db '802801AB (ICH0)', 13,10, 0 |
1388 | msg_ICH2 db 'Intel ICH2', 13,10, 0 |
1426 | msg_ICH2 db '802801BA (ICH2)', 13,10, 0 |
1389 | msg_ICH3 db 'Intel ICH3', 13,10, 0 |
1427 | msg_ICH3 db '802801CA (ICH3)', 13,10, 0 |
1390 | msg_ICH4 db 'Intel ICH4', 13,10, 0 |
1428 | msg_ICH4 db '802801DB (ICH4)', 13,10, 0 |
1391 | msg_ICH5 db 'Intel ICH5', 13,10, 0 |
1429 | msg_ICH5 db '802801EB (ICH5)', 13,10, 0 |
Line 1392... | Line 1430... | ||
1392 | msg_ICH6 db 'Intel ICH6', 13,10, 0 |
1430 | msg_ICH6 db '802801FB (ICH6)', 13,10, 0 |
1393 | msg_ICH7 db 'Intel ICH7', 13,10, 0 |
1431 | msg_ICH7 db '802801GB (ICH7)', 13,10, 0 |
1394 | msg_Intel db 'Intel Corp. ', 0 |
1432 | msg_Intel db 'Intel ', 0 |
1395 | 1433 | ||
Line 1411... | Line 1449... | ||
1411 | msgFail db 'device not found',13,10,0 |
1449 | msgFail db 'device not found',13,10,0 |
1412 | msgAttchIRQ db 'IRQ line not supported', 13,10, 0 |
1450 | msgAttchIRQ db 'IRQ line not supported', 13,10, 0 |
1413 | msgInvIRQ db 'IRQ line not assigned or invalid', 13,10, 0 |
1451 | msgInvIRQ db 'IRQ line not assigned or invalid', 13,10, 0 |
1414 | msgPlay db 'start play', 13,10,0 |
1452 | msgPlay db 'start play', 13,10,0 |
1415 | msgStop db 'stop play', 13,10,0 |
1453 | msgStop db 'stop play', 13,10,0 |
1416 | msgNotify db 'call notify',13,10,0 |
1454 | ;msgNotify db 'call notify',13,10,0 |
1417 | msgIRQ db 'AC97 IRQ', 13,10,0 |
1455 | ;msgIRQ db 'AC97 IRQ', 13,10,0 |
1418 | msgInitCtrl db 'init controller',13,10,0 |
1456 | msgInitCtrl db 'init controller',13,10,0 |
1419 | msgInitCodec db 'init codec',13,10,0 |
1457 | ;msgInitCodec db 'init codec',13,10,0 |
1420 | msgPrimBuff db 'create primary buffer',13,10,0 |
1458 | msgPrimBuff db 'create primary buffer',13,10,0 |
1421 | msgReg db 'set service handler',13,10,0 |
1459 | ;msgReg db 'set service handler',13,10,0 |
1422 | msgOk db 'service installed',13,10,0 |
1460 | msgOk db 'service installed',13,10,0 |
1423 | msgCold db 'cold reset',13,10,0 |
1461 | msgCold db 'cold reset',13,10,0 |
1424 | msgWarm db 'warm reset',13,10,0 |
1462 | msgWarm db 'warm reset',13,10,0 |
1425 | msgWRFail db 'warm reset failed',13,10,0 |
1463 | msgWRFail db 'warm reset failed',13,10,0 |
1426 | msgCRFail db 'cold reset failed',13,10,0 |
1464 | msgCRFail db 'cold reset failed',13,10,0 |
1427 | msgCFail db 'codec not ready',13,10,0 |
1465 | msgCFail db 'codec not ready',13,10,0 |
1428 | msgResetOk db 'reset complete',13,10,0 |
1466 | msgResetOk db 'reset complete',13,10,0 |
1429 | msgStatus db 'global status ',0 |
1467 | msgStatus db 'global status ',0 |
1430 | msgControl db 'global control ',0 |
1468 | msgControl db 'global control ',0 |
- | 1469 | msgPciCmd db 'PCI command ',0 |
|
- | 1470 | msgPciStat db 'PCI status ',0 |
|
- | 1471 | msgCtrlIsaIo db 'controller io base ',0 |
|
- | 1472 | msgMixIsaIo db 'codec io base ',0 |
|
- | 1473 | msgCtrlMMIo db 'controller mmio base ',0 |
|
- | 1474 | msgMixMMIo db 'codec mmio base ',0 |
|
Line 1431... | Line 1475... | ||
1431 | 1475 | ||
Line 1432... | Line 1476... | ||
1432 | section '.data' data readable writable align 16 |
1476 | section '.data' data readable writable align 16 |
1433 | 1477 |