Subversion Repositories Kolibri OS

Rev

Rev 3653 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3653 Rev 3656
Line 1043... Line 1043...
1043
; One transfer descriptor can describe up to 5 pages.
1043
; One transfer descriptor can describe up to 5 pages.
1044
; In the worst case (when the buffer is something*1000h+0FFFh)
1044
; In the worst case (when the buffer is something*1000h+0FFFh)
1045
; this corresponds to 4001h bytes. If the requested size is
1045
; this corresponds to 4001h bytes. If the requested size is
1046
; greater, we should split the transfer into several descriptors.
1046
; greater, we should split the transfer into several descriptors.
1047
; Boundaries to split must be multiples of endpoint transfer size
1047
; Boundaries to split must be multiples of endpoint transfer size
1048
; to avoid short packets except in the end of the transfer,
1048
; to avoid short packets except in the end of the transfer.
-
 
1049
        cmp     [size], 4001h
1049
; 4000h is always a good value.
1050
        jbe     .lastpacket
1050
; 2. While the remaining data cannot fit in one descriptor,
1051
; 2. While the remaining data cannot fit in one descriptor,
1051
; allocate full descriptors (of maximal possible size).
1052
; allocate full descriptors (of maximal possible size).
-
 
1053
; 2a. Calculate size of one descriptor: must be a multiple of transfer size
-
 
1054
; and must be not greater than 4001h.
-
 
1055
        movzx   ecx, word [ebx+ohci_pipe.Flags+2-sizeof.ohci_pipe]
1052
        mov     edi, 4000h
1056
        mov     eax, 4001h
-
 
1057
        xor     edx, edx
-
 
1058
        mov     edi, eax
-
 
1059
        div     ecx
-
 
1060
        sub     edi, edx
1053
        mov     [packetSize], edi
1061
        mov     [packetSize], edi
1054
.fullpackets:
1062
.fullpackets:
1055
        cmp     [size], edi
-
 
1056
        jbe     .lastpacket
-
 
1057
        call    ehci_alloc_packet
1063
        call    ehci_alloc_packet
1058
        test    eax, eax
1064
        test    eax, eax
1059
        jz      .fail
1065
        jz      .fail
1060
        mov     [td], eax
1066
        mov     [td], eax
1061
        add     [buffer], edi
1067
        add     [buffer], edi
1062
        sub     [size], edi
1068
        sub     [size], edi
-
 
1069
        cmp     [size], 4001h
1063
        jmp     .fullpackets
1070
        ja      .fullpackets
1064
; 3. The remaining data can fit in one packet;
1071
; 3. The remaining data can fit in one packet;
1065
; allocate the last descriptor with size = size of remaining data.
1072
; allocate the last descriptor with size = size of remaining data.
1066
.lastpacket:
1073
.lastpacket:
1067
        mov     eax, [size]
1074
        mov     eax, [size]
1068
        mov     [packetSize], eax
1075
        mov     [packetSize], eax