diff --git a/kernel/trunk/bus/usb/pipe.inc b/kernel/trunk/bus/usb/pipe.inc index 087fd19cf0..dfd7bbaaeb 100644 --- a/kernel/trunk/bus/usb/pipe.inc +++ b/kernel/trunk/bus/usb/pipe.inc @@ -697,6 +697,36 @@ endl ret endp +; Part of API for drivers, see documentation for USBGetParam. +proc usb_get_param +virtual at esp + dd ? ; return address +.pipe dd ? +.param dd ? +end virtual + mov edx, [.param] + mov ecx, [.pipe] + mov eax, [ecx+usb_pipe.DeviceData] + test edx, edx + jz .get_device_descriptor + dec edx + jz .get_config_descriptor + dec edx + jz .get_speed + or eax, -1 + ret 8 +.get_device_descriptor: + add eax, usb_device_data.DeviceDescriptor + ret 8 +.get_config_descriptor: + movzx ecx, [eax+usb_device_data.DeviceDescrSize] + lea eax, [eax+ecx+usb_device_data.DeviceDescriptor] + ret 8 +.get_speed: + movzx eax, [eax+usb_device_data.Speed] + ret 8 +endp + ; Initialize software part of usb_gtd. Called from controller-specific code ; somewhere in AllocTransfer with eax -> next (inactive) usb_gtd, ; ebx -> usb_pipe, ebp frame from call to AllocTransfer with [.td] -> diff --git a/kernel/trunk/core/exports.inc b/kernel/trunk/core/exports.inc index c0ece57797..7d4bf5c085 100644 --- a/kernel/trunk/core/exports.inc +++ b/kernel/trunk/core/exports.inc @@ -100,6 +100,7 @@ iglobal szUSBClosePipe db 'USBClosePipe',0 szUSBNormalTransferAsync db 'USBNormalTransferAsync',0 szUSBControlTransferAsync db 'USBControlTransferAsync',0 + szUSBGetParam db 'USBGetParam',0 szNetRegDev db 'NetRegDev',0 szNetUnRegDev db 'NetUnRegDev',0 @@ -196,6 +197,7 @@ kernel_export: dd szUSBClosePipe , usb_close_pipe dd szUSBNormalTransferAsync, usb_normal_transfer_async dd szUSBControlTransferAsync, usb_control_async + dd szUSBGetParam , usb_get_param dd szNetRegDev , NET_add_device dd szNetUnRegDev , NET_remove_device diff --git a/kernel/trunk/docs/usbapi.txt b/kernel/trunk/docs/usbapi.txt index 32fdc4be84..f3fe0f0be1 100644 --- a/kernel/trunk/docs/usbapi.txt +++ b/kernel/trunk/docs/usbapi.txt @@ -60,8 +60,7 @@ called several times with the same 'configdescr' and different 'interfacedescr'. The returned value NULL means that the initialization has failed. Any other value means that configuration was successful; the kernel does not try to interpret the value. It can be, for example, pointer to the internal -data allocated with Kmalloc, or index in some internal table. Remember that -Kmalloc() is NOT stdcall, it destroys ebx. +data allocated with Kmalloc, or index in some internal table. The driver can implement the function @@ -173,22 +172,20 @@ The parameter 'length' is the number of bytes transferred. For control transfers, this includes 8 bytes from SETUP stage, so 0 means that SETUP stage failed and 'size'+8 means full transfer. The parameter 'status' is nonzero if an error occured. -USB_STATUS_OK = 0 ; no error -USB_STATUS_CRC = 1 ; CRC error -USB_STATUS_BITSTUFF = 2 ; bit stuffing violation -USB_STATUS_TOGGLE = 3 ; data toggle mismatch -USB_STATUS_STALL = 4 ; device returned STALL -USB_STATUS_NORESPONSE = 5 ; device not responding -USB_STATUS_PIDCHECK = 6 ; invalid PID check bits -USB_STATUS_WRONGPID = 7 ; unexpected PID value -USB_STATUS_OVERRUN = 8 ; too many data from endpoint -USB_STATUS_UNDERRUN = 9 ; too few data from endpoint -USB_STATUS_BUFOVERRUN = 12 ; overflow of internal controller buffer - ; possible only for isochronous transfers -USB_STATUS_BUFUNDERRUN = 13 ; underflow of internal controller buffer - ; possible only for isochronous transfers -USB_STATUS_CLOSED = 16 ; pipe closed, either explicitly with USBClosePipe - ; or due to device disconnect +USB_STATUS_OK = 0 ; no error +USB_STATUS_CRC = 1 ; CRC error +USB_STATUS_BITSTUFF = 2 ; bit stuffing violation +USB_STATUS_TOGGLE = 3 ; data toggle mismatch +USB_STATUS_STALL = 4 ; device returned STALL +USB_STATUS_NORESPONSE = 5 ; device not responding +USB_STATUS_PIDCHECK = 6 ; invalid PID check bits +USB_STATUS_WRONGPID = 7 ; unexpected PID value +USB_STATUS_OVERRUN = 8 ; too many data from endpoint +USB_STATUS_UNDERRUN = 9 ; too few data from endpoint +USB_STATUS_BUFOVERRUN = 12 ; overflow of internal controller buffer +USB_STATUS_BUFUNDERRUN = 13 ; underflow of internal controller buffer +USB_STATUS_CLOSED = 16 ; pipe closed, either explicitly with USBClosePipe + ; or due to device disconnect If several transfers are queued for the same pipe, their callback functions are called in the same order as they were queued. @@ -196,3 +193,13 @@ When a pipe is closed, either explicitly with USBClosePipe, or implicitly due to device disconnect, all callback functions are called with USB_STATUS_CLOSED. The call to DeviceDisconnected() occurs after all callbacks. + +void* __stdcall USBGetParam(void* pipe0, int param); +Returns miscellaneous parameters of the device. +pipe0 is the pointer to the config pipe. +param = 0: return pointer to device descriptor +param = 1: return pointer to config descriptor, same as passed to AddDevice +param = 2: return speed at which the device is operating, one of + USB_SPEED_FS = 0 ; full-speed + USB_SPEED_LS = 1 ; low-speed + USB_SPEED_HS = 2 ; high-speed