Skip to content

Commit ed03456

Browse files
committed
iosusb: some usbms changes, mask out high bit of arckey like arcfw does
1 parent c0ac465 commit ed03456

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

iosusbdrv/source/usblowms.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ NTSTATUS MspBulkMsgTimeout(IOS_USB_HANDLE DeviceHandle, UCHAR Endpoint, USHORT L
299299
// Free the async context.
300300
ExFreePool( Async );
301301

302-
if (!NT_SUCCESS(Status)) {
302+
if (Status == 0xC0101BBE || Status == 0xC0101B5C) {
303303
MspClearHalt(DeviceHandle, Endpoint);
304304
}
305305

@@ -322,13 +322,13 @@ NTSTATUS MspReset(IOS_USB_HANDLE DeviceHandle, UCHAR Interface, UCHAR EndpointIn
322322
KeDelayExecutionThread(KernelMode, FALSE, &Timeout);
323323

324324
UlCancelEndpoint(DeviceHandle, EndpointIn);
325-
UlCancelEndpoint(DeviceHandle, EndpointOut);
326-
MspClearHalt(DeviceHandle, EndpointIn);
327325
Timeout.QuadPart = -MS_TO_TIMEOUT(10);
328326
KeDelayExecutionThread(KernelMode, FALSE, &Timeout);
329-
MspClearHalt(DeviceHandle, EndpointOut);
327+
UlCancelEndpoint(DeviceHandle, EndpointOut);
330328
Timeout.QuadPart = -MS_TO_TIMEOUT(10);
331329
KeDelayExecutionThread(KernelMode, FALSE, &Timeout);
330+
//MspClearHalt(DeviceHandle, EndpointIn);
331+
//MspClearHalt(DeviceHandle, EndpointOut);
332332

333333
return Status;
334334
}
@@ -417,7 +417,7 @@ NTSTATUS MspReadCsw(
417417
do {
418418
if (!NT_SUCCESS(Status)) {
419419
if (Status == 0xC0101BBE || Status == 0xC0101B5C) {
420-
MspClearHalt(Controller->DeviceHandle, Controller->EndpointIn);
420+
//MspClearHalt(Controller->DeviceHandle, Controller->EndpointIn);
421421
Status = MspBulkMsgTimeout(
422422
Controller->DeviceHandle,
423423
Controller->EndpointIn,
@@ -2147,6 +2147,14 @@ NTSTATUS MspInitDevice(
21472147
BOOLEAN EntryPointsSet = DriverObject->DriverStartIo == MsStartIo;
21482148
CHAR Buffer[512];
21492149
for (int lun = 0; lun < MaxLun; lun++) {
2150+
2151+
KeStallExecutionProcessor(50);
2152+
Status = MspClearErrors(Extension, lun, USBSTORAGE_TIMEOUT);
2153+
if (Status < 0) {
2154+
MspReset(Extension->DeviceHandle, Extension->Interface, Extension->EndpointIn, Extension->EndpointOut);
2155+
Status = MspClearErrors(Extension, lun, USBSTORAGE_TIMEOUT);
2156+
}
2157+
21502158
USBMS_DISK_TYPE DiskType = USBMS_DISK_UNKNOWN;
21512159
Status = MspGetDiskType(Extension, lun, &DiskType, USBSTORAGE_TIMEOUT);
21522160
if (!NT_SUCCESS(Status)) {
@@ -2174,7 +2182,7 @@ NTSTATUS MspInitDevice(
21742182
EntryPointsSet = TRUE;
21752183
}
21762184
// Create the device.
2177-
Status = MspDiskCreate(DriverObject, Controller, lun, SectorSize, SectorCount, IoConfig, ArcKey, DiskType);
2185+
Status = MspDiskCreate(DriverObject, Controller, lun, SectorSize, SectorCount, IoConfig, ArcKey & ~BIT(31), DiskType);
21782186
if (!NT_SUCCESS(Status)) {
21792187
_snprintf(Buffer, sizeof(Buffer), "MspDiskCreate returned %08x\n", Status);
21802188
HalDisplayString(Buffer);

0 commit comments

Comments
 (0)