User:Johnburger/Demo/Ints/User
< User:Johnburger | Demo
Jump to navigation
Jump to search
To demonstrate one technique of allowing User Tasks to request functions from the Executve, I have added two INT
s:
- A
HLT
implementation, sinceHLT
is a Supervisor-only instruction, and User Mode code gets a GPF if it tries it; - A
Yield
implementation, allowing the User Mode code to give up the rest of its time-slice.
Note that these two functions are small, since they're essentially only calling functions that are already implemented. Also note that they're single-use INTs: I could have used a register as a Function holder, similar to the way that BIOS calls use AH
, but I've left that as an exercise for the reader!
Demo/Ints/User.inc
;
; Ints/User.inc
;
; This module demonstrates providing System Services to a User-mode program.
; The interrupts have been given a DPL of 3, to allow the User program access.
;...............................................................................
; HLT is a privileged instruction, since it can lock up the PC. But for demo
; purposes, an interrupt has been set up for the User program to call.
Ints.Halt:
HLT
IRETD ; That was easy!
;...............................................................................
; This interrupt does the same Task Switch that happens on the Timer call.
Ints.Yield:
CLI ; Disable interrupts!
PUSH EAX
CALL Ints.Switch
POP EAX
IRETD