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