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