www.national.com
92
Revision 1.2
Processor Programming (
Continued
)
G
3.9.3
A task
’
s CPL can be changed only through intersegment
control transfers using gates or task switches to a code
segment with a different privilege level. Control transfers
result from exception and interrupt servicing and from
execution of the CALL, JMP, INT, IRET and RET instruc-
tions.
Privilege Level Transfers
There are five types of control transfers that are summa-
rized in Table 3-37. Control transfers can be made only
when the operation causing the control transfer references
the correct descriptor type. Any violation of these descriptor
usage rules causes a general protection fault.
Any control transfer that changes the CPL within a task
results in a change of stack. The initial values for the stack
segment (SS) and stack pointer (ESP) for privilege levels
0, 1, and 2 are stored in the TSS. During a JMP or CALL
control transfer, the SS and ESP are loaded with the new
stack pointer and the previous stack pointer is saved on
the new stack. When returning to the original privilege
level, the RET or IRET instruction restores the SS and
ESP of the less-privileged stack.
Table 3-37. Descriptor Types Used for Control Transfer
Type of Control Transfer
Operation Types
Descriptor
Referenced
Descriptor
Table
Intersegment within the same privilege
level.
JMP, CALL, RET, IRET*
Code Segment
GDT or LDT
Intersegment to the same or a more
privileged level. Interrupt within task
(could change CPL level).
CALL
Gate Call
GDT or LDT
Interrupt Instruction, Exception,
External Interrupt
Trap or Interrupt Gate
IDT
Intersegment to a less privileged level
(changes task CPL).
RET, IRET*
Code Segment
GDT or LDT
Task Switch via TSS
CALL, JMP
Task State Segment
GDT
Task Switch via Task Gate
CALL, JMP
Task Gate
GDT or LDT
IRET**, Interrupt Instruction,
Exception, External Interrupt
Task Gate
IDT
Note:
*NT = 0 (Nested Task bit in EFLAGS, bit 14)
**NT =1 (Nested Task bit in EFLAGS, bit 14)