head_v32.S 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  2. * Code that sets up the DRAM registers, calls the
  3. * decompressor to unpack the piggybacked kernel, and jumps.
  4. *
  5. * Copyright (C) 1999 - 2006, Axis Communications AB
  6. */
  7. #define ASSEMBLER_MACROS_ONLY
  8. #include <hwregs/asm/reg_map_asm.h>
  9. #include <mach/startup.inc>
  10. #define RAM_INIT_MAGIC 0x56902387
  11. #define COMMAND_LINE_MAGIC 0x87109563
  12. ;; Exported symbols
  13. .globl input_data
  14. .text
  15. start:
  16. di
  17. ;; Start clocks for used blocks.
  18. START_CLOCKS
  19. ;; Initialize the DRAM registers.
  20. cmp.d RAM_INIT_MAGIC, $r8 ; Already initialized?
  21. beq dram_init_finished
  22. nop
  23. #if defined CONFIG_ETRAXFS
  24. #include "../../arch-v32/mach-fs/dram_init.S"
  25. #elif defined CONFIG_CRIS_MACH_ARTPEC3
  26. #include "../../arch-v32/mach-a3/dram_init.S"
  27. #else
  28. #error Only ETRAXFS and ARTPEC-3 supported!
  29. #endif
  30. dram_init_finished:
  31. GIO_INIT
  32. ;; Setup the stack to a suitably high address.
  33. ;; We assume 8 MB is the minimum DRAM and put
  34. ;; the SP at the top for now.
  35. move.d 0x40800000, $sp
  36. ;; Figure out where the compressed piggyback image is.
  37. ;; It is either in [NOR] flash (we don't want to copy it
  38. ;; to DRAM before unpacking), or copied to DRAM
  39. ;; by the [NAND] flash boot loader.
  40. ;; The piggyback image is at _edata, but relative to where the
  41. ;; image is actually located in memory, not where it is linked
  42. ;; (the decompressor is linked at 0x40700000+ and runs there).
  43. ;; Use (_edata - herami) as offset to the current PC.
  44. hereami:
  45. lapcq ., $r5 ; get PC
  46. and.d 0x7fffffff, $r5 ; strip any non-cache bit
  47. move.d $r5, $r0 ; source address of 'herami'
  48. add.d _edata, $r5
  49. sub.d hereami, $r5 ; r5 = flash address of '_edata'
  50. move.d hereami, $r1 ; destination
  51. ;; Copy text+data to DRAM
  52. move.d _edata, $r2 ; end destination
  53. 1: move.w [$r0+], $r3 ; from herami+ source
  54. move.w $r3, [$r1+] ; to hereami+ destination (linked address)
  55. cmp.d $r2, $r1 ; finish when destination == _edata
  56. bcs 1b
  57. nop
  58. move.d input_data, $r0 ; for the decompressor
  59. move.d $r5, [$r0] ; for the decompressor
  60. ;; Clear the decompressors BSS (between _edata and _end)
  61. moveq 0, $r0
  62. move.d _edata, $r1
  63. move.d _end, $r2
  64. 1: move.w $r0, [$r1+]
  65. cmp.d $r2, $r1
  66. bcs 1b
  67. nop
  68. ;; Save command line magic and address.
  69. move.d _cmd_line_magic, $r0
  70. move.d $r10, [$r0]
  71. move.d _cmd_line_addr, $r0
  72. move.d $r11, [$r0]
  73. ;; Save boot source indicator
  74. move.d _boot_source, $r0
  75. move.d $r12, [$r0]
  76. ;; Do the decompression and save compressed size in _inptr
  77. jsr decompress_kernel
  78. nop
  79. ;; Restore boot source indicator
  80. move.d _boot_source, $r12
  81. move.d [$r12], $r12
  82. ;; Restore command line magic and address.
  83. move.d _cmd_line_magic, $r10
  84. move.d [$r10], $r10
  85. move.d _cmd_line_addr, $r11
  86. move.d [$r11], $r11
  87. ;; Put start address of root partition in r9 so the kernel can use it
  88. ;; when mounting from flash
  89. move.d input_data, $r0
  90. move.d [$r0], $r9 ; flash address of compressed kernel
  91. move.d inptr, $r0
  92. add.d [$r0], $r9 ; size of compressed kernel
  93. cmp.d 0x40000000, $r9 ; image in DRAM ?
  94. blo enter_kernel ; no, must be [NOR] flash, jump
  95. nop ; delay slot
  96. and.d 0x001fffff, $r9 ; assume compressed kernel was < 2M
  97. enter_kernel:
  98. ;; Enter the decompressed kernel
  99. move.d RAM_INIT_MAGIC, $r8 ; Tell kernel that DRAM is initialized
  100. jump 0x40004000 ; kernel is linked to this address
  101. nop
  102. .data
  103. input_data:
  104. .dword 0 ; used by the decompressor
  105. _cmd_line_magic:
  106. .dword 0
  107. _cmd_line_addr:
  108. .dword 0
  109. _boot_source:
  110. .dword 0
  111. #if defined CONFIG_ETRAXFS
  112. #include "../../arch-v32/mach-fs/hw_settings.S"
  113. #elif defined CONFIG_CRIS_MACH_ARTPEC3
  114. #include "../../arch-v32/mach-a3/hw_settings.S"
  115. #else
  116. #error Only ETRAXFS and ARTPEC-3 supported!
  117. #endif