BDS简单认识

1. BDS (Boot Device Select)

BDS 阶段负责加载额外的驱动,与用户交互,必要的硬件初始化,并转入操作系统。
DXE阶段最后会调用BDS.

下面是DxeMain.c的代码部分

//
  // Transfer control to the BDS Architectural Protocol
  //
  gBds->Entry (gBds);
  

2. 代码流程分析

BDS的入口在 MdeModulePkg/Universal/BdsDxe/BdsEntry.c下面
看下BDS怎么去加载对应的boot oder

/**

  Service routine for BdsInstance->Entry(). Devices are connected, the
  consoles are initialized, and the boot options are tried.

  @param This             Protocol Instance structure.

**/
VOID
EFIAPI
BdsEntry (
  IN EFI_BDS_ARCH_PROTOCOL  *This
  )
{ 
...代码省略
  EfiBootManagerBoot (bootmanager);
...代码省略
}

BIOS 去读定义在NVRAM 里面的boot order 列表,BootOrder 数组中每一项对应于已经添加的启动选项Boot,作为全局变量定义在NVRAM里面。
使用EfiBootManagerBoot这个函数

/**
  Attempt to boot the EFI boot option. This routine sets L"BootCurent" and
  also signals the EFI ready to boot event. If the device path for the option
  starts with a BBS device path a legacy boot is attempted via the registered
  gLegacyBoot function. Short form device paths are also supported via this
  rountine. A device path starting with MEDIA_HARDDRIVE_DP, MSG_USB_WWID_DP,
  MSG_USB_CLASS_DP gets expaned out to find the first device that matches.
  If the BootOption Device Path fails the removable media boot algorithm
  is attempted (\EFI\BOOTIA32.EFI, \EFI\BOOTX64.EFI,... only one file type
  is tried per processor type)

  @param  BootOption    Boot Option to try and boot.
                        On return, BootOption->Status contains the boot status.
                        EFI_SUCCESS     BootOption was booted
                        EFI_UNSUPPORTED A BBS device path was found with no valid callback
                                        registered via EfiBootManagerInitialize().
                        EFI_NOT_FOUND   The BootOption was not found on the system
                        !EFI_SUCCESS    BootOption failed with this error status

**/
VOID
EFIAPI
EfiBootManagerBoot (
  IN  EFI_BOOT_MANAGER_LOAD_OPTION             *BootOption
  )
{
...代码省略
   Status = gBS->LoadImage (...);
   Status = gBS->StartImage (...);
...代码省略
}

在EfiBootManagerBoot使用LoadImage去load loadimage,然后使用
StartImage去进行下一个阶段

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值