|
// Camel - CPU Identifying Tool
// Copyright (C) 2002, Iain Chesworth
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "common.h"
// Included class header files.
#include "cpu_info.h"
// ----------------------------------------------------------------------------
//
// Linux Code:
// This is code to run the Linux version of Camel.
//
// ----------------------------------------------------------------------------
#ifndef _WIN32
int main ()
{
/*
We are going to output something similar to this - an Intel P3 @ 733 MHz
P3 (0.18 �m) With 256 KB On-Die L2 Cache - [CPU #0]
---------------------------------------------------
| Clock Freqency: 732 MHz
| Serial Number: 0000-0000-3a03-a29a-0003-27d7
|
+ On-Chip Hardware Features:
| + APIC Present
| | | APIC ID:0
| | L1 Cache: 32 KB
| | L2 Cache: 256 KB
|
+ Power Management Features:
| | No On-Chip Support
|
+ Supported Features
| [CMOV] Conditional Move Instructions
| [MTRR] Memory Type Range Register Instructions
| [MMX] MultiMedia Extensions
| [SSE] Streaming SIMD Extensions
| [SSE FP] Streaming SIMD Extensions Floating Point
*/
// Define the local variables.
CPUInfo * CPU = new CPUInfo ();
// Check for CPUID presence.
if (!CPU->DoesCPUSupportCPUID ()) {
// No CPUID support.
cerr << "CAMEL - Windows(R) / Linux CPU Identifier" << endl
<< "-----------------------------------------" << endl << endl
<< " " << BAD_CPUID << endl;
return -1;
} else {
// We have CPUID support.
cout << "CAMEL - Windows(R) / Linux CPU Identifier" << endl
<< "-----------------------------------------" << endl << endl
<< " " << CPU->GetExtendedProcessorName () << " - [CPU #0]" << endl
<< " ";
// Underline the CPU name.
for (unsigned int nCounter = 0; nCounter < strlen (CPU->GetExtendedProcessorName ()) + 11; nCounter ++ )
cout << "-";
// Terminate the end of the line.
cout << endl;
// Start outputing the hardware details.
cout << " " << "| Clock Frequency: " << CPU->GetProcessorClockFrequency () << "MHz" << endl;
// If the serial number is enabled output it.
if (CPU->DoesCPUSupportFeature (SERIALNUMBER_FEATURE))
cout << " " << "| Serial Number: " << CPU->GetProcessorSerialNumber () << endl;
// Ok, now do hardware features.
cout << " " << "|" << endl;
cout << " " << "+ On-Chip Hardware Features" << endl;
// State the APIC ID if one is present.
if (CPU->DoesCPUSupportFeature (APIC_FEATURE)) {
// Display that the processor has an AGP Peripheral Component Interconnect [APIC].
cout << " " << "|" << " " << "+ APIC Present" << endl;
// Attempt to display the ID of the APIC.
cout << " " << "|" << " " << "|" << " " << "| APIC ID: " << CPU->GetProcessorAPICID () << endl;
}
// State if the processor supports the Advanced Configuration and Power Interface [ACPI].
if (CPU->DoesCPUSupportFeature (ACPI_FEATURE))
cout << " " << "|" << " " << "| ACPI Capable" << endl;
// State if the processor supports a thermal monitor.
if (CPU->DoesCPUSupportFeature (THERMALMONITOR_FEATURE))
cout << " " << "|" << " " << "| On-Chip Thermal Monitor" << endl;
// Check to see if L1\L2\L3 cache exists.
if (!CPU->DoesCPUSupportFeature (L1CACHE_FEATURE | L2CACHE_FEATURE | L3CACHE_FEATURE))
// Inform the user that on-chip cache is not supported.
cout << " " << "|" << " " << "| No L1\\L2\\L3 Cache Found" << endl;
else {
// State the size of the L1 cache if present.
if (CPU->DoesCPUSupportFeature (L1CACHE_FEATURE))
cout << " " << "|" << " " << "| L1 Cache: " << CPU->GetProcessorCacheXSize (L1CACHE_FEATURE) << "KB" << endl;
// State the size of the L2 cache if present.
if (CPU->DoesCPUSupportFeature (L2CACHE_FEATURE))
cout << " " << "|" << " " << "| L2 Cache: " << CPU->GetProcessorCacheXSize (L2CACHE_FEATURE) << "KB" << endl;
// State the size of the L3 cache if present.
if (CPU->DoesCPUSupportFeature (L3CACHE_FEATURE))
cout << " " << "|" << " " << "| L3 Cache: " << CPU->GetProcessorCacheXSize (L3CACHE_FEATURE) << "KB" << endl;
}
// Ok, now do power management features.
cout << " " << "|" << endl;
cout << " " << "+ Power Management Features" << endl;
// Check to see if power management is supported...
if (!CPU->DoesCPUSupportFeature (TEMPSENSEDIODE_FEATURE | FREQUENCYID_FEATURE | VOLTAGEID_FREQUENCY))
// Inform the user that power management is not supported.
cout << " " << "|" << " " << "| No On-Chip Support" << endl;
else {
// State if a temperature sensing diode is present.
if (CPU->DoesCPUSupportFeature (TEMPSENSEDIODE_FEATURE))
cout << " " << "|" << " " << "| Temperature Sensing Diode";
// State if a frequency ID control is present.
if (CPU->DoesCPUSupportFeature (FREQUENCYID_FEATURE))
cout << " " << "|" << " " << "| Frequency ID (FID) Control";
// State if a voltage ID control is present.
if (CPU->DoesCPUSupportFeature (VOLTAGEID_FREQUENCY))
cout << " " << "|" << " " << "| Voltage ID (VID) Control";
}
// Ok, now do power management features.
cout << " " << "|" << endl;
cout << " " << "+ Supported Features" << endl;
if (!CPU->DoesCPUSupportFeature (CMOV_FEATURE | MTRR_FEATURE | MMX_FEATURE | MMX_PLUS_FEATURE | SSE_FEATURE |
SSE_FP_FEATURE | SSE_MMX_FEATURE | SSE2_FEATURE | AMD_3DNOW_FEATURE |
AMD_3DNOW_PLUS_FEATURE | HYPERTHREAD_FEATURE | MP_CAPABLE | IA64_FEATURE))
// Inform the user that no features were found.
cout << " " << " " << " " << "| No Supported Features Found" << endl;
else {
// State if CMOV instructions are present.
if (CPU->DoesCPUSupportFeature (CMOV_FEATURE))
cout << " " << " " << " " << "| [CMOV] Conditional Move Instructions" << endl;
// State if MTRR instructions are present.
if (CPU->DoesCPUSupportFeature (MTRR_FEATURE))
cout << " " << " " << " " << "| [MTRR] Memory Type Range Registers" << endl;
// State if MMX instructions are present.
if (CPU->DoesCPUSupportFeature (MMX_FEATURE))
cout << " " << " " << " " << "| [MMX] MultiMedia Extensions" << endl;
// State if MMX+ instructions are present.
if (CPU->DoesCPUSupportFeature (MMX_PLUS_FEATURE))
cout << " " << " " << " " << "| [MMX+] MultiMedia Enhanced Extensions" << endl;
// State if SSE instructions are present.
if (CPU->DoesCPUSupportFeature (SSE_FEATURE))
cout << " " << " " << " " << "| [SSE] Streaming SIMD Extensions" << endl;
// State if SSE FP instructions are present.
if (CPU->DoesCPUSupportFeature (SSE_FP_FEATURE))
cout << " " << " " << " " << "| [SSE FP] Streaming SIMD Extensions Floating Point" << endl;
// State if SSE MMX instructions are present.
if (CPU->DoesCPUSupportFeature (SSE_MMX_FEATURE))
cout << " " << " " << " " << "| [SSE MMX] Streaming SIMD Extensions MultiMedia Extensions" << endl;
// State if SSE2 instructions are present.
if (CPU->DoesCPUSupportFeature (SSE2_FEATURE))
cout << " " << " " << " " << "| [SSE2] Streaming SIMD Extensions 2" << endl;
// State if 3DNow! instructions are present.
if (CPU->DoesCPUSupportFeature (AMD_3DNOW_FEATURE))
cout << " " << " " << " " << "| [3DNow!] 3DNow! Instructions" << endl;
// State if 3DNow!+ instructions are present.
if (CPU->DoesCPUSupportFeature (AMD_3DNOW_PLUS_FEATURE))
cout << " " << " " << " " << "| [3DNow!+] 3DNow! Enhanced Instructions" << endl;
// State if Hyperthreading instructions are present.
if (CPU->DoesCPUSupportFeature (HYPERTHREAD_FEATURE)) {
cout << " " << " " << " " << "| [HYPERT] HyperThreading Capable" << endl;
cout << " " << " " << " " << "| [LOGICAL] Logical Processors Per Physical: " << CPU->GetLogicalProcessorsPerPhysical () << endl;
}
// State if the processor is MP capable.
if (CPU->DoesCPUSupportFeature (MP_CAPABLE))
cout << " " << " " << " " << "| [MP-AWARE] Multi-Processor Capable" << endl;
// State if IA64 instructions are present.
if (CPU->DoesCPUSupportFeature (IA64_FEATURE))
cout << " " << " " << " " << "| [IA-64] IA64 Support" << endl;
}
}
return 0;
}
#endif // _WIN32
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Iain Chesworth graduated from Heriot-Watt University in June of 2002 in Computer Science and Physics. He now works as a C++ programmer and plays with code in his spare time. He is also a keen cyclist and swimmer.