Rev 955 | Rev 1094 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 955 | Rev 1021 | ||
|---|---|---|---|
| Line 24... | Line 24... | ||
| 24 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 26 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | # |
27 | # |
| 28 | 28 | ||
| - | 29 | #define IREGISTER_SPACE 120 |
|
| - | 30 | ||
| - | 31 | #define IOFFSET_RAX 0x0 |
|
| - | 32 | #define IOFFSET_RBX 0x8 |
|
| - | 33 | #define IOFFSET_RCX 0x10 |
|
| - | 34 | #define IOFFSET_RDX 0x18 |
|
| - | 35 | #define IOFFSET_RSI 0x20 |
|
| - | 36 | #define IOFFSET_RDI 0x28 |
|
| - | 37 | #define IOFFSET_R8 0x30 |
|
| - | 38 | #define IOFFSET_R9 0x38 |
|
| - | 39 | #define IOFFSET_R10 0x40 |
|
| - | 40 | #define IOFFSET_R11 0x48 |
|
| - | 41 | #define IOFFSET_R12 0x50 |
|
| - | 42 | #define IOFFSET_R13 0x58 |
|
| - | 43 | #define IOFFSET_R14 0x60 |
|
| - | 44 | #define IOFFSET_R15 0x68 |
|
| - | 45 | #define IOFFSET_RBP 0x70 |
|
| 29 | 46 | ||
| 30 | # Mask for interrupts 0 - 31 (bits 0 - 31) where 0 means that int has no error word |
47 | # Mask for interrupts 0 - 31 (bits 0 - 31) where 0 means that int has no error word |
| 31 | # and 1 means interrupt with error word |
48 | # and 1 means interrupt with error word |
| 32 | - | ||
| 33 | - | ||
| 34 | #define ERROR_WORD_INTERRUPT_LIST 0x00027D00 |
49 | #define ERROR_WORD_INTERRUPT_LIST 0x00027D00 |
| 35 | 50 | ||
| 36 | #include <arch/pm.h> |
51 | #include <arch/pm.h> |
| 37 | #include <arch/context_offset.h> |
- | |
| 38 | #include <arch/mm/page.h> |
52 | #include <arch/mm/page.h> |
| 39 | 53 | ||
| 40 | .text |
54 | .text |
| 41 | .global interrupt_handlers |
55 | .global interrupt_handlers |
| 42 | .global syscall_entry |
56 | .global syscall_entry |
| Line 139... | Line 153... | ||
| 139 | movq IOFFSET_R12(%rsp), %r12 |
153 | movq IOFFSET_R12(%rsp), %r12 |
| 140 | movq IOFFSET_R13(%rsp), %r13 |
154 | movq IOFFSET_R13(%rsp), %r13 |
| 141 | movq IOFFSET_R14(%rsp), %r14 |
155 | movq IOFFSET_R14(%rsp), %r14 |
| 142 | movq IOFFSET_R15(%rsp), %r15 |
156 | movq IOFFSET_R15(%rsp), %r15 |
| 143 | .endm |
157 | .endm |
| 144 | 158 | ||
| 145 | ## Declare interrupt handlers |
159 | ## Declare interrupt handlers |
| 146 | # |
160 | # |
| 147 | # Declare interrupt handlers for n interrupt |
161 | # Declare interrupt handlers for n interrupt |
| 148 | # vectors starting at vector i. |
162 | # vectors starting at vector i. |
| 149 | # |
163 | # |
| 150 | # The handlers setup data segment registers |
- | |
| 151 | # and call exc_dispatch(). |
164 | # The handlers call exc_dispatch(). |
| 152 | # |
165 | # |
| 153 | .macro handler i n |
166 | .macro handler i n |
| 154 | subq $IREGISTER_SPACE, %rsp |
- | |
| 155 | save_all_gpr |
- | |
| 156 | 167 | ||
| - | 168 | /* |
|
| 157 | movq $(\i),%rdi # %rdi - first parameter |
169 | * Choose between version with error code and version without error code. |
| 158 | movq %rsp, %rsi # %rsi - pointer to interrupt_context |
170 | * Both versions have to be of the same size. amd64 assembly is, however, |
| - | 171 | * a little bit tricky. For instance, subq $0x80, %rsp and subq $0x78, %rsp |
|
| 159 | call exc_dispatch # exc_dispatch(i, stack) |
172 | * can result in two instructions with different op-code lengths. |
| - | 173 | * Therefore, pay special attention to the extra NOP's that serve as |
|
| - | 174 | * a necessary fill. |
|
| - | 175 | */ |
|
| 160 | 176 | ||
| - | 177 | .iflt \i-32 |
|
| - | 178 | .if (1 << \i) & ERROR_WORD_INTERRUPT_LIST |
|
| - | 179 | /* |
|
| 161 | # Test if this is interrupt with error word or not |
180 | * Version with error word. |
| 162 | mov $\i,%cl; |
181 | */ |
| - | 182 | subq $IREGISTER_SPACE, %rsp |
|
| - | 183 | nop |
|
| - | 184 | nop |
|
| - | 185 | nop |
|
| 163 | movl $1,%eax; |
186 | .else |
| - | 187 | /* |
|
| 164 | test $0xe0,%cl; |
188 | * Version without error word, |
| 165 | jnz 0f; |
189 | */ |
| - | 190 | subq $(IREGISTER_SPACE+8), %rsp |
|
| 166 | and $0x1f,%cl; |
191 | .endif |
| 167 | shl %cl,%eax; |
192 | .else |
| - | 193 | /* |
|
| - | 194 | * Version without error word, |
|
| - | 195 | */ |
|
| 168 | and $ERROR_WORD_INTERRUPT_LIST,%eax; |
196 | subq $(IREGISTER_SPACE+8), %rsp |
| 169 | jz 0f; |
197 | .endif |
| 170 | 198 | ||
| - | 199 | save_all_gpr |
|
| 171 | 200 | ||
| - | 201 | movq $(\i), %rdi # %rdi - first parameter |
|
| 172 | # Return with error word |
202 | movq %rsp, %rsi # %rsi - pointer to istate |
| - | 203 | call exc_dispatch # exc_dispatch(i, istate) |
|
| - | 204 | ||
| 173 | restore_all_gpr |
205 | restore_all_gpr |
| 174 | # $8 = Skip error word |
206 | # $8 = Skip error word |
| 175 | addq $IREGISTER_SPACE + 0x8, %rsp |
- | |
| 176 | iretq |
- | |
| 177 | - | ||
| 178 | 0: |
- | |
| 179 | # Return with no error word |
- | |
| 180 | restore_all_gpr |
- | |
| 181 | addq $IREGISTER_SPACE, %rsp |
207 | addq $(IREGISTER_SPACE+8), %rsp |
| 182 | iretq |
208 | iretq |
| 183 | 209 | ||
| 184 | .if (\n-\i)-1 |
210 | .if (\n-\i)-1 |
| 185 | handler "(\i+1)",\n |
211 | handler "(\i+1)",\n |
| 186 | .endif |
212 | .endif |