UEFI Add Boot Option programmatically

♀尐吖头ヾ 提交于 2019-12-12 16:53:46

问题


How can i write code which add boot option from UEFI driver programmatically? 1) I try to add "Boot0001" variable:

  ZeroMem(Data, 2048);
  StrCpy(Data, L"Boot0001");
  DataSize = StrLen(Data) * 2;

  Status = gRT->SetVariable(L"Boot0001", &dGuid, Attr, DataSize, &Data);

2) I need add entry to "BootOrder" variable. But i can't understand how. Ideally, i want to add boot option boot from sample efi application.


回答1:


To add something to UEFI boot list:

  1. Create BootXXXX variable, it's format looks like this.
  2. Change BootOrder variable, adding newly created option somewhere in the list.

You can find a working code snippet in UEFI shell sources.




回答2:


How this works is described in the UEFI specification - available without payment from the UEFI Forum. The current version is 2.4B.

The BootOrder variable mechanism (among other things) is described in section 3.2 - Globally Defined Variables, but I'll give a brief summary.

It is an array of UINT16 elements in the order of the preferred boot order. The UINT16 value is the number portion of your Boot#### variable name. So to rank options Boot0001, Boot0002 and Boot0003 in reverse order of preference, your BootOrder variable should contain (hex, ignoring endianness) 000300020001.

It also needs to have Non-Volatile, Boot-services and Runtime-services attributes set (as described in table 11 in that chapter).



来源:https://stackoverflow.com/questions/25525590/uefi-add-boot-option-programmatically

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!