Printing serial number in qemu gives null
Posted: Wed May 29, 2024 3:14 am
Hi all, this is my first post in this forum. I am using gnu-efi and QEMU as an emulator. X64 is the arch and uefi is targeted.
I am trying to print the serial number but it gives null, so far the manufacturer and product name prints out fine.
Is there anything I am doing wrong?
I am trying to print the serial number but it gives null, so far the manufacturer and product name prints out fine.
Is there anything I am doing wrong?
Code: Select all
#include <efi.h>
#include <efilib.h>
EFI_STATUS
EFIAPI
efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
EFI_STATUS Status;
SMBIOS_STRUCTURE_POINTER Smbios;
SMBIOS_STRUCTURE_TABLE *SmbiosTable;
UINTN MaximumSize, ProcessedSize = 0;
UINT8 Found = 0, *Raw;
InitializeLib(ImageHandle, SystemTable);
Print(L"Hello!\n");
Status = LibGetSystemConfigurationTable(&SMBIOSTableGuid, (VOID **)&SmbiosTable);
if (Status == EFI_SUCCESS)
{
Print(L"yay!\n");
Smbios.Hdr = (SMBIOS_HEADER *)(UINTN)SmbiosTable->TableAddress;
MaximumSize = (UINTN)SmbiosTable->TableLength;
}
while ((Smbios.Hdr->Type != 0x7F) && (Found < 2))
{
Raw = Smbios.Raw;
if (Smbios.Hdr->Type == 1)
{
Print(L"%a, %a, %a \n", LibGetSmbiosString(&Smbios, Smbios.Type1->Manufacturer),
LibGetSmbiosString(&Smbios, Smbios.Type1->ProductName), LibGetSmbiosString(&Smbios, Smbios.Type1->SerialNumber));
Found++;
}
LibGetSmbiosString(&Smbios, -1);
ProcessedSize += (UINTN)Smbios.Raw - (UINTN)Raw;
if (ProcessedSize > MaximumSize)
{
Print(L"%EAborting system report due to noncompliant SMBIOS%N\n");
return EFI_ABORTED;
}
}
return EFI_SUCCESS;
}