it's a trap!

This commit is contained in:
julianb0 2019-07-09 20:02:36 +02:00
parent cc4b8724cd
commit 4d89b8656a
No known key found for this signature in database
GPG Key ID: DDF8325C95299A62
2 changed files with 14 additions and 18 deletions

View File

@ -2,23 +2,19 @@
; See the LICENSE file in the project root for more information. ; See the LICENSE file in the project root for more information.
TrapHandlers.prolog: TrapHandlers.prolog:
sub rsp, rbp, 56 sub rsp, rbp, 32
mov q[rbp-8], r10 mov q[rbp-8], r11
mov q[rbp-16], r11 mov q[rbp-16], r12
mov q[rbp-24], r12 mov q[rbp-24], r13
mov q[rbp-32], r13 cmp q[rsp], r13
mov q[rbp-40], r14 crash.z
mov q[rbp-48], r15
jmp rax ; go back jmp rax ; go back
TrapHandlers.epilog: TrapHandlers.epilog:
mov r10, q[rbp-8] mov r11, q[rbp-8]
mov r11, q[rbp-16] mov r12, q[rbp-16]
mov r12, q[rbp-24] mov r13, q[rbp-24]
mov r13, q[rbp-32]
mov r14, q[rbp-40]
mov r15, q[rbp-48]
mov ax0, r11 mov ax0, r11
call IDT.DoneHandling call IDT.DoneHandling

View File

@ -61,12 +61,12 @@ When called, a handler will receive the number of the E/I it is handling in R10,
and its own RFRAME ID in R11. (in particular, if exception #25 happens and there are no and its own RFRAME ID in R11. (in particular, if exception #25 happens and there are no
handler for it, the handler #0 that will be called will receive '25' in R10, and '0' in R11). handler for it, the handler #0 that will be called will receive '25' in R10, and '0' in R11).
R11 is the value that must be passed to the 'initdone' iocall. R11 is the value that must be passed to the 'initdone' iocall.
The handler will also receive the previous RFRAME ID in R12, the previous RIP in R15 and the The handler will also receive the previous RFRAME ID in R12.
previous RPC in R14. R13's content is meaningful only to the processor. R13 is also modified but its value is meaningful only to the processor.
To return from an E/I, *after* having called 'idtdone', the handler must simply restore To return from an E/I, *after* having called 'idtdone' (using the value originally in R11),
R10-R15's values to what they were when the handler started executing, and then use the handler must simply restore R12's and R13's values to what they were when the handler
the 'IRET' instruction. started executing, and then use the 'IRET' instruction.
Clearing the interrupt flag prevents (and queues) maskable hardware interrupts Clearing the interrupt flag prevents (and queues) maskable hardware interrupts