UEFI LoadImage hangs

前端 未结 1 1081
深忆病人
深忆病人 2021-01-28 23:59

I am looking at using Bootservices function LoadImage to load a UEFI application image from memory. Function parameters are:

typedef
EFI_STATUS
LoadImage (
  IN         


        
1条回答
  •  说谎
    说谎 (楼主)
    2021-01-29 00:55

    Found my answer, sharing here for others:

    I based my original mempath off of the grub source:http://git.savannah.gnu.org/cgit/grub.git/tree/grub-core/loader/arm64/linux.c?id=7a210304ebfd6d704b4fc08fe496a0c417441879#n249

    I changed the type of end point to instance, the size field of the header. I properly exit the loop now. My original header had the size of the entire structure, so I believe when trying to iterate to the next endpoint it was winding up with an invalid one, instead of going to my correct second element. Here is what I used:

    mempath[0].Header.Type = HARDWARE_DEVICE_PATH;
    mempath[0].Header.SubType = HW_MEMMAP_DP;
    mempath[0].Header.Length[0] = (UINT8)sizeof(MEMMAP_DEVICE_PATH);
    mempath[0].Header.Length[1] = (UINT8)(sizeof(MEMMAP_DEVICE_PATH)>> 8);
    mempath[0].MemoryType = EfiLoaderCode;
    mempath[0].StartingAddress = (UINT32)buff_ptr;
    mempath[0].EndingAddress = (UINT32)(buff_ptr + SIZEOF_HELLO_EFI);
    
    mempath[1].Header.Type = END_DEVICE_PATH_TYPE;
    mempath[1].Header.SubType = END_INSTANCE_DEVICE_PATH_SUBTYPE;
    mempath[1].Header.Length[0] = (UINT8)sizeof(EFI_DEVICE_PATH);
    mempath[1].Header.Length[1] = (UINT8)(sizeof(EFI_DEVICE_PATH)>> 8);
    

    0 讨论(0)
提交回复
热议问题