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. 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 0x08507FFC
  53. __copy_end: .long 0x08607FFC
  54. .word _start
  55. .word __bss_start
  56. .align
  57. __temp_stack: .space 128
  58. __mmu_off:
  59. adr r0, __ofw_data @ read the 1. entry of the memory map
  60. ldr r0, [r0, #4]
  61. orr r0, r0, #0x00600000
  62. sub r0, r0, #4
  63. ldr r1, __copy_end
  64. ldr r3, __copy_target
  65. /* r0 = 0x0e600000 (current end of kernelcode)
  66. * r3 = 0x08508000 (where it should begin)
  67. * r1 = 0x08608000 (end of copying area, 1MB)
  68. * The kernel is compressed, so 1 MB should be enough.
  69. * copy the kernel to the beginning of physical memory
  70. * We start from the highest address, so we can copy
  71. * from 0x08500000 to 0x08508000 if we have only 8MB
  72. */
  73. /* As we get more 2.6-kernels it gets more and more
  74. * uncomfortable to be bound to kernel images of 1MB only.
  75. * So we add a loop here, to be able to copy some more.
  76. * Alexander Schulz 2005-07-17
  77. */
  78. mov r4, #3 @ How many megabytes to copy
  79. __MoveCode: sub r4, r4, #1
  80. __Copy: ldr r2, [r0], #-4
  81. str r2, [r1], #-4
  82. teq r1, r3
  83. bne __Copy
  84. /* The firmware maps us in blocks of 1 MB, the next block is
  85. _below_ the last one. So our decrementing source pointer
  86. ist right here, but the destination pointer must be increased
  87. by 2 MB */
  88. add r1, r1, #0x00200000
  89. add r3, r3, #0x00100000
  90. teq r4, #0
  91. bne __MoveCode
  92. /* and jump to it */
  93. adr r2, __go_on @ where we want to jump
  94. adr r0, __ofw_data @ read the 1. entry of the memory map
  95. ldr r0, [r0, #4]
  96. sub r2, r2, r0 @ we are mapped add 0e50 now, sub that (-0e00)
  97. sub r2, r2, #0x00500000 @ -0050
  98. ldr r0, __copy_target @ and add 0850 8000 instead
  99. add r0, r0, #4
  100. add r2, r2, r0
  101. mov pc, r2 @ and jump there
  102. __go_on:
  103. adr sp, __temp_stack
  104. add sp, sp, #128
  105. adr r0, __ofw_data
  106. mov lr, pc
  107. b create_params
  108. mov r8, #0
  109. mov r7, #15