Esempio n. 1
0
IOService* X3100monitor::probe(IOService *provider, SInt32 *score)
{
	if (super::probe(provider, score) != this) return 0;
	UInt32 vendor_id, device_id;
	if (OSDictionary * dictionary = serviceMatching(kGenericPCIDevice)) {
		if (OSIterator * iterator = getMatchingServices(dictionary)) {
			
			IOPCIDevice* device = 0;
			
			while (device = OSDynamicCast(IOPCIDevice, iterator->getNextObject())) {
				OSData *data = OSDynamicCast(OSData, device->getProperty("vendor-id"));
				if (data)
					vendor_id = *(UInt32*)data->getBytesNoCopy();
				
				data = OSDynamicCast(OSData, device->getProperty("device-id"));				
				if (data)
					device_id = *(UInt32*)data->getBytesNoCopy();
				
				if ((vendor_id==0x8086) && (device_id==0x2a00)){
					InfoLog("found %lx chip", (long unsigned int)device_id);
					VCard = device;
				}
			}
		}
	}	
	return this;
}
Esempio n. 2
0
void IOPlatformExpert::registerNVRAMController(IONVRAMController * caller)
{
    OSData *          data;
    IORegistryEntry * entry;
    OSString *        string = 0;
    uuid_string_t     uuid;

    entry = IORegistryEntry::fromPath( "/efi/platform", gIODTPlane );
    if ( entry )
    {
        data = OSDynamicCast( OSData, entry->getProperty( "system-id" ) );
        if ( data && data->getLength( ) == 16 )
        {
            SHA1_CTX     context;
            uint8_t      digest[ SHA_DIGEST_LENGTH ];
            const uuid_t space = { 0x2A, 0x06, 0x19, 0x90, 0xD3, 0x8D, 0x44, 0x40, 0xA1, 0x39, 0xC4, 0x97, 0x70, 0x37, 0x65, 0xAC };

            SHA1Init( &context );
            SHA1Update( &context, space, sizeof( space ) );
            SHA1Update( &context, data->getBytesNoCopy( ), data->getLength( ) );
            SHA1Final( digest, &context );

            digest[ 6 ] = ( digest[ 6 ] & 0x0F ) | 0x50;
            digest[ 8 ] = ( digest[ 8 ] & 0x3F ) | 0x80;

            uuid_unparse( digest, uuid );
            string = OSString::withCString( uuid );
        }

        entry->release( );
    }

    if ( string == 0 )
    {
        entry = IORegistryEntry::fromPath( "/options", gIODTPlane );
        if ( entry )
        {
            data = OSDynamicCast( OSData, entry->getProperty( "platform-uuid" ) );
            if ( data && data->getLength( ) == sizeof( uuid_t ) )
            {
                uuid_unparse( ( uint8_t * ) data->getBytesNoCopy( ), uuid );
                string = OSString::withCString( uuid );
            }

            entry->release( );
        }
    }

    if ( string )
    {
        getProvider( )->setProperty( kIOPlatformUUIDKey, string );
        publishResource( kIOPlatformUUIDKey, string );

        string->release( );
    }

    publishResource("IONVRAM");
}
IOService* GeforceSensors::probe(IOService *provider, SInt32 *score)
{
  UInt32 vendor_id, device_id, class_id;
	DebugLog("Probing...");
	
	if (super::probe(provider, score) != this) return 0;
	
	InfoLog("GeforceSensors by kozlek (C) 2012");
	s8 ret = 0;
	if (OSDictionary * dictionary = serviceMatching(kGenericPCIDevice)) {
		if (OSIterator * iterator = getMatchingServices(dictionary)) {
			ret = 1;
			IOPCIDevice* device = 0;
			do {
			  device = OSDynamicCast(IOPCIDevice, iterator->getNextObject());
        if (!device) {
          break;
        }
				OSData *data = OSDynamicCast(OSData, device->getProperty(fVendor));
        vendor_id = 0;
				if (data)
					vendor_id = *(UInt32*)data->getBytesNoCopy();
				
        device_id = 0;
				data = OSDynamicCast(OSData, device->getProperty(fDevice));				
				if (data)
					device_id = *(UInt32*)data->getBytesNoCopy();
				
        class_id = 0;
				data = OSDynamicCast(OSData, device->getProperty(fClass));				
				if (data)
					class_id = *(UInt32*)data->getBytesNoCopy();
				
				if ((vendor_id==0x10de) && (class_id == 0x030000)) {
					InfoLog("found %x Nvidia chip", (unsigned int)device_id);
					card.pcidev = device;
          card.device_id = device_id;
					ret = 1; //TODO - count a number of cards
          card.card_index = ret;
					break;
				}
			} while (device);	
		}
	}
	if(ret)
		return this;
	else return 0;
	
	return this;
}
bool IOEthernetInterface::initIfnetParams(struct ifnet_init_params *params)
{
	OSData *uniqueID;
	//get the default values
    super::initIfnetParams( params );
		
    uniqueID = OSDynamicCast(OSData, getProvider()->getProperty(kIOMACAddress));
    if ( (uniqueID == 0) || (uniqueID->getLength() != ETHER_ADDR_LEN) )
    {
        DLOG("%s: kIOMACAddress property access error (len %d)\n",
             getName(), uniqueID ? uniqueID->getLength() : 0);
        return false;
    }
	
	// fill in ethernet specific values
	params->uniqueid = uniqueID->getBytesNoCopy();
	params->uniqueid_len = uniqueID->getLength();
	params->family = APPLE_IF_FAM_ETHERNET;
	params->demux = ether_demux;
	params->add_proto = ether_add_proto;
	params->del_proto = ether_del_proto;
	params->framer = ether_frameout;
	params->check_multi = ether_check_multi;
	params->broadcast_addr = ether_broadcast_addr;
	params->broadcast_len = sizeof(ether_broadcast_addr);
    return true;
}
Esempio n. 5
0
/* pass in a NULL value if you just want to figure out the len */
boolean_t PEReadNVRAMProperty(const char *symbol, void *value,
                              unsigned int *len)
{
    OSObject  *obj;
    OSData *data;
    unsigned int vlen;

    if (!symbol || !len)
        goto err;

    if (init_gIOOptionsEntry() < 0)
        goto err;

    vlen = *len;
    *len = 0;

    obj = gIOOptionsEntry->getProperty(symbol);
    if (!obj)
        goto err;

    /* convert to data */
    data = OSDynamicCast(OSData, obj);
    if (!data) 
        goto err;

    *len  = data->getLength();
    vlen  = min(vlen, *len);
    if (value && vlen)
        memcpy((void *) value, data->getBytesNoCopy(), vlen);

    return TRUE;

err:
    return FALSE;
}
IOReturn IOSharedInterruptController::enableInterrupt(IOService *nub,
						      int source)
{
  IOInterruptSource *interruptSources;
  IOInterruptVectorNumber vectorNumber;
  IOInterruptVector *vector;
  OSData            *vectorData;
  IOInterruptState  interruptState;
  
  interruptSources = nub->_interruptSources;
  vectorData = interruptSources[source].vectorData;
  vectorNumber = *(IOInterruptVectorNumber *)vectorData->getBytesNoCopy();
  vector = &vectors[vectorNumber];
  
  interruptState = IOSimpleLockLockDisableInterrupt(controllerLock);
  if (!vector->interruptDisabledSoft) {
    IOSimpleLockUnlockEnableInterrupt(controllerLock, interruptState);
    return kIOReturnSuccess;
  }
  
  vector->interruptDisabledSoft = 0;
  vectorsEnabled++;
  IOSimpleLockUnlockEnableInterrupt(controllerLock, interruptState);
  
  if (controllerDisabled && (vectorsEnabled == vectorsRegistered)) {
    controllerDisabled = 0;
    provider->enableInterrupt(0);
  }
  
  return kIOReturnSuccess;
}
IOReturn IOSharedInterruptController::disableInterrupt(IOService *nub,
						       int source)
{
  IOInterruptSource *interruptSources;
  long              vectorNumber;
  IOInterruptVector *vector;
  OSData            *vectorData;
  IOInterruptState  interruptState;
  
  interruptSources = nub->_interruptSources;
  vectorData = interruptSources[source].vectorData;
  vectorNumber = *(long *)vectorData->getBytesNoCopy();
  vector = &vectors[vectorNumber];
  
  interruptState = IOSimpleLockLockDisableInterrupt(controllerLock); 
  if (!vector->interruptDisabledSoft) {
    vector->interruptDisabledSoft = 1;
#if __ppc__
    sync();
    isync();
#endif
    vectorsEnabled--;
  }
  IOSimpleLockUnlockEnableInterrupt(controllerLock, interruptState);
  
  if (!getPlatform()->atInterruptLevel()) {
    while (vector->interruptActive);
#if __ppc__
    isync();
#endif
  }
  
  return kIOReturnSuccess;
}
Esempio n. 8
0
bool NullEthernet::init(OSDictionary *properties)
{
    DebugLog("init() ===>\n");

    if (!super::init(properties))
    {
        DebugLog("super::init failed\n");
        return false;
    }

    m_pProvider = NULL;
    m_netif = NULL;
    m_isEnabled = false;
    unitNumber = 0;

    // load default MAC address (can be overridden in DSDT)
    static unsigned char rgDefault[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
    bcopy(rgDefault, m_rgMacAddr, kIOEthernetAddressSize);
    if (properties)
    {
        OSData* pData = OSDynamicCast(OSData, properties->getObject("MAC-address"));
        if (pData && pData->getLength() == kIOEthernetAddressSize)
            bcopy(pData->getBytesNoCopy(), m_rgMacAddr, kIOEthernetAddressSize);
    }

    DebugLog("init() <===>\n");
    return true;
}
IOReturn IOInterruptController::disableInterrupt(IOService *nub, int source)
{
  IOInterruptSource *interruptSources;
  long              vectorNumber;
  IOInterruptVector *vector;
  OSData            *vectorData;
  
  interruptSources = nub->_interruptSources;
  vectorData = interruptSources[source].vectorData;
  vectorNumber = *(long *)vectorData->getBytesNoCopy();
  vector = &vectors[vectorNumber];
  
  vector->interruptDisabledSoft = 1;
#if __ppc__
  sync();
  isync();
#endif
  
  if (!getPlatform()->atInterruptLevel()) {
    while (vector->interruptActive);
#if __ppc__
    isync();
#endif
  }
  
  return kIOReturnSuccess;
}
Esempio n. 10
0
IOReturn IOInterruptController::enableInterrupt(IOService *nub, int source)
{
  IOInterruptSource *interruptSources;
  IOInterruptVectorNumber vectorNumber;
  IOInterruptVector *vector;
  OSData            *vectorData;
  
  interruptSources = nub->_interruptSources;
  vectorData = interruptSources[source].vectorData;
  vectorNumber = *(IOInterruptVectorNumber *)vectorData->getBytesNoCopy();
  vector = &vectors[vectorNumber];
  
  if (vector->interruptDisabledSoft) {
    vector->interruptDisabledSoft = 0;
#if !defined(__i386__) && !defined(__x86_64__)
    OSMemoryBarrier();
#endif

    if (!getPlatform()->atInterruptLevel()) {
      while (vector->interruptActive)
	{}
    }
    if (vector->interruptDisabledHard) {
      vector->interruptDisabledHard = 0;
      
      enableVector(vectorNumber, vector);
    }
  }
  
  return kIOReturnSuccess;
}
Esempio n. 11
0
bool IODTPlatformExpert::getModelName( char * name, int maxLength )
{
    OSData *		prop;
    const char *	str;
    int			len;
    char		c;
    bool		ok = false;

    maxLength--;

    prop = (OSData *) getProvider()->getProperty( gIODTCompatibleKey );
    if( prop ) {
	str = (const char *) prop->getBytesNoCopy();

	if( 0 == strncmp( str, "AAPL,", strlen( "AAPL," ) ))
	    str += strlen( "AAPL," );

	len = 0;
	while( (c = *str++)) {
	    if( (c == '/') || (c == ' '))
		c = '-';

	    name[ len++ ] = c;
	    if( len >= maxLength)
		break;
	}

	name[ len ] = 0;
	ok = true;
    }
    return( ok );
}
Esempio n. 12
0
OSObject* FileNVRAM::cast(const OSSymbol* key, OSObject* obj)
{
	const char* legacy[] = {
		"boot-args",
		"boot-script",
	};

	OSString* str = OSDynamicCast(OSString, key);

	if (str)
	{
		for (int i = 0; i < sizeof(legacy)/sizeof(char*); i++)
		{
			if (str->isEqualTo(legacy[i]))
			{
				LOG(NOTICE, "Found legacy key %s\n", str->getCStringNoCopy());

				// add null char, convert to OSString
				OSData* data = OSDynamicCast(OSData, obj);

				if (data)
				{
					data->appendByte(0x00, 1);

					return OSString::withCString((const char*)data->getBytesNoCopy());
				}
			}
		}
	}

	return obj;
}
Esempio n. 13
0
IOReturn IOSharedInterruptController::disableInterrupt(IOService *nub,
						       int source)
{
  IOInterruptSource *interruptSources;
  IOInterruptVectorNumber vectorNumber;
  IOInterruptVector *vector;
  OSData            *vectorData;
  IOInterruptState  interruptState;
  
  interruptSources = nub->_interruptSources;
  vectorData = interruptSources[source].vectorData;
  vectorNumber = *(IOInterruptVectorNumber *)vectorData->getBytesNoCopy();
  vector = &vectors[vectorNumber];
  
  interruptState = IOSimpleLockLockDisableInterrupt(controllerLock); 
  if (!vector->interruptDisabledSoft) {
    vector->interruptDisabledSoft = 1;
#if !defined(__i386__) && !defined(__x86_64__)
    OSMemoryBarrier();
#endif

    vectorsEnabled--;
  }
  IOSimpleLockUnlockEnableInterrupt(controllerLock, interruptState);
  
  if (!getPlatform()->atInterruptLevel()) {
    while (vector->interruptActive)
	{}
  }
  
  return kIOReturnSuccess;
}
Esempio n. 14
0
bool FakeSMC::init(OSDictionary *properties)
{	
	if (!super::init(properties))
		return false;
    
    IOLog("FakeSMC v%s Copyright %d netkas, slice, usr-sse2, kozlek, navi, THe KiNG, RehabMan. All rights reserved.\n", HWSENSORS_VERSION_STRING, HWSENSORS_LASTYEAR);

    if (IORegistryEntry *efi = IORegistryEntry::fromPath("/efi", gIODTPlane)) {
        if (OSData *vendor = OSDynamicCast(OSData, efi->getProperty("firmware-vendor"))) { // firmware-vendor is in EFI node
            OSData *buffer = OSData::withCapacity(128);
            const unsigned char* data = static_cast<const unsigned char*>(vendor->getBytesNoCopy());
            
            for (unsigned int index = 0; index < vendor->getLength(); index += 2) {
                buffer->appendByte(data[index], 1);
            }
            
            OSString *name = OSString::withCString(static_cast<const char *>(buffer->getBytesNoCopy()));
            
            setProperty(kFakeSMCFirmwareVendor, name);
            
            //OSSafeRelease(vendor);
            //OSSafeRelease(name);
            OSSafeRelease(buffer);
        }
        
        OSSafeRelease(efi);
    }
		
	return true;
}
UInt32 PCIDeviceStub_XHCIMux::getUInt32Property(const char* name)
{
    UInt32 result = 0;
    OSData* data = OSDynamicCast(OSData, getProperty(name));
    if (data && data->getLength() == 4)
        result = *static_cast<const UInt32*>(data->getBytesNoCopy());
    return result;
}
bool PCIDeviceStub_XHCIMux::getBoolProperty(const char* name, bool defValue)
{
    bool result = defValue;
    OSData* data = OSDynamicCast(OSData, getProperty(name));
    if (data && data->getLength() == 1)
        result = *static_cast<const UInt8*>(data->getBytesNoCopy());
    return result;
}
bool IOEthernetInterface::controllerDidOpen(IONetworkController * ctr)
{
    bool                 ret = false;
    OSData *             addrData;
    IOEthernetAddress *  addr;

    do {
        // Call the controllerDidOpen() in superclass first.

        if ( (ctr == 0) || (super::controllerDidOpen(ctr) == false) )
             break;

        // If the controller supports some form of multicast filtering,
        // then set the ifnet IFF_MULTICAST flag.

        if ( GET_SUPPORTED_FILTERS(gIONetworkFilterGroup) &
             (kIOPacketFilterMulticast | kIOPacketFilterMulticastAll) )
        {
            setFlags(IFF_MULTICAST);
        }

        // Advertise Wake on Magic Packet feature if supported.
        
        if ( _supportedWakeFilters & kIOEthernetWakeOnMagicPacket )
        {
            IOPMrootDomain * root = getPMRootDomain();
            if ( root ) root->publishFeature( kWOMPFeatureKey,
                             kIOPMSupportedOnAC | kIOPMSupportedOnUPS, 
                             (uint32_t *)&_publishedFeatureID);
        }

        // Get the controller's MAC/Ethernet address.

        addrData = OSDynamicCast(OSData, ctr->getProperty(kIOMACAddress));
        if ( (addrData == 0) || (addrData->getLength() != ETHER_ADDR_LEN) )
        {
            DLOG("%s: kIOMACAddress property access error (len %d)\n",
                 getName(), addrData ? addrData->getLength() : 0);
            break;
        }

        addr = (IOEthernetAddress *) addrData->getBytesNoCopy();

        DLOG("%s: Ethernet address %02x:%02x:%02x:%02x:%02x:%02x\n",
              ctr->getName(),
              addr->bytes[0],
              addr->bytes[1],
              addr->bytes[2],
              addr->bytes[3],
              addr->bytes[4],
              addr->bytes[5]);

        ret = true;
    }
    while (0);

    return ret;
}
Esempio n. 18
0
// TODO: is it safe to make the data in here static?  It would speed things up slightly.
IOReturn com_veltrop_taylor_driver_virtualhid::setProperties( OSObject * properties )
{
	//IOLog("set properties to driver!!\n");
	OSData* data = OSDynamicCast(OSData, properties);
	if (data) {
		//	int length = data->getLength();	// passing a Hacked/Broken OSData object to this could make us unreliable, lets manually set 3 below, and later only explicitly access known memory!
		const UInt8* button_vector = (const UInt8*)data->getBytesNoCopy(0,3);
		// button_vector[0] -> button number / joystick number
		// button_vector[1] -> button state / button data
		// button_vector[2] -> button data 2
		
		if (_myReportBufferDescInternal) {
			UInt8 target = button_vector[0];
			if (target == hid_XYZ) {
				_myReportBufferDescInternal[0] = button_vector[1];
				_myReportBufferDescInternal[1] = button_vector[2];
			}
			else if (target == hid_rXYZ) {
				_myReportBufferDescInternal[2] = button_vector[1];
				_myReportBufferDescInternal[3] = button_vector[2];
			}
			else if (target == WiiRemoteUpButton || target == WiiRemoteDownButton) {	// swap x with y, the wii mote is probably rotated. > make this an option and do it from the wiiji side
				_myReportBufferDescInternal[0] = button_vector[1] * ((target == WiiRemoteDownButton)*(127) - (target == WiiRemoteUpButton)*(127)); 	// make sure these values stay exclusive
			}
			else if (target == WiiRemoteRightButton || target == WiiRemoteLeftButton) {
				_myReportBufferDescInternal[1] = button_vector[1] * ((target == WiiRemoteLeftButton)*(127) - (target == WiiRemoteRightButton)*(127));
			}
			else {				
				if (target >= WiiRemoteUpButton)	// compensate for the unused dpad button inputs (we route it to x/y right now)
					target -= 4;
				
				int bitoffset = target % 8;
				int octet     = target / 8 + 4;
				UInt8 action  = 0x0001 << bitoffset;
			
				if (octet >= myReportDescSize)
					return kIOReturnError;
			
				if (button_vector[1]) {
					_myReportBufferDescInternal[octet] = _myReportBufferDescInternal[octet] | action;
				}
				else {
					_myReportBufferDescInternal[octet] = _myReportBufferDescInternal[octet] & ~action;
				}
			} 
			
			if (handleReport(_myReportBufferDesc) != kIOReturnSuccess) {
				IOLog("com_veltrop_taylor_driver_virtualhid: handleReport failed in setProperties");
				return kIOReturnError;
			}
			
			return kIOReturnSuccess;
		}
	}
	
	return kIOReturnError;
}
Esempio n. 19
0
IOMapper * IOMapper::copyMapperForDeviceWithIndex(IOService * device, unsigned int index)
{
    OSData *data;
    OSObject * obj;
    IOMapper * mapper = NULL;
    OSDictionary * matching;
    
    obj = device->copyProperty("iommu-parent");
    if (!obj) return (NULL);

    if ((mapper = OSDynamicCast(IOMapper, obj))) goto found;

    if ((data = OSDynamicCast(OSData, obj)))
    {
        if (index >= data->getLength() / sizeof(UInt32)) goto done;
        
        data = OSData::withBytesNoCopy((UInt32 *)data->getBytesNoCopy() + index, sizeof(UInt32));
        if (!data) goto done;

        matching = IOService::propertyMatching(gIOMapperIDKey, data);
        data->release();
    }
    else
        matching = IOService::propertyMatching(gIOMapperIDKey, obj);

    if (matching)
    {
        mapper = OSDynamicCast(IOMapper, IOService::waitForMatchingService(matching));
        matching->release();
    }

done:
    if (obj) obj->release();
found:
    if (mapper)
    {
        if (!mapper->fAllocName)
        {
            char name[MACH_ZONE_NAME_MAX_LEN];
            char kmodname[KMOD_MAX_NAME];
            vm_tag_t tag;
            uint32_t kmodid;

            tag = IOMemoryTag(kernel_map);
            if (!(kmodid = vm_tag_get_kext(tag, &kmodname[0], KMOD_MAX_NAME)))
            {
                snprintf(kmodname, sizeof(kmodname), "%d", tag);
            }
            snprintf(name, sizeof(name), "%s.DMA.%s", kmodname, device->getName());
            mapper->fAllocName = kern_allocation_name_allocate(name, 16);
        }
    }

    return (mapper);
}
Esempio n. 20
0
bool NullEthernet::initMACfromProvider()
{
    bool result = false;
    OSData* pData = OSDynamicCast(OSData, m_pProvider->getProperty("RM,MAC-address"));
    if (pData && pData->getLength() == kIOEthernetAddressSize)
    {
        bcopy(pData->getBytesNoCopy(), m_rgMacAddr, kIOEthernetAddressSize);
        AlwaysLog("Using MAC address from provider: %02x:%02x:%02x:%02x:%02x:%02x\n", m_rgMacAddr[0], m_rgMacAddr[1], m_rgMacAddr[2], m_rgMacAddr[3], m_rgMacAddr[4], m_rgMacAddr[5]);
        result = true;
    }
    return result;
}
Esempio n. 21
0
void IODMAController::registerDMAController(IOOptionBits options)
{
    OSData *phandleData;

    phandleData = OSDynamicCast(OSData, _provider->getProperty("AAPL,phandle"));

    _dmaControllerName = createControllerName(*(UInt32 *)phandleData->getBytesNoCopy());

    setName(_dmaControllerName);

    registerService(options | ((options & kIOServiceAsynchronous) ? 0 : kIOServiceSynchronous));
}
Esempio n. 22
0
void MacRISC2CPU::haltCPU(void)
{
	OSIterator 		*childIterator;
	IORegistryEntry *childEntry, *childDriver;
	IOPCIBridge		*pciDriver;
	OSData			*deviceTypeString;
	UInt32			i;

  
    setCPUState(kIOCPUStateStopped);
  
    if (bootCPU)
    {
		// Some systems require special handling of Ultra-ATA at sleep.
		// Call UniN to prepare for that, if necessary
		uniN->callPlatformFunction ("setupUATAforSleep", false, (void *)0, (void *)0, (void *)0, (void *)0);

		// Notify our pci children to save their state
		if (!topLevelPCIBridgeCount) {
			// First build list of top level bridges - only need to do once as these don't change
			if ((childIterator = macRISC2PE->getChildIterator (gIOServicePlane)) != NULL) {
				while ((childEntry = (IORegistryEntry *)(childIterator->getNextObject ())) != NULL) {
					deviceTypeString = OSDynamicCast( OSData, childEntry->getProperty( "device_type" ));
					if (deviceTypeString) {
						if (!strcmp((const char *)deviceTypeString->getBytesNoCopy(), "pci")) {
							childDriver = childEntry->copyChildEntry(gIOServicePlane);
							if (childDriver) {
								pciDriver = OSDynamicCast( IOPCIBridge, childDriver );
								if (pciDriver)
									if (topLevelPCIBridgeCount < kMaxPCIBridges)
										// Remember this driver
										topLevelPCIBridges[topLevelPCIBridgeCount++] = pciDriver;
									else
										kprintf ("MacRISC2CPU::haltCPU - warning, more than %d PCI bridges - cannot save/restore them all\n", kMaxPCIBridges);
								childDriver->release();
							}
						}
					}
				}
				childIterator->release();
			}
		}
		for (i = 0; i < topLevelPCIBridgeCount; i++)
			if (pciDriver = topLevelPCIBridges[i]) {
				// Got the driver - send the message
				pciDriver->setDevicePowerState (NULL, 2);
			}
    }

   kprintf("MacRISC2CPU::haltCPU %ld Here!\n", getCPUNumber());

   processor_exit(machProcessor);
}
static bool GetUInt32( IORegistryEntry * regEntry, const OSSymbol * name,
			UInt32 * value )
{
    OSData	*data;

    if( (data = OSDynamicCast( OSData, regEntry->getProperty( name )))
      && (4 == data->getLength())) {
        *value = *((UInt32 *) data->getBytesNoCopy());
        return( true );
    } else
        return( false );
}
//----------------------------------------------------------------------------------------------------
// IOHIDUserDevice::newReportDescriptor
//----------------------------------------------------------------------------------------------------
IOReturn IOHIDUserDevice::newReportDescriptor(IOMemoryDescriptor ** descriptor ) const
{
    OSData *                    data;
    
    data = OSDynamicCast(OSData, _properties->getObject(kIOHIDReportDescriptorKey));
    if ( !data )
        return kIOReturnError;
            
	*descriptor = IOBufferMemoryDescriptor::withBytes(data->getBytesNoCopy(), data->getLength(), kIODirectionNone);

	return kIOReturnSuccess;
}
Esempio n. 25
0
int VoodooI2CHIDDevice::i2c_get_slave_address(I2CDevice* hid_device){
    OSObject* result = NULL;
    
    hid_device->provider->evaluateObject("_CRS", &result);
    
    OSData* data = OSDynamicCast(OSData, result);
    
    hid_device->addr = *(int*)data->getBytesNoCopy(16,1) & 0xFF;

    data->release();
    
    return 0;
    
}
Esempio n. 26
0
bool IODTPlatformExpert::getMachineName( char * name, int maxLength )
{
    OSData *		prop;
    bool		ok = false;

    maxLength--;
    prop = (OSData *) getProvider()->getProperty( gIODTModelKey );
    ok = (0 != prop);

    if( ok )
	strncpy( name, (const char *) prop->getBytesNoCopy(), maxLength );

    return( ok );
}
Esempio n. 27
0
IOReturn IOInterruptController::causeInterrupt(IOService *nub, int source)
{
  IOInterruptSource *interruptSources;
  IOInterruptVectorNumber vectorNumber;
  IOInterruptVector *vector;
  OSData            *vectorData;

  interruptSources = nub->_interruptSources;
  vectorData = interruptSources[source].vectorData;
  vectorNumber = *(IOInterruptVectorNumber *)vectorData->getBytesNoCopy();
  vector = &vectors[vectorNumber];
  
  causeVector(vectorNumber, vector);
  
  return kIOReturnSuccess;
}
static IORegistryEntry * FindPHandle( UInt32 phandle )
{
    OSData			*data;
    IORegistryEntry *regEntry = 0;
    int				i;

    for( i = 0; (data = (OSData *)gIODTPHandles->getObject( i )); i++ ) {
        if( phandle == *((UInt32 *)data->getBytesNoCopy())) {
            regEntry = (IORegistryEntry *)
            gIODTPHandleMap->getObject( i );
            break;
        }
    }

    return( regEntry );
}
bool getFSB() {
	FSB = 0;
	IORegistryEntry* efi = IORegistryEntry::fromPath("/efi/platform", IORegistryEntry::getPlane("IODeviceTree"));
	if (efi == 0) {
		warn("EFI registry entry not found!\n");
		return false;
	}
	OSData* fsb = (OSData*) efi->getProperty("FSBFrequency");
	if (fsb == 0) {
		warn("FSB frequency entry not found!\n");
		return false;
	}
	bcopy(fsb->getBytesNoCopy(), &FSB, 8);
	info("FSB = %llu MHz\n", FSB/1000000ULL);
	efi = 0; fsb = 0; // in dono ka kaam khatam	
	return true;
}
Esempio n. 30
0
IODMAController *IODMAController::getController(IOService *provider, UInt32 dmaIndex)
{
    OSData          *dmaParentData;
    const OSSymbol  *dmaParentName;
    IODMAController *dmaController;

    // Find the name of the parent dma controller
    dmaParentData = OSDynamicCast(OSData, provider->getProperty("dma-parent"));
    if (dmaParentData == 0) return NULL;
    dmaParentName = createControllerName(*(UInt32 *)dmaParentData->getBytesNoCopy());
    if (dmaParentName == 0) return NULL;

    // Wait for the parent dma controller
    dmaController = OSDynamicCast(IODMAController, IOService::waitForService(IOService::nameMatching(dmaParentName)));

    return dmaController;
}