start.s

来自「最新版的u-boot,2008-10-18发布」· S 代码 · 共 2,146 行 · 第 1/4 页

S
2,146
字号
/* Alignment exception. */	. = 0x600Alignment:	EXCEPTION_PROLOG(SRR0, SRR1)	mfspr	r4,DAR	stw	r4,_DAR(r21)	mfspr	r5,DSISR	stw	r5,_DSISR(r21)	addi	r3,r1,STACK_FRAME_OVERHEAD	li	r20,MSR_KERNEL	rlwimi	r20,r23,0,16,16		/* copy EE bit from saved MSR */	lwz	r6,GOT(transfer_to_handler)	mtlr	r6	blrl.L_Alignment:	.long	AlignmentException - _start + _START_OFFSET	.long	int_return - _start + _START_OFFSET/* Program check exception */	. = 0x700ProgramCheck:	EXCEPTION_PROLOG(SRR0, SRR1)	addi	r3,r1,STACK_FRAME_OVERHEAD	li	r20,MSR_KERNEL	rlwimi	r20,r23,0,16,16		/* copy EE bit from saved MSR */	lwz	r6,GOT(transfer_to_handler)	mtlr	r6	blrl.L_ProgramCheck:	.long	ProgramCheckException - _start + _START_OFFSET	.long	int_return - _start + _START_OFFSET#ifdef CONFIG_440	STD_EXCEPTION(0x800, FPUnavailable, UnknownException)	STD_EXCEPTION(0x900, Decrementer, DecrementerPITException)	STD_EXCEPTION(0xa00, APU, UnknownException)#endif	STD_EXCEPTION(0xc00, SystemCall, UnknownException)#ifdef CONFIG_440	STD_EXCEPTION(0x1300, DataTLBError, UnknownException)	STD_EXCEPTION(0x1400, InstructionTLBError, UnknownException)#else	STD_EXCEPTION(0x1000, PIT, DecrementerPITException)	STD_EXCEPTION(0x1100, InstructionTLBMiss, UnknownException)	STD_EXCEPTION(0x1200, DataTLBMiss, UnknownException)#endif	CRIT_EXCEPTION(0x2000, DebugBreakpoint, DebugException )	.globl	_end_of_vectors_end_of_vectors:	. = _START_OFFSET#endif	.globl	_start_start:/*****************************************************************************/#if defined(CONFIG_440)	/*----------------------------------------------------------------*/	/* Clear and set up some registers. */	/*----------------------------------------------------------------*/	li	r0,0x0000	lis	r1,0xffff	mtspr	dec,r0			/* prevent dec exceptions */	mtspr	tbl,r0			/* prevent fit & wdt exceptions */	mtspr	tbu,r0	mtspr	tsr,r1			/* clear all timer exception status */	mtspr	tcr,r0			/* disable all */	mtspr	esr,r0			/* clear exception syndrome register */	mtxer	r0			/* clear integer exception register */	/*----------------------------------------------------------------*/	/* Debug setup -- some (not very good) ice's need an event*/	/* to establish control :-( Define CFG_INIT_DBCR to the dbsr */	/* value you need in this case 0x8cff 0000 should do the trick */	/*----------------------------------------------------------------*/#if defined(CFG_INIT_DBCR)	lis	r1,0xffff	ori	r1,r1,0xffff	mtspr	dbsr,r1			/* Clear all status bits */	lis	r0,CFG_INIT_DBCR@h	ori	r0,r0,CFG_INIT_DBCR@l	mtspr	dbcr0,r0	isync#endif	/*----------------------------------------------------------------*/	/* Setup the internal SRAM */	/*----------------------------------------------------------------*/	li	r0,0#ifdef CFG_INIT_RAM_DCACHE	/* Clear Dcache to use as RAM */	addis	r3,r0,CFG_INIT_RAM_ADDR@h	ori	r3,r3,CFG_INIT_RAM_ADDR@l	addis	r4,r0,CFG_INIT_RAM_END@h	ori	r4,r4,CFG_INIT_RAM_END@l	rlwinm. r5,r4,0,27,31	rlwinm	r5,r4,27,5,31	beq	..d_ran	addi	r5,r5,0x0001..d_ran:	mtctr	r5..d_ag:	dcbz	r0,r3	addi	r3,r3,32	bdnz	..d_ag	/*	 * Lock the init-ram/stack in d-cache, so that other regions	 * may use d-cache as well	 * Note, that this current implementation locks exactly 4k	 * of d-cache, so please make sure that you don't define a	 * bigger init-ram area. Take a look at the lwmon5 440EPx	 * implementation as a reference.	 */	msync	isync	/* 8. set TFLOOR/NFLOOR to 8 (-> 8*16*32 bytes locked -> 4k) */	lis	r1,0x0201	ori	r1,r1,0xf808	mtspr	dvlim,r1	lis	r1,0x0808	ori	r1,r1,0x0808	mtspr	dnv0,r1	mtspr	dnv1,r1	mtspr	dnv2,r1	mtspr	dnv3,r1	mtspr	dtv0,r1	mtspr	dtv1,r1	mtspr	dtv2,r1	mtspr	dtv3,r1	msync	isync#endif /* CFG_INIT_RAM_DCACHE */	/* 440EP & 440GR are only 440er PPC's without internal SRAM */#if !defined(CONFIG_440EP) && !defined(CONFIG_440GR)	/* not all PPC's have internal SRAM usable as L2-cache */#if defined(CONFIG_440GX) || \    defined(CONFIG_440SP) || defined(CONFIG_440SPE) || \    defined(CONFIG_460EX) || defined(CONFIG_460GT) || \    defined(CONFIG_460SX)	mtdcr	l2_cache_cfg,r0		/* Ensure L2 Cache is off */#endif	lis	r2,0x7fff	ori	r2,r2,0xffff	mfdcr	r1,isram0_dpc	and	r1,r1,r2		/* Disable parity check */	mtdcr	isram0_dpc,r1	mfdcr	r1,isram0_pmeg	and	r1,r1,r2		/* Disable pwr mgmt */	mtdcr	isram0_pmeg,r1	lis	r1,0x8000		/* BAS = 8000_0000 */#if defined(CONFIG_440GX) || defined(CONFIG_440SP)	ori	r1,r1,0x0980		/* first 64k */	mtdcr	isram0_sb0cr,r1	lis	r1,0x8001	ori	r1,r1,0x0980		/* second 64k */	mtdcr	isram0_sb1cr,r1	lis	r1, 0x8002	ori	r1,r1, 0x0980		/* third 64k */	mtdcr	isram0_sb2cr,r1	lis	r1, 0x8003	ori	r1,r1, 0x0980		/* fourth 64k */	mtdcr	isram0_sb3cr,r1#elif defined(CONFIG_440SPE)	lis	r1,0x0000		/* BAS = 0000_0000 */	ori	r1,r1,0x0984		/* first 64k */	mtdcr	isram0_sb0cr,r1	lis	r1,0x0001	ori	r1,r1,0x0984		/* second 64k */	mtdcr	isram0_sb1cr,r1	lis	r1, 0x0002	ori	r1,r1, 0x0984		/* third 64k */	mtdcr	isram0_sb2cr,r1	lis	r1, 0x0003	ori	r1,r1, 0x0984		/* fourth 64k */	mtdcr	isram0_sb3cr,r1#elif defined(CONFIG_460EX) || defined(CONFIG_460GT)	lis	r1,0x4000		/* BAS = 8000_0000 */	ori	r1,r1,0x4580		/* 16k */	mtdcr	isram0_sb0cr,r1#elif defined(CONFIG_460SX)	lis     r1,0x0000               /* BAS = 0000_0000 */	ori     r1,r1,0x0B84            /* first 128k */	mtdcr   isram0_sb0cr,r1	lis     r1,0x0001	ori     r1,r1,0x0B84            /* second 128k */	mtdcr   isram0_sb1cr,r1	lis     r1, 0x0002	ori     r1,r1, 0x0B84           /* third 128k */	mtdcr   isram0_sb2cr,r1	lis     r1, 0x0003	ori     r1,r1, 0x0B84           /* fourth 128k */	mtdcr   isram0_sb3cr,r1#elif defined(CONFIG_440GP)	ori	r1,r1,0x0380		/* 8k rw */	mtdcr	isram0_sb0cr,r1	mtdcr	isram0_sb1cr,r0		/* Disable bank 1 */#endif#endif /* #if !defined(CONFIG_440EP) && !defined(CONFIG_440GR) */	/*----------------------------------------------------------------*/	/* Setup the stack in internal SRAM */	/*----------------------------------------------------------------*/	lis	r1,CFG_INIT_RAM_ADDR@h	ori	r1,r1,CFG_INIT_SP_OFFSET@l	li	r0,0	stwu	r0,-4(r1)	stwu	r0,-4(r1)		/* Terminate call chain */	stwu	r1,-8(r1)		/* Save back chain and move SP */	lis	r0,RESET_VECTOR@h	/* Address of reset vector */	ori	r0,r0, RESET_VECTOR@l	stwu	r1,-8(r1)		/* Save back chain and move SP */	stw	r0,+12(r1)		/* Save return addr (underflow vect) */#ifdef CONFIG_NAND_SPL	bl	nand_boot_common	/* will not return */#else	GET_GOT	bl	cpu_init_f	/* run low-level CPU init code	   (from Flash) */	bl	board_init_f#endif#endif /* CONFIG_440 *//*****************************************************************************/#ifdef CONFIG_IOP480	/*----------------------------------------------------------------------- */	/* Set up some machine state registers. */	/*----------------------------------------------------------------------- */	addi	r0,r0,0x0000		/* initialize r0 to zero */	mtspr	esr,r0			/* clear Exception Syndrome Reg */	mttcr	r0			/* timer control register */	mtexier r0			/* disable all interrupts */	addis	r4,r0,0xFFFF		/* set r4 to 0xFFFFFFFF (status in the */	ori	r4,r4,0xFFFF		/* dbsr is cleared by setting bits to 1) */	mtdbsr	r4			/* clear/reset the dbsr */	mtexisr r4			/* clear all pending interrupts */	addis	r4,r0,0x8000	mtexier r4			/* enable critical exceptions */	addis	r4,r0,0x0000		/* assume 403GCX - enable core clk */	ori	r4,r4,0x4020		/* dbling (no harm done on GA and GC */	mtiocr	r4			/* since bit not used) & DRC to latch */					/* data bus on rising edge of CAS */	/*----------------------------------------------------------------------- */	/* Clear XER. */	/*----------------------------------------------------------------------- */	mtxer	r0	/*----------------------------------------------------------------------- */	/* Invalidate i-cache and d-cache TAG arrays. */	/*----------------------------------------------------------------------- */	addi	r3,0,1024		/* 1/4 of I-cache size, half of D-cache */	addi	r4,0,1024		/* 1/4 of I-cache */..cloop:	iccci	0,r3	iccci	r4,r3	dccci	0,r3	addic.	r3,r3,-16		/* move back one cache line */	bne	..cloop			/* loop back to do rest until r3 = 0 */	/* */	/* initialize IOP480 so it can read 1 MB code area for SRAM spaces */	/* this requires enabling MA[17..0], by default only MA[12..0] are enabled. */	/* */	/* first copy IOP480 register base address into r3 */	addis	r3,0,0x5000		/* IOP480 register base address hi *//*	ori	r3,r3,0x0000		/  IOP480 register base address lo */#ifdef CONFIG_ADCIOP	/* use r4 as the working variable */	/* turn on CS3 (LOCCTL.7) */	lwz	r4,0x84(r3)		/* LOCTL is at offset 0x84 */	andi.	r4,r4,0xff7f		/* make bit 7 = 0 -- CS3 mode */	stw	r4,0x84(r3)		/* LOCTL is at offset 0x84 */#endif#ifdef CONFIG_DASA_SIM	/* use r4 as the working variable */	/* turn on MA17 (LOCCTL.7) */	lwz	r4,0x84(r3)		/* LOCTL is at offset 0x84 */	ori	r4,r4,0x80		/* make bit 7 = 1 -- MA17 mode */	stw	r4,0x84(r3)		/* LOCTL is at offset 0x84 */#endif	/* turn on MA16..13 (LCS0BRD.12 = 0) */	lwz	r4,0x100(r3)		/* LCS0BRD is at offset 0x100 */	andi.	r4,r4,0xefff		/* make bit 12 = 0 */	stw	r4,0x100(r3)		/* LCS0BRD is at offset 0x100 */	/* make sure above stores all comlete before going on */	sync	/* last thing, set local init status done bit (DEVINIT.31) */	lwz	r4,0x80(r3)		/* DEVINIT is at offset 0x80 */	oris	r4,r4,0x8000		/* make bit 31 = 1 */	stw	r4,0x80(r3)		/* DEVINIT is at offset 0x80 */	/* clear all pending interrupts and disable all interrupts */	li	r4,-1			/* set p1 to 0xffffffff */	stw	r4,0x1b0(r3)		/* clear all pending interrupts */	stw	r4,0x1b8(r3)		/* clear all pending interrupts */	li	r4,0			/* set r4 to 0 */	stw	r4,0x1b4(r3)		/* disable all interrupts */	stw	r4,0x1bc(r3)		/* disable all interrupts */	/* make sure above stores all comlete before going on */	sync	/* Set-up icache cacheability. */	lis	r1, CFG_ICACHE_SACR_VALUE@h	ori	r1, r1, CFG_ICACHE_SACR_VALUE@l	mticcr	r1	isync	/* Set-up dcache cacheability. */	lis	r1, CFG_DCACHE_SACR_VALUE@h	ori	r1, r1, CFG_DCACHE_SACR_VALUE@l	mtdccr	r1	addis	r1,r0,CFG_INIT_RAM_ADDR@h	ori	r1,r1,CFG_INIT_SP_OFFSET /* set up the stack to SDRAM */	li	r0, 0			/* Make room for stack frame header and */	stwu	r0, -4(r1)		/* clear final stack frame so that	*/	stwu	r0, -4(r1)		/* stack backtraces terminate cleanly	*/	GET_GOT			/* initialize GOT access			*/	bl	board_init_f	/* run first part of init code (from Flash)	*/#endif	/* CONFIG_IOP480 *//*****************************************************************************/#if defined(CONFIG_405GP) || defined(CONFIG_405CR) || \    defined(CONFIG_405EP) || defined(CONFIG_405EZ) || \    defined(CONFIG_405EX) || defined(CONFIG_405)	/*----------------------------------------------------------------------- */	/* Clear and set up some registers. */	/*----------------------------------------------------------------------- */	addi	r4,r0,0x0000#if !defined(CONFIG_405EX)	mtspr	sgr,r4#else	/*	 * On 405EX, completely clearing the SGR leads to PPC hangup	 * upon PCIe configuration access. The PCIe memory regions	 * need to be guarded!	 */	lis	r3,0x0000	ori	r3,r3,0x7FFC	mtspr	sgr,r3#endif	mtspr	dcwr,r4	mtesr	r4			/* clear Exception Syndrome Reg */	mttcr	r4			/* clear Timer Control Reg */	mtxer	r4			/* clear Fixed-Point Exception Reg */	mtevpr	r4			/* clear Exception Vector Prefix Reg */	addi	r4,r0,(0xFFFF-0x10000)		/* set r4 to 0xFFFFFFFF (status in the */					/* dbsr is cleared by setting bits to 1) */	mtdbsr	r4			/* clear/reset the dbsr */	/* Invalidate the i- and d-caches. */	bl	invalidate_icache	bl	invalidate_dcache	/* Set-up icache cacheability. */	lis	r4, CFG_ICACHE_SACR_VALUE@h	ori	r4, r4, CFG_ICACHE_SACR_VALUE@l	mticcr	r4	isync	/* Set-up dcache cacheability. */	lis	r4, CFG_DCACHE_SACR_VALUE@h	ori	r4, r4, CFG_DCACHE_SACR_VALUE@l	mtdccr	r4#if !(defined(CFG_EBC_PB0AP) && defined(CFG_EBC_PB0CR))	/*----------------------------------------------------------------------- */	/* Tune the speed and size for flash CS0  */	/*----------------------------------------------------------------------- */	bl	ext_bus_cntlr_init#endif#if !(defined(CFG_INIT_DCACHE_CS) || defined(CFG_TEMP_STACK_OCM))	/*	 * For boards that don't have OCM and can't use the data cache	 * for their primordial stack, setup stack here directly after the	 * SDRAM is initialized in ext_bus_cntlr_init.	 */	lis	r1, CFG_INIT_RAM_ADDR@h	ori	r1,r1,CFG_INIT_SP_OFFSET /* set up the stack in SDRAM */	li	r0, 0			/* Make room for stack frame header and */	stwu	r0, -4(r1)		/* clear final stack frame so that	*/	stwu	r0, -4(r1)		/* stack backtraces terminate cleanly	*/	/*	 * Set up a dummy frame to store reset vector as return address.	 * this causes stack underflow to reset board.	 */	stwu	r1, -8(r1)		/* Save back chain and move SP */	lis	r0, RESET_VECTOR@h	/* Address of reset vector */	ori	r0, r0, RESET_VECTOR@l	stwu	r1, -8(r1)		/* Save back chain and move SP */	stw	r0, +12(r1)		/* Save return addr (underflow vect) */#endif /* !(CFG_INIT_DCACHE_CS	|| !CFG_TEM_STACK_OCM) */#if defined(CONFIG_405EP)	/*----------------------------------------------------------------------- */	/* DMA Status, clear to come up clean */	/*----------------------------------------------------------------------- */	addis	r3,r0, 0xFFFF		/* Clear all existing DMA status */	ori	r3,r3, 0xFFFF	mtdcr	dmasr, r3	bl	ppc405ep_init		/* do ppc405ep specific init */#endif /* CONFIG_405EP */#if defined(CFG_OCM_DATA_ADDR) && defined(CFG_OCM_DATA_SIZE)#if defined(CONFIG_405EZ)	/********************************************************************	 * Setup OCM - On Chip Memory - PPC405EZ uses OCM Controller V2	 *******************************************************************/	/*	 * We can map the OCM on the PLB3, so map it at	 * CFG_OCM_DATA_ADDR + 0x8000	 */	lis	r3,CFG_OCM_DATA_ADDR@h	/* OCM location */	ori	r3,r3,CFG_OCM_DATA_ADDR@l	ori	r3,r3,0x0270		/* 16K for Bank 1, R/W/Enable */	mtdcr	ocmplb3cr1,r3		/* Set PLB Access */	ori	r3,r3,0x4000		/* Add 0x4000 for bank 2 */	mtdcr	ocmplb3cr2,r3		/* Set PLB Access */	isync	lis	r3,CFG_OCM_DATA_ADDR@h	/* OCM location */	ori	r3,r3,CFG_OCM_DATA_ADDR@l	ori	r3,r3,0x0270		/* 16K for Bank 1, R/W/Enable */	mtdcr	ocmdscr1, r3		/* Set Data Side */	mtdcr	ocmiscr1, r3		/* Set Instruction Side */	ori	r3,r3,0x4000		/* Add 0x4000 for bank 2 */	mtdcr	ocmdscr2, r3		/* Set Data Side */	mtdcr	ocmiscr2, r3		/* Set Instruction Side */	addis	r3,0,0x0800		/* OCM Data Parity Disable - 1 Wait State */	mtdcr	ocmdsisdpc,r3	isync#else /* CONFIG_405EZ */	/********************************************************************	 * Setup OCM - On Chip Memory	 *******************************************************************/	/* Setup OCM */	lis	r0, 0x7FFF	ori	r0, r0, 0xFFFF	mfdcr	r3, ocmiscntl		/* get instr-side IRAM config */	mfdcr	r4, ocmdscntl		/* get data-side IRAM config */	and	r3, r3, r0		/* disable data-side IRAM */	and	r4, r4, r0		/* disable data-side IRAM */	mtdcr	ocmiscntl, r3		/* set instr-side IRAM config */	mtdcr	ocmdscntl, r4		/* set data-side IRAM config */	isync	lis	r3,CFG_OCM_DATA_ADDR@h	/* OCM location */	ori	r3,r3,CFG_OCM_DATA_ADDR@l	mtdcr	ocmdsarc, r3	addis	r4, 0, 0xC000		/* OCM data area enabled */	mtdcr	ocmdscntl, r4	isync#endif /* CONFIG_405EZ */#endif	/*----------------------------------------------------------------------- */	/* Setup temporary stack in DCACHE or OCM if needed for SDRAM SPD. */	/*----------------------------------------------------------------------- */#ifdef CFG_INIT_DCACHE_CS	li	r4, PBxAP	mtdcr	ebccfga, r4	lis	r4, CFG_INIT_DCACHE_PBxAR@h	ori	r4, r4, CFG_INIT_DCACHE_PBxAR@l	mtdcr	ebccfgd, r4	addi	r4, 0, PBxCR	mtdcr	ebccfga, r4	lis	r4, CFG_INIT_DCACHE_PBxCR@h	ori	r4, r4, CFG_INIT_DCACHE_PBxCR@l	mtdcr	ebccfgd, r4	/*	 * Enable the data cache for the 128MB storage access control region	 * at CFG_INIT_RAM_ADDR.	 */	mfdccr	r4	oris	r4, r4, PPC_128MB_SACR_VALUE(CFG_INIT_RAM_ADDR)@h	ori	r4, r4, PPC_128MB_SACR_VALUE(CFG_INIT_RAM_ADDR)@l	mtdccr	r4	/*	 * Preallocate data cache lines to be used to avoid a subsequent	 * cache miss and an ensuing machine check exception when exceptions	 * are enabled.	 */	li	r0, 0	lis	r3, CFG_INIT_RAM_ADDR@h	ori	r3, r3, CFG_INIT_RAM_ADDR@l	lis	r4, CFG_INIT_RAM_END@h	ori	r4, r4, CFG_INIT_RAM_END@l	/*	 * Convert the size, in bytes, to the number of cache lines/blocks	 * to preallocate.	 */	clrlwi. r5, r4, (32 - L1_CACHE_SHIFT)	srwi	r5, r4, L1_CACHE_SHIFT	beq	..load_counter	addi	r5, r5, 0x0001..load_counter:	mtctr	r5	/* Preallocate the computed number of cache blocks. */..alloc_dcache_block:	dcba	r0, r3	addi	r3, r3, L1_CACHE_BYTES	bdnz	..alloc_dcache_block	sync	/*	 * Load the initial stack pointer and data area and convert the size,	 * in bytes, to the number of words to initialize to a known value.	 */

⌨️ 快捷键说明

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