⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 traps.c

📁 linux-2.4.29操作系统的源码
💻 C
📖 第 1 页 / 共 4 页
字号:
	{	CHAFSR_CPU,	CHAFSR_CPU_msg		},	{	CHAFSR_CE,	CHAFSR_CE_msg		},	{	CHAFSR_EDC,	CHAFSR_EDC_msg		},	{	CHAFSR_EMC,	CHAFSR_EMC_msg		},	{	CHAFSR_WDC,	CHAFSR_WDC_msg		},	{	CHAFSR_CPC,	CHAFSR_CPC_msg		},	{	CHAFSR_TO,	CHAFSR_TO_msg		},	{	CHAFSR_BERR,	CHAFSR_BERR_msg		},	{	CHPAFSR_DTO,	CHPAFSR_DTO_msg		},	{	CHPAFSR_DBERR,	CHPAFSR_DBERR_msg	},	{	CHPAFSR_THCE,	CHPAFSR_THCE_msg	},	{	CHPAFSR_TSCE,	CHPAFSR_TSCE_msg	},	{	CHPAFSR_TUE,	CHPAFSR_TUE_msg		},	{	CHPAFSR_DUE,	CHPAFSR_DUE_msg		},	/* These two do not update the AFAR. */	{	CHAFSR_IVC,	CHAFSR_IVC_msg		},	{	CHAFSR_IVU,	CHAFSR_IVU_msg		},	{	0,		NULL			},};static const char JPAFSR_JETO_msg[] =	"System interface protocol error, hw timeout caused";static const char JPAFSR_SCE_msg[] =	"Parity error on system snoop results";static const char JPAFSR_JEIC_msg[] =	"System interface protocol error, illegal command detected";static const char JPAFSR_JEIT_msg[] =	"System interface protocol error, illegal ADTYPE detected";static const char JPAFSR_OM_msg[] =	"Out of range memory error has occurred";static const char JPAFSR_ETP_msg[] =	"Parity error on L2 cache tag SRAM";static const char JPAFSR_UMS_msg[] =	"Error due to unsupported store";static const char JPAFSR_RUE_msg[] =	"Uncorrectable ECC error from remote cache/memory";static const char JPAFSR_RCE_msg[] =	"Correctable ECC error from remote cache/memory";static const char JPAFSR_BP_msg[] =	"JBUS parity error on returned read data";static const char JPAFSR_WBP_msg[] =	"JBUS parity error on data for writeback or block store";static const char JPAFSR_FRC_msg[] =	"Foreign read to DRAM incurring correctable ECC error";static const char JPAFSR_FRU_msg[] =	"Foreign read to DRAM incurring uncorrectable ECC error";static struct afsr_error_table __jalapeno_error_table[] = {	{	JPAFSR_JETO,	JPAFSR_JETO_msg		},	{	JPAFSR_SCE,	JPAFSR_SCE_msg		},	{	JPAFSR_JEIC,	JPAFSR_JEIC_msg		},	{	JPAFSR_JEIT,	JPAFSR_JEIT_msg		},	{	CHAFSR_PERR,	CHAFSR_PERR_msg		},	{	CHAFSR_IERR,	CHAFSR_IERR_msg		},	{	CHAFSR_ISAP,	CHAFSR_ISAP_msg		},	{	CHAFSR_UCU,	CHAFSR_UCU_msg		},	{	CHAFSR_UCC,	CHAFSR_UCC_msg		},	{	CHAFSR_UE,	CHAFSR_UE_msg		},	{	CHAFSR_EDU,	CHAFSR_EDU_msg		},	{	JPAFSR_OM,	JPAFSR_OM_msg		},	{	CHAFSR_WDU,	CHAFSR_WDU_msg		},	{	CHAFSR_CPU,	CHAFSR_CPU_msg		},	{	CHAFSR_CE,	CHAFSR_CE_msg		},	{	CHAFSR_EDC,	CHAFSR_EDC_msg		},	{	JPAFSR_ETP,	JPAFSR_ETP_msg		},	{	CHAFSR_WDC,	CHAFSR_WDC_msg		},	{	CHAFSR_CPC,	CHAFSR_CPC_msg		},	{	CHAFSR_TO,	CHAFSR_TO_msg		},	{	CHAFSR_BERR,	CHAFSR_BERR_msg		},	{	JPAFSR_UMS,	JPAFSR_UMS_msg		},	{	JPAFSR_RUE,	JPAFSR_RUE_msg		},	{	JPAFSR_RCE,	JPAFSR_RCE_msg		},	{	JPAFSR_BP,	JPAFSR_BP_msg		},	{	JPAFSR_WBP,	JPAFSR_WBP_msg		},	{	JPAFSR_FRC,	JPAFSR_FRC_msg		},	{	JPAFSR_FRU,	JPAFSR_FRU_msg		},	/* These two do not update the AFAR. */	{	CHAFSR_IVU,	CHAFSR_IVU_msg		},	{	0,		NULL			},};static struct afsr_error_table *cheetah_error_table;static unsigned long cheetah_afsr_errors;/* This is allocated at boot time based upon the largest hardware * cpu ID in the system.  We allocate two entries per cpu, one for * TL==0 logging and one for TL >= 1 logging. */struct cheetah_err_info *cheetah_error_log;static __inline__ struct cheetah_err_info *cheetah_get_error_log(unsigned long afsr){	struct cheetah_err_info *p;	int cpu = smp_processor_id();	if (!cheetah_error_log)		return NULL;	p = cheetah_error_log + (cpu * 2);	if ((afsr & CHAFSR_TL1) != 0UL)		p++;	return p;}extern unsigned int tl0_icpe[], tl1_icpe[];extern unsigned int tl0_dcpe[], tl1_dcpe[];extern unsigned int tl0_fecc[], tl1_fecc[];extern unsigned int tl0_cee[], tl1_cee[];extern unsigned int tl0_iae[], tl1_iae[];extern unsigned int tl0_dae[], tl1_dae[];extern unsigned int cheetah_plus_icpe_trap_vector[], cheetah_plus_icpe_trap_vector_tl1[];extern unsigned int cheetah_plus_dcpe_trap_vector[], cheetah_plus_dcpe_trap_vector_tl1[];extern unsigned int cheetah_fecc_trap_vector[], cheetah_fecc_trap_vector_tl1[];extern unsigned int cheetah_cee_trap_vector[], cheetah_cee_trap_vector_tl1[];extern unsigned int cheetah_deferred_trap_vector[], cheetah_deferred_trap_vector_tl1[];void cheetah_ecache_flush_init(void){	unsigned long largest_size, smallest_linesize, order, ver;	char type[16];	int node, highest_cpu, i;	/* Scan all cpu device tree nodes, note two values:	 * 1) largest E-cache size	 * 2) smallest E-cache line size	 */	largest_size = 0UL;	smallest_linesize = ~0UL;	node = prom_getchild(prom_root_node);	while ((node = prom_getsibling(node)) != 0) {		prom_getstring(node, "device_type", type, sizeof(type));		if (!strcmp(type, "cpu")) {			unsigned long val;			val = prom_getintdefault(node, "ecache-size",						 (2 * 1024 * 1024));			if (val > largest_size)				largest_size = val;			val = prom_getintdefault(node, "ecache-line-size", 64);			if (val < smallest_linesize)				smallest_linesize = val;		}	}	if (largest_size == 0UL || smallest_linesize == ~0UL) {		prom_printf("cheetah_ecache_flush_init: Cannot probe cpu E-cache "			    "parameters.\n");		prom_halt();	}	ecache_flush_size = (2 * largest_size);	ecache_flush_linesize = smallest_linesize;	/* Discover a physically contiguous chunk of physical	 * memory in 'sp_banks' of size ecache_flush_size calculated	 * above.  Store the physical base of this area at	 * ecache_flush_physbase.	 */	for (node = 0; ; node++) {		if (sp_banks[node].num_bytes == 0)			break;		if (sp_banks[node].num_bytes >= ecache_flush_size) {			ecache_flush_physbase = sp_banks[node].base_addr;			break;		}	}	/* Note: Zero would be a valid value of ecache_flush_physbase so	 * don't use that as the success test. :-)	 */	if (sp_banks[node].num_bytes == 0) {		prom_printf("cheetah_ecache_flush_init: Cannot find %d byte "			    "contiguous physical memory.\n", ecache_flush_size);		prom_halt();	}	/* Now allocate error trap reporting scoreboard. */	highest_cpu = 0;#ifdef CONFIG_SMP	for (i = 0; i < NR_CPUS; i++) {		if ((1UL << i) & cpu_present_map)			highest_cpu = i;	}#endif	highest_cpu++;	node = highest_cpu * (2 * sizeof(struct cheetah_err_info));	for (order = 0; order < MAX_ORDER; order++) {		if ((PAGE_SIZE << order) >= node)			break;	}	cheetah_error_log = (struct cheetah_err_info *)		__get_free_pages(GFP_KERNEL, order);	if (!cheetah_error_log) {		prom_printf("cheetah_ecache_flush_init: Failed to allocate "			    "error logging scoreboard (%d bytes).\n", node);		prom_halt();	}	memset(cheetah_error_log, 0, PAGE_SIZE << order);	/* Mark all AFSRs as invalid so that the trap handler will	 * log new new information there.	 */	for (i = 0; i < 2 * highest_cpu; i++)		cheetah_error_log[i].afsr = CHAFSR_INVALID;	__asm__ ("rdpr %%ver, %0" : "=r" (ver));	if ((ver >> 32) == 0x003e0016) {		cheetah_error_table = &__jalapeno_error_table[0];		cheetah_afsr_errors = JPAFSR_ERRORS;	} else if ((ver >> 32) == 0x003e0015) {		cheetah_error_table = &__cheetah_plus_error_table[0];		cheetah_afsr_errors = CHPAFSR_ERRORS;	} else {		cheetah_error_table = &__cheetah_error_table[0];		cheetah_afsr_errors = CHAFSR_ERRORS;	}	/* Now patch trap tables. */	memcpy(tl0_fecc, cheetah_fecc_trap_vector, (8 * 4));	memcpy(tl1_fecc, cheetah_fecc_trap_vector_tl1, (8 * 4));	memcpy(tl0_cee, cheetah_cee_trap_vector, (8 * 4));	memcpy(tl1_cee, cheetah_cee_trap_vector_tl1, (8 * 4));	memcpy(tl0_iae, cheetah_deferred_trap_vector, (8 * 4));	memcpy(tl1_iae, cheetah_deferred_trap_vector_tl1, (8 * 4));	memcpy(tl0_dae, cheetah_deferred_trap_vector, (8 * 4));	memcpy(tl1_dae, cheetah_deferred_trap_vector_tl1, (8 * 4));	if (tlb_type == cheetah_plus) {		memcpy(tl0_dcpe, cheetah_plus_dcpe_trap_vector, (8 * 4));		memcpy(tl1_dcpe, cheetah_plus_dcpe_trap_vector_tl1, (8 * 4));		memcpy(tl0_icpe, cheetah_plus_icpe_trap_vector, (8 * 4));		memcpy(tl1_icpe, cheetah_plus_icpe_trap_vector_tl1, (8 * 4));	}	flushi(PAGE_OFFSET);}static void cheetah_flush_ecache(void){	unsigned long flush_base = ecache_flush_physbase;	unsigned long flush_linesize = ecache_flush_linesize;	unsigned long flush_size = ecache_flush_size;	__asm__ __volatile__("1: subcc	%0, %4, %0\n\t"			     "   bne,pt	%%xcc, 1b\n\t"			     "    ldxa	[%2 + %0] %3, %%g0\n\t"			     : "=&r" (flush_size)			     : "0" (flush_size), "r" (flush_base),			       "i" (ASI_PHYS_USE_EC), "r" (flush_linesize));}static void cheetah_flush_ecache_line(unsigned long physaddr){	unsigned long alias;	physaddr &= ~(8UL - 1UL);	physaddr = (ecache_flush_physbase +		    (physaddr & ((ecache_flush_size>>1UL) - 1UL)));	alias = physaddr + (ecache_flush_size >> 1UL);	__asm__ __volatile__("ldxa [%0] %2, %%g0\n\t"			     "ldxa [%1] %2, %%g0\n\t"			     "membar #Sync"			     : /* no outputs */			     : "r" (physaddr), "r" (alias),			       "i" (ASI_PHYS_USE_EC));}/* Unfortunately, the diagnostic access to the I-cache tags we need to * use to clear the thing interferes with I-cache coherency transactions. * * So we must only flush the I-cache when it is disabled. */static void __cheetah_flush_icache(void){	unsigned long i;	/* Clear the valid bits in all the tags. */	for (i = 0; i < (1 << 15); i += (1 << 5)) {		__asm__ __volatile__("stxa %%g0, [%0] %1\n\t"				     "membar #Sync"				     : /* no outputs */				     : "r" (i | (2 << 3)), "i" (ASI_IC_TAG));	}}static void cheetah_flush_icache(void){	unsigned long dcu_save;	/* Save current DCU, disable I-cache. */	__asm__ __volatile__("ldxa [%%g0] %1, %0\n\t"			     "or %0, %2, %%g1\n\t"			     "stxa %%g1, [%%g0] %1\n\t"			     "membar #Sync"			     : "=r" (dcu_save)			     : "i" (ASI_DCU_CONTROL_REG), "i" (DCU_IC)			     : "g1");	__cheetah_flush_icache();	/* Restore DCU register */	__asm__ __volatile__("stxa %0, [%%g0] %1\n\t"			     "membar #Sync"			     : /* no outputs */			     : "r" (dcu_save), "i" (ASI_DCU_CONTROL_REG));}static void cheetah_flush_dcache(void){	unsigned long i;	for (i = 0; i < (1 << 16); i += (1 << 5)) {		__asm__ __volatile__("stxa %%g0, [%0] %1\n\t"				     "membar #Sync"				     : /* no outputs */				     : "r" (i), "i" (ASI_DCACHE_TAG));	}}/* In order to make the even parity correct we must do two things. * First, we clear DC_data_parity and set DC_utag to an appropriate value. * Next, we clear out all 32-bytes of data for that line.  Data of * all-zero + tag parity value of zero == correct parity. */static void cheetah_plus_zap_dcache_parity(void){	unsigned long i;	for (i = 0; i < (1 << 16); i += (1 << 5)) {		unsigned long tag = (i >> 14);		unsigned long j;		__asm__ __volatile__("membar	#Sync\n\t"				     "stxa	%0, [%1] %2\n\t"				     "membar	#Sync"				     : /* no outputs */				     : "r" (tag), "r" (i),				       "i" (ASI_DCACHE_UTAG));		for (j = i; j < i + (1 << 5); j += (1 << 3))			__asm__ __volatile__("membar	#Sync\n\t"					     "stxa	%%g0, [%0] %1\n\t"					     "membar	#Sync"					     : /* no outputs */					     : "r" (j), "i" (ASI_DCACHE_DATA));	}}/* Conversion tables used to frob Cheetah AFSR syndrome values into * something palatable to the memory controller driver get_unumber * routine. */#define MT0	137#define MT1	138#define MT2	139#define NONE	254#define MTC0	140#define MTC1	141#define MTC2	142#define MTC3	143#define C0	128#define C1	129#define C2	130#define C3	131#define C4	132#define C5	133#define C6	134#define C7	135#define C8	136#define M2	144#define M3	145#define M4	146#define M	147static unsigned char cheetah_ecc_syntab[] = {/*00*/NONE, C0, C1, M2, C2, M2, M3, 47, C3, M2, M2, 53, M2, 41, 29, M,/*01*/C4, M, M, 50, M2, 38, 25, M2, M2, 33, 24, M2, 11, M, M2, 16,/*02*/C5, M, M, 46, M2, 37, 19, M2, M, 31, 32, M, 7, M2, M2, 10,/*03*/M2, 40, 13, M2, 59, M, M2, 66, M, M2, M2, 0, M2, 67, 71, M,/*04*/C6, M, M, 43, M, 36, 18, M, M2, 49, 15, M, 63, M2, M2, 6,/*05*/M2, 44, 28, M2, M, M2, M2, 52, 68, M2, M2, 62, M2, M3, M3, M4,/*06*/M2, 26, 106, M2, 64, M, M2, 2, 120, M, M2, M3, M, M3, M3, M4,/*07*/116, M2, M2, M3, M2, M3, M, M4, M2, 58, 54, M2, M, M4, M4, M3,/*08*/C7, M2, M, 42, M, 35, 17, M2, M, 45, 14, M2, 21, M2, M2, 5,/*09*/M, 27, M, M, 99, M, M, 3, 114, M2, M2, 20, M2, M3, M3, M,/*0a*/M2, 23, 113, M2, 112, M2, M, 51, 95, M, M2, M3, M2, M3, M3, M2,/*0b*/103, M, M2, M3, M2, M3, M3, M4, M2, 48, M, M, 73, M2, M, M3,/*0c*/M2, 22, 110, M2, 109, M2, M, 9, 108, M2, M, M3, M2, M3, M3, M,/*0d*/102, M2, M, M, M2, M3, M3, M, M2, M3, M3, M2, M, M4, M, M3,/*0e*/98, M, M2, M3, M2, M, M3, M4, M2, M3, M3, M4, M3, M, M, M,/*0f*/M2, M3, M3, M, M3, M, M, M, 56, M4, M, M3, M4, M, M, M,/*10*/C8, M, M2, 39, M, 34, 105, M2, M, 30, 104, M, 101, M, M, 4,/*11*/M, M, 100, M, 83, M, M2, 12, 87, M, M, 57, M2, M, M3, M,/*12*/M2, 97, 82, M2, 78, M2, M2, 1, 96, M, M, M, M, M, M3, M2,/*13*/94, M, M2, M3, M2, M, M3, M, M2, M, 79, M, 69, M, M4, M,/*14*/M2, 93, 92, M, 91, M, M2, 8, 90, M2, M2, M, M, M, M, M4,/*15*/89, M, M, M3, M2, M3, M3, M, M, M, M3, M2, M3, M2, M, M3,/*16*/86, M, M2, M3, M2, M, M3, M, M2, M, M3, M, M3, M, M, M3,/*17*/M, M, M3, M2, M3, M2, M4, M, 60, M, M2, M3, M4, M, M, M2,/*18*/M2, 88, 85, M2, 84, M, M2, 55, 81, M2, M2, M3, M2, M3, M3, M4,/*19*/77, M, M, M, M2, M3, M, M, M2, M3, M3, M4, M3, M2, M, M,/*1a*/74, M, M2, M3, M, M, M3, M, M, M, M3, M, M3, M, M4, M3,/*1b*/M2, 70, 107, M4, 65, M2, M2, M, 127, M, M, M, M2, M3, M3, M,/*1c*/80, M2, M2, 72, M, 119, 118, M, M2, 126, 76, M, 125, M, M4, M3,/*1d*/M2, 115, 124, M, 75, M, M, M3, 61, M, M4, M, M4, M, M, M,/*1e*/M, 123, 122, M4, 121, M4, M, M3, 117, M2, M2, M3, M4, M3, M, M,/*1f*/111, M, M, M, M4, M3, M3, M, M, M, M3, M, M3, M2, M, M};static unsigned char cheetah_mtag_syntab[] = {       NONE, MTC0,       MTC1, NONE,       MTC2, NONE,       NONE, MT0,       MTC3, NONE,       NONE, MT1,       NONE, MT2,       NONE, NONE};/* Return the highest priority error conditon mentioned. */static __inline__ unsigned long cheetah_get_hipri(unsigned long afsr){	unsigned long tmp = 0;	int i;	for (i = 0; cheetah_error_table[i].mask; i++) {		if ((tmp = (afsr & cheetah_error_table[i].mask)) != 0UL)			return tmp;	}	return tmp;}static const char *cheetah_get_string(unsigned long bit){	int i;	for (i = 0; cheetah_error_table[i].mask; i++) {		if ((bit & cheetah_error_table[i].mask) != 0UL)			return cheetah_error_table[i].name;	}	return "???";}extern int chmc_getunumber(int, unsigned long, char *, int);static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *info,			       unsigned long afsr, unsigned long afar, int recoverable){	unsigned long hipri;	char unum[256];	printk("%s" "ERROR(%d): Cheetah error trap taken afsr[%016lx] afar[%016lx] TL1(%d)\n",	       (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),	       afsr, afar,	       (afsr & CHAFSR_TL1) ? 1 : 0);	printk("%s" "ERROR(%d): TPC[%016lx] TNPC[%016lx] TSTATE[%016lx]\n",	       (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),	       regs->tpc, regs->tnpc, regs->tstate);	printk("%s" "ERROR(%d): M_SYND(%lx),  E_SYND(%lx)%s%s\n",	       (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),	       (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,	       (afsr & CHAFSR_E_SYNDROME) >> CHAFSR_E_SYNDROME_SHIFT,	       (afsr & CHAFSR_ME) ? ", Multiple Errors" : "",	       (afsr & CHAFSR_PRIV) ? ", Privileged" : "");	hipri = cheetah_get_hipri(afsr);	printk("%s" "ERROR(%d): Highest priority error (%016lx) \"%s\"\n",	       (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),	       hipri, cheetah_get_string(hipri));	/* Try to get unumber if relevant. */#define ESYND_ERRORS	(CHAFSR_IVC | CHAFSR_IVU | \			 CHAFSR_CPC | CHAFSR_CPU | \			 CHAFSR_UE  | CHAFSR_CE  | \			 CHAFSR_EDC | CHAFSR_EDU  | \			 CHAFSR_UCC | CHAFSR_UCU  | \			 CHAFSR_WDU | CHAFSR_WDC)#define MSYND_ERRORS	(CHAFSR_EMC | CHAFSR_EMU)	if (afsr & ESYND_ERRORS) {		int syndrome;		int ret;		syndrome = (afsr & CHAFSR_E_SYNDROME) >> CHAFSR_E_SYNDROME_SHIFT;		syndrome = cheetah_ecc_syntab[syndrome];		ret = chmc_getunumber(syndrome, afar, unum, sizeof(unum));		if (ret != -1)			printk("%s" "ERROR(%d): AFAR E-syndrome [%s]\n",			       (recoverable ? KERN_WARNING : KERN_CRIT),			       smp_processor_id(), unum);	} else if (afsr & MSYND_ERRORS) {		int syndrome;		int ret;		syndrome = (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT;		syndrome = cheetah_mtag_syntab[syndrome];		ret = chmc_getunumber(syndrome, afar, unum, sizeof(unum));		if (ret != -1)			printk("%s" "ERROR(%d): AFAR M-syndrome [%s]\n",			       (recoverable ? KERN_WARNING : KERN_CRIT),			       smp_processor_id(), unum);	}	/* Now dump the cache snapshots. */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -