Rev 3578 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3578 | Rev 3598 | ||
---|---|---|---|
Line 328... | Line 328... | ||
328 | add eax, ehci_controller.IntEDs |
328 | add eax, ehci_controller.IntEDs |
329 | call get_phys_addr |
329 | call get_phys_addr |
330 | ; 2b. Fill first 32 entries. |
330 | ; 2b. Fill first 32 entries. |
331 | inc eax |
331 | inc eax |
332 | inc eax ; set Type to EHCI_TYPE_QH |
332 | inc eax ; set Type to EHCI_TYPE_QH |
333 | push 32 |
- | |
334 | pop ecx |
333 | movi ecx, 32 |
335 | mov edx, ecx |
334 | mov edx, ecx |
336 | @@: |
335 | @@: |
337 | stosd |
336 | stosd |
338 | add eax, sizeof.ehci_static_ep |
337 | add eax, sizeof.ehci_static_ep |
339 | loop @b |
338 | loop @b |
Line 432... | Line 431... | ||
432 | mov [edi+usb_controller.NumPorts+sizeof.ehci_controller-ehci_controller.StructuralParams], ebx |
431 | mov [edi+usb_controller.NumPorts+sizeof.ehci_controller-ehci_controller.StructuralParams], ebx |
433 | mov edi, eax |
432 | mov edi, eax |
434 | ; now edi = MMIOBase2 |
433 | ; now edi = MMIOBase2 |
435 | ; 6. Transfer the controller to a known state. |
434 | ; 6. Transfer the controller to a known state. |
436 | ; 6b. Stop the controller if it is running. |
435 | ; 6b. Stop the controller if it is running. |
437 | push 10 |
- | |
438 | pop ecx |
436 | movi ecx, 10 |
439 | test dword [edi+EhciStatusReg], 1 shl 12 |
437 | test dword [edi+EhciStatusReg], 1 shl 12 |
440 | jnz .stopped |
438 | jnz .stopped |
441 | and dword [edi+EhciCommandReg], not 1 |
439 | and dword [edi+EhciCommandReg], not 1 |
442 | @@: |
440 | @@: |
443 | push 1 |
- | |
444 | pop esi |
441 | movi esi, 1 |
445 | call delay_ms |
442 | call delay_ms |
446 | test dword [edi+EhciStatusReg], 1 shl 12 |
443 | test dword [edi+EhciStatusReg], 1 shl 12 |
447 | jnz .stopped |
444 | jnz .stopped |
448 | loop @b |
445 | loop @b |
449 | dbgstr 'Failed to stop EHCI controller' |
446 | dbgstr 'Failed to stop EHCI controller' |
450 | jmp .fail_unmap |
447 | jmp .fail_unmap |
451 | .stopped: |
448 | .stopped: |
452 | ; 6c. Reset the controller. Wait up to 50 ms checking status every 1 ms. |
449 | ; 6c. Reset the controller. Wait up to 50 ms checking status every 1 ms. |
453 | or dword [edi+EhciCommandReg], 2 |
450 | or dword [edi+EhciCommandReg], 2 |
454 | push 50 |
- | |
455 | pop ecx |
451 | movi ecx, 50 |
456 | @@: |
452 | @@: |
457 | push 1 |
- | |
458 | pop esi |
453 | movi esi, 1 |
459 | call delay_ms |
454 | call delay_ms |
460 | test dword [edi+EhciCommandReg], 2 |
455 | test dword [edi+EhciCommandReg], 2 |
461 | jz .reset_ok |
456 | jz .reset_ok |
462 | loop @b |
457 | loop @b |
463 | dbgstr 'Failed to reset EHCI controller' |
458 | dbgstr 'Failed to reset EHCI controller' |
Line 513... | Line 508... | ||
513 | cmp ecx, [esi+usb_controller.NumPorts] |
508 | cmp ecx, [esi+usb_controller.NumPorts] |
514 | jb @b |
509 | jb @b |
515 | test byte [esi+ehci_controller.StructuralParams-sizeof.ehci_controller], 10h |
510 | test byte [esi+ehci_controller.StructuralParams-sizeof.ehci_controller], 10h |
516 | jz @f |
511 | jz @f |
517 | push esi |
512 | push esi |
518 | push 20 |
- | |
519 | pop esi |
513 | movi esi, 20 |
520 | call delay_ms |
514 | call delay_ms |
521 | pop esi |
515 | pop esi |
522 | @@: |
516 | @@: |
523 | ; 9. Return pointer to usb_controller. |
517 | ; 9. Return pointer to usb_controller. |
524 | xchg eax, esi |
518 | xchg eax, esi |
Line 674... | Line 668... | ||
674 | mov al, 0 |
668 | mov al, 0 |
675 | call pci_read_reg |
669 | call pci_read_reg |
676 | test al, 1 |
670 | test al, 1 |
677 | jz .has_ownership |
671 | jz .has_ownership |
678 | push esi |
672 | push esi |
679 | push 1 |
- | |
680 | pop esi |
673 | movi esi, 1 |
681 | call delay_ms |
674 | call delay_ms |
682 | pop esi |
675 | pop esi |
683 | dec dword [esp] |
676 | dec dword [esp] |
684 | jnz @b |
677 | jnz @b |
685 | dbgstr 'warning: taking EHCI ownership from BIOS timeout' |
678 | dbgstr 'warning: taking EHCI ownership from BIOS timeout' |
Line 860... | Line 853... | ||
860 | end virtual |
853 | end virtual |
861 | ; 1. Zero all fields in the hardware part. |
854 | ; 1. Zero all fields in the hardware part. |
862 | push eax ecx |
855 | push eax ecx |
863 | sub edi, ehci_pipe.SoftwarePart |
856 | sub edi, ehci_pipe.SoftwarePart |
864 | xor eax, eax |
857 | xor eax, eax |
865 | push ehci_pipe.SoftwarePart/4 |
858 | movi ecx, ehci_pipe.SoftwarePart/4 |
866 | pop ecx |
- | |
867 | rep stosd |
859 | rep stosd |
868 | pop ecx eax |
860 | pop ecx eax |
869 | ; 2. Setup PID in the first TD and make sure that the it is not active. |
861 | ; 2. Setup PID in the first TD and make sure that the it is not active. |
870 | xor edx, edx |
862 | xor edx, edx |
871 | test byte [.endpoint], 80h |
863 | test byte [.endpoint], 80h |
Line 881... | Line 873... | ||
881 | ; Copy location from the config pipe. |
873 | ; Copy location from the config pipe. |
882 | mov eax, [ecx+ehci_pipe.Flags-ehci_pipe.SoftwarePart] |
874 | mov eax, [ecx+ehci_pipe.Flags-ehci_pipe.SoftwarePart] |
883 | and eax, 3FFF0000h |
875 | and eax, 3FFF0000h |
884 | ; Use 1 requests per microframe for control/bulk endpoints, |
876 | ; Use 1 requests per microframe for control/bulk endpoints, |
885 | ; use value from the endpoint descriptor for periodic endpoints |
877 | ; use value from the endpoint descriptor for periodic endpoints |
886 | push 1 |
- | |
887 | pop edx |
878 | movi edx, 1 |
888 | test [.type], 1 |
879 | test [.type], 1 |
889 | jz @f |
880 | jz @f |
890 | mov edx, [.maxpacket] |
881 | mov edx, [.maxpacket] |
891 | shr edx, 11 |
882 | shr edx, 11 |
892 | inc edx |
883 | inc edx |
Line 1290... | Line 1281... | ||
1290 | mov [edi+EhciPortsReg+ecx*4], eax |
1281 | mov [edi+EhciPortsReg+ecx*4], eax |
1291 | jmp usb_test_pending_port |
1282 | jmp usb_test_pending_port |
1292 | @@: |
1283 | @@: |
1293 | ; 3. Call the worker procedure to notify the protocol layer |
1284 | ; 3. Call the worker procedure to notify the protocol layer |
1294 | ; about new EHCI device. It is high-speed. |
1285 | ; about new EHCI device. It is high-speed. |
1295 | push USB_SPEED_HS |
1286 | movi eax, USB_SPEED_HS |
1296 | pop eax |
- | |
1297 | call ehci_new_device |
1287 | call ehci_new_device |
1298 | test eax, eax |
1288 | test eax, eax |
1299 | jnz .nothing |
1289 | jnz .nothing |
1300 | ; 4. If something at the protocol layer has failed |
1290 | ; 4. If something at the protocol layer has failed |
1301 | ; (no memory, no bus address), disable the port and stop the initialization. |
1291 | ; (no memory, no bus address), disable the port and stop the initialization. |
Line 1792... | Line 1782... | ||
1792 | ; if babble is detected, return the corresponding error; |
1782 | ; if babble is detected, return the corresponding error; |
1793 | ; * if several non-fatal errors have occured during transaction retries, |
1783 | ; * if several non-fatal errors have occured during transaction retries, |
1794 | ; all corresponding bits are set. In this case, return some error code, |
1784 | ; all corresponding bits are set. In this case, return some error code, |
1795 | ; the order is quite arbitrary. |
1785 | ; the order is quite arbitrary. |
1796 | pop eax ; status |
1786 | pop eax ; status |
1797 | push USB_STATUS_UNDERRUN |
1787 | movi ecx, USB_STATUS_UNDERRUN |
1798 | pop ecx |
- | |
1799 | test al, 40h ; not Halted? |
1788 | test al, 40h ; not Halted? |
1800 | jz .know_error |
1789 | jz .know_error |
1801 | mov cl, USB_STATUS_OVERRUN |
1790 | mov cl, USB_STATUS_OVERRUN |
1802 | test al, 10h ; Babble detected? |
1791 | test al, 10h ; Babble detected? |
1803 | jnz .know_error |
1792 | jnz .know_error |