romInit.s
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:21k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* romInit.s - vxWorks ixdp425 initialization module */
  2. /* Copyright 2002 Wind River Systems, Inc. */
  3. /*
  4. modification history
  5. --------------------
  6. 01d,24sep02,jb3  Going for the Csr_Gold
  7. 01c,24sep02,jb  Changing memory timing
  8. 01b,12jun02,jb  Continuing restructure
  9. 01a,05jun02,jb  initial version...
  10. */
  11. #define _ASMLANGUAGE
  12. #include "vxWorks.h"
  13. #include "arch/arm/arm.h"
  14. #include "arch/arm/mmuArmLib.h"
  15. #include "ixp425.h"
  16. #include "ixdp425.h"
  17. /* macros fail in diab #include "debugutils.h" */
  18. #include "sysLib.h"
  19. #include "config.h"
  20. .data
  21.         .globl  FUNC(copyright_wind_river)
  22.         .long   FUNC(copyright_wind_river)
  23. /*
  24. DESCRIPTION
  25. This module contains the entry code for VxWorks images that start
  26. running from ROM, such as 'bootrom' and 'vxWorks_rom'.
  27. The entry point, romInit(), is the first code executed on power-up.
  28. It performs the minimal setup needed to call the
  29. generic C routine romStart() with parameter BOOT_COLD.
  30. The routine romInit() masks interrupts in the processor, initialises
  31. the MMU, sets the initial stack pointer (to STACK_ADRS which is defined
  32. in configAll.h) and initialises system hardware including configuring
  33. the DRAM controller. Other hardware and device initialisation is
  34. performed later in the sysHwInit routine in sysLib.c.
  35. The IXP425 device has a mechansim to "swap" the Expansion bus CS0 and SDRAM
  36. decode spaces. i.e RAM can be moved to zero (where the vectors live)
  37. without resorting to the use of the MMU.
  38. The routine sysToMonitor() jumps to a location after the beginning of
  39. romInit, (defined by ROM_WARM_ADRS) to perform a "warm boot". This
  40. entry point allows a parameter to be passed to romStart().
  41. It first has to disable the MMU, though, as romInit will disable it
  42. during initialization.
  43. The routines in this module don't use the "C" frame pointer %r11@ ! or
  44. establish a stack frame.
  45. SEE ALSO:
  46. .I "ARM Architecture Reference Manual,"
  47. .I "IXP425 Data Manual,"
  48. */
  49. #define INIT_SDRAM  (1)
  50. #define XSCALE_WB_COAL_ENABLE (1)
  51. /* debug routines */
  52. #define IMMED1 #1
  53. #define DELAY(cycles, reg0)
  54. ldr reg0, = cycles ;
  55. subs reg0, reg0, IMMED1 ;
  56. subne pc, pc, IMMED12 ;
  57. #define DEBUG_UART  (1)  /* Enable Debug uart output */
  58. #define UART_REG_SPREAD (2)
  59. #define UART_DMABodgeDelay              10
  60. #define UARTLCR_DivisorLatchAccess (1<<7)
  61. #define UART_LineControl           (0x03  << UART_REG_SPREAD)
  62. #define BaudRateDivisor_115200     1
  63. #define BaudRateDivisor_9600       0x60
  64. #define UART_DivisorLatchLSB       ( 0x00 << UART_REG_SPREAD )
  65. #define UART_DivisorLatchMSB       ( 0x01 << UART_REG_SPREAD )
  66. #define UARTLCR_CharLength8        (3<<0)
  67. #define UARTLCR_StopBits1          (0<<2)
  68. #define UART_InterruptEnable       0x01
  69. #define UARTFCR_Enable            (1<<0)
  70. #define UART_FIFOControl           (0x02 << UART_REG_SPREAD )
  71. #define UARTFCR_RXReset            (1<<1)
  72. #define ARTFCR_TXReset             (1<<2)
  73. #define UARTFCR_Mode0RXRDYTXRDY    (0<<3)
  74. #define UARTFCR_RXTrigger1         (0<<6)
  75. #define UARTMCR_DTRActive          (1<<0)
  76. #define UART_ModemControl          (4 << UART_REG_SPREAD )
  77. #define UART_LineStatus            (5 << UART_REG_SPREAD )
  78. #define UART_Transmit              (0  << UART_REG_SPREAD )
  79. #define UARTLSR_TXHoldingEmpty     (1<<5)
  80. .macro LED value
  81. /*enable gpio 4 5 6*/
  82.          ldr r0, =0x3f87
  83.          ldr r1, =IXP425_GPIO_GPOER
  84.          str r0, [r1]
  85. /*determine which gpio should be led*/
  86.         ldrh r0, =value
  87.         mov r0, r0, LSL#4
  88.         ldr r1, =0xffff
  89.         eor r0, r0, r1
  90.         ldr r1, =IXP425_GPIO_GPOUTR
  91.         str r0, [r1]
  92. .endm
  93. /* reset the kendin switch chip */
  94. .macro RESET_NET
  95. ldr r0, =0x0
  96. ldr r1, =IXP425_GPIO_GPOUTR
  97. str r0, [r1]
  98. nop
  99. nop
  100. nop
  101. nop
  102. nop
  103. nop
  104. nop
  105. nop
  106. nop
  107. nop
  108. nop
  109. nop
  110. nop
  111. nop
  112. nop
  113. ldr r0, =0x8
  114. str r0, [r1]
  115. .endm
  116.         .data
  117.         .align 4
  118.         .globl  VAR(sdata)
  119. VAR_LABEL(sdata) .asciz  "start of data seg"
  120.         .text
  121.         .align 4
  122.         /* externals */
  123.         .extern FUNC(romStart)
  124.         .extern FUNC(sysPhysMemSize)
  125.         /* globals */
  126.         .globl  FUNC(romInit)
  127.         .globl  _romInit
  128. .globl _vectorTable
  129. .globl FUNC(sysRomVecUndefInstuc)
  130. .globl FUNC(sysRomVecSoftwareInt)
  131. .globl FUNC(sysRomVecPrefetchAbort)
  132. .globl FUNC(sysRomVecDataAbort)
  133. .globl FUNC(sysRomVecUnknow)
  134. .globl FUNC(sysRomVecIRQ)
  135. .globl FUNC(sysRomVecFIQ)
  136. .globl FUNC(sysRomVecDefault)
  137. .globl  FUNC(UARTVString)
  138. .globl  vxWorks_boot
  139. .globl  FUNC(binArrayStart)
  140. .globl  FUNC(binArrayEnd)
  141. _start:
  142. /*******************************************************************************
  143. *
  144. * vectorTable - vector jump tabel
  145. *
  146. */
  147. /* All vectors destroys r0, r1, and r2 */
  148. /* Register Usage:
  149. * r0 contains the vector number but used for temp use
  150. * r1 should contain the vector number in 7seg format
  151. * r2 Used for temp use
  152. */
  153. _vectorTable:
  154.         ldr     pc, =0x1000
  155.         B       FUNC(sysRomVecUndefInstuc)
  156.         B       FUNC(sysRomVecSoftwareInt)
  157.         B       FUNC(sysRomVecPrefetchAbort)
  158.         B       FUNC(sysRomVecDataAbort)
  159.         B       FUNC(sysRomVecUnknow)
  160.         B       FUNC(sysRomVecIRQ)
  161.         B       FUNC(sysRomVecFIQ)
  162. _ARM_FUNCTION(sysRomVecUndefInstuc)
  163.         ldr     pc, UNDEFINSInt
  164. _ARM_FUNCTION(sysRomVecSoftwareInt)
  165.         ldr     pc, SOFTWAREINTIsr
  166. _ARM_FUNCTION(sysRomVecPrefetchAbort)
  167.         ldr     pc, PREFETCHABORTIsr
  168. _ARM_FUNCTION(sysRomVecDataAbort)
  169.         ldr     pc, VECDATAABORTIsr
  170. _ARM_FUNCTION(sysRomVecUnknow)
  171.         ldr     pc, UNKNOWVECIsr
  172. _ARM_FUNCTION(sysRomVecIRQ)
  173.         ldr     pc, IRQRAMIsr
  174. _ARM_FUNCTION(sysRomVecFIQ)
  175.         ldr     pc, FIQRAMIsr
  176. .balign 0x100
  177. UNDEFINSInt:
  178. .long FUNC(sysRomVecUndefInstuc)
  179. SOFTWAREINTIsr:
  180. .long FUNC(sysRomVecSoftwareInt)
  181. PREFETCHABORTIsr:
  182. .long FUNC(sysRomVecPrefetchAbort)
  183. VECDATAABORTIsr:
  184. .long FUNC(sysRomVecDataAbort)
  185. UNKNOWVECIsr:
  186. .long FUNC(sysRomVecUnknow)
  187. IRQRAMIsr:
  188. .long FUNC(sysRomVecIRQ)
  189. FIQRAMIsr:
  190. .long FUNC(sysRomVecFIQ)
  191. .balign 0x1000
  192. /* any data added here should reflect in ROM_TEXT_BASE in Makefile as well as in config.h */
  193. /*******************************************************************************
  194. *
  195. * romInit - entry point for VxWorks in ROM
  196. *
  197. * This is the start of the ROM code.  The CPU will vector here upon reset.
  198. *
  199. * romInit
  200. *     (
  201. *     int startType     /@ only used by 2nd entry point @/
  202. *     )
  203. *
  204. * INTERNAL
  205. * sysToMonitor examines the ROM for the first instruction and the string
  206. * "Copy" in the third word so if this changes, sysToMonitor must be updated.
  207. *
  208. * Register r8 holds startType until jump to the code that starts the whole
  209. * vxWorks boot process
  210. *
  211. */
  212. _ARM_FUNCTION(romInit)
  213. _romInit:
  214. cold:
  215.         MOV     r0, #BOOT_COLD   /* fall through to warm boot entry */
  216.         
  217. warm:
  218.         B       bootStart
  219.         /* copyright notice appears at beginning of ROM (in TEXT segment) */
  220.         .ascii  "Copyright 2000 Wind River Systems, Inc. "
  221.         .align 4
  222. bootStart:
  223.         MOV     r8, r0           /* store off startType */
  224.         /* disable interrupts in CPU and switch to SVC32 mode */
  225.         MRS     r1, cpsr
  226.         BIC     r1, r1, #MASK_MODE
  227.         ORR     r1, r1, #MODE_SVC32 | I_BIT | F_BIT
  228.         MSR     cpsr, r1
  229.         /*
  230.          * CPU INTERRUPTS DISABLED
  231.          *
  232.          * Set processor and MMU to known state as follows (we may have not
  233.          * been entered from a reset):
  234.          *
  235.          * MMU Control Register layout.
  236.          *
  237.          * bit
  238.          *  0 M 0 MMU disabled
  239.          *  1 A 0 Address alignment fault disabled, initially
  240.          *  2 C 0 Data cache disabled
  241.          *  3 W 0 Write Buffer disabled
  242.          *  4 P 1 Should Be One (PROG32 on earlier CPUs)
  243.          *  5 D 1 Should Be One (DATA32 on earlier CPUs)
  244.          *  6 L 1 Should Be One (Late abort on earlier CPUs)
  245.          *  7 B 1 Little-endian  ( Turn no Big Endian mode )
  246.          *  8 S 0 System bit to zero } Modifies MMU protections, not really
  247.          *  9 R 0 ROM bit to one     } relevant until MMU switched on later.
  248.          * 10 F 0 Should Be Zero
  249.          * 11 Z 0 Should Be Zero (Branch prediction control on 810)
  250.          * 12 I 0 Instruction cache disabled
  251.          *
  252.          * Setup MMU Control Register
  253.          */
  254.         /* MOV     r1, #MMU_INIT_VALUE  */
  255.         MOV     r1, #0x80
  256.         MCR     CP_MMU, 0, r1, c1, c0, 0        /* Write to MMU CR */
  257. NOP
  258. NOP
  259. NOP
  260. NOP
  261. NOP
  262.         LED 0x1
  263.         
  264.         RESET_NET
  265.         /*
  266.          * MMU is now off => addresses are physical addresses, no protection.
  267.          *
  268.          * If MMU was on before this, then we'd better hope it was set up
  269.          * for flat translation (at least of this code) or there will
  270.          * be problems. The next three instructions will still be
  271.          * fetched "translated".
  272.          *
  273.          * Set Process ID Register to zero, this effectively disables
  274.          * the process ID remapping feature.
  275.          */
  276.         MOV     r1, #0
  277.         MCR     CP_MMU, 0, r1, c13, c0, 0
  278.         MRC     CP_MMU, 0, r7, c0, c0, 0
  279.         AND     r7,r7,#0xF
  280. /*** Disable Write Buffer Coalescing ***/
  281. mcr p15, 0, r0, c7, c10, 4  /* Drain write/fill buffers */
  282. CPWAIT(r0) /* wait for the write to happen */
  283. CPWAIT(r0) /* wait for the write to happen */
  284. mrc p15, 0, r0, c1, c0, 1   /* Read Auxiliary Control Reg */
  285. orr r0, r0, #0x00000001     /* Disable Coalescing */
  286. mcr p15, 0, r0, c1, c0, 1   /* Write Auxiliary Control Reg */
  287. CPWAIT(r0) /* wait for the write to happen */
  288. NOP
  289. NOP
  290. /* fall through to warm boot entry */
  291.         cmp     r8, #BOOT_COLD
  292.         bne     warm_start
  293. /*establish UART for debug... */
  294.         bl              UARTStart
  295. #if DEBUG_UART
  296. ldr r0 ,_debugStr1
  297. bl FUNC(UARTVString)
  298. #endif
  299. #ifdef INIT_SDRAM
  300. /*read the GPIO 8 9 to identity size of sdram*/
  301.         ldr     r1,     =IXP425_GPIO_GPINR
  302.         ldr     r1,     [r1]
  303.         mov    r1,     r1,    LSR#8
  304.         and     r1,     r1,    #3
  305.         /* set sdram config address */
  306.         ldr  r9, L$LIXP425_SDRAM_CONFIG
  307.         
  308.         cmp     r1,     #0x0
  309.         bne     1f
  310.         /* 64M sdram */        
  311.         mov r10, #SZ_64M
  312.         ldr  r2, L$LSDRAM_CONFIG_64MEG
  313.         b       4f
  314.         
  315.  1:
  316.         cmp     r1,     #0x1
  317.         bne     2f
  318.         /* 256M sdram*/
  319.         mov r10, #SZ_256M
  320.         ldr  r2, L$LSDRAM_CONFIG_256MEG
  321.         str     r2, [r9, #0]
  322.         b       4f
  323.         
  324.  2:
  325.         cmp    r1,     #0x2
  326.         bne     3f
  327.         /* 128M sdram */
  328.         mov r10, #SZ_128M
  329.         ldr  r2, L$LSDRAM_CONFIG_128MEG
  330.         str     r2, [r9, #0]
  331.         b       4f
  332.         
  333. 3:
  334. b       3b
  335. 4:
  336.         /* config sdram size ok */
  337. LED 0x2
  338. init_dram:
  339. /* Disable refresh Cycles */
  340. ldr r9,L$LIXP425_SDRAM_REFRESH
  341. ldr r0,L$LIXP425_SDRAM_REFRESH_DISABLE
  342. str r0, [r9, #0] /* Disable Refresh Cycle */
  343. DELAY(0x4000, r0)
  344. /* Issue a NOP Command to all SDRAM devices */
  345. ldr r9, L$LIXP425_SDRAM_INSTRUCTION
  346. ldr r0, L$LIXP425_SDRAM_IR_NOP_CMD
  347. str r0, [r9, #0] /* Issue NOP cmd to SDRAM */
  348. DELAY(0x4000, r0)
  349. ldr r9,L$LIXP425_SDRAM_REFRESH
  350. ldr r0,L$LIXDP425_SDRAM_CONFIG_REFRESH_CNT
  351. str r0, [r9, #0] /* Set refresh value  */
  352. DELAY(0x4000, r0)
  353. /* Send a PrechargeAll Command to all SDRAM devices */
  354. ldr r9,L$LIXP425_SDRAM_INSTRUCTION
  355. ldr r0,L$LIXP425_SDRAM_IR_PRECHARGE_ALL_CMD
  356. str r0, [r9, #0] /* Precharge all */
  357. DELAY(0x4000, r0)
  358. /* Send 8 AutoRefresh Command. There should Trc cycles between every AutoRefresh */
  359. /* Trc = 70ns for devices used here,  */
  360. ldr r9,L$LIXP425_SDRAM_INSTRUCTION
  361. ldr r0,L$LIXP425_SDRAM_IR_AUTOREFRESH_CMD
  362. str r0, [r9, #0] /* Auto Refresh #1 */
  363. DELAY(0x100, r0)
  364. str r0, [r9, #0] /* Auto Refresh #2 */
  365. DELAY(0x100, r0)
  366. str r0, [r9, #0] /* Auto Refresh #3 */
  367. DELAY(0x100, r0)
  368. str r0, [r9, #0] /* Auto Refresh #4 */
  369. DELAY(0x100, r0)
  370. str r0, [r9, #0] /* Auto Refresh #5 */
  371. DELAY(0x100, r0)
  372. str r0, [r9, #0] /* Auto Refresh #6 */
  373. DELAY(0x100, r0)
  374. str r0, [r9, #0] /* Auto Refresh #7 */
  375. DELAY(0x100, r0)
  376. str r0, [r9, #0] /* Auto Refresh #8 */
  377. DELAY(0x100, r0)
  378. /* Send Mode Reg Set Cmd with CAS Latency 3 */
  379. ldr r9,L$LIXP425_SDRAM_INSTRUCTION
  380. ldr r0,L$LIXP425_SDRAM_IR_MODE_SET_CAS3_CMD
  381. str r0, [r9, #0] /* Send Mode Select Command */
  382. DELAY(0x4000, r0)
  383. ldr r9,L$LIXP425_SDRAM_INSTRUCTION
  384. ldr r0,L$LIXP425_SDRAM_IR_NORMAL_OPERATION_CMD
  385. str r0, [r9, #0x00000000]         /* Issue aNormal Operation command */
  386. #endif /* INIT_SDRAM */
  387. #if DEBUG_UART
  388. ldr r0 ,_debugStr6
  389. bl FUNC(UARTVString)
  390. #endif
  391. /*************** SDRAM Config Complete *******************************************/
  392. /* DebugOutVal INFO_CODE_9 */
  393. LED 0x3
  394. /* Enable Coprocessors access */
  395.         ldr             r0, =0x001
  396.         mcr             p15, 0, r0, c15, c1, 0
  397.         mcr             p15, 0, r0, c7, c10, 4  /* Drain write/fill buffers */
  398. CPWAIT(r0) /* wait for the write to happen */
  399. /* Invalidate I-Cache, D-Cache, and BTB */
  400.         mcr             p15, 0, r0, c7, c7, 0
  401. CPWAIT(r0) /* Wait */
  402. /*
  403.  * Set the CS0 setting for Flash to optimum timings.
  404.  */
  405. ldr r0,L$LIXP425_EXP_CS0_REG
  406. ldr r1,L$LIXDP425_FLASH_CS_DEFAULT
  407. str r1,[r0]
  408. LED 0x4
  409. /*** Enable Write Buffer Coalescing ***/
  410. #if XSCALE_WB_COAL_ENABLE
  411. mcr p15, 0, r0, c7, c10, 4  /* Drain write/fill buffers */
  412. CPWAIT(r0) /* wait for the write to happen */
  413. CPWAIT(r0) /* wait for the write to happen */
  414. mrc p15, 0, r0, c1, c0, 1   /* Read Auxiliary Control Reg */
  415. and r0, r0, #0xfffffffe     /* Enable Coalescing */
  416. mcr p15, 0, r0, c1, c0, 1   /* Write Auxiliary Control Reg */
  417. CPWAIT(r0) /* wait for the write to happen */
  418. NOP
  419. NOP
  420. #endif
  421. warm_start:
  422. /* Disable Interrupts */
  423.         MRS     r1, cpsr                /* get current status */
  424.         ORR     r1, r1, #I_BIT | F_BIT  /* disable IRQ and FIQ */
  425.         MSR     cpsr, r1
  426. /* Interrupts Disabled */
  427.         ldr     r0, =IXP425_ICMR  /* Zero-out Interrupt Mask */
  428.         mov     r2, #0x0
  429.         str     r2, [r0]
  430. /* 3: Jump to here + New FLash Location */
  431. /* We could jump upto location in Flash,
  432.  * But we have already copied enough code to
  433.  * low ram to continue code execution from here
  434.  */
  435. ldr r0,=IXP425_EXPANSION_BUS_BASE2
  436.         orr r0,r0,pc
  437. mov pc,r0
  438. /* 4: Write to Expansion Bus controller to swap Flash & Ram */
  439. ldr r0,=IXP425_EXP_CNFG0
  440. ldr r1,[r0]
  441. and r1,r1,#0x7FFFFFFF
  442. str r1,[r0]
  443. /*
  444.  * End of switch , should now be running in Flash in its relocated position.
  445.  */
  446. /* Enable Coprocessors access */
  447.         ldr     r0, =0x001
  448.         mcr     p15, 0, r0, c15, c1, 0
  449.         mcr     p15, 0, r0, c7, c10, 4  /* Drain write/fill buffers */
  450. CPWAIT(r0) /* wait for the write to happen */
  451. #ifdef ROM_ENABLES_MMU
  452. /* Invalidate I-Cache, D-Cache, and BTB */
  453.         mcr     p15, 0, r0, c7, c7, 0
  454. CPWAIT(r0) /* Wait */
  455. /* If Enable Instruction Cache */
  456.         mrc     p15, 0, r0, c1, c0, 0   /* Read Control Register*/
  457.         orr     r0, r0, #0x1000         /* Set I-Cache bit */
  458.         mcr     p15, 0, r0, c1, c0, 0   /* Write Back Control Register */
  459. CPWAIT(r0) /* Wait */
  460. /* Set Translation Table Base */
  461.         ldr     r0, =MMU_TRANSLATION_BASE
  462.         mcr     p15, 0, r0, c2, c0, 0   /* Set Translation Table Base Register */
  463. /* Invalidate Instruction, Data TLBs */
  464.         mcr     p15, 0, r0, c8, c7, 0   /* Flush I & D TLBs*/
  465. CPWAIT(r0) /* Wait */
  466. /* Set Domain Access Control Register */
  467.         ldr     r0, =0xffffffff         /* Set All 16 domains to manager access */
  468.         mcr     p15, 0, r0, c3, c0, 0   /* Set Domain Permissions */
  469. /* Enable MMU */
  470.         mrc     p15, 0, r0, c1, c0, 0   /* Read Control Register */
  471.         orr     r0, r0, #0x00000001     /* Enable MMU */
  472.         mcr     p15, 0, r0, c1, c0, 0   /* Write Back the Control Register */
  473. CPWAIT(r0) /* Wait */
  474. /* Drain Write/Fill Buffers */
  475.         mcr     p15, 0, r0, c7, c10, 4  /* Drain */
  476. CPWAIT(r0) /* Wait */
  477. /* Enable Data Cache */
  478.         mrc     p15, 0, r0, c1, c0, 0   /* Read Control Reg */
  479.         orr     r0, r0, #0x00000004             /* Enable Data Cache */
  480.         mcr     p15, 0, r0, c1, c0, 0   /* Write Back */
  481. CPWAIT(r0) /* Wait */
  482. /* Enable Branch Target Buffer */
  483.         mrc     p15, 0, r0, c1, c0, 0   /* Read Control Reg */
  484.         orr     r0, r0, #0x00000800             /* Enable BTB */
  485.         mcr     p15, 0, r0, c1, c0, 0   /* Write Back the Control Reg */
  486. CPWAIT(r0) /* Wait */
  487. #endif /* ROM_ENABLES_MMU */
  488. /******************************************************************************/
  489. /******************************************************************************/
  490. /* DebugOutVal INFO_CODE_E */
  491.         LED 0x5
  492. vxWorks_boot:
  493. /*  Now jump to the code that starts the whole vxWorks boot process */
  494. mov r0, r8
  495. ldr sp, L$STACK_ADDR
  496. ldr pc, L$StrtInFlash
  497. /******************************************************************************/
  498. /******************************************************************************/
  499. /************************** UART Helpers ******************************************/
  500. _ARM_FUNCTION(UARTVString)
  501. /* Do nothing as byte reads from flash not allowed */
  502. mov         pc, lr
  503.         ldr             r10, =IXP425_UART1_BASE
  504. UARTNextChar:
  505.         ldrb            r1, [r0], #1
  506.         teq             r1, #0
  507.         beq             URATTxDone
  508.         /* UARTTextOut     r10, r1, r2 */
  509.         and             r1, r1, #0xff
  510. /* Modified, don't even check if there is room in the transfer fifi`o just jut it.. TODO : remove later, on real card */
  511. /*
  512.         ldr             r10, =IXP425_UART1_BASE
  513.         ldr             r2, [r10, #UART_LineStatus]
  514.         TST             r2. #UARTLSR_TXHoldingEmpty
  515.         BEQ             10b
  516. */
  517.         str             r1, [r10, #UART_Transmit] /* strb */
  518. /*Start-  Included to slow down writes to simultor : TODO: Remove later */
  519. DELAY(0x200, r3)
  520. /*End-  Included to slow down writes to simultor : TODO: Remove later */
  521.         B               UARTNextChar
  522. URATTxDone:
  523.         mov             r1, #13
  524.         /* UARTTx          r10, r1, r2 */
  525.         mov             r1, #10
  526.         str             r1, [r10, #UART_Transmit] /* strb */
  527.         /* UARTTx          r10, r1, r2 */
  528.         str             r1, [r10, #UART_Transmit] /* strb */
  529. mov         pc, lr
  530. /*
  531. Better don't use r0, r1, r2 and r10s
  532. Uses r0, r10
  533. */
  534. UARTStart:
  535. ldr         r10, =IXP425_UART1_BASE
  536. ldr         r0, =UART_DMABodgeDelay
  537. UARTDelay:
  538. subs         r0, r0, #1
  539. bne         UARTDelay
  540.     /* enable access to divisor registers */
  541. mov         r0, #UARTLCR_DivisorLatchAccess
  542. str         r0, [r10, #UART_LineControl] /* strb */
  543. ldr         r0, =UART_DMABodgeDelay
  544. UARTDelay1:
  545. subs         r0, r0, #1
  546. bne         UARTDelay1
  547.     /* select baud rate */
  548. /* 115200 Baud */
  549. /* ldr         r0, =BaudRateDivisor_115200   */
  550. /* strb         r0, [r10, #UART_DivisorLatchLSB] */
  551. /* mov         r0, r0, LSR #8   */
  552. /* strb         r0, [r10, #UART_DivisorLatchMSB] */
  553. ldr         r0, =BaudRateDivisor_9600
  554. str         r0, [r10, #UART_DivisorLatchLSB] /*strb  */
  555. mov         r0, r0, LSR #8
  556. str         r0, [r10, #UART_DivisorLatchMSB]  /* strb */
  557.     /* 8 data, 1 stop, no parity */
  558. mov         r0, #UARTLCR_CharLength8 | UARTLCR_StopBits1
  559.     /* also disable access to divisor regs */
  560. str         r0, [r10, #UART_LineControl] /* strb */
  561.     /* no irqs , but enable the UART on IXP425 */
  562. mov         r0, #0x40
  563. str         r0, [r10, #UART_InterruptEnable] /* strb */
  564. mov             r0, #UARTFCR_Enable
  565. str            r0, [r10, #UART_FIFOControl] /* strb */
  566. /* turn fifos on */
  567. mov             r0, #UARTFCR_RXReset | ARTFCR_TXReset | UARTFCR_Mode0RXRDYTXRDY | UARTFCR_RXTrigger1
  568. str            r0, [r10, #UART_FIFOControl] /* strb */
  569.     /* make DTR active, RTS inactive, stop other end */
  570. mov         r0, #UARTMCR_DTRActive
  571. str         r0, [r10, #UART_ModemControl] /* strb */
  572. mov         pc, lr
  573. _debugStr1: .asciz  "IXP425 Uart initialized"
  574. _debugStr2: .asciz  "IXP425 Memory Config 32 Mbytes"
  575. _debugStr3: .asciz  "IXP425 Memory Config 64 Mbytes"
  576. _debugStr4: .asciz  "IXP425 Memory Config 128 Mbytes"
  577. _debugStr5: .asciz  "IXP425 Memory Config  Error"
  578. _debugStr6: .asciz  "IXP425 Memory Config Complete"
  579. _debugStr7: .asciz  "IXP425 Memory Config 256 Mbytes"
  580. .align 4
  581. /* TODO: Resolve these addresses for real. */
  582. L$StrtInRam:    .long   FUNC(romStart) - FUNC(romInit)
  583. L$StrtInFlash: .long   ROM_TEXT_ADRS + FUNC(romStart) - FUNC(romInit)
  584. L$STACK_ADDR: .long STACK_ADRS
  585. L$LIXP425_EXP_CS0_REG: .long IXP425_EXP_CS0_REG
  586. L$LIXDP425_FLASH_CS_DEFAULT: .long IXDP425_FLASH_CS_DEFAULT
  587. /* SDRAM Literals */
  588. L$LIXP425_SDRAM_CONFIG_BASE: .long IXP425_SDRAM_CONFIG_BASE
  589. L$LSDRAM_CONFIG_32MEG: .long SDRAM_CONFIG_32MEG
  590. L$LSDRAM_CONFIG_64MEG: .long   SDRAM_CONFIG_64MEG
  591. L$LSDRAM_CONFIG_128MEG: .long SDRAM_CONFIG_128MEG
  592. L$LSDRAM_CONFIG_256MEG: .long SDRAM_CONFIG_256MEG
  593. L$LIXP425_SDRAM_CONFIG: .long   IXP425_SDRAM_CONFIG
  594. L$LIXP425_SDRAM_REFRESH:  .long  IXP425_SDRAM_REFRESH
  595. L$LIXP425_SDRAM_REFRESH_DISABLE: .long  IXP425_SDRAM_REFRESH_DISABLE
  596. L$LIXP425_SDRAM_INSTRUCTION: .long   IXP425_SDRAM_INSTRUCTION
  597. L$LIXP425_SDRAM_IR_NOP_CMD: .long   IXP425_SDRAM_IR_NOP_CMD
  598. L$LIXDP425_SDRAM_CONFIG_REFRESH_CNT: .long   IXDP425_SDRAM_CONFIG_REFRESH_CNT
  599. L$LIXP425_SDRAM_IR_PRECHARGE_ALL_CMD: .long   IXP425_SDRAM_IR_PRECHARGE_ALL_CMD
  600. L$LIXP425_SDRAM_IR_AUTOREFRESH_CMD: .long   IXP425_SDRAM_IR_AUTOREFRESH_CMD
  601. L$LIXP425_SDRAM_IR_MODE_SET_CAS3_CMD: .long IXP425_SDRAM_IR_MODE_SET_CAS3_CMD
  602. L$LIXP425_SDRAM_IR_NORMAL_OPERATION_CMD: .long   IXP425_SDRAM_IR_NORMAL_OPERATION_CMD
  603. /* DebugOutInitLiteral */
  604. L$CS2_REG: .long 0xc4000008
  605. L$CS2_VAL: .long 0xBFFF0002