Rev 3908 | Rev 5201 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3908 | Rev 4423 | ||
---|---|---|---|
Line 27... | Line 27... | ||
27 | ; when it should be invoked again, possibly infinite. |
27 | ; when it should be invoked again, possibly infinite. |
28 | ; usb_thread_proc selects the minimum from all times returned by |
28 | ; usb_thread_proc selects the minimum from all times returned by |
29 | ; ProcessDeferred and sleeps until this moment is reached or the thread |
29 | ; ProcessDeferred and sleeps until this moment is reached or the thread |
30 | ; is awakened by IRQ handler. |
30 | ; is awakened by IRQ handler. |
Line -... | Line 31... | ||
- | 31 | ||
- | 32 | iglobal |
|
- | 33 | uhci_service_name: |
|
- | 34 | db 'UHCI',0 |
|
- | 35 | ohci_service_name: |
|
- | 36 | db 'OHCI',0 |
|
- | 37 | ehci_service_name: |
|
- | 38 | db 'EHCI',0 |
|
- | 39 | endg |
|
31 | 40 | ||
32 | ; Initializes the USB subsystem. |
41 | ; Initializes the USB subsystem. |
33 | proc usb_init |
42 | proc usb_init |
34 | ; 1. Initialize all locks. |
43 | ; 1. Initialize all locks. |
35 | mov ecx, usb_controllers_list_mutex |
44 | mov ecx, usb_controllers_list_mutex |
36 | call mutex_init |
- | |
37 | mov ecx, usb1_ep_mutex |
- | |
38 | call mutex_init |
- | |
39 | mov ecx, usb_gtd_mutex |
- | |
40 | call mutex_init |
- | |
41 | mov ecx, ehci_ep_mutex |
- | |
42 | call mutex_init |
- | |
43 | mov ecx, ehci_gtd_mutex |
- | |
44 | call mutex_init |
45 | call mutex_init |
45 | ; 2. Kick off BIOS from all USB controllers, calling the corresponding function |
46 | ; 2. Kick off BIOS from all USB controllers, calling the corresponding function |
46 | ; *hci_kickoff_bios. Also count USB controllers for the next step. |
47 | ; *hci_kickoff_bios. Also count USB controllers for the next step. |
47 | ; Note: USB1 companion(s) must go before the corresponding EHCI controller, |
48 | ; Note: USB1 companion(s) must go before the corresponding EHCI controller, |
48 | ; otherwise BIOS could see a device moving from EHCI to a companion; |
49 | ; otherwise BIOS could see a device moving from EHCI to a companion; |
Line 57... | Line 58... | ||
57 | mov esi, [esi+PCIDEV.list.next] |
58 | mov esi, [esi+PCIDEV.list.next] |
58 | cmp esi, pcidev_list |
59 | cmp esi, pcidev_list |
59 | jz .done_kickoff |
60 | jz .done_kickoff |
60 | cmp word [esi+PCIDEV.class+1], 0x0C03 |
61 | cmp word [esi+PCIDEV.class+1], 0x0C03 |
61 | jnz .kickoff |
62 | jnz .kickoff |
62 | mov eax, uhci_kickoff_bios |
63 | mov ebx, uhci_service_name |
63 | cmp byte [esi+PCIDEV.class], 0x00 |
64 | cmp byte [esi+PCIDEV.class], 0x00 |
64 | jz .do_kickoff |
65 | jz .do_kickoff |
65 | mov eax, ohci_kickoff_bios |
66 | mov ebx, ohci_service_name |
66 | cmp byte [esi+PCIDEV.class], 0x10 |
67 | cmp byte [esi+PCIDEV.class], 0x10 |
67 | jz .do_kickoff |
68 | jz .do_kickoff |
68 | mov eax, ehci_kickoff_bios |
69 | mov ebx, ehci_service_name |
69 | cmp byte [esi+PCIDEV.class], 0x20 |
70 | cmp byte [esi+PCIDEV.class], 0x20 |
70 | jnz .kickoff |
71 | jnz .kickoff |
71 | .do_kickoff: |
72 | .do_kickoff: |
72 | inc dword [esp] |
73 | inc dword [esp] |
- | 74 | push ebx esi |
|
- | 75 | stdcall get_service, ebx |
|
- | 76 | pop esi ebx |
|
73 | call eax |
77 | test eax, eax |
- | 78 | jz .driver_fail |
|
- | 79 | mov edx, [eax+USBSRV.usb_func] |
|
- | 80 | cmp [edx+usb_hardware_func.Version], USBHC_VERSION |
|
- | 81 | jnz .driver_invalid |
|
- | 82 | mov [esi+PCIDEV.owner], eax |
|
- | 83 | call [edx+usb_hardware_func.BeforeInit] |
|
- | 84 | jmp .kickoff |
|
- | 85 | .driver_fail: |
|
- | 86 | DEBUGF 1,'K : failed to load driver %s\n',ebx |
|
- | 87 | jmp .kickoff |
|
- | 88 | .driver_invalid: |
|
- | 89 | DEBUGF 1,'K : driver %s has wrong version\n',ebx |
|
74 | jmp .kickoff |
90 | jmp .kickoff |
75 | .done_kickoff: |
91 | .done_kickoff: |
76 | pop eax |
92 | pop eax |
77 | ; 3. If no controllers were found, exit. |
93 | ; 3. If no controllers were found, exit. |
78 | ; Otherwise, run the USB thread. |
94 | ; Otherwise, run the USB thread. |
Line 95... | Line 111... | ||
95 | mov eax, [eax+PCIDEV.list.next] |
111 | mov eax, [eax+PCIDEV.list.next] |
96 | cmp eax, pcidev_list |
112 | cmp eax, pcidev_list |
97 | jz .done_ehci |
113 | jz .done_ehci |
98 | cmp [eax+PCIDEV.class], 0x0C0320 |
114 | cmp [eax+PCIDEV.class], 0x0C0320 |
99 | jnz .scan_ehci |
115 | jnz .scan_ehci |
100 | mov edi, ehci_hardware_func |
- | |
101 | call usb_init_controller |
116 | call usb_init_controller |
102 | jmp .scan_ehci |
117 | jmp .scan_ehci |
103 | .done_ehci: |
118 | .done_ehci: |
104 | ; 4b. Loop over all PCI devices, call usb_init_controller |
119 | ; 4b. Loop over all PCI devices, call usb_init_controller |
105 | ; for all UHCI and OHCI controllers. |
120 | ; for all UHCI and OHCI controllers. |
106 | mov eax, pcidev_list |
121 | mov eax, pcidev_list |
107 | .scan_usb1: |
122 | .scan_usb1: |
108 | mov eax, [eax+PCIDEV.list.next] |
123 | mov eax, [eax+PCIDEV.list.next] |
109 | cmp eax, pcidev_list |
124 | cmp eax, pcidev_list |
110 | jz .done_usb1 |
125 | jz .done_usb1 |
111 | mov edi, uhci_hardware_func |
- | |
112 | cmp [eax+PCIDEV.class], 0x0C0300 |
126 | cmp [eax+PCIDEV.class], 0x0C0300 |
113 | jz @f |
127 | jz @f |
114 | mov edi, ohci_hardware_func |
- | |
115 | cmp [eax+PCIDEV.class], 0x0C0310 |
128 | cmp [eax+PCIDEV.class], 0x0C0310 |
116 | jnz .scan_usb1 |
129 | jnz .scan_usb1 |
117 | @@: |
130 | @@: |
118 | call usb_init_controller |
131 | call usb_init_controller |
119 | jmp .scan_usb1 |
132 | jmp .scan_usb1 |
Line 236... | Line 249... | ||
236 | align 4 |
249 | align 4 |
237 | usb_controllers_list_mutex MUTEX |
250 | usb_controllers_list_mutex MUTEX |
238 | endg |
251 | endg |
Line 239... | Line 252... | ||
239 | 252 | ||
- | 253 | include "memory.inc" |
|
240 | include "memory.inc" |
254 | include "common.inc" |
241 | include "hccommon.inc" |
255 | include "hccommon.inc" |
242 | include "pipe.inc" |
- | |
243 | include "ohci.inc" |
- | |
244 | include "uhci.inc" |
- | |
245 | include "ehci.inc" |
256 | include "pipe.inc" |
246 | include "protocol.inc" |
257 | include "protocol.inc" |
247 | include "hub.inc" |
- |