uefi: Use FuUefiBgrt from the plugin code

This commit is contained in:
Richard Hughes 2018-06-23 20:12:03 +01:00
parent b1e0ab98d1
commit d7cdf9fb67

View File

@ -16,6 +16,7 @@
#include "fu-plugin.h" #include "fu-plugin.h"
#include "fu-plugin-vfuncs.h" #include "fu-plugin-vfuncs.h"
#include "fu-uefi-bgrt.h"
#include "fu-uefi-common.h" #include "fu-uefi-common.h"
#include "fu-uefi-device.h" #include "fu-uefi-device.h"
@ -31,6 +32,7 @@ struct FuPluginData {
gboolean ux_capsule; gboolean ux_capsule;
gchar *esp_path; gchar *esp_path;
gint esrt_status; gint esrt_status;
FuUefiBgrt *bgrt;
}; };
/* drop when upgrading minimum required version of efivar to 33 */ /* drop when upgrading minimum required version of efivar to 33 */
@ -47,6 +49,7 @@ fu_plugin_init (FuPlugin *plugin)
#endif #endif
data->ux_capsule = FALSE; data->ux_capsule = FALSE;
data->esp_path = NULL; data->esp_path = NULL;
data->bgrt = fu_uefi_bgrt_new ();
fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_RUN_AFTER, "upower"); fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_RUN_AFTER, "upower");
fu_plugin_add_compile_version (plugin, "com.redhat.fwupdate", LIBFWUP_LIBRARY_VERSION); fu_plugin_add_compile_version (plugin, "com.redhat.fwupdate", LIBFWUP_LIBRARY_VERSION);
fu_plugin_add_compile_version (plugin, "com.redhat.efivar", EFIVAR_LIBRARY_VERSION); fu_plugin_add_compile_version (plugin, "com.redhat.efivar", EFIVAR_LIBRARY_VERSION);
@ -61,6 +64,7 @@ fu_plugin_destroy (FuPlugin *plugin)
{ {
FuPluginData *data = fu_plugin_get_data (plugin); FuPluginData *data = fu_plugin_get_data (plugin);
g_free (data->esp_path); g_free (data->esp_path);
g_object_unref (data->bgrt);
} }
static gchar * static gchar *
@ -293,8 +297,9 @@ fu_plugin_uefi_get_splash_data (guint width, guint height, GError **error)
} }
static gboolean static gboolean
fu_plugin_uefi_update_splash (GError **error) fu_plugin_uefi_update_splash (FuPlugin *plugin, GError **error)
{ {
FuPluginData *data = fu_plugin_get_data (plugin);
fwup_resource *re = NULL; fwup_resource *re = NULL;
guint best_idx = G_MAXUINT; guint best_idx = G_MAXUINT;
guint32 lowest_border_pixels = G_MAXUINT; guint32 lowest_border_pixels = G_MAXUINT;
@ -319,6 +324,13 @@ fu_plugin_uefi_update_splash (GError **error)
}; };
/* get the boot graphics resource table data */ /* get the boot graphics resource table data */
if (!fu_uefi_bgrt_get_supported (data->bgrt)) {
g_set_error_literal (error,
FWUPD_ERROR,
FWUPD_ERROR_NOT_SUPPORTED,
"BGRT is not supported");
return FALSE;
}
rc = fwup_get_ux_capsule_info (&screen_width, &screen_height); rc = fwup_get_ux_capsule_info (&screen_width, &screen_height);
if (rc < 0) { if (rc < 0) {
g_set_error_literal (error, g_set_error_literal (error,
@ -327,7 +339,7 @@ fu_plugin_uefi_update_splash (GError **error)
"failed to get BGRT screen size"); "failed to get BGRT screen size");
return FALSE; return FALSE;
} }
g_debug ("BGRT screen size %" G_GUINT32_FORMAT " x%" G_GUINT32_FORMAT, g_debug ("framebuffer size %" G_GUINT32_FORMAT " x%" G_GUINT32_FORMAT,
screen_width, screen_height); screen_width, screen_height);
/* find the 'best sized' pre-generated image */ /* find the 'best sized' pre-generated image */
@ -444,7 +456,7 @@ fu_plugin_update (FuPlugin *plugin,
fu_device_set_status (device, FWUPD_STATUS_SCHEDULING); fu_device_set_status (device, FWUPD_STATUS_SCHEDULING);
if (data->ux_capsule) { if (data->ux_capsule) {
if (!fu_plugin_uefi_update_splash (&error_splash)) { if (!fu_plugin_uefi_update_splash (plugin, &error_splash)) {
g_warning ("failed to upload UEFI UX capsule text: %s", g_warning ("failed to upload UEFI UX capsule text: %s",
error_splash->message); error_splash->message);
} }
@ -772,9 +784,10 @@ fu_plugin_coldplug (FuPlugin *plugin, GError **error)
{ {
FuPluginData *data = fu_plugin_get_data (plugin); FuPluginData *data = fu_plugin_get_data (plugin);
fwup_resource *re; fwup_resource *re;
const gchar *str;
g_autoptr(GError) error_local = NULL;
g_autoptr(fwup_resource_iter) iter = NULL; g_autoptr(fwup_resource_iter) iter = NULL;
g_autofree gchar *name = NULL; g_autofree gchar *name = NULL;
const gchar *ux_capsule_str = "Disabled";
/* create a dummy device so we can unlock the feature */ /* create a dummy device so we can unlock the feature */
if (data->esrt_status == FWUP_SUPPORTED_STATUS_LOCKED_CAN_UNLOCK) { if (data->esrt_status == FWUP_SUPPORTED_STATUS_LOCKED_CAN_UNLOCK) {
@ -806,10 +819,11 @@ fu_plugin_coldplug (FuPlugin *plugin, GError **error)
/* for debugging problems later */ /* for debugging problems later */
fu_plugin_uefi_test_secure_boot (plugin); fu_plugin_uefi_test_secure_boot (plugin);
if (data->ux_capsule) if (!fu_uefi_bgrt_setup (data->bgrt, &error_local))
ux_capsule_str = "Enabled"; g_debug ("BGRT setup failed: %s", error_local->message);
g_debug ("UX Capsule support : %s", ux_capsule_str); str = fu_uefi_bgrt_get_supported (data->bgrt) ? "Enabled" : "Disabled";
fu_plugin_add_report_metadata (plugin, "UEFIUXCapsule", ux_capsule_str); g_debug ("UX Capsule support : %s", str);
fu_plugin_add_report_metadata (plugin, "UEFIUXCapsule", str);
return TRUE; return TRUE;
} }