Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

port tlucks upgrade delay into rehabman code. #63

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 42 additions & 13 deletions BrcmPatchRAM/BrcmPatchRAM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,21 @@ IOService* BrcmPatchRAM::probe(IOService *provider, SInt32 *probeScore)
}
#endif

UInt32 delay;
mUpgradeDelay = 0;
if (OSNumber* upgradeDelay = OSDynamicCast(OSNumber, getProperty("UpgradeDelay"))) {
mUpgradeDelay = upgradeDelay->unsigned32BitValue();
AlwaysLog("[brcm (prop)-- UpgradeDelay]: %d \n", mUpgradeDelay);
}
if (PE_parse_boot_argn("bpr_upgradedelay", &delay, sizeof delay)) {
mUpgradeDelay = delay;
AlwaysLog("[brcm (args)-- UpgradeDelay]: %d \n", mUpgradeDelay);
}

clock_get_uptime(&start_time);
// tjl (sjk) port forward.
IOSleep(mUpgradeDelay);


#ifndef NON_RESIDENT
mWorkLock = IOLockAlloc();
Expand Down Expand Up @@ -195,30 +209,43 @@ IOService* BrcmPatchRAM::probe(IOService *provider, SInt32 *probeScore)
mBlurpWait = 400;
#endif

UInt32 delay;
mProbeDelay = 0;
if (OSNumber* probeDelay = OSDynamicCast(OSNumber, getProperty("ProbeDelay")))
if (OSNumber* probeDelay = OSDynamicCast(OSNumber, getProperty("ProbeDelay"))) {
mProbeDelay = probeDelay->unsigned32BitValue();
if (PE_parse_boot_argn("bpr_probedelay", &delay, sizeof delay))
AlwaysLog("[brcm (prop)-- ProbeDelay]: %d \n", mProbeDelay);
}
if (PE_parse_boot_argn("bpr_probedelay", &delay, sizeof delay)) {
mProbeDelay = delay;

AlwaysLog("[brcm (args)-- ProbeDelay]: %d \n", mProbeDelay);
}
mInitialDelay = 100;
if (OSNumber* initialDelay = OSDynamicCast(OSNumber, getProperty("InitialDelay")))
if (OSNumber* initialDelay = OSDynamicCast(OSNumber, getProperty("InitialDelay"))) {
mInitialDelay = initialDelay->unsigned32BitValue();
if (PE_parse_boot_argn("bpr_initialdelay", &delay, sizeof delay))
AlwaysLog("[brcm (prop)-- InitialDelay]: %d \n", mInitialDelay);
}
if (PE_parse_boot_argn("bpr_initialdelay", &delay, sizeof delay)) {
mInitialDelay = delay;

AlwaysLog("[brcm (args)-- InitialDelay]: %d \n", mInitialDelay);
}
mPostResetDelay = 100;
if (OSNumber* postResetDelay = OSDynamicCast(OSNumber, getProperty("PostResetDelay")))
if (OSNumber* postResetDelay = OSDynamicCast(OSNumber, getProperty("PostResetDelay"))) {
mPostResetDelay = postResetDelay->unsigned32BitValue();
if (PE_parse_boot_argn("bpr_postresetdelay", &delay, sizeof delay))
AlwaysLog("[brcm (prop)-- PostResetDelay]: %d \n", mPostResetDelay);
}
if (PE_parse_boot_argn("bpr_postresetdelay", &delay, sizeof delay)) {
mPostResetDelay = delay;
AlwaysLog("[brcm (args)-- PostResetDelay]: %d \n", mPostResetDelay);
}

mPreResetDelay = 20;
if (OSNumber* preResetDelay = OSDynamicCast(OSNumber, getProperty("PreResetDelay")))
if (OSNumber* preResetDelay = OSDynamicCast(OSNumber, getProperty("PreResetDelay"))) {
mPreResetDelay = preResetDelay->unsigned32BitValue();
if (PE_parse_boot_argn("bpr_preresetdelay", &delay, sizeof delay))
AlwaysLog("[brcm (prop)-- PreResetDelay]: %d \n", mPreResetDelay);
}
if (PE_parse_boot_argn("bpr_preresetdelay", &delay, sizeof delay)) {
mPreResetDelay = delay;
AlwaysLog("[brcm (args)-- PreResetDelay]: %d \n", mPreResetDelay);
}

if (OSString* displayName = OSDynamicCast(OSString, getProperty(kDisplayName)))
provider->setProperty(kUSBProductString, displayName);
Expand Down Expand Up @@ -479,7 +506,8 @@ void BrcmPatchRAM::uploadFirmware()
{
// Print out additional device information
printDeviceInfo();

// tjl (sjk) port forward.
IOSleep(2*mUpgradeDelay);
// Set device configuration to composite configuration index 0
// Obtain first interface
if (setConfiguration(0) && findInterface(&mInterface) && mInterface.open(this))
Expand Down Expand Up @@ -1208,7 +1236,8 @@ bool BrcmPatchRAM::performUpgrade()
#ifdef DEBUG
DeviceState previousState = kUnknown;
#endif

// tjl (sjk) port forward.
IOSleep(mUpgradeDelay);
IOLockLock(mCompletionLock);
mDeviceState = kInitialize;

Expand Down
1 change: 1 addition & 0 deletions BrcmPatchRAM/BrcmPatchRAM.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class BrcmPatchRAM : public IOService
UInt32 mPreResetDelay;
UInt32 mPostResetDelay;
UInt32 mInitialDelay;
UInt32 mUpgradeDelay;

USBDeviceShim mDevice;
USBInterfaceShim mInterface;
Expand Down
6 changes: 6 additions & 0 deletions BrcmPatchRAM/BrcmPatchRAM2-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@
<integer>57466</integer>
<key>idVendor</key>
<integer>1161</integer>
<key>UpgradeDelay</key>
<integer>200</integer>
<key>InitialDelay</key>
<integer>400</integer>
<key>PostResetDelay</key>
<integer>400</integer>
</dict>
<key>0489_e087</key>
<dict>
Expand Down