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

📄 post1.s

📁 u-boot-1.1.6 源码包
💻 S
📖 第 1 页 / 共 2 页
字号:
/* * (C) Copyright 2001 * Bill Hunter, Wave 7 Optics, william.hunter@mediaone.net *  and * Erik Theisen, Wave 7 Optics, etheisen@mindspring.com * * See file CREDITS for list of people who contributed to this * project. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA *//* * Description: *	Routine to exercise memory for the bringing up of our boards. */#include <config.h>#include <ppc4xx.h>#define _LINUX_CONFIG_H 1       /* avoid reading Linux autoconf.h file  */#include <ppc_asm.tmpl>#include <ppc_defs.h>#include <asm/cache.h>#include <asm/mmu.h>#include <watchdog.h>#include "errors.h"#define _ASMLANGUAGE	.globl	test_sdram	.globl	test_led	.globl	log_stat	.globl	log_warn	.globl	log_err	.globl  temp_uart_init	.globl  post_puts	.globl  disp_hex/************************************************************   Text Strings for low level printing   *************          In section got2               ************************************************************//* * Define the text strings for errors and warnings. * Switch to .data section. */	.section ".data"err_str: 	.asciz "*** POST ERROR   = "warn_str:	.asciz "*** POST WARNING = "end_str:  .asciz "\r\n"/* * Enter the labels in Global Entry Table (GOT). * Switch to .got2 section. */	START_GOT	GOT_ENTRY(err_str)	GOT_ENTRY(warn_str)	GOT_ENTRY(end_str)	END_GOT/* * Switch  back to .text section. */	.text/**************************************** **************************************** ********    LED register test   ******** **************************************** ***************************************/test_led:	/* save the return info on stack */	mflr	r0			/* Get link register */	stwu	r1, -12(r1)		/* Save back chain and move SP */	stw	r0, +16(r1)		/* Save link register */	stw	r4, +8(r1)		/* save R4 */	WATCHDOG_RESET        		/* Reset the watchdog */	addi    r3, 0, ERR_FF		/* first test value is ffff */	addi	r4, r3, 0		/* save copy of pattern */	bl	set_led			/* store first test value */	bl	get_led			/* read it back */	xor.	r4, r4, r3		/* compare to original */#if defined(CONFIG_W7OLMC)	andi.   r4, r4, 0x00ff		/* lmc has 8 bits */#else	andi.   r4, r4, 0xffff		/* lmg has 16 bits */#endif	beq     LED2			/* next test */	addi    r3, 0, ERR_LED		/* error code = 1 */	bl	log_err			/* display error and halt */LED2:	addi    r3, 0, ERR_00		/* 2nd test value is 0000 */	addi	r4, r3, 0		/* save copy of pattern */	bl	set_led			/* store first test value */	bl	get_led			/* read it back */	xor.	r4, r4, r3		/* compare to original */#if defined(CONFIG_W7OLMC)	andi.   r4, r4, 0x00ff		/* lmc has 8 bits */#else	andi.   r4, r4, 0xffff		/* lmg has 16 bits */#endif	beq     LED3			/* next test */	addi    r3, 0, ERR_LED		/* error code = 1 */	bl	log_err			/* display error and halt */LED3:	/* restore stack and return */	lwz	r0, +16(r1)		/* Get saved link register */	mtlr	r0			/* Restore link register */	lwz	r4, +8(r1)		/* restore r4 */	addi	r1, r1, +12		/* Remove frame from stack */	blr				/* Return to calling function *//**************************************** **************************************** ********     SDRAM TESTS        ******** **************************************** ***************************************/test_sdram:	/* called with mem size in r3 */	/* save the return info on stack */	mflr	r0			/* Get link register */	stwu	r1, -16(r1)		/* Save back chain and move SP */	stw	r0, +20(r1)		/* Save link register */	stmw	r30, +8(r1)		/* save R30,R31 */					/* r30 is log2(mem size) */					/* r31 is mem size */	/* take log2 of total mem size */	addi	r31, r3, 0		/* save total mem size */	addi	r30, 0, 0		/* clear r30 */l2_loop:	srwi.	r31, r31, 1		/* shift right 1 */	addi	r30, r30, 1		/* count shifts */	bne	l2_loop			/* loop till done */	addi	r30, r30, -1		/* correct for over count */	addi	r31, r3, 0		/* save original size */	/* now kick the dog and test the mem */	WATCHDOG_RESET        		/* Reset the watchdog */	bl	Data_Buster		/* test crossed/shorted data lines */	addi	r3, r30, 0		/* get log2(memsize) */	addi	r4, r31, 0		/* get memsize */	bl	Ghost_Buster		/* test crossed/shorted addr lines */	addi	r3, r31, 0		/* get mem size */	bl	Bit_Buster		/* check for bad internal bits */	/* restore stack and return */	lmw	r30, +8(r1)		/* Restore r30, r31 */	lwz	r0, +20(r1)		/* Get saved link register */	mtlr	r0			/* Restore link register */	addi	r1, r1, +16		/* Remove frame from stack */	blr				/* Return to calling function *//**************************************** ********  sdram data bus test   ******** ***************************************/Data_Buster:	/* save the return info on stack */	mflr	r0			/* Get link register */	stwu	r1, -24(r1)		/* Save back chain and move SP */	stw	r0, +28(r1)		/* Save link register */	stmw	r28, 8(r1)		/* save r28 - r31 on stack */					/* r31 i/o register */					/* r30 sdram base address */					/* r29 5555 syndrom */					/* r28 aaaa syndrom */	/* set up led register for this test */	addi    r3, 0, ERR_RAMG		/* set led code to 1 */	bl	log_stat		/* store test value */	/* now test the dram data bus */	xor	r30, r30, r30		/* load r30 with base addr of sdram */	addis	r31, 0, 0x5555		/* load r31 with test value */	ori	r31, r31, 0x5555	stw	r31,0(r30)		/* sto the value */	lwz	r29,0(r30)		/* read it back */	xor	r29,r31,r29		/* compare it to original */	addis	r31, 0, 0xaaaa		/* load r31 with test value */	ori	r31, r31, 0xaaaa	stw	r31,0(r30)		/* sto the value */	lwz	r28,0(r30)		/* read it back */	xor	r28,r31,r28		/* compare it to original */	or	r3,r28,r29		/* or together both error terms */	/*	 * Now that we have the error bits,	 * we have to decide which part they are in.	 */	bl	get_idx			/* r5 is now index to error */	addi	r3, r3, ERR_RAMG	cmpwi	r3, ERR_RAMG		/* check for errors */	beq	db_done			/* skip if no errors */	bl	log_err			/* log the error */db_done:	lmw	r28, 8(r1)		/* restore r28 - r31 from stack */	lwz	r0, +28(r1)		/* Get saved link register */	addi	r1, r1, +24		/* Remove frame from stack */	mtlr	r0			/* Restore link register */	blr				/* Return to calling function *//**************************************************** ********  test for address ghosting in dram ******** ***************************************************/Ghost_Buster:	/* save the return info on stack */	mflr	r0			/* Get link register */	stwu	r1, -36(r1)		/* Save back chain and move SP */	stw	r0, +40(r1)		/* Save link register */	stmw	r25, 8(r1)		/* save r25 - r31 on stack */					/* r31 = scratch register */					/* r30 is main referance loop counter,					   0 to 23 */					/* r29 is ghost loop count, 0 to 22 */					/* r28 is referance address */					/* r27 is ghost address */					/* r26 is log2 (mem size) =					     number of byte addr bits */					/* r25 is mem size */	/* save the log2(mem size) and mem size */	addi	r26, r3, 0		/* r26 is number of byte addr bits */	addi	r25, r4, 0		/* r25 is mem size in bytes */	/* set the leds for address ghost test */	addi	r3, 0, ERR_ADDG	bl	set_led	/* first fill memory with zeros */	srwi	r31, r25, 2		/* convert bytes to longs */	mtctr	r31			/* setup byte counter */	addi	r28, 0, 0		/* start at address at 0 */	addi	r31, 0, 0		/* data value = 0 */clr_loop:	stw	r31, 0(r28)		/* Store zero value */	addi	r28, r28, 4		/* Increment to next word */	andi.	r27, r28, 0xffff	/* check for 2^16 loops */	bne	clr_skip		/* if not there, then skip */	WATCHDOG_RESET   		/* kick the dog every now and then */clr_skip:	bdnz	clr_loop		/* Round and round... */	/* now do main test */	addi	r30, 0, 0		/* start referance counter at 0 */outside:	/*	 * Calculate the referance address	 *   the referance address is calculated by setting the (r30-1)	 *   bit of the base address	 * when r30=0, the referance address is the base address.	 * thus the sequence 0,1,2,4,8,..,2^(n-1)	 * setting the bit is done with the following shift functions.	 */	WATCHDOG_RESET   		/* Reset the watchdog */	addi	r31, 0, 1		/* r31 = 1 */	slw	r28, r31, r30		/* set bit coresponding to loop cnt */	srwi	r28, r28, 1		/* then shift it right one so  */					/*   we start at location 0 */	/* fill referance address with Fs */	addi	r31, 0, 0x00ff		/* r31 = one byte of set bits */	stb     r31,0(r28)		/* save ff in referance address */	/* ghost (inner) loop, now check all posible ghosted addresses */	addi	r29, 0, 0		/* start ghosted loop counter at 0 */inside:	/*	 * Calculate the ghost address by flipping one	 *  bit of referance address.  This gives the	 *  sequence 1,2,4,8,...,2^(n-1)	 */	addi	r31, 0, 1		/* r31 = 1 */	slw     r27, r31, r29		/* set  bit coresponding to loop cnt */	xor	r27, r28, r27		/* ghost address = ref addr with					     bit flipped*/	/* now check for ghosting */	lbz     r31,0(r27)		/* get content of ghost addr */	cmpwi   r31, 0			/* compare read value to 0 */	bne	Casper			/*   we found a ghost! */	/* now close ghost ( inner ) loop */	addi 	r29, r29, 1		/* increment inner loop counter */	cmpw 	r29, r26		/* check for last inner loop */	blt		inside		/* do more inner loops */	/* now close referance ( outer ) loop */	addi 	r31, 0, 0 		/* r31 = zero */	stb	r31, 0(28)		/* zero out the altered address loc. */	/*	 * Increment and check for end, count is zero based.	 * With the ble, this gives us one more loops than	 * address bits for sequence 0,1,2,4,8,...2^(n-1)	*/	addi 	r30, r30, 1		/* increment outer loop counter */	cmpw 	r30, r26		/* check for last inner loop */	ble	outside			/* do more outer loops */	/* were done, lets go home */	b	gb_doneCasper:					/* we found a ghost !! */	addi	r3, 0, ERR_ADDF		/* get indexed error message */	bl	log_err			/* log error led error code */gb_done: /*  pack your bags, and go home */	lmw     r25, 8(r1)              /* restore r25 - r31 from stack */	lwz     r0, +40(r1)             /* Get saved link register */	addi    r1, r1, +36             /* Remove frame from stack */	mtlr    r0                      /* Restore link register */	blr                             /* Return to calling function *//**************************************************** ********      SDRAM data fill tests       ********** ***************************************************/Bit_Buster:	/* called with mem size in r3 */	/* save the return info on stack */	mflr	r0			/* Get link register */	stwu	r1, -16(r1)		/* Save back chain and move SP */	stw	r0, +20(r1)		/* Save link register */	stw	r4, +8(r1)		/* save R4 */	stw	r5, +12(r1)		/* save r5 */	addis	r5, r3, 0		/* save mem size */	/* Test 55555555 */	addi	r3, 0, ERR_R55G		/* set up error code in case we fail */	bl	log_stat		/* store test value */	addis	r4, 0, 0x5555	ori	r4, r4, 0x5555	bl	fill_test	/* Test aaaaaaaa  */	addi	r3, 0, ERR_RAAG		/* set up error code in case we fail */	bl	log_stat		/* store test value */	addis	r4, 0, 0xAAAA	ori	r4, r4, 0xAAAA	bl	fill_test	/* Test 00000000  */	addi	r3, 0, ERR_R00G		/* set up error code in case we fail */	bl	log_stat		/* store test value */	addis	r4, 0, 0	ori	r4, r4, 0	bl	fill_test	/* restore stack and return */	lwz	r5, +12(r1)		/* restore r4 */	lwz	r4, +8(r1)		/* restore r4 */	lwz	r0, +20(r1)		/* Get saved link register */	addi	r1, r1, +16		/* Remove frame from stack */	mtlr	r0			/* Restore link register */

⌨️ 快捷键说明

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