Home | History | Annotate | Line # | Download | only in include
cacheinfo.h revision 1.5
      1 /*	$NetBSD: cacheinfo.h,v 1.5 2008/05/11 14:44:54 ad Exp $	*/
      2 
      3 #ifndef _X86_CACHEINFO_H_
      4 #define _X86_CACHEINFO_H_
      5 
      6 struct x86_cache_info {
      7 	uint8_t		cai_index;
      8 	uint8_t		cai_desc;
      9 	uint8_t		cai_associativity;
     10 	u_int		cai_totalsize; /* #entries for TLB, bytes for cache */
     11 	u_int		cai_linesize;	/* or page size for TLB */
     12 };
     13 
     14 #define	CAI_ITLB	0		/* Instruction TLB (4K pages) */
     15 #define	CAI_ITLB2	1		/* Instruction TLB (2/4M pages) */
     16 #define	CAI_DTLB	2		/* Data TLB (4K pages) */
     17 #define	CAI_DTLB2	3		/* Data TLB (2/4M pages) */
     18 #define	CAI_ICACHE	4		/* Instruction cache */
     19 #define	CAI_DCACHE	5		/* Data cache */
     20 #define	CAI_L2CACHE	6		/* Level 2 cache */
     21 
     22 #define	CAI_COUNT	7
     23 
     24 /*
     25  * AMD Cache Info:
     26  *
     27  *	Athlon, Duron:
     28  *
     29  *		Function 8000.0005 L1 TLB/Cache Information
     30  *		EAX -- L1 TLB 2/4MB pages
     31  *		EBX -- L1 TLB 4K pages
     32  *		ECX -- L1 D-cache
     33  *		EDX -- L1 I-cache
     34  *
     35  *		Function 8000.0006 L2 TLB/Cache Information
     36  *		EAX -- L2 TLB 2/4MB pages
     37  *		EBX -- L2 TLB 4K pages
     38  *		ECX -- L2 Unified cache
     39  *		EDX -- reserved
     40  *
     41  *	K5, K6:
     42  *
     43  *		Function 8000.0005 L1 TLB/Cache Information
     44  *		EAX -- reserved
     45  *		EBX -- TLB 4K pages
     46  *		ECX -- L1 D-cache
     47  *		EDX -- L1 I-cache
     48  *
     49  *	K6-III:
     50  *
     51  *		Function 8000.0006 L2 Cache Information
     52  *		EAX -- reserved
     53  *		EBX -- reserved
     54  *		ECX -- L2 Unified cache
     55  *		EDX -- reserved
     56  */
     57 
     58 /* L1 TLB 2/4MB pages */
     59 #define	AMD_L1_EAX_DTLB_ASSOC(x)	(((x) >> 24) & 0xff)
     60 #define	AMD_L1_EAX_DTLB_ENTRIES(x)	(((x) >> 16) & 0xff)
     61 #define	AMD_L1_EAX_ITLB_ASSOC(x)	(((x) >> 8)  & 0xff)
     62 #define	AMD_L1_EAX_ITLB_ENTRIES(x)	( (x)        & 0xff)
     63 
     64 /* L1 TLB 4K pages */
     65 #define	AMD_L1_EBX_DTLB_ASSOC(x)	(((x) >> 24) & 0xff)
     66 #define	AMD_L1_EBX_DTLB_ENTRIES(x)	(((x) >> 16) & 0xff)
     67 #define	AMD_L1_EBX_ITLB_ASSOC(x)	(((x) >> 8)  & 0xff)
     68 #define	AMD_L1_EBX_ITLB_ENTRIES(x)	( (x)        & 0xff)
     69 
     70 /* L1 Data Cache */
     71 #define	AMD_L1_ECX_DC_SIZE(x)		((((x) >> 24) & 0xff) * 1024)
     72 #define	AMD_L1_ECX_DC_ASSOC(x)		 (((x) >> 16) & 0xff)
     73 #define	AMD_L1_ECX_DC_LPT(x)		 (((x) >> 8)  & 0xff)
     74 #define	AMD_L1_ECX_DC_LS(x)		 ( (x)        & 0xff)
     75 
     76 /* L1 Instruction Cache */
     77 #define	AMD_L1_EDX_IC_SIZE(x)		((((x) >> 24) & 0xff) * 1024)
     78 #define	AMD_L1_EDX_IC_ASSOC(x)		 (((x) >> 16) & 0xff)
     79 #define	AMD_L1_EDX_IC_LPT(x)		 (((x) >> 8)  & 0xff)
     80 #define	AMD_L1_EDX_IC_LS(x)		 ( (x)        & 0xff)
     81 
     82 /* Note for L2 TLB -- if the upper 16 bits are 0, it is a unified TLB */
     83 
     84 /* L2 TLB 2/4MB pages */
     85 #define	AMD_L2_EAX_DTLB_ASSOC(x)	(((x) >> 28)  & 0xf)
     86 #define	AMD_L2_EAX_DTLB_ENTRIES(x)	(((x) >> 16)  & 0xfff)
     87 #define	AMD_L2_EAX_IUTLB_ASSOC(x)	(((x) >> 12)  & 0xf)
     88 #define	AMD_L2_EAX_IUTLB_ENTRIES(x)	( (x)         & 0xfff)
     89 
     90 /* L2 TLB 4K pages */
     91 #define	AMD_L2_EBX_DTLB_ASSOC(x)	(((x) >> 28)  & 0xf)
     92 #define	AMD_L2_EBX_DTLB_ENTRIES(x)	(((x) >> 16)  & 0xfff)
     93 #define	AMD_L2_EBX_IUTLB_ASSOC(x)	(((x) >> 12)  & 0xf)
     94 #define	AMD_L2_EBX_IUTLB_ENTRIES(x)	( (x)         & 0xfff)
     95 
     96 /* L2 Cache */
     97 #define	AMD_L2_ECX_C_SIZE(x)		((((x) >> 16) & 0xffff) * 1024)
     98 #define	AMD_L2_ECX_C_ASSOC(x)		 (((x) >> 12) & 0xf)
     99 #define	AMD_L2_ECX_C_LPT(x)		 (((x) >> 8)  & 0xf)
    100 #define	AMD_L2_ECX_C_LS(x)		 ( (x)        & 0xff)
    101 
    102 /*
    103  * VIA Cache Info:
    104  *
    105  *	Nehemiah (at least)
    106  *
    107  *		Function 8000.0005 L1 TLB/Cache Information
    108  *		EAX -- reserved
    109  *		EBX -- L1 TLB 4K pages
    110  *		ECX -- L1 D-cache
    111  *		EDX -- L1 I-cache
    112  *
    113  *		Function 8000.0006 L2 Cache Information
    114  *		EAX -- reserved
    115  *		EBX -- reserved
    116  *		ECX -- L2 Unified cache
    117  *		EDX -- reserved
    118  */
    119 
    120 /* L1 TLB 4K pages */
    121 #define	VIA_L1_EBX_DTLB_ASSOC(x)	(((x) >> 24) & 0xff)
    122 #define	VIA_L1_EBX_DTLB_ENTRIES(x)	(((x) >> 16) & 0xff)
    123 #define	VIA_L1_EBX_ITLB_ASSOC(x)	(((x) >> 8)  & 0xff)
    124 #define	VIA_L1_EBX_ITLB_ENTRIES(x)	( (x)        & 0xff)
    125 
    126 /* L1 Data Cache */
    127 #define	VIA_L1_ECX_DC_SIZE(x)		((((x) >> 24) & 0xff) * 1024)
    128 #define	VIA_L1_ECX_DC_ASSOC(x)		 (((x) >> 16) & 0xff)
    129 #define	VIA_L1_ECX_DC_LPT(x)		 (((x) >> 8)  & 0xff)
    130 #define	VIA_L1_ECX_DC_LS(x)		 ( (x)        & 0xff)
    131 
    132 /* L1 Instruction Cache */
    133 #define	VIA_L1_EDX_IC_SIZE(x)		((((x) >> 24) & 0xff) * 1024)
    134 #define	VIA_L1_EDX_IC_ASSOC(x)		 (((x) >> 16) & 0xff)
    135 #define	VIA_L1_EDX_IC_LPT(x)		 (((x) >> 8)  & 0xff)
    136 #define	VIA_L1_EDX_IC_LS(x)		 ( (x)        & 0xff)
    137 
    138 /* L2 Cache (pre-Nehemiah) */
    139 #define	VIA_L2_ECX_C_SIZE(x)		((((x) >> 24) & 0xff) * 1024)
    140 #define	VIA_L2_ECX_C_ASSOC(x)		 (((x) >> 16) & 0xff)
    141 #define	VIA_L2_ECX_C_LPT(x)		 (((x) >> 8)  & 0xff)
    142 #define	VIA_L2_ECX_C_LS(x)		 ( (x)        & 0xff)
    143 
    144 /* L2 Cache (Nehemiah and newer) */
    145 #define	VIA_L2N_ECX_C_SIZE(x)		((((x) >> 16) & 0xffff) * 1024)
    146 #define	VIA_L2N_ECX_C_ASSOC(x)		 (((x) >> 12) & 0xf)
    147 #define	VIA_L2N_ECX_C_LPT(x)		 (((x) >> 8)  & 0xf)
    148 #define	VIA_L2N_ECX_C_LS(x)		 ( (x)        & 0xff)
    149 
    150 #endif /* _X86_CACHEINFO_H_ */
    151