Commit graph

46237 commits

Author SHA1 Message Date
Johannes Anderwald e9a0c8ba68 [USBSTOR]
- Add asserts
- Rewrite queue methods to accept the FDO only 
- Fix multiple synchronization bugs
- Don't start next irp before current irp has completed
- Use contiouslogicalbytes blocks from srb
- Should fix race conditions

svn path=/branches/usb-bringup/; revision=51764
2011-05-15 14:59:16 +00:00
Johannes Anderwald 793e8870ca [USBSTOR]
- Fix one more warning

svn path=/branches/usb-bringup/; revision=51760
2011-05-15 12:49:17 +00:00
Johannes Anderwald 5c5f758afa [USBSTOR]
- Silence warnings
- Silence traces
- Add asserts
- Add code to detect usb reset in progress. In that case cancel the request
- Add more code to synchronize urb action
- WIP, still hangs are observed

svn path=/branches/usb-bringup/; revision=51759
2011-05-15 12:47:54 +00:00
Michael Martin e5f521c90a [USBSTOR]
- Start implementing error handling.
- On errors use a worker thread to attempt a recovery. If successful restart the operation that failed.
- If STALL_PID is received reset the pipe of the device.
- Not entered into code path yet. WIP.

svn path=/branches/usb-bringup/; revision=51754
2011-05-15 11:23:16 +00:00
Michael Martin f1ec4fbe16 [USBSTOR]
- USBSTOR_SendRequest: The buffer for read/write may not be NonPagedPool, which is documented as a requirement for using MmBuildMdlForNonPagedPool. Also locking the buffers pages is also not an option as the routine is called at DISPATCH_LEVEL.
It so happens that Irp->MdlAddress is valid for read/write operations. Use it instead of procedure above.
- Add a sanity check to make sure the Mdl does describe the transfer buffer.
Fixes IRQL_NOT_LESS_OR_EQUAL bugcheck in windows. These changes also may fixed writing to device.

svn path=/branches/usb-bringup/; revision=51752
2011-05-15 08:23:32 +00:00
Johannes Anderwald be12088a55 [USBSTOR]
- Start implementing queued srb handling
- Implement SRB_FUNCTION_RELEASE_QUEUE, SRB_FUNCTION_FLUSH, SRB_FUNCTION_FLUSH_QUEUE
- WIP, not yet working perfectly

svn path=/branches/usb-bringup/; revision=51739
2011-05-14 18:09:00 +00:00
Johannes Anderwald 3f8c058a07 [USBSTOR]
- Start implementing write command
- Disabled for now as it causes corruptions

svn path=/branches/usb-bringup/; revision=51695
2011-05-13 14:44:24 +00:00
Johannes Anderwald 89aa9d3264 [USBSTOR]
- Fix bug in read command, which uses wrong format. LBA address is stored in the CDB10 struct
- Don't build the mdl for nonpaged pool if the driver passes an mdl (i/o paging requests)
- Usbstor can now list disk contents and browse files when used in Windows XP
- Need to implement SCSIOP_WRITE to write files

svn path=/branches/usb-bringup/; revision=51694
2011-05-13 14:04:38 +00:00
Johannes Anderwald eb228159bc [USBSTOR]
- Handle SCSIOP_MEDIUM_REMOVAL
- Handle paging i/o requests. These request don't provide a data buffer in the srb, but the buffer is stored in the irp' mdl
- Fix the hack for unimplemented Mode Sense command
- Usbstor now completes initializes and receives read requests
- Still need to fix read request, as Windows XP fails to recognize the disk format, WIP

svn path=/branches/usb-bringup/; revision=51693
2011-05-13 13:37:50 +00:00
Michael Martin 98ed611448 [USBSTOR]
- Add a check at USBSTOR_FdoHandleStartDevice to make sure the device uses Bulk Transfers.
- Use macros for initializing the Urbs. The macros ensure that the proper fields of the URB are set correctly.
Fixes failing of getting device descriptor and getting devices BlockLength.


svn path=/branches/usb-bringup/; revision=51691
2011-05-13 09:14:28 +00:00
Michael Martin 9d7751a2f6 [USBHUB_NEW]
- Only get the string descriptors if they are available. Fixes crash when using usb mouse and keyboards in windows.

svn path=/branches/usb-bringup/; revision=51688
2011-05-12 23:31:32 +00:00
Michael Martin 76310d7679 [USBEHCI_NEW]
- Modify BuildBulkTransferQueueHead to support TransferBufferLengths larger than PAGE_SIZE * 5.
- Acquire a SpinLock before adding QueueHeads to AsyncList and PendingList.
- Dont request a new QueueHead for incomplete transfers in QueueHeadCompletion, as the memory for the just completed QueueHead has not been released yet. Doing so overwrites the m_TransferDescriptor[x] members with new address resulting in memory leaks. Instead request a new QueueHead after the QueueHead has been freed in QueueHeadCleanup.
- Fix a bug where a QueueHead was removed from the m_CompletedRequestAsyncList instead of the m_PendingRequestAsyncList.
- Temporary hackfix InternalCalculateTransferLength to return the TransferBufferLength. This hack will be removed as soon as possible.
- With these changes the hub and ehci driver allow viewing content of and transfers to/from usb disks.

svn path=/branches/usb-bringup/; revision=51684
2011-05-12 13:35:06 +00:00
Michael Martin 8d98341ac8 [USBHUB_NEW]
- Implement IOCTL_INTERNAL_USB_GET_PORT_STATUS.
- Fixes to comments




svn path=/branches/usb-bringup/; revision=51683
2011-05-12 12:58:07 +00:00
Johannes Anderwald b0b03bfdd1 [USBSTOR]
- Rewrite scsi method to act asynchronous

svn path=/branches/usb-bringup/; revision=51673
2011-05-11 03:49:15 +00:00
Michael Martin 4f76ebe078 [USBHUB_NEW]
- Save PortNumber in child device extensions as its needed when PNP request device capabilities.
- Handle IOCTL_INTERNAL_USB_SUBMIT_URB request by creating a new Irp and passing the Urb down to the miniport. 
- Now working with our ehci driver, we at least see a usb driver and can browse directory in Windows, though doing so results in assert as ehci doesnt support transfers over 5 Pages yet. Fix coming soon.



svn path=/branches/usb-bringup/; revision=51672
2011-05-11 02:25:11 +00:00
Johannes Anderwald fc298e51a5 [USBSTOR]
- Partly implement test unit command

svn path=/branches/usb-bringup/; revision=51671
2011-05-10 23:26:56 +00:00
Michael Martin db5142f32f [USBHUB_NEW]
- Forgotten change in 51641. Fixes build of usbhub.

svn path=/branches/usb-bringup/; revision=51657
2011-05-09 10:48:00 +00:00
Johannes Anderwald fc34f0177d [USBSTOR]
- Start implementing SCSI read

svn path=/branches/usb-bringup/; revision=51654
2011-05-08 22:18:55 +00:00
Johannes Anderwald 45f27e8b8c [USBEHCI_NEW]
- Fix retrieving drive capacity
- Fix ufi command structures

svn path=/branches/usb-bringup/; revision=51649
2011-05-08 19:33:41 +00:00
Michael Martin 741b7ea0aa [USBEHCI_NEW]
- When clearing feature port reset, remove the flag from Change and if the port is hardware enabled set the enable flag in Status. 
- When checking port status, if Change has any flags set an SCE request most be completed. Verified while writing usbhub driver in xp.
- Probably fixes a case where an endless loop of completing SCE requests.

svn path=/branches/usb-bringup/; revision=51642
2011-05-08 12:42:15 +00:00
Michael Martin 3063e3bf5e [USBHUB_NEW]
- Implement constructing CompatibleIds string using device descriptor. However, if the Class of the device descriptor is 0, then Class, SubClass and Prot which make up this string must come from the Interface.
- Change Ids and Descriptions to Unicode Strings. 
- Move the creating of Id strings to one place, CreateDeviceIds, and called it at device creation.

svn path=/branches/usb-bringup/; revision=51641
2011-05-08 12:24:26 +00:00
Michael Martin 54c5af9906 [USBHUB_NEW]
- Some devices implement a default Language, LangId of 0. Some do not. Use LangId 0x0409 (English) until LangId is implemented.
- Remove an unused variable.

svn path=/branches/usb-bringup/; revision=51622
2011-05-07 16:10:09 +00:00
Michael Martin e9fe271ad6 [USBHUB_NEW]
- The lower level driver completes the SCE IRP whenever the change state has been modified for a port. When handling the SCE IRP completion only check for flags in change state. The Change flags must be cleared else the hub driver will get non stop SCE IRP completions.
- Allocate IRP from Pool vice calling IoAllocateIrp. Dont free the IRP in the completion routine as the port driver, oddly, frees them.
- GetUsbDeviceDescriptor: Remove use of MDL and use only buffer instead to make our new usbehci happy.
- When calling the interface routines, correctly use the BusContext returned from the interface instead of the RootHubPdo. This worked on windows as it just happened they were the same.
- Implement RootHubInitCallbackFunction, which only job currently is to send the first SCE IRP.
- For Start Device for child device objects fake success for now. Will be implemented later.
- Implement returning IRP_MN_QUERY_IDs, IRP_MN_QUERY_DEVICE_TEXTs and IRP_MN_QUERY_BUS_INFORMATION.
- Add basic handling for IRP_MJ_POWER.
- Misc code changes.
 

svn path=/branches/usb-bringup/; revision=51620
2011-05-07 14:49:02 +00:00
Johannes Anderwald 5573560a44 [USBSTOR]
- Implement SCSI mode sense

svn path=/branches/usb-bringup/; revision=51609
2011-05-06 17:23:19 +00:00
Johannes Anderwald ff67bee091 [USBSTOR]
- Implement retrieving drive capacity
- Use constant from scsi.h instead of defining own format
- Don't reset returned parameters length to zero, as ioctl handler might set it


svn path=/branches/usb-bringup/; revision=51608
2011-05-06 16:25:01 +00:00
Johannes Anderwald 5c9e645604 [USBSTOR]
- Implement retrieving adapter descriptor (IOCTL_STORAGE_QUERY_PROPERTY)
- Implement retrieving device descriptor (IOCTL_STORAGE_QUERY_PROPERTY)
- Next Function to implement is SRB_FUNCTION_EXECUTE_SCSI

svn path=/branches/usb-bringup/; revision=51607
2011-05-06 13:29:27 +00:00
Johannes Anderwald c5af801a10 [USBSTOR]
- Rename common device extension, it conflicts with classpnp.h header structures
- Start implementing disk ioctls
- Implement SRB_FUNCTION_CLAIM_DEVICE, SRB_FUNCTION_RELEASE_DEVICE

svn path=/branches/usb-bringup/; revision=51585
2011-05-05 00:39:00 +00:00
Johannes Anderwald dd5249b4b6 [USBEHCI_NEW]
- Silence debug flood

svn path=/branches/usb-bringup/; revision=51584
2011-05-05 00:35:56 +00:00
Johannes Anderwald c071ae0f59 [USBSTOR]
- Make DeviceId generation to match ms usbstor
- Don't hardcode the device type in USBSTOR_PdoHandleQueryHardwareId
- Don't hardcode device type in USBSTOR_PdoHandleQueryCompatibleId
- Hackfix generation of instance id
- Add comments
- Cleanup code
- Usbstor now receives ioctl from disk.sys

svn path=/branches/usb-bringup/; revision=51582
2011-05-04 23:14:32 +00:00
Michael Martin e84208fd18 [USBHUB_NEW]
- Add UsbDeviceHandle to child device extensions structure to be passed with URB requests.
- Reimplement the Worker Thread DeviceStatusChangeThread called on SCE completion. Each SetFeature and ClearFeature resend SCE request.
Only create the usb child device if the PortStatusChange member of the device extensions was modified.
- Implement CreateUsbChildDeviceObject used for creating a deviceobject for the USB device and initializing it.
- Implement GetUsbStringDescriptor for getting DeviceId, TextDescription and InstanceId from USB Device.
- Move the initial QueryStatusChangeEndpoint to after the hub device receives start pnp.
- USBHUB driver is now back to the same functionality of previous version. Showing the device wizard for connected devices.

svn path=/branches/usb-bringup/; revision=51581
2011-05-04 21:45:55 +00:00
Johannes Anderwald 8d93646c2d [USBSTOR]
- Rewrite hardware id / instance id matching
- Implement support for compatible id
- UsbStor still not attached to disk.sys, needs more research on how to get this done

svn path=/branches/usb-bringup/; revision=51580
2011-05-04 20:19:33 +00:00
Michael Martin 0fe38c839b [USBHUB_NEW]
- Change parameter name for DeviceObject in functions to clearify which device object is to received IRPs.
- Fix a typo in GetPortStatusAndChange that caused the function to return nothing for status and change.
- Call QueryStatusChangeEndpoint to send the first SCE request in Query Bus Releations.
- Complete implementation of StatusChangeEndpointCompletion. Queue a work item for DeviceStatusChangeThread, which will be used to initialize the usb device and create related device objects.



svn path=/branches/usb-bringup/; revision=51576
2011-05-04 12:58:42 +00:00
Johannes Anderwald 062111f2e1 [USBSTOR]
- Don't free device descriptor if it failed to acquire it
- Don't move out of usb configuration array. Found by special pool
- Fix bug when storing interface information which lead to a overwrite
- Implement retrieving generic type for device
- Fix bugs in QueryDeviceId
- Implement querying hardware ids
- Implement querying instance ids
- With these changes, usbstor now initializes and create pdo, which is also enumerated
- Needs more code / fixes so that disk.sys attaches to usbstor
- WIP

svn path=/branches/usb-bringup/; revision=51575
2011-05-04 12:33:01 +00:00
Johannes Anderwald 11ca3bd492 [USBEHCI_NEW]
- Fix warnings
- Fix mingw build

svn path=/branches/usb-bringup/; revision=51573
2011-05-04 12:09:07 +00:00
Johannes Anderwald c2b34a98be [USBEHCI_NEW]
- Invoke status change callback at passive level
- Fill out usb descriptor struct instead passing everything in char array
- Use 1 byte interrupt endpoint packet size for hub for now
- Fill in interface information when SelectConfiguration request is passed. Fixes sce callback and pool corruptions
- Return device descriptor in USBHI_QueryDeviceInformation
- Tested in WinXP with special pool enabled & overrun support

svn path=/branches/usb-bringup/; revision=51572
2011-05-04 11:49:00 +00:00
Michael Martin 9cbc4f8f60 [USBHUB_NEW]
- Add UsbHub_New to build.



svn path=/branches/usb-bringup/; revision=51570
2011-05-04 01:08:37 +00:00
Michael Martin af70a910fb [USBHUB_NEW]
- Start work on reimplementing UsbHub driver.
- Implement SubmitRequestToRootHub, QueryStatusChangeEndpoint, QueryInterface, GetPortStatusAndChange, SetPortFeature and ClearPortFeature.Handle QueryBusRelations.
- Partially implement PNP handling for FDO. When starting the device get all the information about the RootHub the driver will need and enable Power on all ports.
- Partially implement PNP handling for PDO, QueryId and QueryDeviceText.
- WIP



svn path=/branches/usb-bringup/; revision=51569
2011-05-04 01:07:21 +00:00
Johannes Anderwald 7821a805ef [USBSTOR]
- Implement retrieving string device type from SCSI device type
- Handle BusQueryDeviceId
- Implement support routines for sending CBW / CSW / Data
- Implement retrieving device type (SCSI inquiry request)
- WIP

svn path=/branches/usb-bringup/; revision=51567
2011-05-03 19:40:03 +00:00
Johannes Anderwald 991d02daa5 [USBEHCI_NEW]
- Remove function declaration
[USBSTOR]
- Start on usbstor driver (USB Mass Storage Driver)
- Implement reading device descriptor / configuration descriptor
- Implement scanning of configuration descriptor for bulk in / bulk out endpoints
- Implement selecting configuration and interface and verify selected interface
- Implement reading max lun and create child device object for each lun
- Handle PnP requests for functional device object
- Implement support routines to send urb's to lower device object (usbhub)
- Start implementing PDO routines

svn path=/branches/usb-bringup/; revision=51563
2011-05-03 00:15:23 +00:00
Johannes Anderwald bca978808b [USBEHCI_NEW]
- Silence usb bulk control traces

svn path=/branches/usb-bringup/; revision=51507
2011-04-30 18:46:10 +00:00
Johannes Anderwald 6321f84f30 [USBEHCI_NEW]
- Store number of bytes transferred in the transfer descriptors
- Perform queue head completion when the door bell ring has been acknowledged. Fixes race condition between multiple irps in the async list
- Fix calculation of transfer length when the request is an bulk in operation
- Use EndPointDescriptor member to access transfer type / pid direction
- Use MmGetSystemAddressForMdlSafe to retrieve system address for urb buffer
- Fix check if first transfer buffer finishes on first size if the size is of page_size
- With these changes and little luck and good weather, usb mass storage devices have been seen to  work in Windows XP SP3 
- Code inspired of mjmartin usbehci driver and Haiku's usb stack


svn path=/branches/usb-bringup/; revision=51506
2011-04-30 17:44:43 +00:00
Johannes Anderwald 547ea14508 [USBEHCI_NEW]
- Port URB_FUNCTION_CLASS_INTERFACE from mjmartin usbehci driver
- Fix typo in interface declaration
- Disable assert for now
- Return irp status pending when irp is added to the queue
- Fix bug in InternalGetPidDirection
- More work on the bulk transfers, not yet working

svn path=/branches/usb-bringup/; revision=51501
2011-04-30 08:04:35 +00:00
Michael Martin bdfaf318b8 [USBEHCI_NEW]
- Fix a type causing CommitIrp to fail.
- Add a sanity check in StatusChangeEndpointCallBack to check that a pending SCE irp is queued.
- Start Implementing Bulk Transfers. Needs more work.



svn path=/branches/usb-bringup/; revision=51493
2011-04-29 13:16:03 +00:00
Michael Martin 07dbb71da0 [USBEHCI_NEW]
- Set the NakCountReload to 0 in the QueueHead that is set in the Async register, as this is a dead QueueHead marked as halted and does not need it.
- Set the Async register in StartController. Note: The Async and Periodic registers can only be modified when the controller is stopped. 
- Driver now works in Qemu.

svn path=/branches/usb-bringup/; revision=51491
2011-04-29 06:14:44 +00:00
Johannes Anderwald 20a1892864 [USBEHCI_NEW]
- Fix SelectConfiguration / SelectInterface
- By mjmartin

svn path=/branches/usb-bringup/; revision=51490
2011-04-29 03:17:57 +00:00
Johannes Anderwald 3b6ba2f1d8 [USBEHCI_NEW]
- Implement SelectInterface / SelectConfiguration based on mjmartin usbehci driver
- Initialization runs untill SelectInterface request
- Tested with WinXP SP2

svn path=/branches/usb-bringup/; revision=51489
2011-04-29 02:46:04 +00:00
Michael Martin f48754e09b [USBEHCI_NEW]
- hub_controller.cpp: Change RtlSetBit and RtlClearBit to RtlSetBtis and RtlClearBits for Win2k compatibility.

svn path=/branches/usb-bringup/; revision=51488
2011-04-29 02:19:10 +00:00
Johannes Anderwald e8cf4c5591 [USBEHCI_NEW]
- Remove assert for unknown clear feature
- Implement retrieving string descriptors, based on mjmartin usbehci driver
- Start implementing USBHI_RestoreUsbDevice
- Fixup device stack in USBHI_SetDeviceHandleData. Needs more investigation

svn path=/branches/usb-bringup/; revision=51487
2011-04-28 23:59:53 +00:00
Johannes Anderwald 823176506d [USBEHCI_NEW]
- Implement retrieving device / configuration descriptor for usb devices
- Based on mjmartin usbehci driver
- Mass storage device found wizard now pops up (fails to install - WIP)

svn path=/branches/usb-bringup/; revision=51478
2011-04-28 17:45:32 +00:00
Johannes Anderwald a3f701378c [USBEHCI_NEW]
- Move error checking if controller reported an error inside the door bell ring check block
- Extend interface of IUSBRequest to include DeviceAddress, which is needed to retrieve configuration descriptor of newly set address
- Allocate CtrlSetup from nonpaged pool
- Release setup packet on cleanup
- Devices now receive an device address
- Currently asserts while retrieving configuration descriptor as this code path is not yet existant
*** Assertion failed: Urb->UrbHeader.UsbdDeviceHandle == NULL
***   Source File: d:\usb-bringup\drivers\usb\usbehci_new\hub_controller.cpp, line 1118

svn path=/branches/usb-bringup/; revision=51477
2011-04-28 16:40:07 +00:00