|
PAPI
5.0.1.0
|

Go to the source code of this file.
Functions | |
| int | _x86_cache_info (PAPI_mh_info_t *mh_info) |
| int | _x86_detect_hypervisor (char *vendor_name) |
| int _x86_cache_info | ( | PAPI_mh_info_t * | mh_info | ) |
< Not implemented
Definition at line 40 of file x86_cpuid_info.c.
{
int retval = 0;
union
{
struct
{
unsigned int ax, bx, cx, dx;
} e;
char vendor[20]; /* leave room for terminator bytes */
} reg;
/* Don't use cpu_type to determine the processor.
* get the information directly from the chip.
*/
reg.e.ax = 0; /* function code 0: vendor string */
/* The vendor string is composed of EBX:EDX:ECX.
* by swapping the register addresses in the call below,
* the string is correctly composed in the char array.
*/
cpuid( ®.e.ax, ®.e.bx, ®.e.dx, ®.e.cx );
reg.vendor[16] = 0;
MEMDBG( "Vendor: %s\n", ®.vendor[4] );
init_mem_hierarchy( mh_info );
if ( !strncmp( "GenuineIntel", ®.vendor[4], 12 ) ) {
init_intel( mh_info, &mh_info->levels);
} else if ( !strncmp( "AuthenticAMD", ®.vendor[4], 12 ) ) {
init_amd( mh_info, &mh_info->levels );
} else {
MEMDBG( "Unsupported cpu type; Not Intel or AMD x86\n" );
return PAPI_ENOIMPL;
}
/* This works only because an empty cache element is initialized to 0 */
MEMDBG( "Detected L1: %d L2: %d L3: %d\n",
mh_info->level[0].cache[0].size + mh_info->level[0].cache[1].size,
mh_info->level[1].cache[0].size + mh_info->level[1].cache[1].size,
mh_info->level[2].cache[0].size + mh_info->level[2].cache[1].size );
return retval;
}

| int _x86_detect_hypervisor | ( | char * | vendor_name | ) |
Definition at line 1486 of file x86_cpuid_info.c.
{
unsigned int eax, ebx, ecx, edx;
char hyper_vendor_id[13];
cpuid2(&eax, &ebx, &ecx, &edx,0x1,0);
/* This is the hypervisor bit, ecx bit 31 */
if (ecx&0x80000000) {
/* There are various values in the 0x4000000X range */
/* It is questionable how standard they are */
/* For now we just return the name. */
cpuid2(&eax, &ebx, &ecx, &edx, 0x40000000,0);
memcpy(hyper_vendor_id + 0, &ebx, 4);
memcpy(hyper_vendor_id + 4, &ecx, 4);
memcpy(hyper_vendor_id + 8, &edx, 4);
hyper_vendor_id[12] = '\0';
strncpy(vendor_name,hyper_vendor_id,PAPI_MAX_STR_LEN);
return 1;
}
else {
strncpy(vendor_name,"none",PAPI_MAX_STR_LEN);
}
return 0;
}

