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

📄 sbdreset_evb64120a.s

📁 microwindows移植到S3C44B0的源码
💻 S
📖 第 1 页 / 共 2 页
字号:
/* * Copyright 1997 Algorithmics Ltd *	All Rights Reserved *	 * gal9/sbdreset.sx -- low level board dependent routines */#ifdef EVB64120A#include <asm/asm.h>#include <asm/regdef.h>#include <asm/cacheops.h>#include <asm/current.h>#include <asm/offset.h>#include <asm/processor.h>#include <asm/regdef.h>#include <asm/cachectl.h>#include <asm/mipsregs.h>#include <asm/stackframe.h>#include <asm/cpu.h>#include "sbd.h"#include "gt64011.h"#include "ns16550.h"			#ifdef GALILEO_PORT // miniBios crack#define C0_CONFIG CP0_CONFIG#define C0_STATUS CP0_STATUS#define C0_TLBLO0 CP0_ENTRYLO0#define C0_TLBLO1 CP0_ENTRYLO1#define C0_PGMASK CP0_PAGEMASK#define C0_TLBHI CP0_ENTRYHI #define C0_INX CP0_INDEX#define NTLBENTRIES     48                #define CFG_IB CONF_IB#define CFG_DB CONF_DB#define CFG_C_NONCOHERENT CONF_CM_CACHABLE_NONCOHERENT#define C0_SR CP0_STATUS        #define SR_DE ST0_DE                #define SLEAF(x) LEAF(x)        #define SEND(x) END(x)        #define XLEAF(x) LEAF(x)        #define SBD_DISPLAY(a,b,c,d,e) ; #define K0BASE          0x80000000#define K0SIZE          0x20000000#define K1BASE          0xa0000000#define K1SIZE          0x20000000#define K2BASE          0xc0000000#define PHYS_TO_K0(pa)  ((pa)|K0BASE)#define PHYS_TO_K1(pa)  ((pa)|K1BASE)#define K0_TO_PHYS(va)  ((va)&(K0SIZE-1))#define K1_TO_PHYS(va)  ((va)&(K1SIZE-1))#define K0_TO_K1(va)    ((va)|K1SIZE)#define K1_TO_K0(va)    ((va)&~K1SIZE)#define PA_TO_KVA0(pa)  PHYS_TO_K0(pa)#define PA_TO_KVA1(pa)  PHYS_TO_K1(pa)#define KVA_TO_PA(pa)   K1_TO_PHYS(pa)#define KSEG0_BASE      K0BASE#define KSEG1_BASE      K1BASE#endif#define MB	0x100000				#define MemTypeNone		0x8000#define MemRasMask		0x0f00#define MemRasShift		8#define MemCasMask		0x000f#define MemCasShift 		0#define rasave	s0#define p64011	s1#define bank0	s2#define bank1	s3#define bank2	s4#define bank3	s5#define memtop	s6#define membase	s7	/*#if #endian(big)	*/#ifdef __MIPSEB__#define HTOLL(sr,tr) \	.set noat ; \	srl	AT,sr,24 ; \	srl	tr,sr,8 ; \	and	tr,0xff00 ; \	or	AT,tr ; \	and	tr,sr,0xff00 ; \	sll	tr,8 ; \	or	AT,tr ; \	sll	tr,sr,24 ; \	or	sr,AT,tr ; \	.set at#else#define HTOLL(sr,tr)#endif				#undef DBGSBD	#ifdef DBGSBD#define DBG(s) \	.rdata ; \88:	.asciiz	s ; \	.text ; \	la	a0, 88b ; \	jal	_dbgmsg	LEAF(_dbgmsg)	.set noat	li	AT,PHYS_TO_K1(NS16550_CHANB)waitrdy:	lbu	v1,LSR(AT)	.set noreorder;	nop; nop; nop; nop; nop; nop; nop; nop; .set reorder	and	v1,LSR_TXRDY	beqz	v1,waitrdy		lbu	v1,(a0)	addu	a0,1	beqz	v1,9f	sb	v1,DATA(AT)	.set noreorder;	nop; nop; nop; nop; nop; nop; nop; nop; .set reorder	b	waitrdy	9:	j	ra	.set atEND(_dbgmsg)LEAF(_dbghex)	li	a1,PHYS_TO_K1(NS16550_CHANB)	li	t0,81:	lbu	t1,LSR(a1)	.set noreorder;	nop; nop; nop; nop; nop; nop; nop; nop; .set reorder	and	t1,LSR_TXRDY	beqz	t1,1b		srl	t1,a0,28	addu	t1,'0'	ble	t1,'9',2f	addu	t1,'a'-'0'-102:	sb	t1,DATA(a1)	.set noreorder;	nop; nop; nop; nop; nop; nop; nop; nop; .set reorder	sll	a0,4	sub	t0,1	bnez	t0,1b			j	ra	.set atEND(_dbghex)		.rdatainitb_str:	.byte	9,0x40	/* Reset CH B */	.byte	1,0x00	/* Interrupt disabled */	.byte	3,0xc1	/* 8 bits/char rx enable */	.byte	4,0x44	/* x16 clk mode 1 stop bit */	.byte	5,0x6a	/* tx 8/bit RTS & tx enable */	.byte	9,0x0a	/* MIE Master int enab. and NV No Vector */	.byte	11,0x50	/* Select BR gen. out for both rx and ts */	.byte	0,0x10	.byte	0,0x10	.byte	14,0x01	/* enable baud rate gen. */	.byte	15,0x00	/* known state for reg 15 */		.byte	14,0x00	/* disable baud rate gen. */	.byte	12,0x0a /* 0x0a	= 9600 baud time const. - lower 8 bits */	.byte	13,0x00	/* 9600 buad time const. - upper 8 bits */	.byte	14,0x01	/* enable baud rate gen. */	.byte	0xff	.text	SLEAF(_dbginit)        /*        li	v0,PHYS_TO_K1(NS16550_CHANB)	la	a0,initb_str	or	a0,K1BASE1:	lbu	t0,0(a0)	beq	t0,0xff,1f	sb	t0,LSR(v0)	.set noreorder;	nop; nop; nop; nop; nop; nop; nop; nop; .set reorder	addu	a0,1	b	1b        */        jal     init_ns16550_chan_b # Debug channel	j	raSEND(_dbginit)		#else#define DBG(s)		#endif		LEAF(sbdreset)	move	rasave,ra	/* if launched by ITROM, leave Config alone */#ifndef ITBASE		/* set config register for 32b/32b cachelines, kseg0 cacheable */	mfc0	t1,C0_CONFIG	and	t1,~0x3f		# set bits 5..0 only	or	t1,CFG_IB | CFG_DB | CFG_C_NONCOHERENT	mtc0	t1,C0_CONFIG#endif	       /* Initialize stack pointer to 6MB address */                 li sp,0xa0600000                 /*	 * slight amount of kludgery here to stop RAM resident	 * program from overwriting itself...	 *///	li	v1,0x1fc00000		/* check return address is in ROM *///	and	v0,ra,v1//	bne	v0,v1,.noinit        /* table driven hardware register initialization */        la      a0, reginittab        or      a0, K1BASE              /* force to kseg1 */1:      lw      v0,0(a0)        lw      v1,4(a0)        addu    a0,8        beqz    v0,8f        sw      v1,0(v0)        b       1b8:#ifdef DBGSBD	jal     init_ns16550_chan_b   # was - _dbginit	DBG("sbdreset\r\n")#endif#define DEVICE_BANK0PARAMETERS                                                          0x45C#define DEVICE_BANK1PARAMETERS                                                          0x460#define DEVICE_BANK2PARAMETERS                                                          0x464#define DEVICE_BANK3PARAMETERS                                                          0x468#define DEVICE_BOOT_BANK_PARAMETERS                                                     0x46C#define GT_INTERNAL_REG_BASE 0xb4000000        li      p64011, PA_TO_KVA1(GT64011_BASE)                 li  v0,0xb400046c       /* Boot Device */        lw  t0,0(v0)        and t0,0x00003000       /* Keep the correct boot size */	or  t0,htoll(0x3847de70)	sw  t0,0(v0)                li  v0,0xb4000468       /* CS3 Device - 16 bit FLASH memory */        li  t0,htoll(0x3859e6e8)	sw  t0,0(v0)                                li  v0,0xb4000c84       /* PCI 1 timeout register */        li  t0,htoll(0xffff)	sw  t0,0(v0)                                li  v0,0xb4000c3c       /* Enable I/O response on PCI0 */        li  t0,htoll(0x7)	sw  t0,0(v0)        li  v0,0xb4000cbc       /* Enable I/O response on PCI1 */        li  t0,htoll(0x7)	sw  t0,0(v0)        /* GT-64120 Initialization */                li      p64011, PA_TO_KVA1(GT64011_BASE)	        /*********************************************************************/        /************************* SDRAM initializing ************************/        /******************************* START *******************************/                                                        /* SDRAM banks 0,1,2,3 parameters               */        li      t0,htoll(0x01908200)    /* - Standard Monitor: Interleave enabled       */        li      v0,0xb4000448           /* - Registered SDRAM (Bit 23)                  */        sw      t0,0(v0)                /* - Duplicate Dadr11,BankSel1 and Dadr12       */                                        /* - Cas latency: 2 Cycles                      */                                        /* - Flow Through enable: One sample            */                                        /* - SRAS - precharge time: 3 Cycles            */                                        /* - No ECC                                     */                                        /* - No ByPass                                  */                                        /* - Burst length: 8                            */                /* Detect whether we have a 16,64,128 or 256 Mbit SDRAM on DIMM0 */        /* Set bank0`s range to: 0 - 0x10000000 (256 MByte)     */_DIMM0:        li  v0,0xb4000008      	li  t0,htoll(0x0)	sw  t0,0(v0)                li  v0,0xb4000010      	li  t0,htoll(0x7f)	sw  t0,0(v0)                /* Close banks 2 and 3 */        li  v0,0xb4000018      	li  t0,htoll(0x7ff)	sw  t0,0(v0)        li  v0,0xb4000020      	li  t0,htoll(0x00)	sw  t0,0(v0)                /* Extend bank0 to 0x10000000 and Close bank1,2 and 3 */        DBG("Extend bank0 to 0x10000000 and Close bank1,2 and 3...\r\n")        li  v0,0xb4000400      	li  t0,htoll(0x0)	sw  t0,0(v0)        li  v0,0xb4000404      	li  t0,htoll(0xff)	sw  t0,0(v0)        li  v0,0xb4000408      	li  t0,htoll(0xff)	sw  t0,0(v0)           li  v0,0xb400040c      	li  t0,htoll(0x00)	sw  t0,0(v0)        li  v0,0xb4000410      	li  t0,htoll(0xff)	sw  t0,0(v0)           li  v0,0xb4000414      	li  t0,htoll(0x00)	sw  t0,0(v0)        li  v0,0xb4000418      	li  t0,htoll(0xff)	sw  t0,0(v0)           li  v0,0xb400041c      	li  t0,htoll(0x00)	sw  t0,0(v0)                /* Configure bank0 to 256 Mbit */        DBG("Configure bank0 to 256 Mbit...\r\n")        li  v0,0xb400044c      	li  t0,htoll(0x00004c69)        sw  t0,0(v0)                /* Config the SDRAM banks decode system */	li  v0,0xb400047c      	li  t0,htoll(2)	sw  t0,0(v0)         li  v0,0xb4000474        	li  t0,htoll(0x3)	sw  t0,0(v0)                li  v0,0xa0000000        li  t0,0        sw  t0,0(v0)                li  v0,0xb4000474        	li  t0,htoll(0x0)	sw  t0,0(v0)                      /* Write to address 0x2000000 and check if 0x00000000 is being written too */        DBG("Write to address 0x2000000 and check if 0x00000000 is being written too...\r\n")        li  v0,0xa0000000        li  t1,0xa0000010        li  t0,htoll(0x0)1:      sw  t0,0(v0)        addu v0,4        bne t1,v0,1b        /* The address should activate Dadr12 */        li  v0,0xa2000000      	li  t0,0x11111111        sw  t0,0(v0)        li  v0,0xa0000010        li  t1,0xa0000100        li  t0,0x222222222:      sw  t0,0(v0)        addu v0,4        bne t1,v0,2b        DBG("Check address 0x00000000 for duplications...\r\n")        li    t0,0xa0000000        li    v0,0x11111111        lw    t0,(t0)        bne   t0,v0,_256MBIT                /* Write to address 0x1000 and check if 0x00000000 is being written too */        DBG("Write to address 0x1000 and check if 0x00000000 is being written too...\r\n")        li  v0,0xa0000000        li  t1,0xa0000010        li  t0,htoll(0x0)1:      sw  t0,0(v0)        addu v0,4        bne t1,v0,1b        /* The address should activate bank select1*/        li  v0,0xa0001000      	li  t0,0x11111111        sw  t0,0(v0)        li  v0,0xa0000010        li  t1,0xa0000100        li  t0,0x222222222:      sw  t0,0(v0)        addu v0,4        bne t1,v0,2b        DBG("Check address 0x00000000 for duplications...\r\n")        li    t0,0xa0000000        li    v0,0x11111111        lw    t0,(t0)        beq   t0,v0,_16MBIT        /* Write to address 0x8000000 and check if 0x00000000 is being written too */        DBG("Write to address 0x8000000 and check if 0x00000000 is being written too...\r\n")        li  v0,0xa0000000        li  t1,0xa0000010        li  t0,htoll(0x0)1:      sw  t0,0(v0)        addu v0,4        bne t1,v0,1b        /* The address should activate Dadr9 which on the column cycle is in active with 64 Mbit           device */        li  v0,0xa8000000      	li  t0,0x11111111        sw  t0,0(v0)        li  v0,0xa0000010        li  t1,0xa0000100        li  t0,0x222222222:      sw  t0,0(v0)        addu v0,4        bne t1,v0,2b        DBG("Check address 0x00000000 for duplications...\r\n")        li    t0,0xa0000000        li    v0,0x11111111        lw    t0,(t0)        beq   t0,v0,_64MBIT        b     _128MBIT        _16MBIT:        DBG("16 Mbit SDRAM detected...\r\n")        /* In 16 Mbit SDRAM we must use 2 way bank interleaving!!! */        li  v0,0xb4000810      	li  t0,htoll(16)	sw  t0,0(v0)        li  t1,htoll(0x00000449)        b   _DIMM1_64MBIT:        DBG("64 Mbit SDRAM detected...\r\n")        /* In 64 Mbit SDRAM we must use 4 way bank interleaving!!! */        li  v0,0xb4000810      	li  t0,htoll(64)	sw  t0,0(v0)        li  t1,htoll(0x00000c69)        b   _DIMM1_128MBIT:        DBG("128 Mbit SDRAM detected...\r\n")        /* In 128 Mbit SDRAM we must use 4 way bank interleaving!!! */        li  v0,0xb4000810      	li  t0,htoll(128)	sw  t0,0(v0)        li  t1,htoll(0x00000c69)        b   _DIMM1_256MBIT:        DBG("256 Mbit SDRAM detected...\r\n")        /* In 256 Mbit SDRAM we must use 4 way bank interleaving!!! */        li  v0,0xb4000810      	li  t0,htoll(256)	sw  t0,0(v0)        li  t1,htoll(0x00004c69)        b   _DIMM1        _DIMM1:                li  v0,0xb400044c        sw  t1,0(v0)  # Bank0        sw  t1,4(v0)  # Bank1                           /* Detect whether we have a 16,64,128 or 256 Mbit SDRAM on DIMM1 */        /* Close banks 0 and 1 */        li  v0,0xb4000008      	li  t0,htoll(0xff)	sw  t0,0(v0)                li  v0,0xb4000010      	li  t0,htoll(0x0)	sw  t0,0(v0)                /* Set bank2`s range to: 0 - 0x10000000 (256 MByte)     */        li  v0,0xb4000018      	li  t0,htoll(0x0)	sw  t0,0(v0)        li  v0,0xb4000020      	li  t0,htoll(0x7f)	sw  t0,0(v0)                /* Extend bank2 to 0x10000000 and Close bank0,1 and 3 */        DBG("Extend bank2 to 0x10000000 and Close banks 0,1 and 3...\r\n")        li  v0,0xb4000400      	li  t0,htoll(0xff)	sw  t0,0(v0)        li  v0,0xb4000404      	li  t0,htoll(0x00)	sw  t0,0(v0)        li  v0,0xb4000408      	li  t0,htoll(0xff)	sw  t0,0(v0)           li  v0,0xb400040c      	li  t0,htoll(0x00)	sw  t0,0(v0)        li  v0,0xb4000410      	li  t0,htoll(0x00)	sw  t0,0(v0)           li  v0,0xb4000414      	li  t0,htoll(0xff)	sw  t0,0(v0)        li  v0,0xb4000418      	li  t0,htoll(0xff)

⌨️ 快捷键说明

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