Page 1 of 1

UEFI GUID issue

Posted: Sun Jun 15, 2025 12:06 pm
by Rover
In the UEFI spec, the EFI_FILE_INFO_ID is defined as:

Code: Select all

#define EFI_FILE_INFO_ID {0x09576e92,0x6d3f,0x11d2,{0x8e39,0x00,0xa0,0xc9,0x69,0x72,0x3b}}
This causes an overflow warning with GCC and using it with GetInfo returns an EFI_UNSUPPORTED error.

Code: Select all

./Bootloader/SEFI/Headers/simpleFileSystemProtocol.h:7:53: warning: unsigned conversion from ‘int’ to ‘unsigned char’ changes value from ‘36409’ to ‘57’ [-Woverflow]
    7 | #define EFI_FILE_INFO_ID {0x09576e92,0x6d3f,0x11d2,{0x8e39,0x00,0xa0,0xc9,0x69,0x72,0x3b}}
      |                                                     ^~~~~~
./Bootloader/x86_64/file.c:22:23: note: in expansion of macro ‘EFI_FILE_INFO_ID’
   22 |     EFI_GUID ifGuid = EFI_FILE_INFO_ID;
   
~~~~~~~

From the log file:

Failed with err: 0x8000000000000003
Failed to get file info
I checked an older version of the spec, 2.8, and it's the same as the newest version.
However, if I change the define to:

Code: Select all

#define EFI_FILE_INFO_ID {0x09576e92,0x6d3f,0x11d2,{0x8e,0x39,0x00,0xa0,0xc9,0x69,0x72,0x3b}}
then I get no errors from the UEFI function or GCC.

Here's my code for getting file info

Code: Select all

EFI_STATUS getFileInfo(EFIFile *file){
    EFI_GUID ifGuid = EFI_FILE_INFO_ID;
    UINTN sz = 0;
    EFI_STATUS status = file->File->GetInfo(file->File,&ifGuid,&sz,NULL);
    if(status != EFI_BUFFER_TOO_SMALL){sprint(L"Failed with err: 0x%lx\n",status); return status;}
    file->Info = (EFI_FILE_INFO*)allocPool(sz);
    status = file->File->GetInfo(file->File,&ifGuid,&sz,file->Info);
    if(status != EFI_SUCCESS){freePool(file->Info); return status;}
    return EFI_SUCCESS;
}
I know the files are loading correctly since I can load my kernel just fine.

EFIFile is just a struct I made for convenience

Code: Select all

typedef struct EFIFile{
    uint16_t *name; //!< File name
    EFI_HANDLE image; //!< EFI image
    EFI_FILE_PROTOCOL *Volume; //!< EFI volume
    EFI_FILE_PROTOCOL *File; //!< File handle
    EFI_FILE_PROTOCOL *Directory; //!< EFI Directory
    EFI_FILE_INFO *Info; //!< File info
    uint64_t mode; //!< File mode
    uint64_t flags; //!< File flags
    EFI_LOADED_IMAGE_PROTOCOL *ldImg; //!< EFI protocol
    EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *io; //!< EFI protocol
}EFIFile;
Is this an error with the UEFI spec or is there something wrong with my code?
My UEFI headers are at https://github.com/Roverx64/SEFI
You can see my definitions for all UEFI structs and types on there as well.

The definition for the GUID is on page 486 (13.5. File Protocol) of the latest UEFI spec.

Re: UEFI GUID issue

Posted: Mon Jun 16, 2025 10:16 am
by Octocontrabass
Rover wrote: Sun Jun 15, 2025 12:06 pmIs this an error with the UEFI spec or is there something wrong with my code?
It's a typo in the UEFI spec. I've found several typos while writing my own UEFI headers.

Re: UEFI GUID issue

Posted: Mon Jun 16, 2025 12:58 pm
by Rover
Octocontrabass wrote: Mon Jun 16, 2025 10:16 am
Rover wrote: Sun Jun 15, 2025 12:06 pmIs this an error with the UEFI spec or is there something wrong with my code?
It's a typo in the UEFI spec. I've found several typos while writing my own UEFI headers.
Thank you!
I noticed a few other typos littered throughout the spec as well. I suppose next time I should check the linux headers to make sure I have the right definition.