head.S 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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 <asm/arch/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. #include "../../mach/dram_init.S"
  24. dram_init_finished:
  25. GIO_INIT
  26. ;; Setup the stack to a suitably high address.
  27. ;; We assume 8 MB is the minimum DRAM and put
  28. ;; the SP at the top for now.
  29. move.d 0x40800000, $sp
  30. ;; Figure out where the compressed piggyback image is.
  31. ;; It is either in [NOR] flash (we don't want to copy it
  32. ;; to DRAM before unpacking), or copied to DRAM
  33. ;; by the [NAND] flash boot loader.
  34. ;; The piggyback image is at _edata, but relative to where the
  35. ;; image is actually located in memory, not where it is linked
  36. ;; (the decompressor is linked at 0x40700000+ and runs there).
  37. ;; Use (_edata - herami) as offset to the current PC.
  38. hereami:
  39. lapcq ., $r5 ; get PC
  40. and.d 0x7fffffff, $r5 ; strip any non-cache bit
  41. move.d $r5, $r0 ; source address of 'herami'
  42. add.d _edata, $r5
  43. sub.d hereami, $r5 ; r5 = flash address of '_edata'
  44. move.d hereami, $r1 ; destination
  45. ;; Copy text+data to DRAM
  46. move.d _edata, $r2 ; end destination
  47. 1: move.w [$r0+], $r3 ; from herami+ source
  48. move.w $r3, [$r1+] ; to hereami+ destination (linked address)
  49. cmp.d $r2, $r1 ; finish when destination == _edata
  50. bcs 1b
  51. nop
  52. move.d input_data, $r0 ; for the decompressor
  53. move.d $r5, [$r0] ; for the decompressor
  54. ;; Clear the decompressors BSS (between _edata and _end)
  55. moveq 0, $r0
  56. move.d _edata, $r1
  57. move.d _end, $r2
  58. 1: move.w $r0, [$r1+]
  59. cmp.d $r2, $r1
  60. bcs 1b
  61. nop
  62. ;; Save command line magic and address.
  63. move.d _cmd_line_magic, $r0
  64. move.d $r10, [$r0]
  65. move.d _cmd_line_addr, $r0
  66. move.d $r11, [$r0]
  67. ;; Save boot source indicator
  68. move.d _boot_source, $r0
  69. move.d $r12, [$r0]
  70. ;; Do the decompression and save compressed size in _inptr
  71. jsr decompress_kernel
  72. nop
  73. ;; Restore boot source indicator
  74. move.d _boot_source, $r12
  75. move.d [$r12], $r12
  76. ;; Restore command line magic and address.
  77. move.d _cmd_line_magic, $r10
  78. move.d [$r10], $r10
  79. move.d _cmd_line_addr, $r11
  80. move.d [$r11], $r11
  81. ;; Put start address of root partition in r9 so the kernel can use it
  82. ;; when mounting from flash
  83. move.d input_data, $r0
  84. move.d [$r0], $r9 ; flash address of compressed kernel
  85. move.d inptr, $r0
  86. add.d [$r0], $r9 ; size of compressed kernel
  87. cmp.d 0x40000000, $r9 ; image in DRAM ?
  88. blo enter_kernel ; no, must be [NOR] flash, jump
  89. nop ; delay slot
  90. and.d 0x001fffff, $r9 ; assume compressed kernel was < 2M
  91. enter_kernel:
  92. ;; Enter the decompressed kernel
  93. move.d RAM_INIT_MAGIC, $r8 ; Tell kernel that DRAM is initialized
  94. jump 0x40004000 ; kernel is linked to this address
  95. nop
  96. .data
  97. input_data:
  98. .dword 0 ; used by the decompressor
  99. _cmd_line_magic:
  100. .dword 0
  101. _cmd_line_addr:
  102. .dword 0
  103. _boot_source:
  104. .dword 0
  105. #include "../../mach/hw_settings.S"