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

📄 tgt_machdep.c

📁 国产CPU-龙芯(loongson)BIOS源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
	tgt_putchar('\r');	tgt_putchar('\n');}voidclrhndlrs(){}inttgt_getmachtype(){	return(md_cputype());}/* *  Create stubs if network is not compiled in */#ifdef INETvoidtgt_netpoll(){	splx(splhigh());}#elseextern void longjmp(label_t *, int);void gsignal(label_t *jb, int sig);voidgsignal(label_t *jb, int sig){	if(jb != NULL) {		longjmp(jb, 1);	}};int	netopen (const char *, int);int	netread (int, void *, int);int	netwrite (int, const void *, int);long	netlseek (int, long, int);int	netioctl (int, int, void *);int	netclose (int);int netopen(const char *p, int i)	{ return -1;}int netread(int i, void *p, int j)	{ return -1;}int netwrite(int i, const void *p, int j)	{ return -1;}int netclose(int i)	{ return -1;}long int netlseek(int i, long j, int k)	{ return -1;}int netioctl(int j, int i, void *p)	{ return -1;}void tgt_netpoll()	{};#endif /*INET*/#define SPINSZ		0x800000#define DEFTESTS	7#define MOD_SZ		20#define BAILOUT		if (bail) goto skip_test;#define BAILR		if (bail) return;#ifdef DEEP_DEBUG/* memspeed operations */#define MS_BCOPY	1#define MS_COPY		2#define MS_WRITE	3#define MS_READ		4struct map_struct {	unsigned long *start;	unsigned long *end;};struct map_struct map[] = {    {(unsigned long*)0x80100000,(unsigned long*)(0x84000000 - 0x100000)},   {(unsigned long*)0x0,(unsigned long*)0x0}};int segs=1;int bail;volatile unsigned long *p;unsigned long p1, p2;int test_ticks, nticks;unsigned long bad;int ecount = 0, errors = 0;void poll_errors(void);static void update_err_counts(void);static unsigned long my_roundup(unsigned long value, unsigned long mask){	return (value + mask) & ~mask;}/* * Print an individual error */void print_err( unsigned long *adr, unsigned long good, unsigned long bad, unsigned long xor) {	printf("adr=%x,good=%x,bad=%x,xor=%x\n",adr,good,bad,xor);}/* * Display data error message. Don't display duplicate errors. */void error(unsigned long *adr, unsigned long good, unsigned long bad){	unsigned long xor;	xor = good ^ bad;	update_err_counts();	print_err(adr, good, bad, xor);}/* * Display data error message from the block move test.  The actual failing * address is unknown so don't use this failure information to create * BadRAM patterns. */void mv_error(unsigned long *adr, unsigned long good, unsigned long bad){	unsigned long xor;	update_err_counts();	xor = good ^ bad;	print_err(adr, good, bad, xor);}/* * Display address error message. * Since this is strictly an address test, trying to create BadRAM * patterns does not make sense.  Just report the error. */void ad_err1(unsigned long *adr1, unsigned long *adr2, unsigned long good, unsigned long bad){	unsigned long xor;	update_err_counts();	xor = ((unsigned long)adr1) ^ ((unsigned long)adr2);	print_err(adr1, good, bad, xor);}/* * Display address error message. * Since this type of address error can also report data errors go * ahead and generate BadRAM patterns. */void ad_err2(unsigned long *adr, unsigned long bad){#if 0	int patnchg;	/* Process the address in the pattern administration */	patnchg=insertaddress ((unsigned long) adr);#endif	update_err_counts();	print_err(adr, (unsigned long)adr, bad, ((unsigned long)adr) ^ bad);}void print_hdr(void){	printf("Tst  Pass   Failing Address          Good       Bad     Err-Bits  Count Chan\n");	printf("---  ----  -----------------------  --------  --------  --------  ----- ----\n");}static void update_err_counts(void){	++(ecount);	errors++;}/* * Show progress by displaying elapsed time and update bar graphs */void do_tick(void){	printf(".");}/* * Memory address test, walking ones */void addr_tst1(void){	int i, j, k;	volatile unsigned long *pt;	volatile unsigned long *end;	unsigned long bad, mask, bank;	printf("address test 1..\n");	/* Test the global address bits */	for (p1=0, j=0; j<2; j++) {        	//hprint(LINE_PAT, COL_PAT, p1);		printf("\npat=%x\n",p1);		/* Set pattern in our lowest multiple of 0x20000 */		p = (unsigned long *)my_roundup((unsigned long)map[0].start, 0x1ffff);		*p = p1;			/* Now write pattern compliment */		p1 = ~p1;		end = map[segs-1].end;		for (i=0; i<1000; i++) {			mask = 4;			do {				pt = (unsigned long *)((unsigned long)p | mask);				if (pt == p) {					mask = mask << 1;					continue;				}				if (pt >= end) {					break;				}				*pt = p1;				if ((bad = *p) != ~p1) {					ad_err1((unsigned long *)p, (unsigned long *)mask,						bad, ~p1);					i = 1000;				}				mask = mask << 1;			} while(mask);		do_tick();		}		BAILR	}	/* Now check the address bits in each bank */	/* If we have more than 8mb of memory then the bank size must be */	/* bigger than 256k.  If so use 1mb for the bank size. */	if (map[segs-1].end - map[0].start > (0x800000 >> 12)) {		bank = 0x100000;	} else {		bank = 0x40000;	}	for (p1=0, k=0; k<2; k++) {        	//hprint(LINE_PAT, COL_PAT, p1);		printf("\npat=%x\n",p1);		for (j=0; j<segs; j++) {			p = map[j].start;			/* Force start address to be a multiple of 256k */			p = (unsigned long *)my_roundup((unsigned long)p, bank - 1);			end = map[j].end;			while (p < end) {				*p = p1;				p1 = ~p1;				for (i=0; i<200; i++) {					mask = 4;					do {						pt = (unsigned long *)						    ((unsigned long)p | mask);						if (pt == p) {							mask = mask << 1;							continue;						}						if (pt >= end) {							break;						}						*pt = p1;						if ((bad = *p) != ~p1) {							ad_err1((unsigned long *)p,							    (unsigned long *)mask,							    bad,~p1);							i = 200;						}						mask = mask << 1;					} while(mask);				}				if (p + bank > p) {					p += bank;				} else {					p = end;				}				p1 = ~p1;			}			do_tick();		}		BAILR		p1 = ~p1;	}}/* * Memory address test, own address */void addr_tst2(void){	int j, done;	volatile unsigned long *pe;	volatile unsigned long *end, *start;        //cprint(LINE_PAT, COL_PAT, "        ");	printf("addr test 2...\n");	/* Write each address with it's own address */	for (j=0; j<segs; j++) {		start = map[j].start;		end = map[j].end;		pe = (unsigned long *)start;		p = start;		done = 0;		do {			/* Check for overflow */			if (pe + SPINSZ > pe) {				pe += SPINSZ;			} else {				pe = end;			}			if (pe >= end) {				pe = end;				done++;			}			if (p == pe ) {				break;			} 			for (; p < pe; p++) {				*p = (unsigned long)p;			}			do_tick();			BAILR		} while (!done);	}	/* Each address should have its own address */	for (j=0; j<segs; j++) {		start = map[j].start;		end = map[j].end;		pe = (unsigned long *)start;		p = start;		done = 0;		do {			/* Check for overflow */			if (pe + SPINSZ > pe) {				pe += SPINSZ;			} else {				pe = end;			}			if (pe >= end) {				pe = end;				done++;			}			if (p == pe ) {				break;			} 			for (; p < pe; p++) { 				if((bad = *p) != (unsigned long)p) { 					ad_err2((unsigned long*)p, bad); 				} 			}			do_tick();			BAILR		} while (!done);	}}/* * Test all of memory using a "moving inversions" algorithm using the * pattern in p1 and it's complement in p2. */void movinv1(int iter, unsigned long p1, unsigned long p2){	int i, j, done;	volatile unsigned long *pe;	volatile unsigned long len;	volatile unsigned long *start,*end;	/* Display the current pattern */        //hprint(LINE_PAT, COL_PAT, p1);	printf("movinv test with p1=%x,p2=%x...\n",p1,p2);	/* Initialize memory with the initial pattern.  */	for (j=0; j<segs; j++) {		start = map[j].start;		end = map[j].end;		pe = start;		p = start;		done = 0;		do {			/* Check for overflow */			if (pe + SPINSZ > pe) {				pe += SPINSZ;			} else {				pe = end;			}			if (pe >= end) {				pe = end;				done++;			}			len = pe - p;			if (p == pe ) {				break;			}			for (; p < pe; p++) {				*p = p1;			}			do_tick();			BAILR		} while (!done);	}	/* Do moving inversions test. Check for initial pattern and then	 * write the complement for each memory location. Test from bottom	 * up and then from the top down.  */	for (i=0; i<iter; i++) {		for (j=0; j<segs; j++) {			start = map[j].start;			end = map[j].end;			pe = start;			p = start;			done = 0;			do {				/* Check for overflow */				if (pe + SPINSZ > pe) {					pe += SPINSZ;				} else {					pe = end;				}				if (pe >= end) {					pe = end;					done++;				}				if (p == pe ) {					break;				}				for (; p < pe; p++) {					if ((bad=*p) != p1) {						error((unsigned long*)p, p1, bad);					}					*p = p2;				}				do_tick();				BAILR			} while (!done);		}		for (j=segs-1; j>=0; j--) {			start = map[j].start;			end = map[j].end;			pe = end -1;			p = end -1;			done = 0;			do {				/* Check for underflow */				if (pe - SPINSZ < pe) {					pe -= SPINSZ;				} else {					pe = start;				}				if (pe <= start) {					pe = start;					done++;				}				if (p == pe ) {					break;				} 				do {					if ((bad=*p) != p2) {						error((unsigned long*)p, p2, bad);				}					*p = p1;				} while (p-- > pe);				do_tick();				BAILR			} while (!done);		}	}}/* * Test all of memory using modulo X access pattern. */void modtst(int offset, int iter, unsigned long p1, unsigned long p2){	int j, k, l, done;	volatile unsigned long *pe;	volatile unsigned long *start, *end;	/* Display the current pattern */	/*        hprint(LINE_PAT, COL_PAT-2, p1);	cprint(LINE_PAT, COL_PAT+6, "-");        dprint(LINE_PAT, COL_PAT+7, offset, 2, 1);	*/	printf("modtst offset=%x,p1=%x,p2=%x\n",offset,p1,p2);	/* Write every nth location with pattern */	for (j=0; j<segs; j++) {		start = map[j].start;		end = map[j].end;		pe = (unsigned long *)start;		p = start+offset;		done = 0;		do {			/* Check for overflow */			if (pe + SPINSZ > pe) {				pe += SPINSZ;			} else {				pe = end;			}			if (pe >= end) {				pe = end;				done++;			}			if (p == pe ) {				break;			} 			for (; p < pe; p += MOD_SZ) { 				*p = p1; 			}			do_tick();			BAILR		} while (!done);	}	/* Write the rest of memory "iter" times with the pattern complement */	for (l=0; l<iter; l++) {		for (j=0; j<segs; j++) {			start = map[j].start;			end = map[j].end;			pe = (unsigned long *)start;			p = start;			done = 0;			k = 0;			do {				/* Check for overflow */				if (pe + SPINSZ > pe) {					pe += SPINSZ;				} else {					pe = end;				}				if (pe >= end) {					pe = end;					done++;				}				if (p == pe ) {					break;				} 				for (; p < pe; p++) { 					if (k != offset) { 						*p = p2; 					} 					if (++k > MOD_SZ-1) { 						k = 0; 					} 				}				do_tick();				BAILR			} while (!done);		}	}	/* Now check every nth location */	for (j=0; j<segs; j++) {		start = map[j].start;		end = map[j].end;		pe = (unsigned long *)start;		p = start+offset;		done = 0;		do {			/* Check for overflow */			if (pe + SPINSZ > pe) {				pe += SPINSZ;			} else {				pe = end;			}			if (pe >= end) {				pe = end;				done++;			}			if (p == pe ) {				break;			} 			for (; p < pe; p += MOD_SZ) { 				if ((bad=*p) != p1) { 					error((unsigned long*)p, p1, bad); 				}			}			do_tick();			BAILR		} while (!done);	}}#endif

⌨️ 快捷键说明

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