MCPcopy Create free account
hub / github.com/acidanthera/BrcmPatchRAM / continuousRead

Method continuousRead

BrcmPatchRAM/BrcmPatchRAM.cpp:1004–1048  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1002}
1003
1004bool BrcmPatchRAM::continuousRead()
1005{
1006 if (!mReadBuffer)
1007 {
1008 mReadBuffer = IOBufferMemoryDescriptor::inTaskWithOptions(kernel_task, 0, 0x200);
1009 if (!mReadBuffer)
1010 {
1011 AlwaysLog("[%04x:%04x]: continuousRead - failed to allocate read buffer.\n", mVendorId, mProductId);
1012 return false;
1013 }
1014#ifndef TARGET_ELCAPITAN
1015 mInterruptCompletion.target = this;
1016#else
1017 mInterruptCompletion.owner = this;
1018#endif
1019 mInterruptCompletion.action = readCompletion;
1020 mInterruptCompletion.parameter = NULL;
1021 }
1022
1023 IOReturn result = mReadBuffer->prepare();
1024 if (result != kIOReturnSuccess)
1025 {
1026 AlwaysLog("[%04x:%04x]: continuousRead - failed to prepare buffer (0x%08x)\n", mVendorId, mProductId, result);
1027 return false;
1028 }
1029
1030 if ((result = mInterruptPipe.read(mReadBuffer, 0, 0, mReadBuffer->getLength(), &mInterruptCompletion)) != kIOReturnSuccess)
1031 {
1032 AlwaysLog("[%04x:%04x]: continuousRead - Failed to queue read (0x%08x)\n", mVendorId, mProductId, result);
1033
1034 if (result == kIOUSBPipeStalled)
1035 {
1036 mInterruptPipe.clearStall();
1037 result = mInterruptPipe.read(mReadBuffer, 0, 0, mReadBuffer->getLength(), &mInterruptCompletion);
1038
1039 if (result != kIOReturnSuccess)
1040 {
1041 AlwaysLog("[%04x:%04x]: continuousRead - Failed, read dead (0x%08x)\n", mVendorId, mProductId, result);
1042 return false;
1043 }
1044 }
1045 }
1046
1047 return true;
1048}
1049
1050#ifndef TARGET_ELCAPITAN
1051void BrcmPatchRAM::readCompletion(void* target, void* parameter, IOReturn status, UInt32 bufferSizeRemaining)

Callers

nothing calls this directly

Calls 2

readMethod · 0.45
clearStallMethod · 0.45

Tested by

no test coverage detected