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

📄 llsc4.c

📁 Linux内核源代码 为压缩文件 是<<Linux内核>>一书中的源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
	int		cpu;	long 		synerr;	int		selt;	selt = selective_trigger && stillbad > 1 && 			memcmp(cap->blockdata, cap->blockdata_fc, 128) != 0 &&			memcmp(cap->shaddata, cap->shaddata_fc, 128) == 0;	if (selt) {		trigger_la(pass);	} else if (selective_trigger) {		k_go = ST_STOP;		return k_stop_on_error;;	}	spin(1);	printk ("\nDataError!: %-20s, test %ld, thread %d, line:%d, pass %d (0x%x), time %ld expected:%x, found:%x\n",	    msg, k_testnumber, thread, linei, pass, pass, jiffies, exp, found);	dumpline (lp, "Corrupted data", "D ", cap->blockaddr, cap->blockdata, cap->size);	if (memcmp(cap->blockdata, cap->blockdata_fc, 128))		dumpline (lp, "Corrupted data", "DF", cap->blockaddr, cap->blockdata_fc, cap->size);	if (cap->shadaddr) {		dumpline (slp, "Shadow    data", "S ", cap->shadaddr, cap->shaddata, cap->size);		if (memcmp(cap->shaddata, cap->shaddata_fc, 128))			dumpline (slp, "Shadow    data", "SF", cap->shadaddr, cap->shaddata_fc, cap->size);	}		printk("Threadpasses: ");	for (cpu=0; cpu<MAXCPUS; cpu++)		if (k_threadprivate[cpu]->threadpasses)			printk("  %d:0x%x", cpu, k_threadprivate[cpu]->threadpasses);	printk("\nData was %sfixed by flushcache\n", (stillbad == 1 ? "**** NOT **** " : " "));	synerr = getsynerr();	if (synerr)		printk("SYNERR: Thread %d, Synerr: 0x%lx\n", thread, synerr);	spin(2);	printk("\n\n");	if (errstop_enabled) {		local_irq_disable();		while(1);	}	return k_stop_on_error;}static voiddumpline(void *lp, char *str1, char *str2, void *addr, void *data, int size){	long *p;	int i, off;	printk("%s at 0x%lx, size %d, block starts at 0x%lx\n", str1, (long)addr, size, (long)lp);	p = (long*) data;	for (i=0; i<16; i++, p++) {		if (i==0) printk("%2s", str2);		if (i==8) printk("  ");		printk(" %016lx", *p);		if ((i&7)==7) printk("\n");	}	printk("   ");	off = (((long)addr) ^ size) & 63L;	for (i=0; i<off+size; i++) {		printk("%s", (i>=off) ? "--" : "  ");		if ((i%8) == 7)			printk(" ");	}	off = ((long)addr) & 127;	printk(" (line %d)\n", off/64+1);}static intrandn(uint max, uint *seedp){	if (max == 1)		return(0);	else		return((int)(zrandom(seedp)>>10) % max);}static intcheckstop(int thread, int pass, uint lockpat){	long	synerr;	if (k_go == ST_RUN)		return 0;	if (k_go == ST_STOP)		return 1;	if (errstop_enabled) {		local_irq_disable();		while(1);	}	synerr = getsynerr();	spin(2);	if (k_go == ST_STOP)		return 1;	if (synerr)		printk("SYNERR: Thread %d, Synerr: 0x%lx\n", thread, synerr);	return 1;}static voidspin(int j){	udelay(j * 500000);}static voidcapturedata(capture_t *cap, uint pass, void *blockaddr, void *shadaddr, int size){	if (!selective_trigger)		trigger_la (pass);	memcpy (cap->blockdata, CACHEALIGN(blockaddr), 128);	if (shadaddr) 		memcpy (cap->shaddata, CACHEALIGN(shadaddr), 128);	if (k_stop_on_error) {		k_go = ST_ERRSTOP;	} 	cap->size = size;	cap->blockaddr = blockaddr;	cap->shadaddr = shadaddr;	asm volatile ("fc %0" :: "r"(blockaddr) : "memory");	ia64_sync_i();	ia64_srlz_d();	memcpy (cap->blockdata_fc, CACHEALIGN(blockaddr), 128);	if (shadaddr) {		asm volatile ("fc %0" :: "r"(shadaddr) : "memory");		ia64_sync_i();		ia64_srlz_d();		memcpy (cap->shaddata_fc, CACHEALIGN(shadaddr), 128);	}}int             zranmult = 0x48c27395;static uint  zrandom (uint *seedp){        *seedp = (*seedp * zranmult) & 0x7fffffff;        return (*seedp);}voidset_autotest_params(void){	static int	testnumber=-1;	if (llsctest_number >= 0) {		testnumber = llsctest_number;	} else {		testnumber++;		if (autotest_table[testnumber].passes == 0)			testnumber = 0;	}	k_passes = autotest_table[testnumber].passes;	k_linepad = autotest_table[testnumber].linepad;	k_linecount = autotest_table[testnumber].linecount;	k_testnumber = testnumber;	if (IS_RUNNING_ON_SIMULATOR()) {		printk ("llsc start test %ld\n", k_testnumber);		k_passes = 1000;	}}static voidset_leds(int errs){	unsigned char	leds=0;	/*	 * Leds are:	 * 	ppppeee-  	 *   where	 *      pppp = test number	 *       eee = error count but top bit is stick	 */	leds =  ((errs&7)<<1) | ((k_testnumber&15)<<4) | (errs ? 0x08 : 0);	bringup_set_led_bits(leds, 0xfe);}static voidsetup_block_addresses(void){	int		i, stride, memmapi;	stride = LINESTRIDE;	memmapi = 0;	for (i=0; i<memmapx; i++) {		memmap[i].nextaddr = memmap[i].vstart;		memmap[i].wrapcount = 0;	}	for (i=0; i<k_linecount; i++) {		blocks[i] = memmap[memmapi].nextaddr;		memmap[memmapi].nextaddr += stride;		if (memmap[memmapi].nextaddr + sizeof(dataline_t) >= memmap[memmapi].vend) {			memmap[memmapi].wrapcount++;			memmap[memmapi].nextaddr = memmap[memmapi].vstart + 					memmap[memmapi].wrapcount * sizeof(dataline_t);		}		memset((void*)blocks[i], 0, sizeof(dataline_t));		if (stride > 16384) {			memmapi++;			if (memmapi == memmapx)				memmapi = 0;		}	}}static voidset_thread_state(int cpuid, int state){	if (k_threadprivate[cpuid]->threadstate == TS_KILLED) {		bringup_set_led_bits(0xfe, 0xfe);		while(1);	}	k_threadprivate[cpuid]->threadstate = state;}static intbuild_mem_map(unsigned long start, unsigned long end, void *arg){	long	lstart;	/*	 * HACK - skip the kernel on the first node 	 */	printk ("LLSC memmap: start 0x%lx, end 0x%lx, (0x%lx - 0x%lx)\n", 		start, end, (long) virt_to_page(start), (long) virt_to_page(end-PAGE_SIZE));	while (end > start && (PageReserved(virt_to_page(end-PAGE_SIZE)) || virt_to_page(end-PAGE_SIZE)->count.counter > 0))		end -= PAGE_SIZE;	lstart = end;	while (lstart > start && (!PageReserved(virt_to_page(lstart-PAGE_SIZE)) && virt_to_page(lstart-PAGE_SIZE)->count.counter == 0))		lstart -= PAGE_SIZE;	printk ("     memmap: start 0x%lx, end 0x%lx\n", lstart, end);	if (lstart >= end)		return 0;	memmap[memmapx].vstart = lstart;	memmap[memmapx].vend = end;	memmapx++;	return 0;}void int_test(void);intllsc_main (int cpuid, long mbasex){	int		i, cpu, is_master, repeatcnt=0;	unsigned int	preverr=0, errs=0, pass=0;	int		automode=0;#ifdef INTTEST	if (inttest)		int_test();#endif	if (!autotest_enabled)		return 0;#ifdef CONFIG_SMP	is_master = !smp_processor_id();#else	is_master = 1;#endif	if (is_master) {		print_params();		if(!IS_RUNNING_ON_SIMULATOR())			spin(10);		mbase = (control_t*)mbasex;		k_currentpass = 0;		k_go = ST_IDLE;		k_passes = DEF_PASSES;		k_napticks = DEF_NAPTICKS;		k_stop_on_error = DEF_STOP_ON_ERROR;		k_verbose = DEF_VERBOSE;		k_linecount = DEF_LINECOUNT;		k_iter_msg = DEF_ITER_MSG;		k_vv = DEF_VV;		k_linepad = DEF_LINEPAD;		k_blocks = (void*)blocks;		efi_memmap_walk(build_mem_map, 0);	#ifdef CONFIG_IA64_SGI_AUTOTEST		automode = 1;#endif		for (i=0; i<MAXCPUS; i++) {			k_threadprivate[i] = THREADPRIVATE(i);			memset(k_threadprivate[i], 0, sizeof(*k_threadprivate[i]));		}		initialized = 1;	} else {		while (initialized == 0)			udelay(100);	}loop:	if (is_master) {		if (automode) {			if (!preverr || repeatcnt++ > 5) {				set_autotest_params();				repeatcnt = 0;			}		} else {			while (k_go == ST_IDLE);		}		k_go = ST_INIT;		if (k_linecount > MAX_LINECOUNT) k_linecount = MAX_LINECOUNT;		k_linecount = k_linecount & ~1;		setup_block_addresses();		k_currentpass = pass++;		k_go = ST_RUN;		if (fail_enabled)			fail_enabled--;	} else {		while (k_go != ST_RUN || k_currentpass != pass);		pass++;	}	set_leds(errs);	set_thread_state(cpuid, TS_RUNNING);	errs += ran_conf_llsc(cpuid);	preverr = (k_go == ST_ERRSTOP);	set_leds(errs);	set_thread_state(cpuid, TS_STOPPED);	if (is_master) {		Speedo();		for (i=0, cpu=0; cpu<MAXCPUS; cpu++) {			while (k_threadprivate[cpu]->threadstate == TS_RUNNING) {				i++;				if (i == 10000) { 					k_go = ST_STOP;					printk ("  llsc master stopping test number %ld\n", k_testnumber);				}				if (i > 100000) {					k_threadprivate[cpu]->threadstate = TS_KILLED;					printk ("  llsc: master killing cpuid %d, running test number %ld\n", 							cpu, k_testnumber);				}				udelay(1000);			}		}	}	goto loop;}static voidSpeedo(void){	static int i = 0;	switch (++i%4) {	case 0:		printk("|\b");		break;	case 1:		printk("\\\b");		break;	case 2:		printk("-\b");		break;	case 3:		printk("/\b");		break;	}}#ifdef INTTEST/* ========================================================================================================  * * Some test code to verify that interrupts work * * Add the following to the arch/ia64/kernel/smp.c after the comment "Reschedule callback" * 		if (zzzprint_resched) printk("  cpu %d got interrupt\n", smp_processor_id()); * * Enable the code in arch/ia64/sn/sn1/smp.c to print sending IPIs. * */static int __init set_inttest(char *str){        inttest = 1;	autotest_enabled = 1;	return 1;}	__setup("inttest=", set_inttest);int	zzzprint_resched=0;voidint_test() {	int			mycpu, cpu;	static volatile int	control_cpu=0;	mycpu = smp_processor_id();	zzzprint_resched = 2;	printk("Testing cross interrupts\n");		while (control_cpu != smp_num_cpus) {		if (mycpu == cpu_logical_map(control_cpu)) {			for (cpu=0; cpu<smp_num_cpus; cpu++) {				printk("Sending interrupt from %d to %d\n", mycpu, cpu_logical_map(cpu));				udelay(IS_RUNNING_ON_SIMULATOR ? 10000 : 400000);				smp_send_reschedule(cpu_logical_map(cpu));				udelay(IS_RUNNING_ON_SIMULATOR ? 10000 : 400000);				smp_send_reschedule(cpu_logical_map(cpu));				udelay(IS_RUNNING_ON_SIMULATOR ? 10000 : 400000);			}			control_cpu++;		}	}	zzzprint_resched = 1;	if (mycpu == cpu_logical_map(smp_num_cpus-1)) {		printk("\nTight loop of cpu %d sending ints to cpu 0 (every 100 us)\n", mycpu);		udelay(IS_RUNNING_ON_SIMULATOR ? 1000 : 1000000);		__cli();		while (1) {			smp_send_reschedule(0);			udelay(100);		}	}	while(1);}#endif

⌨️ 快捷键说明

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