Compile EDK2 to set boot order to PXE EFI_LOAD_OPTION
Werner,toggle quoted messageShow quoted text
From a UEFI Specification point of view the boot policy is controlled by NVRAM variables. The variables in EFI have a GUID/UUID and a Unicode string name. The variables owned by the UEFI Spec use the gEfiGlobalVariableGuid  namespace. The BootOrder variable is an array of UINT16 values that map into Boot##### variables. The ##### is the hex values of the BootOrder Entry. The Boot#### use an EFI_LOAD_OPTION  that contains an EFI_DEVICE_PATH_PROTOCOL. The EFI_DEVICE_PATH_PROTOCOL will point to the boot device and then a path for the file to boot.
The common way this works is an OS is installed on a system and the OS installer writes the nvram variable to point to the OS loader on the EFI System Partition. The Firmware BDS will carry some defaults (platform defined) and will typically default the variables based on some platform policy. The UI you launch from the BDS to boot likely will write the BootOrder (or reorder it) and add the Boot#### variables.
Also the old style PXE boot was more about telling the network what kind of device you are and the UUID and have the server send you back something useful. In this case the EFI_DEVICE_PATH_PROTOCOL is just going to point to the MAC address of the NIC. I think booting from files is more of an iPXE iSCSI kind of thing.
If you `git grep BootOrder` it looks like the ArmVirtPkg and OvmfPkg are doing work to set boot defaults that might be interesting for your work. The BootMaintenanceManagerUiLib is the UI to set the variables/boot policy.
Sorry this is just generic background and not the specific answer to your problem but the products I work on use a custom BDS so I don’t know the open source answer off the top of my mind. Maybe some one else will have a more specific answer.
Feel free to ask questions if you get stuck on specific bits of the solution like how to create the EFI_DEVICE_PATH_PROTOCOL.
 #define EFI_GLOBAL_VARIABLE \
 This is a variable sized structure that you may need to lookup in the UEFI Spec see 3.1.3 : https://uefi.org/sites/default/files/resources/UEFI%20Spec%202.8B%20May%202020.pdf
On Jan 29, 2021, at 2:45 PM, wernerbuck@... wrote: