
2-77
2
PRELIMINARY
System Management Mode
System Management Mode
2-77
Saving the CPU State
The programmer must save the value of any
registers that may be changed by the SMI service
routine. For data accesses immediately after
entering the SMI service routine, the programmer
must use CS as a segment override. I/O port
access is possible during the routine but care must
be taken to save registers modified by the I/O
instructions. Before using a segment register, the
register and the register’s descriptor cache contents
should be saved using the SVDC instruction.
While executing in the SMM space, execution flow
can transfer to normal memory locations.
Program Execution
Hardware interrupts, (INTRs and NMIs), may
be serviced during a SMI service routine. If
interrupts are to be serviced while executing in
the SMM memory space, the SMM memory
space must be within the 0 to 1 MByte address
range to guarantee proper return to the SMI
service routine after handling the interrupt.
INTRs are automatically disabled when entering
SMM since the IF flag is set to its reset value.
Once in SMM, the INTR can be enabled by
setting the IF flag. NMI is also automatically
disable when entering SMM. Once in SMM,
NMI can be enabled by setting NMI_EN in
CCR3. If NMI is not enabled, the CPU latches
one NMI event and services the interrupt after
NMI has been enabled or after exiting SMM
through the RSM instruction.
Within the SMI service routine, protected mode
may be entered and exited as required, and real
or protected mode device drivers may be
called.
Exiting SMM
To exit the SMI service routine, a Resume
(RSM) instruction, rather than an IRET, is
executed. The RSM instruction causes the M II
processor to restore the CPU state using the
SMM header information and resume execution
at the interrupted point. If the full CPU state
was saved by the programmer, the stored values
should be reloaded prior to executing the RSM
instruction using the MOV, RSDC, RSLDT and
RSTS instructions.
When the RSM instruction is executed at the
end of the SMI handler, the EIP instruction
pointer is automatically read from the NEXT IP
field in the SMM header.
When restarting I/O instructions, the value of
NEXT IP may need modification. Before
executing the RSM instruction, use a MOV
instruction to move the CURRENT IP value to
the NEXT IP location as the CURRENT IP value
is valid if an I/O instruction was executing when
the SMI interrupt occurred. Execution is then
returned to the I/O instruction, rather than to
the instruction after the I/O instruction.
A set H bit in the SMM header indicates that a
HLT instruction was being executed when the
SMI occurred. To resume execution of the HLT
instruction, the NEXT IP field in the SMM
header should be decremented by one before
executing RSM instruction.