User:Johnburger/Demo/Exec/Ints/BadStack

From OSDev Wiki
< User:Johnburger‎ | Demo
Revision as of 09:30, 29 August 2017 by No92 (talk | contribs) (Fix links to moved pages)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

There are two aspects of the Stack Fault handler: the installer, and the handler itself. The generic routines have been written, it's just a matter of calling them.

Note that when a Task does an IRET, it picks up again from the next instruction! I don't know about you, but it looks weird to me...

Demo/Exec/Ints/BadStack.inc

;
; Exec/Ints/BadStack.inc
;
; Ths module installs a Stack Fault handler. It's mostly a stub, leaving the
; hard work to the generic .Fault handler.
Exec.Ints.BadStack:
MOVEAX,IDT.BadStack; This is the IDT Entry
MOVEBX,Exec.LDT.BadStack; This is the LDT triple
MOVEDX,.Handler; This is the handler
CALLExec.Ints.Fault; Set it up
RET
.Handler:
; PUSH DWORD 0  ; Pseudo-fault code (not required)
PUSH12; Interrupt number
MOVEBX,Exec.LDT.BadStack.TSS; For TSS Backlink
CALLExec.Ints.Fault.Handler
ADDESP,8; Get rid of above
IRETD; Return, but resumes here, so...
JMP.Handler; ...go back for more
Retrieved from "https://wiki.osdev.org/index.php?title=User:Johnburger/Demo/Exec/Ints/BadStack&oldid=21440"