Home | History | Annotate | Line # | Download | only in include
cacheinfo.h revision 1.1
      1  1.1  fvdl /*	$NetBSD: cacheinfo.h,v 1.1 2003/04/25 21:54:30 fvdl Exp $	*/
      2  1.1  fvdl 
      3  1.1  fvdl #ifndef _X86_CACHEINFO_H
      4  1.1  fvdl #define _X86_CACHEINFO_H
      5  1.1  fvdl 
      6  1.1  fvdl struct x86_cache_info {
      7  1.1  fvdl 	uint8_t		cai_index;
      8  1.1  fvdl 	uint8_t		cai_desc;
      9  1.1  fvdl 	uint8_t		cai_associativity;
     10  1.1  fvdl 	u_int		cai_totalsize; /* #entries for TLB, bytes for cache */
     11  1.1  fvdl 	u_int		cai_linesize;	/* or page size for TLB */
     12  1.1  fvdl 	const char	*cai_string;
     13  1.1  fvdl };
     14  1.1  fvdl 
     15  1.1  fvdl #define	CAI_ITLB	0		/* Instruction TLB (4K pages) */
     16  1.1  fvdl #define	CAI_ITLB2	1		/* Instruction TLB (2/4M pages) */
     17  1.1  fvdl #define	CAI_DTLB	2		/* Data TLB (4K pages) */
     18  1.1  fvdl #define	CAI_DTLB2	3		/* Data TLB (2/4M pages) */
     19  1.1  fvdl #define	CAI_ICACHE	4		/* Instruction cache */
     20  1.1  fvdl #define	CAI_DCACHE	5		/* Data cache */
     21  1.1  fvdl #define	CAI_L2CACHE	6		/* Level 2 cache */
     22  1.1  fvdl 
     23  1.1  fvdl #define	CAI_COUNT	7
     24  1.1  fvdl 
     25  1.1  fvdl struct cpu_info;
     26  1.1  fvdl 
     27  1.1  fvdl const struct x86_cache_info *cache_info_lookup(const struct x86_cache_info *,
     28  1.1  fvdl 					       u_int8_t);
     29  1.1  fvdl void amd_cpu_cacheinfo(struct cpu_info *);
     30  1.1  fvdl void x86_print_cacheinfo(struct cpu_info *);
     31  1.1  fvdl 
     32  1.1  fvdl /*
     33  1.1  fvdl  * AMD Cache Info:
     34  1.1  fvdl  *
     35  1.1  fvdl  *	Athlon, Duron:
     36  1.1  fvdl  *
     37  1.1  fvdl  *		Function 8000.0005 L1 TLB/Cache Information
     38  1.1  fvdl  *		EAX -- L1 TLB 2/4MB pages
     39  1.1  fvdl  *		EBX -- L1 TLB 4K pages
     40  1.1  fvdl  *		ECX -- L1 D-cache
     41  1.1  fvdl  *		EDX -- L1 I-cache
     42  1.1  fvdl  *
     43  1.1  fvdl  *		Function 8000.0006 L2 TLB/Cache Information
     44  1.1  fvdl  *		EAX -- L2 TLB 2/4MB pages
     45  1.1  fvdl  *		EBX -- L2 TLB 4K pages
     46  1.1  fvdl  *		ECX -- L2 Unified cache
     47  1.1  fvdl  *		EDX -- reserved
     48  1.1  fvdl  *
     49  1.1  fvdl  *	K5, K6:
     50  1.1  fvdl  *
     51  1.1  fvdl  *		Function 8000.0005 L1 TLB/Cache Information
     52  1.1  fvdl  *		EAX -- reserved
     53  1.1  fvdl  *		EBX -- TLB 4K pages
     54  1.1  fvdl  *		ECX -- L1 D-cache
     55  1.1  fvdl  *		EDX -- L1 I-cache
     56  1.1  fvdl  *
     57  1.1  fvdl  *	K6-III:
     58  1.1  fvdl  *
     59  1.1  fvdl  *		Function 8000.0006 L2 Cache Information
     60  1.1  fvdl  *		EAX -- reserved
     61  1.1  fvdl  *		EBX -- reserved
     62  1.1  fvdl  *		ECX -- L2 Unified cache
     63  1.1  fvdl  *		EDX -- reserved
     64  1.1  fvdl  */
     65  1.1  fvdl 
     66  1.1  fvdl /* L1 TLB 2/4MB pages */
     67  1.1  fvdl #define	AMD_L1_EAX_DTLB_ASSOC(x)	(((x) >> 24) & 0xff)
     68  1.1  fvdl #define	AMD_L1_EAX_DTLB_ENTRIES(x)	(((x) >> 16) & 0xff)
     69  1.1  fvdl #define	AMD_L1_EAX_ITLB_ASSOC(x)	(((x) >> 8)  & 0xff)
     70  1.1  fvdl #define	AMD_L1_EAX_ITLB_ENTRIES(x)	( (x)        & 0xff)
     71  1.1  fvdl 
     72  1.1  fvdl /* L1 TLB 4K pages */
     73  1.1  fvdl #define	AMD_L1_EBX_DTLB_ASSOC(x)	(((x) >> 24) & 0xff)
     74  1.1  fvdl #define	AMD_L1_EBX_DTLB_ENTRIES(x)	(((x) >> 16) & 0xff)
     75  1.1  fvdl #define	AMD_L1_EBX_ITLB_ASSOC(x)	(((x) >> 8)  & 0xff)
     76  1.1  fvdl #define	AMD_L1_EBX_ITLB_ENTRIES(x)	( (x)        & 0xff)
     77  1.1  fvdl 
     78  1.1  fvdl /* L1 Data Cache */
     79  1.1  fvdl #define	AMD_L1_ECX_DC_SIZE(x)		((((x) >> 24) & 0xff) * 1024)
     80  1.1  fvdl #define	AMD_L1_ECX_DC_ASSOC(x)		 (((x) >> 16) & 0xff)
     81  1.1  fvdl #define	AMD_L1_ECX_DC_LPT(x)		 (((x) >> 8)  & 0xff)
     82  1.1  fvdl #define	AMD_L1_ECX_DC_LS(x)		 ( (x)        & 0xff)
     83  1.1  fvdl 
     84  1.1  fvdl /* L1 Instruction Cache */
     85  1.1  fvdl #define	AMD_L1_EDX_IC_SIZE(x)		((((x) >> 24) & 0xff) * 1024)
     86  1.1  fvdl #define	AMD_L1_EDX_IC_ASSOC(x)		 (((x) >> 16) & 0xff)
     87  1.1  fvdl #define	AMD_L1_EDX_IC_LPT(x)		 (((x) >> 8)  & 0xff)
     88  1.1  fvdl #define	AMD_L1_EDX_IC_LS(x)		 ( (x)        & 0xff)
     89  1.1  fvdl 
     90  1.1  fvdl /* Note for L2 TLB -- if the upper 16 bits are 0, it is a unified TLB */
     91  1.1  fvdl 
     92  1.1  fvdl /* L2 TLB 2/4MB pages */
     93  1.1  fvdl #define	AMD_L2_EAX_DTLB_ASSOC(x)	(((x) >> 28)  & 0xf)
     94  1.1  fvdl #define	AMD_L2_EAX_DTLB_ENTRIES(x)	(((x) >> 16)  & 0xfff)
     95  1.1  fvdl #define	AMD_L2_EAX_IUTLB_ASSOC(x)	(((x) >> 12)  & 0xf)
     96  1.1  fvdl #define	AMD_L2_EAX_IUTLB_ENTRIES(x)	( (x)         & 0xfff)
     97  1.1  fvdl 
     98  1.1  fvdl /* L2 TLB 4K pages */
     99  1.1  fvdl #define	AMD_L2_EBX_DTLB_ASSOC(x)	(((x) >> 28)  & 0xf)
    100  1.1  fvdl #define	AMD_L2_EBX_DTLB_ENTRIES(x)	(((x) >> 16)  & 0xfff)
    101  1.1  fvdl #define	AMD_L2_EBX_IUTLB_ASSOC(x)	(((x) >> 12)  & 0xf)
    102  1.1  fvdl #define	AMD_L2_EBX_IUTLB_ENTRIES(x)	( (x)         & 0xfff)
    103  1.1  fvdl 
    104  1.1  fvdl /* L2 Cache */
    105  1.1  fvdl #define	AMD_L2_ECX_C_SIZE(x)		((((x) >> 16) & 0xffff) * 1024)
    106  1.1  fvdl #define	AMD_L2_ECX_C_ASSOC(x)		 (((x) >> 12) & 0xf)
    107  1.1  fvdl #define	AMD_L2_ECX_C_LPT(x)		 (((x) >> 8)  & 0xf)
    108  1.1  fvdl #define	AMD_L2_ECX_C_LS(x)		 ( (x)        & 0xff)
    109  1.1  fvdl 
    110  1.1  fvdl #endif /* _X86_CACHEINFO_H */
    111