133 unsigned int ax, bx, cx, dx;
135 unsigned char byt[16];
137 int i, j, levels = 0;
145 MEMDBG(
"Initializing AMD memory info\n" );
147 reg.e.ax = 0x80000005;
148 cpuid( ®.e.ax, ®.e.bx, ®.e.cx, ®.e.dx );
150 MEMDBG(
"e.ax=%#8.8x e.bx=%#8.8x e.cx=%#8.8x e.dx=%#8.8x\n",
151 reg.e.ax, reg.e.bx, reg.e.cx, reg.e.dx );
153 (
":\neax: %#x %#x %#x %#x\nebx: %#x %#x %#x %#x\necx: %#x %#x %#x %#x\nedx: %#x %#x %#x %#x\n",
154 reg.byt[0], reg.byt[1], reg.byt[2], reg.byt[3], reg.byt[4],
155 reg.byt[5], reg.byt[6], reg.byt[7], reg.byt[8], reg.byt[9],
156 reg.byt[10], reg.byt[11], reg.byt[12], reg.byt[13], reg.byt[14],
196 if ( L[0].tlb[
i].associativity == 0xff )
209 if ( L[0].
cache[0].line_size )
211 MEMDBG(
"D-Cache Line Count: %d; Computed: %d\n", reg.byt[9],
212 L[0].cache[0].num_lines );
222 if ( L[0].
cache[1].line_size )
224 MEMDBG(
"I-Cache Line Count: %d; Computed: %d\n", reg.byt[13],
225 L[0].cache[1].num_lines );
227 for (
i = 0;
i < 2;
i++ ) {
228 if ( L[0].
cache[
i].associativity == 0xff )
235 reg.e.ax = 0x80000006;
236 cpuid( ®.e.ax, ®.e.bx, ®.e.cx, ®.e.dx );
238 MEMDBG(
"e.ax=%#8.8x e.bx=%#8.8x e.cx=%#8.8x e.dx=%#8.8x\n",
239 reg.e.ax, reg.e.bx, reg.e.cx, reg.e.dx );
241 (
":\neax: %#x %#x %#x %#x\nebx: %#x %#x %#x %#x\necx: %#x %#x %#x %#x\nedx: %#x %#x %#x %#x\n",
242 reg.byt[0], reg.byt[1], reg.byt[2], reg.byt[3], reg.byt[4],
243 reg.byt[5], reg.byt[6], reg.byt[7], reg.byt[8], reg.byt[9],
244 reg.byt[10], reg.byt[11], reg.byt[12], reg.byt[13], reg.byt[14],
249 if ( reg.byt[0] | reg.byt[1] ) {
253 ( ( ( short ) ( reg.byt[1] & 0xF ) << 8 ) + reg.byt[0] ) / 2;
265 if ( reg.byt[2] | reg.byt[3] ) {
269 ( ( ( short ) ( reg.byt[3] & 0xF ) << 8 ) + reg.byt[2] ) / 2;
282 if ( reg.byt[4] | reg.byt[5] ) {
285 ( ( short ) ( reg.byt[5] & 0xF ) << 8 ) + reg.byt[4];
286 L[1].tlb[4].page_size = 4 << 10;
287 L[1].tlb[4].associativity =
290 if ( reg.byt[6] | reg.byt[7] ) {
293 ( ( short ) ( reg.byt[7] & 0xF ) << 8 ) + reg.byt[6];
294 L[1].tlb[5].page_size = 4 << 10;
295 L[1].tlb[5].associativity =
303 L[1].
cache[0].
size = ( int ) ( ( reg.e.cx & 0xffff0000 ) >> 6 );
308 if ( L[1].
cache[0].line_size )
311 MEMDBG(
"U-Cache Line Count: %d; Computed: %d\n", reg.byt[9] & 0xF,
312 L[1].cache[0].num_lines );
319 L[2].
cache[0].
size = ( int ) ( reg.e.dx & 0xfffc0000 ) << 1;
324 if ( L[2].
cache[0].line_size )
327 MEMDBG(
"U-Cache Line Count: %d; Computed: %d\n", reg.byt[13] & 0xF,
328 L[1].cache[0].num_lines );
338 *num_levels = levels;
PAPI_mh_level_t level[PAPI_MAX_MEM_HIERARCHY_LEVELS]
#define PAPI_MH_TYPE_INST
static void cpuid(unsigned int *a, unsigned int *b, unsigned int *c, unsigned int *d)
#define PAPI_MH_TYPE_PSEUDO_LRU
#define PAPI_MH_MAX_LEVELS
#define PAPI_MH_TYPE_DATA
#define MEMDBG(format, args...)
PAPI_mh_cache_info_t cache[PAPI_MH_MAX_LEVELS]
static short int _amd_L2_L3_assoc(unsigned short int pattern)
#define PAPI_MH_TYPE_UNIFIED
PAPI_mh_tlb_info_t tlb[PAPI_MH_MAX_LEVELS]
#define PAPI_MH_TYPE_EMPTY
#define PAPI_MAX_MEM_HIERARCHY_LEVELS