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