int DeviceDriver::close(int handle, int flags) { LogicalUnitInfo *currentUnit = logicalUnits[getUnitNumber(handle)]; if (currentUnit != 0) { delete currentUnit; logicalUnits[getUnitNumber(handle)] = 0; } return ESUCCESS; }
int DeviceDriver::readIntervals(int handle, int flags, int reg, int count, byte *buf) { LogicalUnitInfo *currentUnit = logicalUnits[getUnitNumber(handle)]; if (currentUnit == 0) return ENOTCONN; if (count < 8) return EMSGSIZE; fromHostTo32LE(currentUnit->intervalTime[0], &buf[0]); fromHostTo32LE(currentUnit->intervalTime[1], &buf[4]); return 8; }
int DeviceDriver::timerRateStop(int timerSelector, int action, int handle, int flags, int reg, int count, byte *buf) { int lun = getUnitNumber(handle); if (lun < 0 || lun >= logicalUnitCount) return EINVAL; LogicalUnitInfo *currentUnit = logicalUnits[lun]; if (currentUnit == 0) return ENOTCONN; if (timerSelector != 0 && timerSelector != 1) return EINVAL; if (flags != (int)(DAF::MILLI_STOP) && flags != (int)(DAF::MICRO_STOP)) return EINVAL; currentUnit->eventAction[timerSelector].enabled = false; return ESUCCESS; }
int DeviceDriver::timerRateRun(int timerSelector,int action, int handle, int flags, int reg, int count, byte *buf) { int lun = getUnitNumber(handle); if (lun < 0 || lun >= logicalUnitCount) return EINVAL; LogicalUnitInfo *currentUnit = logicalUnits[lun]; if (currentUnit == 0) return ENOTCONN; if (timerSelector != 0 && timerSelector != 1) return EINVAL; if (flags != (int)(DAF::MILLI_RUN) && flags != (int)(DAF::MICRO_RUN)) return EINVAL; currentUnit->eventAction[timerSelector].action = action; currentUnit->eventAction[timerSelector].handle = handle; currentUnit->eventAction[timerSelector].flags = flags; currentUnit->eventAction[timerSelector].reg = reg; currentUnit->eventAction[timerSelector].count = count; currentUnit->eventAction[timerSelector].enabled = true; return ESUCCESS; }
void IOEthernetInterface::reportInterfaceWakeFlags( IONetworkController * ctr ) { ifnet_t ifnet; OSNumber * number; unsigned long wakeSetting = 0; uint32_t disabled = 0; uint32_t filters = 0; uint32_t linkStatus = 0; ifnet = getIfnet(); if (!ifnet || !ctr) return; // Across system sleep/wake, link down is expected, this should // not trigger a wake flags changed. if (_controllerLostPower) { DLOG("en%u: controllerLostPower\n", getUnitNumber()); return; } do { // Report negative if controller is disabled or does not support WOL. if (!_ctrEnabled || ((_supportedWakeFilters & kIOEthernetWakeOnMagicPacket) == 0)) { DLOG("en%u: ctrEnabled = %x, WakeFilters = %x\n", getUnitNumber(), _ctrEnabled, _supportedWakeFilters); break; } // Poll for disabled WOL filters, which is allowed to change // after every link and WOL changed event. if (_disabledWakeFilters) { if ( ctr->getPacketFilters( gIOEthernetDisabledWakeOnLANFilterGroup, (UInt32 *) &disabled ) != kIOReturnSuccess ) { disabled = 0; } _disabledWakeFilters->setValue( disabled ); } // Check if network wake option is enabled, // that also implies system is on AC power. getAggressiveness(kPMEthernetWakeOnLANSettings, &wakeSetting); filters = wakeSetting & _supportedWakeFilters & ~disabled; DLOG("en%u: WakeSetting = %lx, WakeFilters = %x, disabled = %x\n", getUnitNumber(), wakeSetting, _supportedWakeFilters, disabled); if ((kIOEthernetWakeOnMagicPacket & filters) == 0) break; // Check driver is reporting valid link. number = OSDynamicCast(OSNumber, ctr->getProperty(kIOLinkStatus)); if (!number) { filters = 0; break; } linkStatus = number->unsigned32BitValue(); if ((linkStatus & (kIONetworkLinkValid | kIONetworkLinkActive)) == kIONetworkLinkValid) { filters = 0; } } while (false); filters &= IFNET_WAKE_ON_MAGIC_PACKET; if (filters != (ifnet_get_wake_flags(ifnet) & IFNET_WAKE_ON_MAGIC_PACKET)) { ifnet_set_wake_flags(ifnet, filters, IFNET_WAKE_ON_MAGIC_PACKET); DLOG("en%u: ifnet_set_wake_flags = %x\n", getUnitNumber(), filters); // Lazy create of kernel assertion if (kIOPMUndefinedDriverAssertionID == _wompEnabledAssertionID) { _wompEnabledAssertionID = getPMRootDomain()->createPMAssertion( kIOPMDriverAssertionMagicPacketWakeEnabledBit, (filters & IFNET_WAKE_ON_MAGIC_PACKET) ? kIOPMDriverAssertionLevelOn : kIOPMDriverAssertionLevelOff, this, getName()); } else { getPMRootDomain()->setPMAssertionLevel(_wompEnabledAssertionID, (filters & IFNET_WAKE_ON_MAGIC_PACKET) ? kIOPMDriverAssertionLevelOn : kIOPMDriverAssertionLevelOff); } } }