Rev 3626 | Rev 4423 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3626 | Rev 4265 | ||
---|---|---|---|
Line 103... | Line 103... | ||
103 | ; the common code and status interrupt pipe opened by us. |
103 | ; the common code and status interrupt pipe opened by us. |
104 | ConfigPipe dd ? |
104 | ConfigPipe dd ? |
105 | StatusPipe dd ? |
105 | StatusPipe dd ? |
106 | NumPorts dd ? |
106 | NumPorts dd ? |
107 | ; Number of downstream ports; from 1 to 255. |
107 | ; Number of downstream ports; from 1 to 255. |
- | 108 | MaxPacketSize dd ? |
|
- | 109 | ; Maximum packet size for interrupt endpoint. |
|
- | 110 | ; Usually equals ceil((1+NumPorts)/8), but some hubs give additional bytes. |
|
108 | Actions dd ? |
111 | Actions dd ? |
109 | ; Bitfield with HUB_* constants. |
112 | ; Bitfield with HUB_* constants. |
110 | PoweredOnTime dd ? |
113 | PoweredOnTime dd ? |
111 | ; Time (in ticks) when all downstream ports were powered up. |
114 | ; Time (in ticks) when all downstream ports were powered up. |
112 | ResetTime dd ? |
115 | ResetTime dd ? |
Line 248... | Line 251... | ||
248 | jnz .lookep |
251 | jnz .lookep |
249 | ; We have located the descriptor for INTERRUPT IN endpoint, |
252 | ; We have located the descriptor for INTERRUPT IN endpoint, |
250 | ; the pointer is in edx. |
253 | ; the pointer is in edx. |
251 | ; 2. Allocate memory for the hub descriptor. |
254 | ; 2. Allocate memory for the hub descriptor. |
252 | ; Maximum length (assuming 255 downstream ports) is 40 bytes. |
255 | ; Maximum length (assuming 255 downstream ports) is 40 bytes. |
- | 256 | ; Allocate 4 extra bytes to keep wMaxPacketSize. |
|
253 | ; 2a. Save registers. |
257 | ; 2a. Save registers. |
254 | push edx |
258 | push edx |
255 | ; 2b. Call the allocator. |
259 | ; 2b. Call the allocator. |
256 | movi eax, 40 |
260 | movi eax, 44 |
257 | call malloc |
261 | call malloc |
258 | ; 2c. Restore registers. |
262 | ; 2c. Restore registers. |
259 | pop ecx |
263 | pop ecx |
260 | ; 2d. If failed, say something to the debug board and return error. |
264 | ; 2d. If failed, say something to the debug board and return error. |
261 | test eax, eax |
265 | test eax, eax |
Line 265... | Line 269... | ||
265 | ; 3. Open a pipe for the status endpoint with descriptor found in step 1. |
269 | ; 3. Open a pipe for the status endpoint with descriptor found in step 1. |
266 | mov ebx, [.pipe] |
270 | mov ebx, [.pipe] |
267 | movzx eax, [ecx+usb_endpoint_descr.bEndpointAddress] |
271 | movzx eax, [ecx+usb_endpoint_descr.bEndpointAddress] |
268 | movzx edx, [ecx+usb_endpoint_descr.bInterval] |
272 | movzx edx, [ecx+usb_endpoint_descr.bInterval] |
269 | movzx ecx, [ecx+usb_endpoint_descr.wMaxPacketSize] |
273 | movzx ecx, [ecx+usb_endpoint_descr.wMaxPacketSize] |
- | 274 | test ecx, (1 shl 11) - 1 |
|
- | 275 | jz .free |
|
- | 276 | push ecx |
|
270 | stdcall usb_open_pipe, ebx, eax, ecx, INTERRUPT_PIPE, edx |
277 | stdcall usb_open_pipe, ebx, eax, ecx, INTERRUPT_PIPE, edx |
- | 278 | pop ecx |
|
271 | ; If failed, free the memory allocated in step 2, |
279 | ; If failed, free the memory allocated in step 2, |
272 | ; say something to the debug board and return error. |
280 | ; say something to the debug board and return error. |
273 | test eax, eax |
281 | test eax, eax |
274 | jz .free |
282 | jz .free |
275 | ; 4. Send control query for the hub descriptor, |
283 | ; 4. Send control query for the hub descriptor, |
276 | ; pass status pipe as a callback parameter, |
284 | ; pass status pipe as a callback parameter, |
277 | ; allow short packets. |
285 | ; allow short packets. |
- | 286 | and ecx, (1 shl 11) - 1 |
|
- | 287 | mov [esi+40], ecx |
|
278 | mov dword [esi], 0xA0 + \ ; class-specific request |
288 | mov dword [esi], 0xA0 + \ ; class-specific request |
279 | (USB_GET_DESCRIPTOR shl 8) + \ |
289 | (USB_GET_DESCRIPTOR shl 8) + \ |
280 | (0 shl 16) + \ ; descriptor index 0 |
290 | (0 shl 16) + \ ; descriptor index 0 |
281 | (USB_HUB_DESCRIPTOR shl 24) |
291 | (USB_HUB_DESCRIPTOR shl 24) |
282 | mov dword [esi+4], 40 shl 16 |
292 | mov dword [esi+4], 40 shl 16 |
Line 350... | Line 360... | ||
350 | jb .invalid |
360 | jb .invalid |
351 | sub [length], 8 |
361 | sub [length], 8 |
352 | cmp [length], edx |
362 | cmp [length], edx |
353 | jb .invalid |
363 | jb .invalid |
354 | ; 5. Allocate the memory for usb_hub structure. |
364 | ; 5. Allocate the memory for usb_hub structure. |
355 | ; Total size of variable-length data is ALIGN_UP(2*(floor(NumPorts/8)+1),4)+8*NumPorts. |
365 | ; Total size of variable-length data is ALIGN_UP(floor(NumPorts/8)+1+MaxPacketSize,4)+8*NumPorts. |
- | 366 | add edx, [eax+40] |
|
356 | lea edx, [sizeof.usb_hub+(edx-sizeof.usb_hub_descr)*2+3] |
367 | add edx, sizeof.usb_hub - sizeof.usb_hub_descr + 3 |
357 | and edx, not 3 |
368 | and edx, not 3 |
358 | lea eax, [edx+ecx*8] |
369 | lea eax, [edx+ecx*8] |
359 | push ecx edx |
370 | push ecx edx |
360 | call malloc |
371 | call malloc |
361 | pop edx ecx |
372 | pop edx ecx |
Line 372... | Line 383... | ||
372 | mov [ebx+usb_hub.Controller], edx |
383 | mov [ebx+usb_hub.Controller], edx |
373 | mov eax, [calldata] |
384 | mov eax, [calldata] |
374 | mov [ebx+usb_hub.StatusPipe], eax |
385 | mov [ebx+usb_hub.StatusPipe], eax |
375 | push esi edi |
386 | push esi edi |
376 | mov esi, [buffer] |
387 | mov esi, [buffer] |
- | 388 | mov eax, [esi+40] |
|
- | 389 | mov [ebx+usb_hub.MaxPacketSize], eax |
|
377 | ; The following commands load bNbrPorts, wHubCharacteristics, bPwrOn2PwrGood. |
390 | ; The following commands load bNbrPorts, wHubCharacteristics, bPwrOn2PwrGood. |
378 | mov edx, dword [esi+usb_hub_descr.bNbrPorts] |
391 | mov edx, dword [esi+usb_hub_descr.bNbrPorts] |
379 | mov dl, 0 |
392 | mov dl, 0 |
380 | ; The following command zeroes AccStatusChange and stores |
393 | ; The following command zeroes AccStatusChange and stores |
381 | ; HubCharacteristics and PowerOnInterval. |
394 | ; HubCharacteristics and PowerOnInterval. |
Line 485... | Line 498... | ||
485 | 498 | ||
486 | ; Requests notification about any changes in hub/ports configuration. |
499 | ; Requests notification about any changes in hub/ports configuration. |
487 | ; Called when initial configuration is done and when a previous notification |
500 | ; Called when initial configuration is done and when a previous notification |
488 | ; has been processed. |
501 | ; has been processed. |
489 | proc usb_hub_wait_change |
- | |
490 | mov ecx, [eax+usb_hub.NumPorts] |
- | |
491 | shr ecx, 3 |
- | |
492 | inc ecx |
502 | proc usb_hub_wait_change |
493 | stdcall usb_normal_transfer_async, [eax+usb_hub.StatusPipe], \ |
503 | stdcall usb_normal_transfer_async, [eax+usb_hub.StatusPipe], \ |
494 | [eax+usb_hub.StatusChangePtr], ecx, usb_hub_changed, eax, 1 |
504 | [eax+usb_hub.StatusChangePtr], [eax+usb_hub.MaxPacketSize], usb_hub_changed, eax, 1 |
495 | ret |
505 | ret |
Line 496... | Line 506... | ||
496 | endp |
506 | endp |
497 | 507 | ||
Line 511... | Line 521... | ||
511 | ; this corresponds to 'state of other ports was not changed' |
521 | ; this corresponds to 'state of other ports was not changed' |
512 | mov ecx, [eax+usb_hub.NumPorts] |
522 | mov ecx, [eax+usb_hub.NumPorts] |
513 | shr ecx, 3 |
523 | shr ecx, 3 |
514 | inc ecx |
524 | inc ecx |
515 | sub ecx, [length] |
525 | sub ecx, [length] |
- | 526 | jbe .restart |
|
516 | push eax edi |
527 | push eax edi |
517 | mov edi, [buffer] |
528 | mov edi, [buffer] |
518 | add edi, [length] |
529 | add edi, [length] |
519 | xor eax, eax |
530 | xor eax, eax |
520 | rep stosb |
531 | rep stosb |