128{
129 union
130 {
131 struct
132 {
133 unsigned int ax, bx, cx, dx;
134 } e;
135 unsigned char byt[16];
136 } reg;
137 int i, j, levels = 0;
139
140
141
142
143
144
145 MEMDBG(
"Initializing AMD memory info\n" );
146
147 reg.e.ax = 0x80000005;
148 cpuid( ®.e.ax, ®.e.bx, ®.e.cx, ®.e.dx );
149
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],
157 reg.byt[15] );
158
159
160
161
162
167
172
173
178
183
184
189
194
196 if ( L[0].tlb[
i].associativity == 0xff )
198 }
199
200
206
207
208
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 );
213
214
219
220
221
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 );
226
227 for (
i = 0;
i < 2;
i++ ) {
228 if ( L[0].cache[
i].associativity == 0xff )
230 }
231
232
233
234
235 reg.e.ax = 0x80000006;
236 cpuid( ®.e.ax, ®.e.bx, ®.e.cx, ®.e.dx );
237
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],
245 reg.byt[15] );
246
247
248
249 if ( reg.byt[0] | reg.byt[1] ) {
250
253 ( ( ( short ) ( reg.byt[1] & 0xF ) << 8 ) + reg.byt[0] ) / 2;
257
258
263 }
264
265 if ( reg.byt[2] | reg.byt[3] ) {
266
269 ( ( ( short ) ( reg.byt[3] & 0xF ) << 8 ) + reg.byt[2] ) / 2;
273
274
279 }
280
281
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 =
289 }
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 =
297 }
298
299
300 if ( reg.e.cx ) {
303 L[1].
cache[0].
size = (
int ) ( ( reg.e.cx & 0xffff0000 ) >> 6 );
307
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 );
313 }
314
315
316 if ( reg.e.dx ) {
319 L[2].
cache[0].
size = (
int ) ( reg.e.dx & 0xfffc0000 ) << 1;
323
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 );
329 }
332
336 }
337 }
338 *num_levels = levels;
340}
#define PAPI_MAX_MEM_HIERARCHY_LEVELS
#define PAPI_MH_TYPE_DATA
#define PAPI_MH_MAX_LEVELS
#define PAPI_MH_TYPE_PSEUDO_LRU
#define PAPI_MH_TYPE_INST
#define PAPI_MH_TYPE_EMPTY
#define PAPI_MH_TYPE_UNIFIED
PAPI_mh_tlb_info_t tlb[PAPI_MH_MAX_LEVELS]
static short int _amd_L2_L3_assoc(unsigned short int pattern)