head_v10.S 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. * arch/cris/boot/compressed/head.S
  3. *
  4. * Copyright (C) 1999, 2001 Axis Communications AB
  5. *
  6. * Code that sets up the DRAM registers, calls the
  7. * decompressor to unpack the piggybacked kernel, and jumps.
  8. *
  9. */
  10. #define ASSEMBLER_MACROS_ONLY
  11. #include <arch/sv_addr_ag.h>
  12. #define RAM_INIT_MAGIC 0x56902387
  13. #define COMMAND_LINE_MAGIC 0x87109563
  14. ;; Exported symbols
  15. .globl input_data
  16. .text
  17. nop
  18. di
  19. ;; We need to initialze DRAM registers before we start using the DRAM
  20. cmp.d RAM_INIT_MAGIC, $r8 ; Already initialized?
  21. beq dram_init_finished
  22. nop
  23. #include "../../arch-v10/lib/dram_init.S"
  24. dram_init_finished:
  25. ;; Initiate the PA and PB ports
  26. move.b CONFIG_ETRAX_DEF_R_PORT_PA_DATA, $r0
  27. move.b $r0, [R_PORT_PA_DATA]
  28. move.b CONFIG_ETRAX_DEF_R_PORT_PA_DIR, $r0
  29. move.b $r0, [R_PORT_PA_DIR]
  30. move.b CONFIG_ETRAX_DEF_R_PORT_PB_DATA, $r0
  31. move.b $r0, [R_PORT_PB_DATA]
  32. move.b CONFIG_ETRAX_DEF_R_PORT_PB_DIR, $r0
  33. move.b $r0, [R_PORT_PB_DIR]
  34. ;; Setup the stack to a suitably high address.
  35. ;; We assume 8 MB is the minimum DRAM in an eLinux
  36. ;; product and put the sp at the top for now.
  37. move.d 0x40800000, $sp
  38. ;; Figure out where the compressed piggyback image is
  39. ;; in the flash (since we wont try to copy it to DRAM
  40. ;; before unpacking). It is at _edata, but in flash.
  41. ;; Use (_edata - basse) as offset to the current PC.
  42. basse: move.d $pc, $r5
  43. and.d 0x7fffffff, $r5 ; strip any non-cache bit
  44. subq 2, $r5 ; compensate for the move.d $pc instr
  45. move.d $r5, $r0 ; save for later - flash address of 'basse'
  46. add.d _edata, $r5
  47. sub.d basse, $r5 ; $r5 = flash address of '_edata'
  48. ;; Copy text+data to DRAM
  49. move.d basse, $r1 ; destination
  50. move.d _edata, $r2 ; end destination
  51. 1: move.w [$r0+], $r3
  52. move.w $r3, [$r1+]
  53. cmp.d $r2, $r1
  54. bcs 1b
  55. nop
  56. move.d $r5, [input_data] ; for the decompressor
  57. ;; Clear the decompressors BSS (between _edata and _end)
  58. moveq 0, $r0
  59. move.d _edata, $r1
  60. move.d _end, $r2
  61. 1: move.w $r0, [$r1+]
  62. cmp.d $r2, $r1
  63. bcs 1b
  64. nop
  65. ;; Save command line magic and address.
  66. move.d _cmd_line_magic, $r12
  67. move.d $r10, [$r12]
  68. move.d _cmd_line_addr, $r12
  69. move.d $r11, [$r12]
  70. ;; Do the decompression and save compressed size in inptr
  71. jsr decompress_kernel
  72. ;; Put start address of root partition in $r9 so the kernel can use it
  73. ;; when mounting from flash
  74. move.d [input_data], $r9 ; flash address of compressed kernel
  75. add.d [inptr], $r9 ; size of compressed kernel
  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. ;; Enter the decompressed kernel
  82. move.d RAM_INIT_MAGIC, $r8 ; Tell kernel that DRAM is initialized
  83. jump 0x40004000 ; kernel is linked to this address
  84. .data
  85. input_data:
  86. .dword 0 ; used by the decompressor
  87. _cmd_line_magic:
  88. .dword 0
  89. _cmd_line_addr:
  90. .dword 0
  91. #include "../../arch-v10/lib/hw_settings.S"