il.s 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #include "mem.h"
  2. /*
  3. * Entered here from Compaq's bootldr. First relocate to
  4. * the location we're linked for and then copy back the
  5. * decompressed kernel.
  6. *
  7. * All
  8. */
  9. TEXT _start(SB), $-4
  10. MOVW $setR12(SB), R12 /* load the SB */
  11. MOVW $1, R0 /* dance to make 5l think that the magic */
  12. MOVW $1, R1 /* numbers in WORDs below are being used */
  13. CMP.S R0, R1 /* and to align them to where bootldr wants */
  14. BEQ _start2
  15. WORD $0x016f2818 /* magic number to say we are a kernel */
  16. WORD $0xc0008000 /* entry point address */
  17. WORD $0 /* size?, or end of data? */
  18. _start2:
  19. /* SVC mode, interrupts disabled */
  20. MOVW $(PsrDirq|PsrDfiq|PsrMsvc), R1
  21. MOVW R1, CPSR
  22. /* disable the MMU */
  23. MOVW $0x130, R1
  24. MCR CpMMU, 0, R1, C(CpControl), C(0x0)
  25. /* enable caches */
  26. MRC CpMMU, 0, R0, C(CpControl), C(0x0)
  27. ORR $(CpCdcache|CpCicache|CpCwb), R0
  28. MCR CpMMU, 0, R0, C(CpControl), C(0x0)
  29. /* flush caches */
  30. MCR CpMMU, 0, R0, C(CpCacheFlush), C(0x7), 0
  31. /* drain prefetch */
  32. MOVW R0,R0
  33. MOVW R0,R0
  34. MOVW R0,R0
  35. MOVW R0,R0
  36. /* drain write buffer */
  37. MCR CpMMU, 0, R0, C(CpCacheFlush), C(0xa), 4
  38. /* relocate to where we expect to be */
  39. MOVW $(512*1024),R3
  40. MOVW $0xC0008000,R1
  41. MOVW $0xC0200000,R2
  42. ADD R1,R3
  43. _relloop:
  44. MOVW (R1),R0
  45. MOVW R0,(R2)
  46. ADD $4,R1
  47. ADD $4,R2
  48. CMP.S R1,R3
  49. BNE _relloop
  50. MOVW $(MACHADDR+BY2PG), R13 /* stack */
  51. SUB $4, R13 /* link */
  52. /* jump to where we've been relocated */
  53. MOVW $_relocated(SB),R15
  54. TEXT _relocated(SB),$-4
  55. BL main(SB)
  56. BL exit(SB)
  57. /* we shouldn't get here */
  58. _mainloop:
  59. B _mainloop
  60. BL _div(SB) /* hack to get _div etc loaded */
  61. TEXT mypc(SB),$-4
  62. MOVW R14,R0
  63. RET
  64. TEXT draincache(SB),$-4
  65. /* write back any dirty data */
  66. MOVW $0xe0000000,R0
  67. ADD $(8*1024),R0,R1
  68. _cfloop:
  69. MOVW.P 32(R0),R2
  70. CMP.S R0,R1
  71. BNE _cfloop
  72. /* drain write buffer and invalidate i&d cache contents */
  73. MCR CpMMU, 0, R0, C(CpCacheFlush), C(0xa), 4
  74. MCR CpMMU, 0, R0, C(CpCacheFlush), C(0x7), 0
  75. /* drain prefetch */
  76. MOVW R0,R0
  77. MOVW R0,R0
  78. MOVW R0,R0
  79. MOVW R0,R0
  80. /* disable caches */
  81. MRC CpMMU, 0, R0, C(CpControl), C(0x0)
  82. BIC $(CpCdcache|CpCicache|CpCwb), R0
  83. MCR CpMMU, 0, R0, C(CpControl), C(0x0)
  84. RET