efi: app: Detect running under QEMU
When the app is running under QEMU we may wish to do some things differently. Add a flag for this and use the SMBIOS tables to detect it. Co-developed-by: Claude <noreply@anthropic.com> Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include <image.h>
|
||||
#include <init.h>
|
||||
#include <malloc.h>
|
||||
#include <smbios.h>
|
||||
#include <sysreset.h>
|
||||
#include <u-boot/uuid.h>
|
||||
#include <asm/global_data.h>
|
||||
@@ -179,6 +180,27 @@ static void scan_tables(struct efi_system_table *sys_table)
|
||||
}
|
||||
}
|
||||
|
||||
static bool detect_emulator(void)
|
||||
{
|
||||
struct smbios_info info;
|
||||
struct smbios_type1 *t1;
|
||||
const char *manufacturer;
|
||||
|
||||
/* Check if running in QEMU by looking at SMBIOS manufacturer */
|
||||
if (!smbios_locate(gd_smbios_start(), &info)) {
|
||||
t1 = (void *)smbios_get_header(&info,
|
||||
SMBIOS_SYSTEM_INFORMATION);
|
||||
if (t1) {
|
||||
manufacturer = smbios_get_string(&t1->hdr,
|
||||
t1->manufacturer);
|
||||
if (manufacturer && !strcmp(manufacturer, "QEMU"))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void find_protocols(struct efi_priv *priv)
|
||||
{
|
||||
efi_guid_t guid = EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID;
|
||||
@@ -415,7 +437,8 @@ efi_status_t EFIAPI efi_main(efi_handle_t image,
|
||||
|
||||
printf("starting\n");
|
||||
|
||||
board_init_f(GD_FLG_SKIP_RELOC);
|
||||
board_init_f(GD_FLG_SKIP_RELOC |
|
||||
(detect_emulator() ? GD_FLG_EMUL : 0));
|
||||
gd = gd->new_gd;
|
||||
board_init_r(NULL, 0);
|
||||
free_memory(priv);
|
||||
|
||||
Reference in New Issue
Block a user