head-shark.S
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:3k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

  1. /* The head-file for the Shark
  2.  * by Alexander Schulz
  3.  *
  4.  * Does the following:
  5.  * - get the memory layout from firmware. This can only be done as long as the mmu
  6.  *   is still on.
  7.  * - switch the mmu off, so we have physical addresses
  8.  * - copy the kernel to 0x08508000. This is done to have a fixed address where the
  9.  *   C-parts (misc.c) are executed. This address must be known at compile-time,
  10.  *   but the load-address of the kernel depends on how much memory is installed.
  11.  * - Jump to this location.
  12.  * - Set r8 with 0, r7 with the architecture ID for head.S
  13.  */
  14. #include <linux/linkage.h>
  15. #include <asm/assembler.h>
  16. .section ".start", "ax"
  17. b __beginning
  18. __ofw_data: .long 0 @ the number of memory blocks
  19. .space  128 @ (startaddr,size) ...
  20. .space  128 @ bootargs
  21. .align
  22. __beginning: mov r4, r0 @ save the entry to the firmware
  23. mov r0, #0xC0 @ disable irq and fiq
  24. mov r1, r0
  25. mrs r3, cpsr
  26. bic r2, r3, r0
  27. eor r2, r2, r1
  28. msr cpsr_c, r2
  29. mov r0, r4 @ get the Memory layout from firmware
  30. adr r1, __ofw_data
  31. add r2, r1, #4
  32. mov lr, pc
  33. b ofw_init
  34. mov r1, #0
  35. adr r2, __mmu_off @ calculate physical address
  36. sub r2, r2, #0xf0000000 @ openprom maps us at f000 virt, 0e50 phys
  37. adr r0, __ofw_data
  38. ldr r0, [r0, #4]
  39. add r2, r2, r0
  40. add r2, r2, #0x00500000
  41. mrc p15, 0, r3, c1, c0
  42. bic r3, r3, #0xC @ Write Buffer and DCache
  43. bic r3, r3, #0x1000 @ ICache
  44. mcr p15, 0, r3, c1, c0 @ disabled
  45. mov r0, #0
  46. mcr p15, 0, r0, c7, c7 @ flush I,D caches on v4
  47. mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
  48. mcr p15, 0, r0, c8, c7 @ flush I,D TLBs on v4
  49. bic r3, r3, #0x1 @ MMU
  50. mcr p15, 0, r3, c1, c0 @ disabled
  51. mov pc, r2
  52. __copy_target: .long 0x08508000
  53. __copy_end: .long 0x08608000
  54. .word _start
  55. .word __bss_start
  56. .align
  57. __temp_stack: .space 128
  58. __mmu_off:
  59. adr r0, __ofw_data
  60. ldr r0, [r0, #4]
  61. orr r0, r0, #0x00600000
  62. ldr r1, __copy_end
  63. ldr r3, __copy_target
  64. /* r0 = 0x0e600000 (current end of kernelcode)
  65.  * r3 = 0x08508000 (where it should begin)
  66.  * r1 = 0x08608000 (end of copying area, 1MB)
  67.  * The kernel is compressed, so 1 MB should be enough.
  68.  * copy the kernel to the beginning of physical memory
  69.  * We start from the highest address, so we can copy
  70.  * from 0x08500000 to 0x08508000 if we have only 8MB
  71.  */
  72. __Copy: ldr r2, [r0], #-4
  73. str r2, [r1], #-4
  74. teq r1, r3
  75. bne __Copy
  76. /* and jump to it */
  77. adr r2, __go_on
  78. adr r0, __ofw_data
  79. ldr r0, [r0, #4]
  80. sub r2, r2, r0
  81. sub r2, r2, #0x00500000
  82. ldr r0, __copy_target
  83. add r2, r2, r0
  84. mov pc, r2
  85. __go_on:
  86. adr sp, __temp_stack
  87. add sp, sp, #128
  88. adr r0, __ofw_data
  89. mov lr, pc
  90. b create_params
  91. mov r8, #0
  92. mov r7, #15