RE: How obtain CPU info from IORegistry?
RE: How obtain CPU info from IORegistry?
- Subject: RE: How obtain CPU info from IORegistry?
- From: Guy Jonathan <email@hidden>
- Date: Thu, 30 Jan 2003 14:44:26 -0000
-----Original Message-----
From: email@hidden [
mailto:email@hidden]
Sent: 30 January 2003 12:08
To: email@hidden
Subject: How obtain CPU info from IORegistry?
Hi,
I4m trying to deal with the IORegistry (IOKit) to obtain all the info
related to the processor (clock frequency, name, cache sizes, etc...).
In the IORegistryExplorer utility I can see all this info from
IOService/Root/PowerMacx,x/Core99PE/PowerPC,xx@0 or from
IODeviceTree/Root/DeviceTree/cpus/PowerPC,xx@0... but by the moment I
haven4t had success in accessing this path from my code with the IOKit.
Please, could you help me?
Thanks a lot
Hi, I managed to get the cpu name using this method. You can get the other
characteristics by similar means.
- (NSString *)getCPUName
{
kern_return_t kernResult;
mach_port_t machPort;
io_iterator_t iterator;
io_object_t serviceObj;
CFMutableDictionaryRef classesToMatch;
const UInt8* rawdata = NULL;
CFDataRef data = NULL;
NSString* devType = @"";
NSString* nsCPU = @"Unknown";
kernResult = IOMasterPort( MACH_PORT_NULL, &machPort );
if ( kernResult == KERN_SUCCESS ) {
classesToMatch = IOServiceMatching( "IOPlatformDevice" );
if ( classesToMatch ) {
kernResult = IOServiceGetMatchingServices( machPort,
classesToMatch, &iterator );
if ( (kernResult == KERN_SUCCESS) && iterator ) {
do {
serviceObj = IOIteratorNext( iterator );
if ( serviceObj ) {
data = IORegistryEntryCreateCFProperty( serviceObj,
CFSTR( "device_type" ), kCFAllocatorDefault, 0 );
rawdata = CFDataGetBytePtr(data);
devType = [NSString stringWithCString:rawdata];
}
} while (![devType isEqual:@"cpu"]);
data = IORegistryEntryCreateCFProperty( serviceObj, CFSTR(
"name" ), kCFAllocatorDefault, 0 );
rawdata = CFDataGetBytePtr(data);
nsCPU = [NSString stringWithCString:rawdata];
IOObjectRelease(serviceObj);
}
IOObjectRelease(iterator);
}
}
mach_port_deallocate(mach_task_self(), machPort);
return nsCPU;
}
Hope this helps
Jonathan Guy
DISCLAIMER: The information in this email is confidential. The contents may
not be disclosed or used by anyone other than the addressee. If you are not
the intended recipient(s), any use, disclosure, copying, distribution or any
action taken or omitted to be taken in reliance on it is prohibited and may
be unlawful. If you have received this communication in error please notify
us by e-mail or by telephone on +44 (0) 20 7779 8888 and then delete the
e-mail and all attachments and any copies thereof.
Euromoney Institutional Investor PLC (its subsidiaries and associates)
cannot accept responsibility for the accuracy or completeness of this email
as it has been transmitted over a public network. If you suspect that the
email may have been intercepted or amended, please call the sender. Any
views expressed by an individual in this email do not necessarily reflect
views of Euromoney Institutional Investor PLC (its subsidiaries and
associates). This communication is from Euromoney Institutional Investor
PLC, a company registered in England and Wales under company number 954730
with registered office at Nestor House, Playhouse Yard, London EC4V 5EX.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.