head-shark.S 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. .arch armv4
  18. b __beginning
  19. __ofw_data: .long 0 @ the number of memory blocks
  20. .space 128 @ (startaddr,size) ...
  21. .space 128 @ bootargs
  22. .align
  23. __beginning: mov r4, r0 @ save the entry to the firmware
  24. mov r0, #0xC0 @ disable irq and fiq
  25. mov r1, r0
  26. mrs r3, cpsr
  27. bic r2, r3, r0
  28. eor r2, r2, r1
  29. msr cpsr_c, r2
  30. mov r0, r4 @ get the Memory layout from firmware
  31. adr r1, __ofw_data
  32. add r2, r1, #4
  33. mov lr, pc
  34. b ofw_init
  35. mov r1, #0
  36. adr r2, __mmu_off @ calculate physical address
  37. sub r2, r2, #0xf0000000 @ openprom maps us at f000 virt, 0e50 phys
  38. adr r0, __ofw_data
  39. ldr r0, [r0, #4]
  40. add r2, r2, r0
  41. add r2, r2, #0x00500000
  42. mrc p15, 0, r3, c1, c0
  43. bic r3, r3, #0xC @ Write Buffer and DCache
  44. bic r3, r3, #0x1000 @ ICache
  45. mcr p15, 0, r3, c1, c0 @ disabled
  46. mov r0, #0
  47. mcr p15, 0, r0, c7, c7 @ flush I,D caches on v4
  48. mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
  49. mcr p15, 0, r0, c8, c7 @ flush I,D TLBs on v4
  50. bic r3, r3, #0x1 @ MMU
  51. mcr p15, 0, r3, c1, c0 @ disabled
  52. mov pc, r2
  53. __copy_target: .long 0x08507FFC
  54. __copy_end: .long 0x08607FFC
  55. .word _start
  56. .word __bss_start
  57. .align
  58. __temp_stack: .space 128
  59. __mmu_off:
  60. adr r0, __ofw_data @ read the 1. entry of the memory map
  61. ldr r0, [r0, #4]
  62. orr r0, r0, #0x00600000
  63. sub r0, r0, #4
  64. ldr r1, __copy_end
  65. ldr r3, __copy_target
  66. /* r0 = 0x0e600000 (current end of kernelcode)
  67. * r3 = 0x08508000 (where it should begin)
  68. * r1 = 0x08608000 (end of copying area, 1MB)
  69. * The kernel is compressed, so 1 MB should be enough.
  70. * copy the kernel to the beginning of physical memory
  71. * We start from the highest address, so we can copy
  72. * from 0x08500000 to 0x08508000 if we have only 8MB
  73. */
  74. /* As we get more 2.6-kernels it gets more and more
  75. * uncomfortable to be bound to kernel images of 1MB only.
  76. * So we add a loop here, to be able to copy some more.
  77. * Alexander Schulz 2005-07-17
  78. */
  79. mov r4, #3 @ How many megabytes to copy
  80. __MoveCode: sub r4, r4, #1
  81. __Copy: ldr r2, [r0], #-4
  82. str r2, [r1], #-4
  83. teq r1, r3
  84. bne __Copy
  85. /* The firmware maps us in blocks of 1 MB, the next block is
  86. _below_ the last one. So our decrementing source pointer
  87. ist right here, but the destination pointer must be increased
  88. by 2 MB */
  89. add r1, r1, #0x00200000
  90. add r3, r3, #0x00100000
  91. teq r4, #0
  92. bne __MoveCode
  93. /* and jump to it */
  94. adr r2, __go_on @ where we want to jump
  95. adr r0, __ofw_data @ read the 1. entry of the memory map
  96. ldr r0, [r0, #4]
  97. sub r2, r2, r0 @ we are mapped add 0e50 now, sub that (-0e00)
  98. sub r2, r2, #0x00500000 @ -0050
  99. ldr r0, __copy_target @ and add 0850 8000 instead
  100. add r0, r0, #4
  101. add r2, r2, r0
  102. mov pc, r2 @ and jump there
  103. __go_on:
  104. adr sp, __temp_stack
  105. add sp, sp, #128
  106. adr r0, __ofw_data
  107. mov lr, pc
  108. b create_params
  109. mov r8, #0
  110. mov r7, #15