MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / CompileBootOption

Function CompileBootOption

rEFIt_UEFI/Platform/BootOptions.cpp:627–680  ·  view source on GitHub ↗

Compiles boot option params set in BootOption to valid BootXXXX var content (BootOption->Variable). * BootOption fields Attributes, FilePathListLength, FilePathList, Description, OptionalData * and OptionalDataSize must be set. */

Source from the content-addressed store, hash-verified

625 * and OptionalDataSize must be set.
626 */
627EFI_STATUS
628CompileBootOption (
629 BO_BOOT_OPTION *BootOption
630 )
631{
632 UINT8 *Ptr8;
633
634
635 if (BootOption->Description == NULL ||
636 BootOption->FilePathList == NULL ||
637 BootOption->FilePathListLength == 0 ||
638 (BootOption->OptionalData != NULL && BootOption->OptionalDataSize == 0)
639 ) {
640 DBG("CompileBootOption: invalid input params\n");
641 return EFI_INVALID_PARAMETER;
642 }
643
644 BootOption->DescriptionSize = StrSize(BootOption->Description);
645 BootOption->VariableSize = sizeof(BootOption->Attributes) //UINT32
646 + sizeof(BootOption->FilePathListLength) //UINT16
647 + BootOption->DescriptionSize
648 + BootOption->FilePathListLength
649 + BootOption->OptionalDataSize;
650 BootOption->Variable = (__typeof__(BootOption->Variable))AllocateZeroPool(BootOption->VariableSize);
651 if (BootOption->Variable == NULL) {
652 DBG("CompileBootOption: EFI_OUT_OF_RESOURCES\n");
653 return EFI_OUT_OF_RESOURCES;
654 }
655 Ptr8 = (UINT8*)BootOption->Variable;
656
657 // Attributes
658 *((UINT32*)Ptr8) = BootOption->Attributes;
659 Ptr8 += sizeof(BootOption->Attributes);
660
661 // FilePathListLength;
662 *((UINT16*)Ptr8) = BootOption->FilePathListLength;
663 Ptr8 += sizeof(BootOption->FilePathListLength);
664
665 // Description
666 CopyMem((CHAR16*)Ptr8, BootOption->Description, BootOption->DescriptionSize);
667 Ptr8 += BootOption->DescriptionSize;
668
669 // FilePathList
670 CopyMem(Ptr8, BootOption->FilePathList, BootOption->FilePathListLength);
671 Ptr8 += BootOption->FilePathListLength;
672
673 // OptionalData
674 if (BootOption->OptionalDataSize > 0) {
675 CopyMem(Ptr8, BootOption->OptionalData, BootOption->OptionalDataSize);
676// Ptr8 += BootOption->OptionalDataSize;
677 }
678
679 return EFI_SUCCESS;
680}
681
682
683/** Reads BootXXXX (XXXX = BootNum) var, parses it and returns in BootOption.

Callers 1

AddBootOptionFunction · 0.85

Calls 3

StrSizeFunction · 0.50
AllocateZeroPoolFunction · 0.50
CopyMemFunction · 0.50

Tested by

no test coverage detected