Detect CPUs in a more reliable fashion

pull/16/head
Timothy Pearson 13 years ago
parent d2480b90f5
commit 7fd6a1177d

@ -2137,13 +2137,15 @@ void TDEHardwareDevices::processModifiedCPUs() {
processorNumber = curline.toInt(); processorNumber = curline.toInt();
if (!cdevice) { if (!cdevice) {
cdevice = dynamic_cast<TDECPUDevice*>(findBySystemPath(TQString("/sys/devices/system/cpu/cpu%1").arg(processorNumber))); cdevice = dynamic_cast<TDECPUDevice*>(findBySystemPath(TQString("/sys/devices/system/cpu/cpu%1").arg(processorNumber)));
// Set up CPU information structures if (cdevice) {
if (cdevice->name() != modelName) modified = true; // Set up CPU information structures
cdevice->internalSetName(modelName); if (cdevice->name() != modelName) modified = true;
if (cdevice->vendorName() != vendorName) modified = true; cdevice->internalSetName(modelName);
cdevice->internalSetVendorName(vendorName); if (cdevice->vendorName() != vendorName) modified = true;
if (cdevice->vendorEncoded() != vendorName) modified = true; cdevice->internalSetVendorName(vendorName);
cdevice->internalSetVendorEncoded(vendorName); if (cdevice->vendorEncoded() != vendorName) modified = true;
cdevice->internalSetVendorEncoded(vendorName);
}
} }
} }
curline = curline.stripWhiteSpace(); curline = curline.stripWhiteSpace();
@ -4630,33 +4632,24 @@ void TDEHardwareDevices::addCoreSystemDevices() {
// Handle CPUs, which are currently handled terribly by udev // Handle CPUs, which are currently handled terribly by udev
// Parse /proc/cpuinfo to extract some information about the CPUs // Parse /proc/cpuinfo to extract some information about the CPUs
hwdevice = 0; hwdevice = 0;
TQStringList lines; TQDir d("/sys/devices/system/cpu/");
TQFile file( "/proc/cpuinfo" ); d.setFilter( TQDir::Dirs );
if ( file.open( IO_ReadOnly ) ) { const TQFileInfoList *list = d.entryInfoList();
TQTextStream stream( &file ); TQFileInfoListIterator it( *list );
TQString line; TQFileInfo *fi;
int processorNumber = -1; while ((fi = it.current()) != 0) {
while ( !stream.atEnd() ) { TQString directoryName = fi->fileName();
line = stream.readLine(); if (directoryName.startsWith("cpu")) {
// WARNING This routine assumes that "processor" is always the first entry in /proc/cpuinfo! directoryName = directoryName.remove(0,3);
// FIXME Parse all available information, such as frequency, etc. bool isInt;
if (line.startsWith("processor")) { int processorNumber = directoryName.toUInt(&isInt, 10);
line.remove(0, line.find(":")+1); if (isInt) {
line = line.stripWhiteSpace();
processorNumber = line.toInt();
hwdevice = new TDECPUDevice(TDEGenericDeviceType::CPU); hwdevice = new TDECPUDevice(TDEGenericDeviceType::CPU);
hwdevice->internalSetSystemPath(TQString("/sys/devices/system/cpu/cpu%1").arg(processorNumber)); hwdevice->internalSetSystemPath(TQString("/sys/devices/system/cpu/cpu%1").arg(processorNumber));
m_deviceList.append(hwdevice); m_deviceList.append(hwdevice);
#if 0
// Set up CPU information monitor
// The only way CPU information can be changed is if something changes in the cpufreq node
// This may change in the future, but for now it is a fairly good assumption
m_cpuWatch->addDir(TQString("/sys/devices/system/cpu/cpu%1/cpufreq").arg(processorNumber));
#endif
} }
lines += line;
} }
file.close(); ++it;
} }
// Populate CPU information // Populate CPU information

Loading…
Cancel
Save