7.7 Boot Mode
Sometime, PEIMs need to determine the boot mode (e.g. S3, S5, normal boot, diagnostics, etc.) and take appropriate actions depending on it. For example, the VariablePei module will not install EFI ReadOnlyVariable2Ppi in the recovery boot path.
The Pei Service Table provides one pair of services to Set or Get the mode.
Accordingly, the Pei Service Library APIs are: SetBootMode() and GetBootMode().
The following is one example of how to get boot mode:
//
// Check if this is recovery boot path. If no, publish the variable
// access capability to other modules. If yes, the content of variable
// area is not reliable. Therefore, in this case we should not provide
// variable service to other pei modules.
//
Status = PeiServicesGetBootMode (&BootMode);
ASSERT_EFI_ERROR (Status);
if (BootMode == BOOT_IN_RECOVERY_MODE)
{
return EFI_UNSUPPORTED;
}
Status = PeiServicesInstallPpi (&mPpiListVariable);
Note:
The PI Specification lists all possible boot modes.