本文整理汇总了C++中OSString::isEqualTo方法的典型用法代码示例。如果您正苦于以下问题:C++ OSString::isEqualTo方法的具体用法?C++ OSString::isEqualTo怎么用?C++ OSString::isEqualTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OSString
的用法示例。
在下文中一共展示了OSString::isEqualTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cast
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;
}
示例2: start
bool FakeSMC::start(IOService *provider)
{
if (!super::start(provider))
return false;
OSString *vendor = OSDynamicCast(OSString, getProperty(kFakeSMCFirmwareVendor));
int arg_value = 1;
if (PE_parse_boot_argn("-fakesmc-force-start", &arg_value, sizeof(arg_value))) {
HWSensorsInfoLog("firmware vendor check disabled");
}
else if (vendor && vendor->isEqualTo("Apple")) {
HWSensorsFatalLog("forbidding start on Apple hardware");
return false;
}
if (!smcDevice->initAndStart(provider, this)) {
HWSensorsInfoLog("failed to initialize SMC device");
return false;
}
registerService();
// Load keys from NVRAM
if (PE_parse_boot_argn("-fakesmc-use-nvram", &arg_value, sizeof(arg_value))) {
if (UInt32 count = smcDevice->loadKeysFromNVRAM())
HWSensorsInfoLog("%d key%s loaded from NVRAM", count, count == 1 ? "" : "s");
else
HWSensorsInfoLog("NVRAM will be used to store system written keys...");
}
return true;
}
示例3: withCString
OSString* Xbox360ControllerClass::newProductString() const
{
OSString *retString = getDeviceString(GetOwnerProvider(this)->GetProductStringIndex());
if (retString->isEqualTo("Controller")) {
retString->release();
return OSString::withCString("Xbox 360 Wired Controller");
} else {
return retString;
}
}
示例4: initWithHeader
bool AppleLVMVolume::initWithHeader(OSDictionary * props)
{
IOLog1("AppleLVMVolume::initWithHeader() entered\n");
if (lvProps) lvProps->release();
lvProps = props;
lvProps->retain();
if (!getVolumeUUID()) return false;
if (!getGroupUUID()) return false;
OSNumber * number;
number = OSDynamicCast(OSNumber, lvProps->getObject(kAppleLVMVolumeSequenceKey));
if (!number) return false;
lvSequenceNumber = number->unsigned32BitValue();
number = OSDynamicCast(OSNumber, lvProps->getObject(kAppleLVMVolumeExtentCountKey));
if (!number) return false;
lvExtentCount = number->unsigned64BitValue();
number = OSDynamicCast(OSNumber, lvProps->getObject(kAppleLVMVolumeSizeKey));
if (!number) return false;
lvClaimedSize = number->unsigned64BitValue();
OSString * type = OSDynamicCast(OSString, lvProps->getObject(kAppleLVMVolumeTypeKey));
if (!type) return false;
if (type->isEqualTo(kAppleLVMVolumeTypeConcat)) lvTypeID = kLVMTypeConcat;
if (type->isEqualTo(kAppleLVMVolumeTypeBitMap)) lvTypeID = kLVMTypeBitMap;
if (type->isEqualTo(kAppleLVMVolumeTypeSnapRO)) lvTypeID = kLVMTypeSnapRO;
if (type->isEqualTo(kAppleLVMVolumeTypeSnapRW)) lvTypeID = kLVMTypeSnapRW;
if (type->isEqualTo(kAppleLVMVolumeTypeMaster)) lvTypeID = kLVMTypeMaster;
if (!lvTypeID) return false;
lvSnapShot = NULL; // just clear these, they might not exist yet.
lvBitMap = NULL;
lvParent = NULL;
IOLog1("AppleLVMVolume::initWithHeader() successful for %s, size = %llu extent count = %llu\n",
getVolumeUUIDString(), lvClaimedSize, lvExtentCount);
return true;
}
示例5: addTemperatureSensors
bool SuperIOMonitor::addTemperatureSensors(OSDictionary *configuration)
{
HWSensorsDebugLog("adding temperature sensors...");
for (int i = 0; i < temperatureSensorsLimit(); i++)
{
char key[8];
OSString* name;
float reference = 0.0f;
float gain = 0.0f;
float offset = 0.0f;
snprintf(key, 8, "TEMPIN%X", i);
if (process_sensor_entry(configuration->getObject(key), &name, &reference, &gain, &offset)) {
if (name->isEqualTo("CPU")) {
if (!addSensor(KEY_CPU_HEATSINK_TEMPERATURE, TYPE_SP78, TYPE_SPXX_SIZE, kSuperIOTemperatureSensor, i, reference, gain, offset))
HWSensorsWarningLog("can't add CPU temperature sensor");
}
if (name->isEqualTo("CPU Proximity")) {
if (!addSensor(KEY_CPU_PROXIMITY_TEMPERATURE, TYPE_SP78, TYPE_SPXX_SIZE, kSuperIOTemperatureSensor, i, reference, gain, offset))
HWSensorsWarningLog("can't add CPU Proximity temperature sensor");
}
else if (name->isEqualTo("System")) {
if (!addSensor(KEY_NORTHBRIDGE_TEMPERATURE, TYPE_SP78, TYPE_SPXX_SIZE, kSuperIOTemperatureSensor, i, reference, gain, offset))
HWSensorsWarningLog("can't add System temperature sensor");
}
else if (name->isEqualTo("Ambient")) {
if (!addSensor(KEY_AMBIENT_TEMPERATURE, TYPE_SP78, TYPE_SPXX_SIZE, kSuperIOTemperatureSensor, i, reference, gain, offset))
HWSensorsWarningLog("can't add Ambient temperature sensor");
}
else if (name->isEqualTo("PCH")) {
if (!addSensor(KEY_PCH_DIE_TEMPERATURE, TYPE_SP78, TYPE_SPXX_SIZE, kSuperIOTemperatureSensor, i, reference, gain, offset))
HWSensorsWarningLog("can't add PCH temperature sensor");
}
}
}
return true;
}
示例6: passiveMatch
bool FileNVRAM::passiveMatch (OSDictionary *matching, bool changesOK)
{
OSString *str = OSDynamicCast(OSString, matching->getObject(gIOProviderClassKey));
if (str)
{
LOG(NOTICE, "passiveMatch(%s) called\n", str->getCStringNoCopy());
}
if (str && str->isEqualTo("AppleEFINVRAM"))
{
return true;
}
return super::passiveMatch (matching, changesOK);
}
示例7: OSDynamicCast
bool
IOUSBNub::IsWildCardMatch( OSDictionary * matching, const char * key )
{
// We return success iff the key in the dictionary exists AND it is a OSString "*"
// the property table.
//
OSString *theString;
bool matches;
theString = OSDynamicCast(OSString, matching->getObject( key ));
if ( theString)
matches = theString->isEqualTo("*");
else
matches = false;
return matches;
}
示例8: DbgLog
IOService * DellWMIController::probe(IOService *provider, SInt32 *score )
{
IOService * ret = NULL;
OSObject * obj;
OSString * name;
IOACPIPlatformDevice *dev;
do
{
DbgLog("%s: Probe()\n", this->getName());
if (!super::probe(provider, score))
continue;
dev = OSDynamicCast(IOACPIPlatformDevice, provider);
if (NULL == dev)
continue;
dev->evaluateObject("_UID", &obj);
name = OSDynamicCast(OSString, obj);
if (NULL == name)
continue;
DbgLog("%s: Probe(%s)\n", this->getName(), name->getCStringNoCopy());
if (name->isEqualTo("DELLWMI"))
{
DbgLog("%s: Probe(OK)\n", this->getName());
*score +=20;
ret = this;
}
name->release();
}
while (false);
return (ret);
}
示例9: if
OSString * IOHIDDeviceShim::newProductString() const
{
OSString * string = NULL;
OSString * returnString = NULL;
if (_device &&
((string = OSDynamicCast(OSString, _device->getProperty("USB Product Name"))) ||
(string = OSDynamicCast(OSString, _device->getProperty(kIOHIDProductKey)))))
{
returnString = OSString::withString(string);
}
else if (_hiDevice)
{
if (_hiDevice->hidKind() == kHIRelativePointingDevice)
{
if ((string = (OSString *)_hiDevice->getProperty(kIOHIDPointerAccelerationTypeKey)) &&
(string->isEqualTo(kIOHIDTrackpadAccelerationType)))
{
returnString = OSString::withCString("Trackpad");
}
else
{
returnString = OSString::withCString("Mouse");
}
}
else if (_hiDevice->hidKind() == kHIKeyboardDevice)
{
returnString = (_transport == kIOHIDTransportADB) ? OSString::withCString("Built-in keyboard") : OSString::withCString("Keyboard");
}
}
if ( _hiDevice && returnString )
_hiDevice->setProperty(kIOHIDProductKey, returnString);
return returnString;
}
示例10: switch
/*-----------------------------------------------------------------------------*
* Script engine PCI initialization
*
* This routine determines the chip version/revision, enables the chip address
* ranges and allocates a virtual mapping to the script engine's registers and
* on-board ram.
*-----------------------------------------------------------------------------*/
bool Sym8xxSCSIController::Sym8xxInitPCI()
{
unsigned long pciReg0, pciReg8;
UInt32 chipRev;
UInt32 n;
UInt32 ramReg;
OSString *matchEntry;
/*
* Determine the number of memory ranges for the PCI device.
*
* The hardware implementation may or may not have a ROM present
* accounting for the difference in the number of ranges.
*/
n = provider->getDeviceMemoryCount();
if ( !( n == 3 || n == 4 ) )
{
return false;
}
/*
* Determine the hardware version. Check the deviceID and
* RevID in the PCI config regs.
*/
pciReg0 = provider->configRead32( 0x00 );
pciReg8 = provider->configRead32( 0x08 );
chipId = pciReg0 >> 16;
chipRev = pciReg8 & 0xff;
// IOLog( "SCSI(Symbios8xx): Chip Id = %04x Chip rev = %02x\n\r", chipId, chipRev );
ioMapRegs = provider->mapDeviceMemoryWithRegister( 0x14 );
if ( ioMapRegs == 0 )
{
return false;
}
switch ( chipId )
{
case kChipIdSym875:
ramReg = 0x18;
break;
case kChipIdSym895:
case kChipIdSym896:
case kChipIdSym1010:
ramReg = 0x1C;
break;
default:
ramReg = 0x1C;
}
ioMapRam = provider->mapDeviceMemoryWithRegister( ramReg );
if ( ioMapRam == 0 )
{
return false;
}
/*
* Assume 80Mhz external clock rate for motherboard 875 implementations
* and 40Mhz for others.
*/
matchEntry = OSDynamicCast( OSString, getProperty( gIONameMatchedKey ) );
if ( matchEntry == 0 )
{
IOLog("SCSI(Sym8xx): Cannot obtain matching property.\n");
return false;
}
if ( matchEntry->isEqualTo( "apple53C8xx" ) == true )
{
chipClockRate = CLK_80MHz;
}
else
{
chipClockRate = CLK_40MHz;
}
/*
* BUS MASTER, MEM I/O Space, MEM WR & INV
*/
provider->configWrite32( 0x04, 0x16 );
/*
* set Latency to Max , cache 32
*/
provider->configWrite32( 0x0C, 0x2008 );
/*
//.........这里部分代码省略.........
示例11: DLOG
/*---------------------------------------------------------------------------
*
* Intercept the setup for the control register pointers so we can set the
* timing register in the cell to some safe value prior to scanning for devices
* start.
*
*
---------------------------------------------------------------------------*/
bool
AppleKiwiATA::configureTFPointers(void)
{
DLOG("AppleKiwiATA config TF Pointers \n");
OSString* locationCompare = OSString::withCString( "1" );
if( locationCompare->isEqualTo( getProvider()->getLocation() ))
{
busChildNumber = 1;
}
locationCompare->release();
locationCompare = NULL;
DLOG("AppleKiwiATA busChildNumber = %d, string = %1s \n", busChildNumber, getProvider()->getLocation());
ioBaseAddrMap[0] = getProvider()->mapDeviceMemoryWithIndex( busChildNumber == 0 ? 0 : 2 );
if ( ioBaseAddrMap[0] == NULL )
{
return false;
}
volatile UInt8* baseAddress = (volatile UInt8*)ioBaseAddrMap[0]->getVirtualAddress();
_tfDataReg = (volatile UInt16*) (baseAddress + 0x00);
_tfFeatureReg = baseAddress + 0x01;
_tfSCountReg = baseAddress + 0x02;
_tfSectorNReg = baseAddress + 0x03;
_tfCylLoReg = baseAddress + 0x04;
_tfCylHiReg = baseAddress + 0x05;
_tfSDHReg = baseAddress + 0x06;
_tfStatusCmdReg = baseAddress + 0x07;
DLOG("AppleKiwiATA base address 0 = %lX \n", baseAddress);
// get the address of the alt-status register from the second base address.
ioBaseAddrMap[1] = getProvider()->mapDeviceMemoryWithIndex( busChildNumber == 0 ? 1 : 3 );
if ( ioBaseAddrMap[1] == NULL )
{
return false;
}
baseAddress = (volatile UInt8 *)ioBaseAddrMap[1]->getVirtualAddress();
_tfAltSDevCReg = baseAddress + 2;
DLOG("AppleKiwiATA base address 1 = %lX altStatus at %lx \n", baseAddress, _tfAltSDevCReg);
// get the address of the BusMaster/DMA control registers from last base address.
ioBaseAddrMap[2] = getProvider()->mapDeviceMemoryWithIndex( 4 );
if ( ioBaseAddrMap[2] == NULL )
{
return false;
}
volatile UInt8* bmAddress = (volatile UInt8*)ioBaseAddrMap[2]->getVirtualAddress();
if( busChildNumber == 1)
{
bmAddress += 0x08; // secondary bus
}
DLOG("AppleKiwiATA base address 2 = %lX \n", bmAddress);
_bmCommandReg = bmAddress;
_bmStatusReg = bmAddress + 2;
_bmPRDAddresReg = (volatile UInt32*) (bmAddress + 4);
// get the address of the mmio control registers from base address 5.
ioBaseAddrMap[3] = getProvider()->mapDeviceMemoryWithIndex( 5 );
if ( ioBaseAddrMap[3] == NULL )
{
return false;
}
volatile UInt8* bar5Address = (volatile UInt8*)ioBaseAddrMap[3]->getVirtualAddress();
DLOG("AppleKiwiATA base address 5 = %lx \n", bar5Address);
if( busChildNumber == 1)
{
globalControlReg = (volatile UInt32*) (bar5Address + 0x1208); // secondary bus
timingAReg0 =(volatile UInt32*) (bar5Address + 0x120c);
timingBReg0 =(volatile UInt32*) (bar5Address + 0x1210);
timingAReg1 =(volatile UInt32*) (bar5Address + 0x1214);
timingBReg1 =(volatile UInt32*) (bar5Address + 0x1218);
} else {
//.........这里部分代码省略.........
示例12: if
bool IT87x::start(IOService * provider)
{
DebugLog("starting ...");
if (!super::start(provider))
return false;
InfoLog("found ITE %s", getModelName());
OSDictionary* list = OSDynamicCast(OSDictionary, getProperty("Sensors Configuration"));
OSDictionary *configuration=NULL;
OSData *data;
IORegistryEntry * rootNode = fromPath("/efi/platform", gIODTPlane);
if(rootNode) {
data = OSDynamicCast(OSData, rootNode->getProperty("OEMVendor"));
if (data) {
bcopy(data->getBytesNoCopy(), vendor, data->getLength());
OSString * VendorNick = vendorID(OSString::withCString(vendor));
if (VendorNick) {
data = OSDynamicCast(OSData, rootNode->getProperty("OEMBoard"));
if (!data) {
WarningLog("no OEMBoard");
data = OSDynamicCast(OSData, rootNode->getProperty("OEMProduct"));
}
if (data) {
bcopy(data->getBytesNoCopy(), product, data->getLength());
OSDictionary *link = OSDynamicCast(OSDictionary, list->getObject(VendorNick));
if (link){
configuration = OSDynamicCast(OSDictionary, link->getObject(OSString::withCString(product)));
InfoLog(" mother vendor=%s product=%s", vendor, product);
}
}
} else {
WarningLog("unknown OEMVendor %s", vendor);
}
} else {
WarningLog("no OEMVendor");
}
}
if (list && !configuration) {
configuration = OSDynamicCast(OSDictionary, list->getObject("Default"));
WarningLog("set default configuration");
}
if(configuration) {
this->setProperty("Current Configuration", configuration);
}
// Temperature Sensors
if (configuration) {
for (int i = 0; i < 3; i++) {
char key[8];
snprintf(key, 8, "TEMPIN%X", i);
if(readTemperature(i)<MAX_TEMP_THRESHOLD) { // Need to check if temperature sensor valid
if (OSString* name = OSDynamicCast(OSString, configuration->getObject(key))) {
if (name->isEqualTo("CPU")) {
if (!addSensor(KEY_CPU_HEATSINK_TEMPERATURE, TYPE_SP78, 2, kSuperIOTemperatureSensor, i)) {
WarningLog("error adding heatsink temperature sensor");
}
}
else if (name->isEqualTo("System")) {
if (!addSensor(KEY_NORTHBRIDGE_TEMPERATURE, TYPE_SP78, 2, kSuperIOTemperatureSensor,i)) {
WarningLog("error adding system temperature sensor");
}
}
else if (name->isEqualTo("Ambient")) {
if (!addSensor(KEY_AMBIENT_TEMPERATURE, TYPE_SP78, 2, kSuperIOTemperatureSensor,i)) {
WarningLog("error adding Ambient temperature sensor");
}
}
}
}
}
}
else {
if(readTemperature(0)<MAX_TEMP_THRESHOLD) // Need to check if temperature sensor valid
if (!addSensor(KEY_CPU_HEATSINK_TEMPERATURE, TYPE_SP78, 2, kSuperIOTemperatureSensor, 0)) {
WarningLog("error adding heatsink temperature sensor");
}
if(readTemperature(1)<MAX_TEMP_THRESHOLD) // Need to check if temperature sensor valid
if (!addSensor(KEY_AMBIENT_TEMPERATURE, TYPE_SP78, 2, kSuperIOTemperatureSensor, 1)) {
WarningLog("error adding Ambient temperature sensor");
}
if(readTemperature(2)<MAX_TEMP_THRESHOLD) // Need to check if temperature sensor valid
if (!addSensor(KEY_NORTHBRIDGE_TEMPERATURE, TYPE_SP78, 2, kSuperIOTemperatureSensor, 2)) {
WarningLog("error adding system temperature sensor");
}
}
// Voltage
UInt8 tmp = readByte(address, ITE_ADC_CHANNEL_ENABLE);
DebugLog("ADC Enable register = %X",tmp);
vbat_updates = false;
if(configuration)
{
//.........这里部分代码省略.........
示例13: start
bool PTIDSensors::start(IOService * provider)
{
if (!super::start(provider))
return false;
acpiDevice = (IOACPIPlatformDevice *)provider;
if (!acpiDevice) {
HWSensorsFatalLog("ACPI device not ready");
return false;
}
// Update timers
clock_get_system_nanotime((clock_sec_t*)&temperatureNextUpdate.tv_sec, (clock_nsec_t*)&temperatureNextUpdate.tv_nsec);
acpiDevice->evaluateInteger("IVER", &version);
if (version == 0) {
OSString *name = OSDynamicCast(OSString, getProperty("IONameMatched"));
if (name && name->isEqualTo("INT3F0D"))
version = 0x30000;
else
return false;
}
setProperty("version", version, 64);
// Parse sensors
switch (version) {
case 0x30000: {
OSObject *object = NULL;
// Temperatures
if(kIOReturnSuccess == acpiDevice->evaluateObject("TSDL", &object) && object) {
OSArray *description = OSDynamicCast(OSArray, object);
if (OSIterator *iterator = OSCollectionIterator::withCollection(description)) {
HWSensorsDebugLog("Parsing temperatures...");
UInt32 count = 0;
while (OSObject *item = iterator->getNextObject()) {
parseTemperatureName(OSDynamicCast(OSString, item), count / 2);
count += 2;
}
}
}
else HWSensorsErrorLog("failed to evaluate TSDL table");
// Tachometers
if(kIOReturnSuccess == acpiDevice->evaluateObject("OSDL", &object) && object) {
OSArray *description = OSDynamicCast(OSArray, object);
if (OSIterator *iterator = OSCollectionIterator::withCollection(description)) {
HWSensorsDebugLog("Parsing tachometers...");
UInt32 count = 0;
while (OSObject *item = iterator->getNextObject()) {
parseTachometerName(OSDynamicCast(OSString, item), count / 3);
count += 3;
}
}
}
else HWSensorsErrorLog("failed to evaluate OSDL table");
break;
}
case 0x20001: {
OSObject *object = NULL;
// Temperatures
if(kIOReturnSuccess == acpiDevice->evaluateObject("TMPV", &object) && object) {
OSArray *description = OSDynamicCast(OSArray, object);
if (OSIterator *iterator = OSCollectionIterator::withCollection(description)) {
HWSensorsDebugLog("Parsing temperatures...");
UInt32 count = 0;
while (OSObject *item = iterator->getNextObject()) {
parseTemperatureName(OSDynamicCast(OSString, item), count + 1);
count += 3;
}
}
}
else HWSensorsErrorLog("failed to evaluate TMPV table");
// Tachometers
if(kIOReturnSuccess == acpiDevice->evaluateObject("OSDV", &object) && object) {
OSArray *description = OSDynamicCast(OSArray, object);
//.........这里部分代码省略.........
示例14: start
bool PTIDSensors::start(IOService * provider)
{
if (!super::start(provider))
return false;
acpiDevice = (IOACPIPlatformDevice *)provider;
if (!acpiDevice) {
HWSensorsFatalLog("ACPI device not ready");
return false;
}
// On some computers (eg. RehabMan's ProBook 4530s), the system will hang on startup
// if kernel cache is used, because of the early call to updateTemperatures and/or
// updateTachometers. At least that is the case with an SSD and a valid pre-linked
// kernel, along with kernel cache enabled. This 1000ms sleep seems to fix the problem,
// enabling a clean boot with PTIDSensors enabled.
IOSleep(1000);
// Update timers
temperaturesLastUpdated = ptimer_read() - NSEC_PER_SEC;
tachometersLastUpdated = temperaturesLastUpdated;
acpiDevice->evaluateInteger("IVER", &version);
if (version == 0) {
OSString *name = OSDynamicCast(OSString, provider->getProperty("name"));
if (name && name->isEqualTo("INT3F0D"))
version = 0x30000;
else
return false;
}
setProperty("version", version, 64);
// Parse sensors
switch (version) {
case 0x30000: {
OSObject *object = NULL;
// Temperatures
if(kIOReturnSuccess == acpiDevice->evaluateObject("TSDL", &object) && object) {
if (OSArray *description = OSDynamicCast(OSArray, object)) {
HWSensorsDebugLog("Parsing temperatures...");
int count = description->getCount();
for (int i = 1; i < count; i += 2) {
parseTemperatureName(OSDynamicCast(OSString, description->getObject(i)), i/2);
}
}
}
else HWSensorsErrorLog("failed to evaluate TSDL table");
// Tachometers
if(kIOReturnSuccess == acpiDevice->evaluateObject("OSDL", &object) && object) {
if (OSArray *description = OSDynamicCast(OSArray, object)) {
HWSensorsDebugLog("Parsing tachometers...");
int count = description->getCount();
for (int i = 2; i < count; i += 3) {
parseTachometerName(OSDynamicCast(OSString, description->getObject(i)), OSDynamicCast(OSString, description->getObject(i-1)), i/3);
}
}
}
else HWSensorsErrorLog("failed to evaluate OSDL table");
break;
}
case 0x20001: {
OSObject *object = NULL;
// Temperatures
if (kIOReturnSuccess == acpiDevice->evaluateObject("TMPV", &object) && object) {
if (OSArray *description = OSDynamicCast(OSArray, object)) {
HWSensorsDebugLog("Parsing temperatures...");
int count = description->getCount();
for (int i = 1; i < count; i += 3) {
parseTemperatureName(OSDynamicCast(OSString, description->getObject(i)), i+1);
}
}
}
else HWSensorsErrorLog("failed to evaluate TMPV table");
// Tachometers
if (kIOReturnSuccess == acpiDevice->evaluateObject("OSDV", &object) && object) {
if (OSArray *description = OSDynamicCast(OSArray, object)) {
HWSensorsDebugLog("Parsing tachometers...");
int count = description->getCount();
for (int i = 2; i < count; i += 4) {
parseTachometerName(OSDynamicCast(OSString, description->getObject(i)), OSDynamicCast(OSString, description->getObject(i-1)), i+1);
}
}
}
else HWSensorsErrorLog("failed to evaluate OSDV table");
break;
}
//.........这里部分代码省略.........
示例15: OSDynamicCast
bool
AppleFileSystemDriver::mediaNotificationHandler(
void * target, void * ref,
IOService * service,
IONotifier * notifier)
{
AppleFileSystemDriver * fs;
IOMedia * media;
IOReturn status = kIOReturnError;
OSString * contentHint;
const char * contentStr;
VolumeUUID volumeUUID;
OSString * uuidProperty;
uuid_t uuid;
bool matched = false;
DEBUG_LOG("%s[%p]::%s -> '%s'\n", kClassName, target, __func__, service->getName());
do {
fs = OSDynamicCast( AppleFileSystemDriver, (IOService *)target );
if (fs == 0) break;
media = OSDynamicCast( IOMedia, service );
if (media == 0) break;
// i.e. does it know how big it is / have a block size
if ( media->isFormatted() == false ) break;
// If the media already has a UUID property, try that first.
uuidProperty = OSDynamicCast( OSString, media->getProperty("UUID") );
if (uuidProperty != NULL) {
if (fs->_uuidString && uuidProperty->isEqualTo(fs->_uuidString)) {
VERBOSE_LOG("existing UUID property matched\n");
matched = true;
break;
}
}
// only IOMedia's with content hints are interesting
contentHint = OSDynamicCast( OSString, media->getProperty(kIOMediaContentHintKey) );
if (contentHint == NULL) break;
contentStr = contentHint->getCStringNoCopy();
if (contentStr == NULL) break;
// probe based on content hint
if ( strcmp(contentStr, "Apple_HFS" ) == 0 ||
strcmp(contentStr, "Apple_HFSX" ) == 0 ||
strcmp(contentStr, "Apple_Boot" ) == 0 ||
strcmp(contentStr, "Apple_Recovery" ) == 0 ||
strcmp(contentStr, "48465300-0000-11AA-AA11-00306543ECAC" ) == 0 || /* APPLE_HFS_UUID */
strcmp(contentStr, "426F6F74-0000-11AA-AA11-00306543ECAC" ) == 0 || /* APPLE_BOOT_UUID */
strcmp(contentStr, "5265636F-7665-11AA-AA11-00306543ECAC" ) == 0 ) { /* APPLE_RECOVERY_UUID */
status = readHFSUUID( media, (void **)&volumeUUID );
} else {
DEBUG_LOG("contentStr %s\n", contentStr);
break;
}
if (status != kIOReturnSuccess) {
break;
}
if (createUUIDFromName( kFSUUIDNamespaceSHA1,
volumeUUID.bytes, kVolumeUUIDValueLength,
uuid ) != kIOReturnSuccess) {
break;
}
#if VERBOSE
OSString *str = createStringFromUUID(uuid);
OSString *bsdn = OSDynamicCast(OSString,media->getProperty("BSD Name"));
if (str) {
IOLog(" UUID %s found on volume '%s' (%s)\n", str->getCStringNoCopy(),
media->getName(), bsdn ? bsdn->getCStringNoCopy():"");
str->release();
}
#endif
if (fs->_uuid) {
if ( uuid_compare(uuid, fs->_uuid) == 0 ) {
VERBOSE_LOG(" UUID matched on volume %s\n", media->getName());
matched = true;
}
}
} while (false);
if (matched) {
// prevent more notifications, if notifier is available
if (fs->_notifier != NULL) {
fs->_notifier->remove();
fs->_notifier = NULL;
}
DEBUG_LOG("%s::%s publishing boot-uuid-media '%s'\n", kClassName, __func__, media->getName());
IOService::publishResource( kBootUUIDMediaKey, media );
// Now that our job is done, get rid of the matching property
// and kill the driver.
//.........这里部分代码省略.........