Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef __M68KNOMMU_ENTRY_H |
| 2 | #define __M68KNOMMU_ENTRY_H |
| 3 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | #include <asm/setup.h> |
| 5 | #include <asm/page.h> |
| 6 | |
| 7 | /* |
| 8 | * Stack layout in 'ret_from_exception': |
| 9 | * |
| 10 | * This allows access to the syscall arguments in registers d1-d5 |
| 11 | * |
| 12 | * 0(sp) - d1 |
| 13 | * 4(sp) - d2 |
| 14 | * 8(sp) - d3 |
| 15 | * C(sp) - d4 |
| 16 | * 10(sp) - d5 |
| 17 | * 14(sp) - a0 |
| 18 | * 18(sp) - a1 |
| 19 | * 1C(sp) - a2 |
| 20 | * 20(sp) - d0 |
| 21 | * 24(sp) - orig_d0 |
| 22 | * 28(sp) - stack adjustment |
| 23 | * 2C(sp) - [ sr ] [ format & vector ] |
| 24 | * 2E(sp) - [ pc-hiword ] [ sr ] |
| 25 | * 30(sp) - [ pc-loword ] [ pc-hiword ] |
| 26 | * 32(sp) - [ format & vector ] [ pc-loword ] |
| 27 | * ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ |
| 28 | * M68K COLDFIRE |
| 29 | */ |
| 30 | |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 31 | #define ALLOWINT (~0x700) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | |
| 33 | #ifdef __ASSEMBLY__ |
| 34 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | #define SWITCH_STACK_SIZE (6*4+4) /* Includes return address */ |
| 36 | |
| 37 | /* |
| 38 | * This defines the normal kernel pt-regs layout. |
| 39 | * |
| 40 | * regs are a2-a6 and d6-d7 preserved by C code |
| 41 | * the kernel doesn't mess with usp unless it needs to |
| 42 | */ |
| 43 | |
| 44 | #ifdef CONFIG_COLDFIRE |
Greg Ungerer | 1c83af5 | 2010-11-04 13:53:26 +1000 | [diff] [blame] | 45 | #ifdef CONFIG_COLDFIRE_SW_A7 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | /* |
Greg Ungerer | 1c83af5 | 2010-11-04 13:53:26 +1000 | [diff] [blame] | 47 | * This is made a little more tricky on older ColdFires. There is no |
| 48 | * separate supervisor and user stack pointers. Need to artificially |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | * construct a usp in software... When doing this we need to disable |
Greg Ungerer | 1c83af5 | 2010-11-04 13:53:26 +1000 | [diff] [blame] | 50 | * interrupts, otherwise bad things will happen. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | */ |
Greg Ungerer | 1c83af5 | 2010-11-04 13:53:26 +1000 | [diff] [blame] | 52 | .globl sw_usp |
| 53 | .globl sw_ksp |
| 54 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | .macro SAVE_ALL |
| 56 | move #0x2700,%sr /* disable intrs */ |
| 57 | btst #5,%sp@(2) /* from user? */ |
| 58 | bnes 6f /* no, skip */ |
| 59 | movel %sp,sw_usp /* save user sp */ |
| 60 | addql #8,sw_usp /* remove exception */ |
| 61 | movel sw_ksp,%sp /* kernel sp */ |
| 62 | subql #8,%sp /* room for exception */ |
| 63 | clrl %sp@- /* stkadj */ |
| 64 | movel %d0,%sp@- /* orig d0 */ |
| 65 | movel %d0,%sp@- /* d0 */ |
| 66 | lea %sp@(-32),%sp /* space for 8 regs */ |
| 67 | moveml %d1-%d5/%a0-%a2,%sp@ |
| 68 | movel sw_usp,%a0 /* get usp */ |
Heiko Carstens | f159ee7 | 2009-08-31 14:43:33 +0200 | [diff] [blame] | 69 | movel %a0@-,%sp@(PT_OFF_PC) /* copy exception program counter */ |
| 70 | movel %a0@-,%sp@(PT_OFF_FORMATVEC)/*copy exception format/vector/sr */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | bra 7f |
| 72 | 6: |
| 73 | clrl %sp@- /* stkadj */ |
| 74 | movel %d0,%sp@- /* orig d0 */ |
| 75 | movel %d0,%sp@- /* d0 */ |
| 76 | lea %sp@(-32),%sp /* space for 8 regs */ |
| 77 | moveml %d1-%d5/%a0-%a2,%sp@ |
| 78 | 7: |
| 79 | .endm |
| 80 | |
Greg Ungerer | 1c83af5 | 2010-11-04 13:53:26 +1000 | [diff] [blame] | 81 | .macro RESTORE_USER |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | move #0x2700,%sr /* disable intrs */ |
| 83 | movel sw_usp,%a0 /* get usp */ |
Heiko Carstens | f159ee7 | 2009-08-31 14:43:33 +0200 | [diff] [blame] | 84 | movel %sp@(PT_OFF_PC),%a0@- /* copy exception program counter */ |
| 85 | movel %sp@(PT_OFF_FORMATVEC),%a0@-/*copy exception format/vector/sr */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | moveml %sp@,%d1-%d5/%a0-%a2 |
| 87 | lea %sp@(32),%sp /* space for 8 regs */ |
| 88 | movel %sp@+,%d0 |
| 89 | addql #4,%sp /* orig d0 */ |
| 90 | addl %sp@+,%sp /* stkadj */ |
| 91 | addql #8,%sp /* remove exception */ |
| 92 | movel %sp,sw_ksp /* save ksp */ |
| 93 | subql #8,sw_usp /* set exception */ |
| 94 | movel sw_usp,%sp /* restore usp */ |
| 95 | rte |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | .endm |
| 97 | |
Greg Ungerer | 1c83af5 | 2010-11-04 13:53:26 +1000 | [diff] [blame] | 98 | .macro RDUSP |
| 99 | movel sw_usp,%a2 |
| 100 | .endm |
| 101 | |
| 102 | .macro WRUSP |
| 103 | movel %a0,sw_usp |
| 104 | .endm |
| 105 | |
| 106 | #else /* !CONFIG_COLDFIRE_SW_A7 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | /* |
Greg Ungerer | 1c83af5 | 2010-11-04 13:53:26 +1000 | [diff] [blame] | 108 | * Modern ColdFire parts have separate supervisor and user stack |
| 109 | * pointers. Simple load and restore macros for this case. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | */ |
Greg Ungerer | 1c83af5 | 2010-11-04 13:53:26 +1000 | [diff] [blame] | 111 | .macro SAVE_ALL |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | move #0x2700,%sr /* disable intrs */ |
| 113 | clrl %sp@- /* stkadj */ |
| 114 | movel %d0,%sp@- /* orig d0 */ |
| 115 | movel %d0,%sp@- /* d0 */ |
| 116 | lea %sp@(-32),%sp /* space for 8 regs */ |
| 117 | moveml %d1-%d5/%a0-%a2,%sp@ |
| 118 | .endm |
| 119 | |
Greg Ungerer | 1c83af5 | 2010-11-04 13:53:26 +1000 | [diff] [blame] | 120 | .macro RESTORE_USER |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | moveml %sp@,%d1-%d5/%a0-%a2 |
| 122 | lea %sp@(32),%sp /* space for 8 regs */ |
| 123 | movel %sp@+,%d0 |
| 124 | addql #4,%sp /* orig d0 */ |
| 125 | addl %sp@+,%sp /* stkadj */ |
| 126 | rte |
| 127 | .endm |
| 128 | |
Greg Ungerer | 1c83af5 | 2010-11-04 13:53:26 +1000 | [diff] [blame] | 129 | .macro RDUSP |
| 130 | /*move %usp,%a2*/ |
| 131 | .word 0x4e6a |
| 132 | .endm |
| 133 | |
| 134 | .macro WRUSP |
| 135 | /*move %a0,%usp*/ |
| 136 | .word 0x4e60 |
| 137 | .endm |
| 138 | |
| 139 | #endif /* !CONFIG_COLDFIRE_SW_A7 */ |
| 140 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | .macro SAVE_SWITCH_STACK |
| 142 | lea %sp@(-24),%sp /* 6 regs */ |
| 143 | moveml %a3-%a6/%d6-%d7,%sp@ |
| 144 | .endm |
| 145 | |
| 146 | .macro RESTORE_SWITCH_STACK |
| 147 | moveml %sp@,%a3-%a6/%d6-%d7 |
| 148 | lea %sp@(24),%sp /* 6 regs */ |
| 149 | .endm |
| 150 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | #else /* !CONFIG_COLDFIRE */ |
| 152 | |
| 153 | /* |
| 154 | * Standard 68k interrupt entry and exit macros. |
| 155 | */ |
| 156 | .macro SAVE_ALL |
| 157 | clrl %sp@- /* stkadj */ |
| 158 | movel %d0,%sp@- /* orig d0 */ |
| 159 | movel %d0,%sp@- /* d0 */ |
| 160 | moveml %d1-%d5/%a0-%a2,%sp@- |
| 161 | .endm |
| 162 | |
| 163 | .macro RESTORE_ALL |
| 164 | moveml %sp@+,%a0-%a2/%d1-%d5 |
| 165 | movel %sp@+,%d0 |
| 166 | addql #4,%sp /* orig d0 */ |
| 167 | addl %sp@+,%sp /* stkadj */ |
| 168 | rte |
| 169 | .endm |
| 170 | |
| 171 | .macro SAVE_SWITCH_STACK |
| 172 | moveml %a3-%a6/%d6-%d7,%sp@- |
| 173 | .endm |
| 174 | |
| 175 | .macro RESTORE_SWITCH_STACK |
| 176 | moveml %sp@+,%a3-%a6/%d6-%d7 |
| 177 | .endm |
| 178 | |
Greg Ungerer | 1c83af5 | 2010-11-04 13:53:26 +1000 | [diff] [blame] | 179 | #endif /* !COLDFIRE_SW_A7 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | #endif /* __ASSEMBLY__ */ |
| 181 | #endif /* __M68KNOMMU_ENTRY_H */ |