Boot Mode

From PhoenixWiki

Jump to: navigation, search

The Boot Mode is the reason why the platform started execution at the CPU reset vector. From the perspective of BIOS firmware, the platform’s life begins by executing code at the CPU reset vector. The CPU reset vector is a memory location 16 bytes below 4GB. There are several reasons why the system might start executing code at this location. In the Tiano and PI architectures, these reasons are called Boot Modes. Here’s the standard list:

See Also: Boot Mode Related Topics

Boot Mode Description
BOOT_WITH_FULL_CONFIGURATION After system power-on, configure all standard devices, making no assumptions about what changes might have been made.
BOOT_WITH_MINIMAL_CONFIGURATION After system power-on, configure the minimum number of devices, making no assumptions about what changes might have been made.
BOOT_ASSUMING_NO_CONFIGURATION_CHANGES After system power-on, configure all devices the same way they were during the last known-good boot, assuming that no changes have been made.
BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS After system power-on, configure all standard devices, making no assumptions about what changes might have been made and perform extended diagnostics.
BOOT_WITH_DEFAULT_SETTINGS After system power-on, configure all devices using the default settings.
BOOT_ON_S4_RESUME The system was awakened from an S4 (Hibernate) power-state by a wake event.
BOOT_ON_S5_RESUME The system was awakened from an S5 (Power-Off) power-state by a wake event other than the normal power button.
BOOT_ON_S2_RESUME The system was awakened from an S2 (Standby) power-state by a wake event.
BOOT_ON_S3_RESUME The system was awakened from an S3 (Suspend) power-state by a wake event.
BOOT_ON_FLASH_UPDATE The system was awakened from some other power-state to update the system BOS flash device.
BOOT_IN_RECOVERY_MODE The system was awakened from some other power-state, but a crisis recovery condition (such as corrupt flash or a jumper) was detected.

Now, for those of you familiar with the PC architecture, there seem to be some missing, including the famous warm-reset (0x1234 anybody?) software jump to the reset vector and the CPU-only reset (used for core-logic bus adjustments). In general, these other reasons are coerced into one of the above values.

Some of the listed Boot Modes are easy to detect because there are standard hardware registers on most ACPI-compliant systems which provide the information. But some of the Boot Modes (such as the various power-on modes) require special platform knowledge to distinguish between them. That is why it is the responsibility of one of the early PEI drivers to finalize the boot mode and install the EFI_PEI_MASTER_BOOT_MODE_PEIM_PPI. Also, if the Boot Mode is BOOT_IN_RECOVERY_MODE, the platform driver is also responsible to install the EFI_PEI_BOOT_IN_RECOVERY_MODE_PEIM_PPI.

Reading The Boot Mode In PEI

The PEI Services Table provides the GetBootMode() function to determine the current boot mode. The catch is that the value returned from this function is only guaranteed to be valid after the EFI_PEI_MASTER_BOOT_MODE_PEIM_PPI has been installed. The easiest way to make sure that this is true is to add this PPI into the Dependency Expression (.dxs) file. For example:

#include "EfiDepex.h"

#include EFI_PPI_DEFINITION (CpuIo)
#include EFI_PPI_DEFINITION (PciCfg) 
#include EFI_PPI_DEFINITION (SmbusPolicy)
#include EFI_PPI_DEFINITION (Stall)
#include EFI_PPI_DEFINITION (BootMode)

DEPENDENCY_START
  PEI_CPU_IO_PPI_GUID AND 
  PEI_PCI_CFG_PPI_GUID AND
  PEI_SMBUS_POLICY_PPI_GUID AND
  PEI_STALL_PPI_GUID AND
  PEI_MASTER_BOOT_MODE_PEIM_PPI
DEPENDENCY_END

If you don’t want to wait until the PPI is installed, then the PEI driver can receive notification, using the NotifyPpi() PEI service. For example:

EFI_STATUS
EFIAPI
MasterBootModeDetected (
  IN EFI_PEI_SERVICES **PeiServices,
  IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
  IN VOID *Ppi
  )
{
   ...my callback code...
}

EFI_PEI_NOTIFY_DESCRIPTOR NotifyDescriptor = {
  EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
   &gPeiMasterBootModePpiGuid,
   MasterBootModeDetected
};

Status = (**PeiServices).NotifyPpi(PeiServices, &NotifyDescriptor);


Reading The Boot Mode In DXE

It is possible to determine the boot mode during the DXE phase. The PEI Foundation stores the Boot Mode in the PHIT HOB. The PHIT HOB is always the first HOB in the HOB List. A pointer to the start of the HOB List is installed in the EFI System Configuration Table by the DXE Dispatcher using the EFI_HOB_LIST_GUID. The following code fragrment shows how to retrieve it using the EDK library function EfiLibGetSystemConfigurationTable():

extern EFI_GUID gEfiHobListGuid;

EFI_STATUS Status;
EFI_HOB_HANDOFF_INFO_TABLE *PhitHob; 
EFI_BOOT_MODE BootMode;

Status = EfiLibGetSystemConfigurationTable(
          &gEfiHobListGuid, 
          (VOID**) &PhitHob);
ASSERT_EFI_ERROR(Status);

ASSERT(GET_HOB_TYPE(PhitHob) == EFI_HOB_TYPE_HANDOFF);
BootMode = PhitHob->BootMode;

Copyright (C) 2009-2010 Phoenix Technologies Ltd. All Rights Reserved.

Personal tools