Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1300179
  • 博文数量: 548
  • 博客积分: 7597
  • 博客等级: 少将
  • 技术积分: 4224
  • 用 户 组: 普通用户
  • 注册时间: 2010-12-15 13:21
个人简介

嵌入式软件工程师&&太极拳

文章分类

全部博文(548)

文章存档

2014年(10)

2013年(76)

2012年(175)

2011年(287)

分类:

2012-04-13 16:45:25


点击(此处)折叠或打开

  1. ############################################################
  2. # MODULE: Makefile
  3. #
  4. # PURPOSE:
  5. # This file is used to compiler the basic initialization.
  6. #
  7. # COPYRIGHT (C) 2000-2001, CoreTek Systems Inc.
  8. # ALL RIGHTS RESERVED
  9. ############################################################
  10. # AUTHOR(S): Kernel_Group
  11. #
  12. # DATE CREATED: 2001/03/29
  13. #
  14. # MODIFICATIONS:
  15. # Date userName Description
  16. #
  17. ############################################################
  18. CC=dcore-gcc
  19. AS=dcore-as
  20. LD=dcore-ld
  21. CFLAGS=-c -Wall -I. -Wa,-EL
  22. ASFLAGS=-I. -EL
  23. LDFLAGS=-oformat elf32-littlearm -format elf32-littlearm -r
  24. all:crt0.o
  25. rm -rf crt1.o vectors.o
  26. crt0.o:crt1.o vectors.o
  27. ${LD} ${LDFLAGS} -o crt0.o crt1.o vectors.o
  28. crt1.o: crt0.S
  29. ${AS} ${ASFLAGS} -o crt1.o crt0.S
  30. vectors.o: vectors.S
  31. ${AS} ${ASFLAGS} -o vectors.o vectors.S
  32. clean:
  33. rm -rf *.o

crt0.s

点击(此处)折叠或打开

  1. @ Some standard definitions...
  2. .equ Mode_USR, 0x10
  3. .equ Mode_FIQ, 0x11
  4. .equ Mode_IRQ, 0x12
  5. .equ Mode_SVC, 0x13
  6. .equ Mode_ABT, 0x17
  7. .equ Mode_ABORT, 0x17
  8. .equ Mode_UNDEF, 0x1B
  9. .equ Mode_SYS, 0x1F @ only available on ARM Arch. v4
  10. .equ I_Bit, 0x80
  11. .equ F_Bit, 0x40
  12. .extern _bss_start,_bss_end /*It's defined at IDE development evenment*/
  13. .extern _lmain
  14. .globl _start
  15. /*
  16. * EntryPoint code
  17. */
  18. _start:
  19. /*
  20. * set the cpu to SVC32 mode
  21. */
  22. mrs r0,cpsr
  23. bic r0,r0,#0x1f
  24. orr r0,r0,#0xd3
  25. msr cpsr,r0
  26. bl cpu_init_crit /*跳到初始化CPU及重映射内存部份*/
  27. /*
  28. *我认为,重定位代码已经不必要了,在映射内存之时应该搞定
  29. *至此,假设内存映射已经按照表中设置
  30. */
  31. /* 设置系统堆栈及用户栈 */
  32. @ initialize IRQ, FIQ interrupt stack
  33. mov r0, #Mode_IRQ | I_Bit | F_Bit @ No interrupts
  34. msr cpsr, r0
  35. ldr sp, = _irq_stack_top
  36. mov r0, #Mode_FIQ | I_Bit | F_Bit @ No interrupts
  37. msr cpsr, r0
  38. ldr sp, = _fiq_stack_top
  39. @ build the stack
  40. mov r0, #Mode_SYS | I_Bit | F_Bit @ No interrupts
  41. msr cpsr, r0
  42. ldr sp,=_stack_top
  43. mov r0, #0x6000
  44. mov r1, #0x6000
  45. mov r2, #0x6000
  46. stmdb sp!, {r0, r1, r2}
  47. bl lmain /*Jump into lmain loader.*/
  48. /*
  49. *DELAY_FOR 宏定义,定义总线周期延迟操作宏
  50. */
  51. .macro DELAY_FOR cycles, reg0
  52. ldr \reg0, =\cycles
  53. subs \reg0, \reg0, #1
  54. subne pc, pc, #0xc
  55. .endm
  56. /*CPU init 执行板级初始化代码,关掉MMU清指令及数据CACHE,并在重定位之前应该执行内存地址及FLASH地址的重映射
  57. *根据UBOOT本身的代码进行融合,将lowlevelinit.s及start.s整合到一个文件之中
  58. */
  59. cpu_init_crit:
  60. /*
  61. * flush v4 I/D caches
  62. */
  63. mov r0, #0
  64. mcr p15, 0, r0, c7, c7, 0 /* flush v3/v4 cache */
  65. mcr p15, 0, r0, c8, c7, 0 /* flush v4 TLB */
  66. /*
  67. * disable MMU stuff and caches
  68. */
  69. mrc p15, 0, r0, c1, c0, 0
  70. bic r0, r0, #0x00002300 @ clear bits 13, 9:8 (--V- --RS)
  71. bic r0, r0, #0x00000087 @ clear bits 7, 2:0 (B--- -CAM)
  72. orr r0, r0, #0x00000002 @ set bit 2 (A) Align
  73. orr r0, r0, #0x00001000 @ set bit 12 (I) I-Cache
  74. mcr p15, 0, r0, c1, c0, 0
  75. /*
  76. * before relocating, we have to setup RAM timing
  77. * because memory timing is board-dependend, you will
  78. * find a lowlevel_init.S in your board directory.
  79. */
  80. mov ip, lr
  81. bl lowlevel_init /*跳到板级初始化代码部份*/
  82. mov lr, ip
  83. mov pc, lr
  84. lowlevel_init:
  85. ldr r1,=(0x03FF0000+0xE01C)
  86. ldr r2,=(0x28B)
  87. str r2,[r1]
  88. ldr r1,=(0x03FF0000+0xE00C)
  89. mov r2,#0x03
  90. str r2,[r1]
  91. ldr r1, =(0x03FF0000+0xE004)
  92. mov r2, #0x41
  93. str r2, [r1] /* write 'A' */
  94. /*
  95. * 我想利用指令预取功能,重映射后仍然在这里执行
  96. * ram from address 0, and flash at 32MB.
  97. * Flash bank 0: start address 0x01000000 end address 0x011FFFFF 2M flash size
  98. */
  99. ldr r1, =(0x03FF0000+0x4010)
  100. ldr r2, =0x43d0007c /*0x43d0007c--1M flash 0x41d0007c--512K flash*/
  101. ldr r3,=(highflash+0x01000000)
  102. str r2, [r1] /* large flash map */
  103. mov pc,r3
  104. highflash:
  105. /*
  106. *我们的系统只有一块flash,不需要重映射其它寄存器
  107. */
  108. /*
  109. * before relocating, we have to setup RAM timing
  110. * SDRAM bank 0 address: startaddress-0x00000000 endaddress-0x0x0080000
  111. */
  112. ldr r1, =(0x03FF0000+0x4030)
  113. ldr r2, =0x1fc0000c /* 8MB 32bit 0x1fc0000e 16bit 0x1fc0000c
  114. 2MB 16bit 0x07c0000c */
  115. str r2, [r1] /* configure sdram bank0 setup */
  116. ldr r1, =(0x03FF0000+0x4034)
  117. mov r2, #0
  118. str r2, [r1] /* configure sdram bank1 setup */
  119. ldr r1, =(0x03FF0000+0x4038)
  120. ldr r2, =0x0000000a /* 0x00000005 (RAS-CAS 2 CAS-DATA 2)*/
  121. str r2, [r1] /* set RAS/CAS timing */
  122. ldr r1, =(0x03FF0000+0x403c)
  123. ldr r2, =0x00030000
  124. str r2, [r1] /* send NOP command */
  125. DELAY_FOR 0x200, r0
  126. ldr r2, =0x00010000
  127. str r2, [r1] /* send PRECHARGE-ALL */
  128. DELAY_FOR 0x200, r0
  129. ldr r1, =(0x03FF0000+0x4040)
  130. ldr r2, =0x00000020
  131. str r2, [r1] /* set for fast refresh */
  132. DELAY_FOR 0x100, r0
  133. ldr r2, =360
  134. str r2, [r1] /* set normal refresh timing */
  135. ldr r1, =(0x03FF0000+0x403c)
  136. ldr r2, =0x00020037
  137. str r2, [r1] /* send mode command */
  138. DELAY_FOR 0x100, r0
  139. ldr r2, =0x01f00000 /*For Test two sdram bank . 0x1b00000 , it should be 0x1f00000*/
  140. str r2, [r1] /* enable sdram fifos */
  141. /*
  142. * set pll to top speed
  143. */
  144. ldr r1, =(0x03FF0000+0x0004)
  145. mov r2, #0
  146. str r2, [r1] /* set pll clock to 166 sysclk=100MMHz */
  147. ldr r1, =(0x03FF0000+0xE800)
  148. ldr r2, [r1] /* Get switch ctrl0 register */
  149. and r2, r2, #0x0fc00000 /* Mask out LED control bits */
  150. orr r2, r2, #0x01800000 /* Set Link/activity/speed actions */
  151. str r2, [r1]
  152. /*重定位代码后拷贝内存到原始映射的FLASH地址,然后仍然跳回去运行*/
  153. ldr r0, =(0x1000000)
  154. ldr r1, =(0x0000000)
  155. ldr r2, =(0x1001000)
  156. copy_loop:
  157. ldmia r0!, {r3-r10} /* copy from source address [r0] */
  158. stmia r1!, {r3-r10} /* copy to target address [r1] */
  159. cmp r0, r2 /* until source end addreee [r2] */
  160. ble copy_loop
  161. mov pc, lr

点击(此处)折叠或打开

  1. @############################################################
  2. @# MODULE: vectors.S
  3. @#
  4. @# PURPOSE:
  5. @# This file contains the vector table of snds100
  6. @#
  7. @# COPYRIGHT (C) 2000-2001, CoreTek Systems Inc.
  8. @# ALL RIGHTS RESERVED
  9. @############################################################
  10. @# AUTHOR(S): Kernel_Group
  11. @#
  12. @# DATE CREATED: 2001/03/29
  13. @#
  14. @# MODIFICATIONS:
  15. @# Date userName Description
  16. @#
  17. @############################################################
  18. .equ I_Bit, 0x80
  19. .equ F_Bit, 0x40
  20. .equ Mode_SVC, 0x13
  21. @ standard exception vectors table Must be located at address 0
  22. .section ".vectors","ax"
  23. Vector_Init_Block:
  24. LDR PC, Reset_Addr
  25. LDR PC, Undefined_Addr
  26. LDR PC, SWI_Addr
  27. LDR PC, Prefetch_Addr
  28. LDR PC, Abort_Addr
  29. NOP
  30. LDR PC, IRQ_Addr
  31. LDR PC, FIQ_Addr
  32. .balign 0x100
  33. .globl Reset_Addr
  34. Reset_Addr: .long _start
  35. Undefined_Addr: .long Undefined_Handler
  36. SWI_Addr: .long SWI_Handler
  37. Prefetch_Addr: .long Prefetch_Handler
  38. Abort_Addr: .long Abort_Handler
  39. Unknown_Addr: .long Unknow_handler
  40. IRQ_Addr: .long IRQ_Handler
  41. FIQ_Addr: .long FIQ_Handler
  42. IRQ_shared_Addr:.long IRQ_Handler_shared
  43. FIQ_shared_Addr:.long FIQ_Handler_shared
  44. .text
  45. @ The following handlers do not do anything useful
  46. .globl Undefined_Handler
  47. Undefined_Handler:
  48. b Undefined_Handler
  49. .globl SWI_Handler
  50. SWI_Handler:
  51. b SWI_Handler
  52. .globl Prefetch_Handler
  53. Prefetch_Handler:
  54. b Prefetch_Handler
  55. .globl Abort_Handler
  56. Abort_Handler:
  57. b Abort_Handler
  58. .globl Unknow_handler
  59. Unknow_handler:
  60. b Unknow_handler
  61. .globl IRQ_Handler
  62. IRQ_Handler:
  63. b IRQ_Handler
  64. .globl FIQ_Handler
  65. FIQ_Handler:
  66. b FIQ_Handler
  67. .globl IRQ_Handler_shared
  68. IRQ_Handler_shared:
  69. b IRQ_Handler_shared
  70. .globl FIQ_Handler_shared
  71. FIQ_Handler_shared:
  72. b FIQ_Handler_shared
  73. .end


阅读(747) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~