PAPI 7.1.0.0
Loading...
Searching...
No Matches
x86_cpuid_info.h File Reference
This graph shows which files directly or indirectly include this file:

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)
 

Function Documentation

◆ _x86_cache_info()

int _x86_cache_info ( PAPI_mh_info_t mh_info)

Definition at line 50 of file x86_cpuid_info.c.

51{
52 int retval = 0;
53 union
54 {
55 struct
56 {
57 unsigned int ax, bx, cx, dx;
58 } e;
59 char vendor[20]; /* leave room for terminator bytes */
60 } reg;
61
62 /* Don't use cpu_type to determine the processor.
63 * get the information directly from the chip.
64 */
65 reg.e.ax = 0; /* function code 0: vendor string */
66 /* The vendor string is composed of EBX:EDX:ECX.
67 * by swapping the register addresses in the call below,
68 * the string is correctly composed in the char array.
69 */
70 cpuid( &reg.e.ax, &reg.e.bx, &reg.e.dx, &reg.e.cx );
71 reg.vendor[16] = 0;
72 MEMDBG( "Vendor: %s\n", &reg.vendor[4] );
73
74 init_mem_hierarchy( mh_info );
75
76 if ( !strncmp( "GenuineIntel", &reg.vendor[4], 12 ) ) {
77 init_intel( mh_info, &mh_info->levels);
78 } else if ( !strncmp( "AuthenticAMD", &reg.vendor[4], 12 ) ) {
79 init_amd( mh_info, &mh_info->levels );
80 } else {
81 MEMDBG( "Unsupported cpu type; Not Intel or AMD x86\n" );
82 return PAPI_ENOIMPL;
83 }
84
85 /* This works only because an empty cache element is initialized to 0 */
86 MEMDBG( "Detected L1: %d L2: %d L3: %d\n",
87 mh_info->level[0].cache[0].size + mh_info->level[0].cache[1].size,
88 mh_info->level[1].cache[0].size + mh_info->level[1].cache[1].size,
89 mh_info->level[2].cache[0].size + mh_info->level[2].cache[1].size );
90 return retval;
91}
#define PAPI_ENOIMPL
Definition: f90papi.h:219
#define MEMDBG(format, args...)
Definition: papi_debug.h:71
int levels
Definition: papi.h:768
PAPI_mh_level_t level[PAPI_MAX_MEM_HIERARCHY_LEVELS]
Definition: papi.h:769
PAPI_mh_cache_info_t cache[PAPI_MH_MAX_LEVELS]
Definition: papi.h:762
static int init_amd(PAPI_mh_info_t *mh_info, int *levels)
static void cpuid(unsigned int *a, unsigned int *b, unsigned int *c, unsigned int *d)
static int init_intel(PAPI_mh_info_t *mh_info, int *levels)
static void init_mem_hierarchy(PAPI_mh_info_t *mh_info)
int retval
Definition: zero_fork.c:53
Here is the call graph for this function:

◆ _x86_detect_hypervisor()

int _x86_detect_hypervisor ( char *  vendor_name)

Definition at line 1507 of file x86_cpuid_info.c.

1508{
1509 unsigned int eax, ebx, ecx, edx;
1510 char hyper_vendor_id[13];
1511
1512 cpuid2(&eax, &ebx, &ecx, &edx,0x1,0);
1513 /* This is the hypervisor bit, ecx bit 31 */
1514 if (ecx&0x80000000) {
1515 /* There are various values in the 0x4000000X range */
1516 /* It is questionable how standard they are */
1517 /* For now we just return the name. */
1518 cpuid2(&eax, &ebx, &ecx, &edx, 0x40000000,0);
1519 memcpy(hyper_vendor_id + 0, &ebx, 4);
1520 memcpy(hyper_vendor_id + 4, &ecx, 4);
1521 memcpy(hyper_vendor_id + 8, &edx, 4);
1522 hyper_vendor_id[12] = '\0';
1523 strncpy(vendor_name,hyper_vendor_id,PAPI_MAX_STR_LEN);
1524 return 1;
1525 }
1526 else {
1527 strncpy(vendor_name,"none",PAPI_MAX_STR_LEN);
1528 }
1529 return 0;
1530}
#define PAPI_MAX_STR_LEN
Definition: f90papi.h:77
static void cpuid2(unsigned int *eax, unsigned int *ebx, unsigned int *ecx, unsigned int *edx, unsigned int index, unsigned int ecx_in)
Here is the call graph for this function:
Here is the caller graph for this function: