/* * Allows changing the DMA callback function or data. This may be needed if * the driver shares a single DMA channel for multiple dma triggers. */ int omap_set_dma_callback(int lch, void (*callback)(int lch, u16 ch_status, void *data), void *data) { unsigned long flags; if (lch < 0) return -ENODEV; spin_lock_irqsave(&dma_chan_lock, flags); if (dma_chan[lch].dev_id == -1) { IOLog("DMA callback for not set for free channel"); spin_unlock_irqrestore(&dma_chan_lock, flags); return -EINVAL; } dma_chan[lch].callback = callback; dma_chan[lch].data = data; spin_unlock_irqrestore(&dma_chan_lock, flags); return 0; }
IOReturn IrDAUserClient::getIrDAStatus(void *pIn, void *pOut, IOByteCount inputSize, IOByteCount *outPutSize) { IrDAComm *irda; require(*outPutSize == sizeof(IrDAStatus), Fail); require(fDriver, Fail); bzero(pOut, sizeof(IrDAStatus)); irda = fDriver->GetIrDAComm(); if (irda) // sometimes IrDA may not be there irda->GetIrDAStatus((IrDAStatus *)pOut); fDriver->GetIrDAStatus((IrDAStatus *)pOut); return kIOReturnSuccess; Fail: IOLog("IrDA: Failing to get status\n"); return kIOReturnBadArgument; }
bool Xbox360Peripheral::QueueSerialRead(void) { IOUSBCompletion complete; IOReturn err; if ((serialInPipe == NULL) || (serialInBuffer == NULL)) return false; complete.target = this; complete.action = SerialReadCompleteInternal; complete.parameter = serialInBuffer; err = serialInPipe->Read(serialInBuffer, 0, 0, serialInBuffer->getLength(), &complete); if (err == kIOReturnSuccess) { return true; } else { IOLog("read - failed to start for chatpad (0x%.8x)\n",err); return false; } }
/** * @brief omap_dma_set_global_params : Set global priority settings for dma * * @param arb_rate * @param max_fifo_depth * @param tparams - Number of threads to reserve : DMA_THREAD_RESERVE_NORM * DMA_THREAD_RESERVE_ONET * DMA_THREAD_RESERVE_TWOT * DMA_THREAD_RESERVE_THREET */ void omap_dma_set_global_params(int arb_rate, int max_fifo_depth, int tparams) { u32 reg; if (!cpu_class_is_omap2()) { IOLog("FIXME: no %s on 15xx/16xx", __func__); return; } if (max_fifo_depth == 0) max_fifo_depth = 1; if (arb_rate == 0) arb_rate = 1; reg = 0xff & max_fifo_depth; reg |= (0x3 & tparams) << 12; reg |= (arb_rate & 0xff) << 16; dma_write(reg, GCR); }
/** * @brief omap_dma_set_prio_lch : Set channel wise priority settings * * @param lch * @param read_prio - Read priority * @param write_prio - Write priority * Both of the above can be set with one of the following values : * DMA_CH_PRIO_HIGH/DMA_CH_PRIO_LOW */ int omap_dma_set_prio_lch(int lch, unsigned char read_prio, unsigned char write_prio) { u32 l; if (unlikely((lch < 0 || lch >= dma_lch_count))) { IOLog("Invalid channel id\n"); return -EINVAL; } l = dma_read(CCR(lch)); l &= ~((1 << 6) | (1 << 26)); if (cpu_is_omap2430() || cpu_is_omap34xx() || cpu_is_omap44xx()) l |= ((read_prio & 0x1) << 6) | ((write_prio & 0x1) << 26); else l |= ((read_prio & 0x1) << 6); dma_write(l, CCR(lch)); return 0; }
int kXAudioDevice::debug_func(int where,const char *__format, ... ) { if(where<=0) return 0; // ignore this log char string[256]; const char *subop="??"; switch(where) { case DERR: subop="ERROR"; break; case DLIB: subop="HAL"; break; } va_list ap; va_start(ap, __format); vsnprintf(string,sizeof(string),__format,ap); IOLog("kXAudioDevice [%s] %s",subop,string); va_end(ap); return 0; }
IOReturn NoSleepExtension::clamshellEventInterestHandler(UInt32 messageType, IOService * provider, void * messageArgument, vm_size_t argSize) { if(messageType == kIOPMMessageClamshellStateChange) { #ifdef DEBUG IOLog("%s[%p]::%s(%u, %p, %p, %lu)\n", getName(), this, __FUNCTION__, (unsigned int)messageType, provider, messageArgument, (long unsigned int)argSize); #endif clamshellState = (bool)(((uintptr_t)messageArgument) & kClamshellStateBit); clamshellShouldSleep = (bool)(((uintptr_t)messageArgument) & kClamshellSleepBit); isClamshellStateInitialized = true; if((getCurrentSleepSuppressionState() == kNoSleepStateEnabled)) { setUserSleepDisabled(true); UInt64 deadline; clock_interval_to_deadline(10, kSecondScale, &deadline); thread_call_enter_delayed(delayTimer, deadline); if(clamshellShouldSleep) { pRootDomain->receivePowerNotification(kIOPMDisableClamshell); } // Lock screen when lid closed if(clamshellState == true && oldClamshellState == false) { lockScreen(); //notify_ //notify_post("com.apple.loginwindow.notify"); //mach_port_t bp = bootstrap_port; //task_get_bootstrap_port(bootstrap_port, &bp); } } oldClamshellState = clamshellState; } return kIOReturnSuccess; }
bool AppleARMPE::start(IOService * provider) { DTEntry entry; char *dtype; unsigned int size; IOLog("AppleARMPE::start: Welcome to the NeXT generation.\n"); if (!super::start(provider)) { panic("IOPlatformExpert failed to start"); } removeProperty(kIOPlatformMapperPresentKey); assert(IOService::getPlatform() == this); registerService(); /* * Let these time out to let everything else initialize right. */ #if 0 publishResource("IONVRAM"); publishResource("IORTC"); #endif if (kSuccess == DTLookupEntry(NULL, "/", &entry)) { /* * What's the device name? */ if (kSuccess == DTGetProperty(entry, "compatible", (void **) &dtype, &size)) { populate_model_name(dtype); } else { populate_model_name("Generic ARM Device"); } } else { populate_model_name("Generic ARM Device"); } return true; }
// Process new data void WirelessHIDDevice::receivedMessage(IOMemoryDescriptor *data) { unsigned char buf[29]; if (data->getLength() != 29) return; data->readBytes(0, buf, 29); switch (buf[1]) { case 0x0f: // Initial info if (buf[16] == 0x13) receivedUpdate(0x13, buf + 17); serialString[0] = HexData[(buf[0x0A] & 0xF0) >> 4]; serialString[1] = HexData[buf[0x0A] & 0x0F]; serialString[2] = HexData[(buf[0x0B] & 0xF0) >> 4]; serialString[3] = HexData[buf[0x0B] & 0x0F]; serialString[4] = HexData[(buf[0x0C] & 0xF0) >> 4]; serialString[5] = HexData[buf[0x0C] & 0x0F]; serialString[6] = HexData[(buf[0x0D] & 0xF0) >> 4]; serialString[7] = HexData[buf[0x0D] & 0x0F]; serialString[8] = '\0'; IOLog("Got serial number: %s", serialString); break; case 0x01: // HID info update if (buf[3] == 0xf0) receivedHIDupdate(buf + 4, buf[5]); break; case 0x00: // Info update receivedUpdate(buf[3], buf + 4); break; default: break; } }
UInt32 AgereET131x::outputPacket(mbuf_t m, void * param) { int status = 0; /************************************************************************** Queue is not empty or TCB is not available *************************************************************************/ if( MP_TCB_RESOURCES_NOT_AVAILABLE( &adapter )) { /********************************************************************** NOTE - If there's an error on send, no need to queue the packet under Linux; if we just send an error up to the netif layer, it will resend the skb to us. *********************************************************************/ // IOLog("TCB Resources Not Available\n" ); freePacket(m); netStats->outputErrors += 1; return kIOReturnOutputDropped; } /********************************************************************** We need to see if the link is up; if it's not, make the netif layer think we're good and drop the packet *********************************************************************/ if( MP_SHOULD_FAIL_SEND( &adapter ) ){ freePacket( m ); netStats->outputErrors += 1; return kIOReturnOutputDropped; } status = send_packet( m ); if( status != 0 ){ IOLog( "General error, drop packet(%d)\n", status ); freePacket( m ); netStats->outputErrors += 1; return kIOReturnOutputDropped; } return kIOReturnSuccess; }
void omap_set_dma_dest_burst_mode(int lch, enum omap_dma_burst_mode burst_mode) { unsigned int burst = 0; u32 l; l = dma_read(CSDP(lch)); l &= ~(0x03 << 14); switch (burst_mode) { case OMAP_DMA_DATA_BURST_DIS: break; case OMAP_DMA_DATA_BURST_4: if (cpu_class_is_omap2()) burst = 0x1; else burst = 0x2; break; case OMAP_DMA_DATA_BURST_8: if (cpu_class_is_omap2()) burst = 0x2; else burst = 0x3; break; case OMAP_DMA_DATA_BURST_16: if (cpu_class_is_omap2()) { burst = 0x3; break; } /* OMAP1 don't support burst 16 * fall through */ default: IOLog("Invalid DMA burst mode"); BUG(); return; } l |= (burst << 14); dma_write(l, CSDP(lch)); }
//init method // ->alloc everything here bool com_objective_see_firewall::init(OSDictionary *dict) { //return var bool result = false; //dbg msg IOLog("LULU: in %s\n", __FUNCTION__); //super if(true != super::init(dict)) { //bail goto bail; } //happy result = true; bail: return result; }
IOReturn PhantomAudioEngine::performAudioEngineStart() { IOLog("PhantomAudioEngine[%p]::performAudioEngineStart()\n", this); // When performAudioEngineStart() gets called, the audio engine should be started from the beginning // of the sample buffer. Because it is starting on the first sample, a new timestamp is needed // to indicate when that sample is being read from/written to. The function takeTimeStamp() // is provided to do that automatically with the current time. // By default takeTimeStamp() will increment the current loop count in addition to taking the current // timestamp. Since we are starting a new audio engine run, and not looping, we don't want the loop count // to be incremented. To accomplish that, false is passed to takeTimeStamp(). // The audio engine will also have to take a timestamp each time the buffer wraps around // How that is implemented depends on the type of hardware - PCI hardware will likely // receive an interrupt to perform that task takeTimeStamp(false); currentBlock = 0; timerEventSource->setTimeoutUS(blockTimeoutUS); return kIOReturnSuccess; }
void PhantomAudioEngine::free() { IOLog("PhantomAudioEngine[%p]::free()\n", this); // We need to free our resources when we're going away if (inputBuffer != NULL) { // We only need to free the input buffer buffer if it was allocated independently of the output buffer if (inputBuffer != outputBuffer) { IOFree(inputBuffer, inputBufferSize); } inputBuffer = NULL; } if (outputBuffer != NULL) { IOFree(outputBuffer, outputBufferSize); outputBuffer = NULL; } super::free(); }
bool PAEngine::setDeviceInfo(struct PAVirtualDeviceInfo *newInfo) { debugFunctionEnter(); info = newInfo; if (!info->blockSize || (NUM_SAMPLE_FRAMES % info->blockSize) != 0) { IOLog("%s(%p):: bogus blockSize %d\n", getName(), this, (int) info->blockSize); return false; } channelsIn = info->channelsIn; channelsOut = info->channelsOut; nStreams = max(channelsIn, channelsOut) / CHANNELS_PER_STREAM; if (nStreams == 0) return false; return true; }
/*! @function getInformationForDisplayMode @abstract Return information about a given display mode. @discussion IOFramebuffer subclasses must implement this method to return information in the IODisplayModeInformation structure for the display mode with the passed ID. @param displayMode A display mode ID previously returned by getDisplayModes(). @param info Pointer to a structure of type IODisplayModeInformation to be filled out by the driver. IODisplayModeInformation is documented in IOGraphicsTypes.h. @result an IOReturn code. A return other than kIOReturnSuccess will prevent the system from using the device. */ IOReturn com_doequalsglory_driver_IOProxyFramebuffer::getInformationForDisplayMode(IODisplayModeID displayMode, IODisplayModeInformation *info) { #if defined(DEBUG_CALLS) IOLog(kDebugStr "getInformationForDisplayMode(%d)\n", displayMode); #endif if (!info) { return kIOReturnBadArgument; } bzero (info, sizeof (*info)); info->maxDepthIndex = kDepth32Bit; info->nominalWidth = gProxyDisplayModes[displayMode].nominalWidth; info->nominalHeight = gProxyDisplayModes[displayMode].nominalHeight; //info->refreshRate = 0x3C0000; // 60Hz in fixed point 16.16. //info->refreshRate = 60 << 16; // from IOBootFramebuffer.cpp //info->refreshRate = 0x0; info->refreshRate = gProxyDisplayModes[displayMode].refreshRate; info->flags = gProxyDisplayModes[displayMode].flags; return kIOReturnSuccess; }
IOService *Apple16X50PCI:: probe(IOService *provider, SInt32 *score) { Provider = OSDynamicCast(IOPCIDevice, provider); if (!Provider) { IOLog ("Apple16X50PCI: Attached to non-IOPCIDevice provider! Failing probe()\n"); return NULL; } if (!super::probe(provider, score)) return NULL; char buf[80]; UInt8 dev = Provider->getDeviceNumber(); UInt8 func = Provider->getFunctionNumber(); UInt8 bus = Provider->getBusNumber(); OSData *propData = OSDynamicCast(OSData, Provider->getProperty("AAPL,slot-name")); if (propData && (propData->getLength()) < 16) snprintf(buf, sizeof (buf), "PCI %s Bus=%d Dev=%d Func=%d", (char *)(propData->getBytesNoCopy()), bus, dev, func); else snprintf(buf, sizeof (buf), "PCI Bus=%d Dev=%d Func=%d", bus, dev, func); setProperty(kLocationKey, buf); Location = (OSDynamicCast(OSString, getProperty(kLocationKey))->getCStringNoCopy()); setProperty(kIOTTYBaseNameKey, "pci-serial"); // this will be the TTY base name for all UARTS InterfaceBaseName="PCI Serial Adapter"; // this will (eventually) be displayed in NetworkPrefs InterfaceInstance=dev; snprintf(buf, sizeof (buf), "Apple16X50PCI%d", (int)InterfaceInstance); setName(buf); // turn off all access except Config space (for now) Provider->setMemoryEnable(false); Provider->setIOEnable(false); Provider->setBusMasterEnable(false); return this; }
void fuse_vncache_purge(vnode_t vp) { #if FUSE_TRACE_VNCACHE IOLog("osxfuse: cache purge vp=%p\n", vp); #endif #if M_OSXFUSE_ENABLE_BIG_LOCK struct fuse_data *data = fuse_get_mpdata(vnode_mount(vp)); bool biglock_locked = fuse_biglock_have_lock(data->biglock); if (biglock_locked) { fuse_biglock_unlock(data->biglock); } #endif /* M_OSXFUSE_ENABLE_BIG_LOCK */ cache_purge(vp); #if M_OSXFUSE_ENABLE_BIG_LOCK if (biglock_locked) { fuse_biglock_lock(data->biglock); } #endif }
IOReturn AppleKiwiATA::selectIOTimerValue( IOATADevConfig* configRequest, UInt32 unitNumber) { // This particular chip snoops the SetFeatures command, so we just snag what the // driver tells us as info, but don't set the chip in anyway. busTimings[unitNumber].ataPIOSpeedMode = configRequest->getPIOMode(); busTimings[unitNumber].ataPIOCycleTime = configRequest->getPIOCycleTime(); busTimings[unitNumber].ataMultiDMASpeed = configRequest->getDMAMode(); busTimings[unitNumber].ataMultiCycleTime = configRequest->getDMACycleTime(); busTimings[unitNumber].ataUltraDMASpeedMode = configRequest->getUltraMode(); IOLog("AppleKiwiATA: PIO Mode %d UDMA mode %d \n", bitSigToNumeric(busTimings[unitNumber].ataPIOSpeedMode), bitSigToNumeric(busTimings[unitNumber].ataUltraDMASpeedMode) ); // stuff the values back into the request structure and return result return getConfig( configRequest, unitNumber); }
void SoftU2FUserClient::frameReceivedGated(IOMemoryDescriptor *report) { IOLog("%s[%p]::%s(%p)\n", getName(), this, __FUNCTION__, report); IOMemoryMap *reportMap = nullptr; if (isInactive()) return; if (report->prepare() != kIOReturnSuccess) return; reportMap = report->map(); // Notify userland that we got a report. if (_notifyRef && reportMap->getLength() == sizeof(U2FHID_FRAME)) { io_user_reference_t *args = (io_user_reference_t *)reportMap->getAddress(); sendAsyncResult64(*_notifyRef, kIOReturnSuccess, args, sizeof(U2FHID_FRAME) / sizeof(io_user_reference_t)); } reportMap->release(); report->complete(); }
void fuse_vncache_enter(vnode_t dvp, vnode_t vp, struct componentname *cnp) { #if FUSE_TRACE_VNCACHE IOLog("osxfuse: cache enter dvp=%p, vp=%p, %s\n", dvp, vp, cnp->cn_nameptr); #endif #if M_OSXFUSE_ENABLE_BIG_LOCK struct fuse_data *data = fuse_get_mpdata(vnode_mount(dvp)); bool biglock_locked = fuse_biglock_have_lock(data->biglock); if (biglock_locked) { fuse_biglock_unlock(data->biglock); } #endif /* M_OSXFUSE_ENABLE_BIG_LOCK */ cache_enter(dvp, vp, cnp); #if M_OSXFUSE_ENABLE_BIG_LOCK if (biglock_locked) { fuse_biglock_lock(data->biglock); } #endif }
void NoSleepExtension::setUserSleepDisabled(bool disable) { static bool oldValue = false; if(oldValue == disable) { return; } oldValue = disable; #ifdef DEBUG IOLog("%s[%p]::%s(%d)\n", getName(), this, __FUNCTION__, disable ? 1 : 0); #endif const OSSymbol *sleepdisabled_string = OSSymbol::withCString("SleepDisabled"); const OSObject *objects[] = { OSBoolean::withBoolean(disable) }; const OSSymbol *keys[] = { sleepdisabled_string }; OSDictionary *dict = OSDictionary::withObjects(objects, keys, 1); pRootDomain->setProperties(dict); dict->release(); //pRootDomain->removeProperty(sleepdisabled_string); }
// Handles a message from the userspace IOHIDDeviceInterface122::setReport function IOReturn Xbox360ControllerClass::setReport(IOMemoryDescriptor *report,IOHIDReportType reportType,IOOptionBits options) { char data[2]; report->readBytes(0, data, 2); if (GetOwner(this)->rumbleType == 1) // Don't Rumble return kIOReturnSuccess; switch(data[0]) { case 0x00: // Set force feedback if((data[1]!=report->getLength()) || (data[1]!=0x04)) return kIOReturnUnsupported; { XBOX360_OUT_RUMBLE rumble; Xbox360_Prepare(rumble,outRumble); report->readBytes(2,data,2); rumble.big=data[0]; rumble.little=data[1]; GetOwner(this)->QueueWrite(&rumble,sizeof(rumble)); // IOLog("Set rumble: big(%d) little(%d)\n", rumble.big, rumble.little); } return kIOReturnSuccess; case 0x01: // Set LEDs if((data[1]!=report->getLength())||(data[1]!=0x03)) return kIOReturnUnsupported; { XBOX360_OUT_LED led; report->readBytes(2,data,1); Xbox360_Prepare(led,outLed); led.pattern=data[0]; GetOwner(this)->QueueWrite(&led,sizeof(led)); // IOLog("Set LED: %d\n", led.pattern); } return kIOReturnSuccess; default: IOLog("Unknown escape %d\n", data[0]); return kIOReturnUnsupported; } }
//================================================================================================ // // RestoreControllerStateFromSleep // //================================================================================================ // IOReturn AppleUSBUHCI::RestoreControllerStateFromSleep(void) { int i; UInt16 value; bool wakeMsg = false; USBLog(5, "AppleUSBUHCI[%p]::RestoreControllerStateFromSleep RUN - resuming controller", this); for (i=0; i< 2; i++) { value = ReadPortStatus(i); if (value & kUHCI_PORTSC_CSC) { USBLog(5, "AppleUSBUHCI[%p]::RestoreControllerStateFromSleep Port %d on bus 0x%x connected or disconnected", this, (int)i+1, (uint32_t)_busNumber); // IOLog("USB (UHCI):Port %d on bus 0x%x connected or disconnected\n", (int)i+1, (uint32_t)_busNumber); } else if (value & kUHCI_PORTSC_RD) { USBLog(5, "AppleUSBUHCI[%p]::RestoreControllerStateFromSleep Port %d on bus 0x%x has remote wakeup from some device", this, (int)i+1, (uint32_t)_busNumber); // because of how UHCI works, the root hub driver might not be able to detect that there was a remote wakeup // on a port if the upper level driver issues a Resume before the root hub interrupt timer runs // Let the hub driver know that from here to make sure we get the log if (_rootHubDevice && _rootHubDevice->GetPolicyMaker()) { _rootHubDevice->GetPolicyMaker()->message(kIOUSBMessageRootHubWakeEvent, this, (void *)(uintptr_t) i); } else { IOLog("USB (UHCI):Port %d on bus 0x%x has remote wakeup from some device\n", (int)i+1, (uint32_t)_busNumber); } } } ResumeController(); return kIOReturnSuccess; }
/********************************************************************* * This function is registered before kmod_load_from_memory() is * invoked to actually load a new kmod. It rounds up the header and * total sizes and vm_allocates a buffer for the kmod. Now, KLD doesn't * enforce any alignment of headers or segments, and we want to make * sure that the executable code of the kmod lies on a page boundary. * to do so, this function figures the pad between the actual header * size and the page-rounded header size, and returns that offset into * the allocated buffer. After kmod_load_from_memory() returns, its * caller will move the mach_header struct back to the beginning of the * allocated buffer so that the kmod_info_t structure contains the * correct address. *********************************************************************/ static unsigned long alloc_for_kmod( unsigned long size, unsigned long headers_size) { vm_address_t buffer = 0; kern_return_t k_result; unsigned long round_headers_size; unsigned long round_segments_size; unsigned long round_size; unsigned long headers_pad; round_headers_size = round_page_32(headers_size); round_segments_size = round_page_32(size - headers_size); round_size = round_headers_size + round_segments_size; headers_pad = round_headers_size - headers_size; k_result = vm_allocate(kernel_map, (vm_offset_t *)&buffer, round_size, TRUE); if (k_result != KERN_SUCCESS) { IOLog("alloc_for_kmod(): Can't allocate memory.\n"); LOG_DELAY(); link_buffer_address = 0; // make sure it's clear link_load_address = 0; // error sentinel for kld client return 0; } link_load_size = size; link_buffer_address = buffer; link_buffer_size = round_size; link_header_size = headers_size; // NOT rounded! link_load_address = link_buffer_address + headers_pad; return link_load_address; }
IOReturn MacRISC2CPU::DFS(UInt32 newLevel, UInt32 mode) { IOReturn cpfResult = kIOReturnSuccess; IOLog("MacRISC2CPU::DFS - START!\n"); if (newLevel) { if (mode & kToggleDelayAACK) uniN->callPlatformFunction (uniN_setAACKDelay, false, (void *)1, (void *)0, (void *)0, (void *)0); else if (needAACKDelay) uniN->callPlatformFunction (uniN_setAACKDelay, false, (void *)1, (void *)0, (void *)0, (void *)0); DFS_Status = kDFSLow; if ( !( mode & kDelayAACKOnly)) { ml_set_processor_speed(newLevel ? 1 : 0); if (!( mode & kNoVoltage )) cpfResult = keyLargo->callPlatformFunction (keyLargo_setPowerSupply, false, (void *)0, (void *)0, (void *)0, (void *)0); } } else { if (!( mode & kNoVoltage )) cpfResult = keyLargo->callPlatformFunction (keyLargo_setPowerSupply, false, (void *)1, (void *)0, (void *)0, (void *)0); DFS_Status = kDFSHigh; if ( !( mode & kDelayAACKOnly)) ml_set_processor_speed(newLevel ? 1 : 0); if (mode & kToggleDelayAACK) uniN->callPlatformFunction (uniN_setAACKDelay, false, (void *)0, (void *)0, (void *)0, (void *)0); else if (needAACKDelay) uniN->callPlatformFunction (uniN_setAACKDelay, false, (void *)0, (void *)0, (void *)0, (void *)0); } return kIOReturnSuccess; }
IOReturn IOI2CMaxim1631::getTemp( UInt32 maximReg /* unused */, SInt32 * temp ) { IOReturn status; union { UInt16 aShort; UInt8 aByte[2]; } readBuffer; // get the temperature. // this is done by issuing a COMBINED (default for readI2C) I2C request, with // 'kReadCurrentTemp' as the "sub-addr' and reading 2 bytes, since the current // temp register is 16 bits. if (kIOReturnSuccess == (status = readI2C( kReadCurrentTemp, &readBuffer.aByte[0], 2 ))) { // temperature register format: // // MS byte: 1/sign, 7 integer // LS byte: 4/fraction, 4/zero // format the 16.16 fixed point temperature and return it // ( the 0xFFFFF000 allows for the propagation of the sign bit, // which could happen in the case of a very cold room inlet temperature ) *temp = ( ( ( ( SInt16 ) readBuffer.aShort ) << 8 ) & 0xFFFFF000 ); //DLog( "IOI2CMaxim1631::getTemp - raw data = 0x%04X, returning %08lX\n", // i2cBuffer.aShort, *temp ); } else { IOLog( "IOI2CMaxim1631::getTemp - unable to read temperature (status = 0x%08X)\n", status ); *temp = 0x7FFFFFFF; // pass back very large positive number - will probably set off warning` } return status; }
void com_milvich_driver_Thrustmaster::handleInit() { IOReturn status; // loop through each init command and issue them. Stop if the need to close // flag is set. (Due to threads, it might not be updated in time... hopefully // DeviceRequest is smart enough to detect a problem and stop us.) for(int i = 0; i < kNumInitCmds && !fNeedToClose; i++) { IOSleep(50); status = fIface->DeviceRequest(&gInitSequence[i], NULL); if(status != kIOReturnSuccess) { IOLog("%s: Init sequence failed on command %d. Value = %d, Error = %08x\n", NAME, i, gInitSequence[i].wValue, status); break; } } //IOLog("%s: Finished init\n", NAME); // this is so we can hopefully safely close the provider if there was an error... fGate->runAction(initFinished); }
// clientClose is called as a result of the user process calling IOServiceClose. IOReturn PsychtoolboxKernelDriverUserClient::clientClose(void) { // IOLog("PsychtoolboxKernelDriverUserClient::clientClose()\n"); // Defensive coding in case the user process called IOServiceClose // without calling closeUserClient first. (void) closeUserClient(); // Inform the user process that this user client is no longer available. This will also cause the // user client instance to be destroyed. // // terminate would return false if the user process still had this user client open. // This should never happen in our case because this code path is only reached if the user process // explicitly requests closing the connection to the user client. bool success = terminate(); if (!success) { IOLog("PsychtoolboxKernelDriverUserClient::clientClose(): terminate() failed.\n"); } // DON'T call super::clientClose, which just returns kIOReturnUnsupported. return kIOReturnSuccess; }
/********************************************************************* * This function is registered before kmod_load_from_memory() is * invoked to build symbol table entries for an already-loaded * kmod. This function just checks the g_current_kmod_info variable * to gets its load address, and futzes it by the header offset (pad). * See lower comments for more info on load address futzing. *********************************************************************/ static unsigned long address_for_loaded_kmod( unsigned long size, unsigned long headers_size) { unsigned long round_headers_size; unsigned long headers_pad; if (!g_current_kmod_info) { IOLog("address_for_loaded_kmod(): No current kmod.\n"); LOG_DELAY(); link_load_address = 0; // error sentinel for kld client return 0; } round_headers_size = round_page_32(headers_size); headers_pad = round_headers_size - headers_size; link_load_address = (unsigned long)g_current_kmod_info->address + headers_pad; return link_load_address; }