Subversion Repositories Kolibri OS

Rev

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

Rev 3725 Rev 4423
Line 10... Line 10...
10
 
10
 
Line 11... Line 11...
11
; Note: size must be a multiple of required alignment.
11
; Note: size must be a multiple of required alignment.
Line 12... Line -...
12
 
-
 
13
; Data for one pool: dd pointer to the first page, MUTEX lock.
-
 
14
 
-
 
15
uglobal
-
 
16
; Structures in UHCI and OHCI have equal sizes.
-
 
17
; Thus, functions and data for allocating/freeing can be shared;
-
 
18
; we keep them here rather than in controller-specific files.
-
 
19
align 4
-
 
20
; Data for UHCI and OHCI endpoints pool.
-
 
21
usb1_ep_first_page      dd      ?
-
 
22
usb1_ep_mutex           MUTEX
-
 
23
; Data for UHCI and OHCI general transfer descriptors pool.
-
 
24
usb_gtd_first_page      dd      ?
-
 
25
usb_gtd_mutex           MUTEX
-
 
26
endg
-
 
27
 
-
 
28
; sanity check: structures in UHCI and OHCI should be the same for allocation
-
 
29
if (sizeof.ohci_pipe = sizeof.uhci_pipe)
-
 
30
 
-
 
31
; Allocates one endpoint structure for UHCI/OHCI.
-
 
32
; Returns pointer to software part (usb_pipe) in eax.
-
 
33
proc usb1_allocate_endpoint
-
 
34
        push    ebx
-
 
35
        mov     ebx, usb1_ep_mutex
-
 
36
        stdcall usb_allocate_common, (sizeof.ohci_pipe + sizeof.usb_pipe + 0Fh) and not 0Fh
-
 
37
        test    eax, eax
-
 
38
        jz      @f
-
 
39
        add     eax, sizeof.ohci_pipe
-
 
40
@@:
-
 
41
        pop     ebx
-
 
42
        ret
-
 
43
endp
-
 
44
 
-
 
45
; Free one endpoint structure for UHCI/OHCI.
-
 
46
; Stdcall with one argument, pointer to software part (usb_pipe).
-
 
47
proc usb1_free_endpoint
-
 
48
        sub     dword [esp+4], sizeof.ohci_pipe
-
 
49
        jmp     usb_free_common
-
 
50
endp
-
 
51
 
-
 
52
else
-
 
53
; sanity check continued
-
 
54
.err allocate_endpoint/free_endpoint must be different for OHCI and UHCI
-
 
55
end if
-
 
56
 
-
 
57
; sanity check: structures in UHCI and OHCI should be the same for allocation
-
 
58
if (sizeof.ohci_gtd = sizeof.uhci_gtd)
-
 
59
 
-
 
60
; Allocates one general transfer descriptor structure for UHCI/OHCI.
-
 
61
; Returns pointer to software part (usb_gtd) in eax.
-
 
62
proc usb1_allocate_general_td
-
 
63
        push    ebx
-
 
64
        mov     ebx, usb_gtd_mutex
-
 
65
        stdcall usb_allocate_common, (sizeof.ohci_gtd + sizeof.usb_gtd + 0Fh) and not 0Fh
-
 
66
        test    eax, eax
-
 
67
        jz      @f
-
 
68
        add     eax, sizeof.ohci_gtd
-
 
69
@@:
-
 
70
        pop     ebx
-
 
71
        ret
-
 
72
endp
-
 
73
 
-
 
74
; Free one general transfer descriptor structure for UHCI/OHCI.
-
 
75
; Stdcall with one argument, pointer to software part (usb_gtd).
-
 
76
proc usb1_free_general_td
-
 
77
        sub     dword [esp+4], sizeof.ohci_gtd
-
 
78
        jmp     usb_free_common
-
 
79
endp
-
 
80
 
-
 
81
else
-
 
82
; sanity check continued
-
 
83
.err allocate_general_td/free_general_td must be different for OHCI and UHCI
12
 
84
end if
13
; Data for one pool: dd pointer to the first page, MUTEX lock.
85
 
14
 
86
; Allocator for fixed-size blocks: allocate a block.
15
; Allocator for fixed-size blocks: allocate a block.
87
; [ebx-4] = pointer to the first page, ebx = pointer to MUTEX structure.
16
; [ebx-4] = pointer to the first page, ebx = pointer to MUTEX structure.
Line 185... Line 114...
185
        jnz     @b
114
        jnz     @b
186
        pop     edx ecx
115
        pop     edx ecx
187
        ret     4
116
        ret     4
188
endp
117
endp
Line 189... Line 118...
189
 
118
 
190
; Helper procedure for OHCI: translate physical address in ecx
119
; Helper procedure: translate physical address in ecx
-
 
120
; of some transfer descriptor to linear address.
191
; of some transfer descriptor to linear address.
121
; in: eax = address of first page
192
proc usb_td_to_virt
122
proc usb_td_to_virt
193
; Traverse all pages used for transfer descriptors, looking for the one
123
; Traverse all pages used for transfer descriptors, looking for the one
194
; with physical address as in ecx.
-
 
195
        mov     eax, [usb_gtd_first_page]
124
; with physical address as in ecx.
196
@@:
125
@@:
197
        test    eax, eax
126
        test    eax, eax
198
        jz      .zero
127
        jz      .zero
199
        push    eax
128
        push    eax