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 1056... Line 1056...
1056
; One transfer descriptor can describe up to two pages.
1056
; One transfer descriptor can describe up to two pages.
1057
; In the worst case (when the buffer is something*1000h+0FFFh)
1057
; In the worst case (when the buffer is something*1000h+0FFFh)
1058
; this corresponds to 1001h bytes. If the requested size is
1058
; this corresponds to 1001h bytes. If the requested size is
1059
; greater, we should split the transfer into several descriptors.
1059
; greater, we should split the transfer into several descriptors.
1060
; Boundaries to split must be multiples of endpoint transfer size
1060
; Boundaries to split must be multiples of endpoint transfer size
1061
; to avoid short packets except in the end of the transfer,
1061
; to avoid short packets except in the end of the transfer.
-
 
1062
        cmp     [size], 1001h
1062
; 1000h is always a good value.
1063
        jbe     .lastpacket
1063
; 2. While the remaining data cannot fit in one packet,
1064
; 2. While the remaining data cannot fit in one packet,
1064
; allocate page-sized descriptors.
1065
; allocate full-sized descriptors.
-
 
1066
; 2a. Calculate size of one descriptor: must be a multiple of transfer size
-
 
1067
; and must be not greater than 1001h.
-
 
1068
        movzx   ecx, word [ebx+ohci_pipe.Flags+2-sizeof.ohci_pipe]
1065
        mov     edi, 1000h
1069
        mov     eax, 1001h
-
 
1070
        xor     edx, edx
-
 
1071
        mov     edi, eax
-
 
1072
        div     ecx
-
 
1073
        sub     edi, edx
-
 
1074
; 2b. Allocate in loop.
1066
        mov     [packetSize], edi
1075
        mov     [packetSize], edi
1067
.fullpackets:
1076
.fullpackets:
1068
        cmp     [size], edi
-
 
1069
        jbe     .lastpacket
-
 
1070
        call    ohci_alloc_packet
1077
        call    ohci_alloc_packet
1071
        test    eax, eax
1078
        test    eax, eax
1072
        jz      .fail
1079
        jz      .fail
1073
        mov     [td], eax
1080
        mov     [td], eax
1074
        add     [buffer], edi
1081
        add     [buffer], edi
1075
        sub     [size], edi
1082
        sub     [size], edi
-
 
1083
        cmp     [size], 1001h
1076
        jmp     .fullpackets
1084
        ja      .fullpackets
1077
; 3. The remaining data can fit in one descriptor;
1085
; 3. The remaining data can fit in one descriptor;
1078
; allocate the last descriptor with size = size of remaining data.
1086
; allocate the last descriptor with size = size of remaining data.
1079
.lastpacket:
1087
.lastpacket:
1080
        mov     eax, [size]
1088
        mov     eax, [size]
1081
        mov     [packetSize], eax
1089
        mov     [packetSize], eax