kogiidena | 9d44190 | 2006-01-16 22:14:10 -0800 | [diff] [blame] | 1 | /* |
| 2 | * relocate_kernel.S - put the kernel image in place to boot |
| 3 | * 2005.9.17 kogiidena@eggplant.ddo.jp |
| 4 | * |
| 5 | * LANDISK/sh4 is supported. Maybe, SH archtecture works well. |
| 6 | * |
| 7 | * This source code is licensed under the GNU General Public License, |
| 8 | * Version 2. See the file COPYING for more details. |
| 9 | */ |
kogiidena | 9d44190 | 2006-01-16 22:14:10 -0800 | [diff] [blame] | 10 | #include <linux/linkage.h> |
Paul Mundt | 510c72ad | 2006-11-27 12:06:26 +0900 | [diff] [blame] | 11 | #include <asm/addrspace.h> |
| 12 | #include <asm/page.h> |
kogiidena | 9d44190 | 2006-01-16 22:14:10 -0800 | [diff] [blame] | 13 | |
| 14 | .globl relocate_new_kernel |
| 15 | relocate_new_kernel: |
| 16 | /* r4 = indirection_page */ |
| 17 | /* r5 = reboot_code_buffer */ |
| 18 | /* r6 = start_address */ |
| 19 | /* r7 = vbr_reg */ |
| 20 | |
Paul Mundt | 510c72ad | 2006-11-27 12:06:26 +0900 | [diff] [blame] | 21 | mov.l 10f,r8 /* PAGE_SIZE */ |
| 22 | mov.l 11f,r9 /* P2SEG */ |
kogiidena | 9d44190 | 2006-01-16 22:14:10 -0800 | [diff] [blame] | 23 | |
| 24 | /* stack setting */ |
| 25 | add r8,r5 |
| 26 | mov r5,r15 |
| 27 | |
| 28 | bra 1f |
| 29 | mov r4,r0 /* cmd = indirection_page */ |
| 30 | 0: |
| 31 | mov.l @r4+,r0 /* cmd = *ind++ */ |
| 32 | |
Paul Mundt | 510c72ad | 2006-11-27 12:06:26 +0900 | [diff] [blame] | 33 | 1: /* addr = (cmd | P2SEG) & 0xfffffff0 */ |
kogiidena | 9d44190 | 2006-01-16 22:14:10 -0800 | [diff] [blame] | 34 | mov r0,r2 |
| 35 | or r9,r2 |
| 36 | mov #-16,r1 |
| 37 | and r1,r2 |
| 38 | |
| 39 | /* if(cmd & IND_DESTINATION) dst = addr */ |
| 40 | tst #1,r0 |
| 41 | bt 2f |
| 42 | bra 0b |
| 43 | mov r2,r5 |
| 44 | |
| 45 | 2: /* else if(cmd & IND_INDIRECTION) ind = addr */ |
| 46 | tst #2,r0 |
| 47 | bt 3f |
| 48 | bra 0b |
| 49 | mov r2,r4 |
| 50 | |
| 51 | 3: /* else if(cmd & IND_DONE) goto 6 */ |
| 52 | tst #4,r0 |
| 53 | bt 4f |
| 54 | bra 6f |
| 55 | nop |
| 56 | |
| 57 | 4: /* else if(cmd & IND_SOURCE) memcpy(dst,addr,PAGE_SIZE) */ |
| 58 | tst #8,r0 |
| 59 | bt 0b |
| 60 | |
| 61 | mov r8,r3 |
| 62 | shlr2 r3 |
| 63 | shlr2 r3 |
| 64 | 5: |
| 65 | dt r3 |
| 66 | mov.l @r2+,r1 /* 16n+0 */ |
| 67 | mov.l r1,@r5 |
| 68 | add #4,r5 |
| 69 | mov.l @r2+,r1 /* 16n+4 */ |
| 70 | mov.l r1,@r5 |
| 71 | add #4,r5 |
| 72 | mov.l @r2+,r1 /* 16n+8 */ |
| 73 | mov.l r1,@r5 |
| 74 | add #4,r5 |
| 75 | mov.l @r2+,r1 /* 16n+12 */ |
| 76 | mov.l r1,@r5 |
| 77 | add #4,r5 |
| 78 | bf 5b |
| 79 | |
| 80 | bra 0b |
| 81 | nop |
| 82 | 6: |
| 83 | #ifdef CONFIG_SH_STANDARD_BIOS |
| 84 | ldc r7, vbr |
| 85 | #endif |
| 86 | jmp @r6 |
| 87 | nop |
| 88 | |
| 89 | .align 2 |
| 90 | 10: |
| 91 | .long PAGE_SIZE |
| 92 | 11: |
Paul Mundt | 510c72ad | 2006-11-27 12:06:26 +0900 | [diff] [blame] | 93 | .long P2SEG |
kogiidena | 9d44190 | 2006-01-16 22:14:10 -0800 | [diff] [blame] | 94 | |
| 95 | relocate_new_kernel_end: |
| 96 | |
| 97 | .globl relocate_new_kernel_size |
| 98 | relocate_new_kernel_size: |
| 99 | .long relocate_new_kernel_end - relocate_new_kernel |