fwupd/plugins/thunderbolt/fu-thunderbolt-image.h
Richard Hughes 86b79fb039 Speed up fwupd startup by loading less thunderbolt firmware
We load the Thunderbolt controller firmware to see if the controller is in
native mode, as this changes the GUID. If the controller is asleep the firmware
is not cached by the kernel and it can take more than 4 seconds to read out
504kB of firmware.

We only need the first two 64-byte chunks, so only read what is required.
This speeds up fwupd starting substantially, and also means we don't have to
allocate a giant chunk of heap memory just to inspect one byte.

Fixes: https://github.com/hughsie/fwupd/issues/848
2018-11-14 16:21:52 +00:00

31 lines
686 B
C

/*
* Copyright (C) 2017 Intel Corporation.
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#ifndef __FU_THUNDERBOLT_IMAGE_H__
#define __FU_THUNDERBOLT_IMAGE_H__
#include <glib.h>
typedef enum {
VALIDATION_PASSED,
VALIDATION_FAILED,
UNKNOWN_DEVICE,
} FuPluginValidation;
/* byte offsets in firmware image */
#define FU_TBT_OFFSET_NATIVE 0x7B
#define FU_TBT_CHUNK_SZ 0x40
FuPluginValidation fu_thunderbolt_image_validate (GBytes *controller_fw,
GBytes *blob_fw,
GError **error);
gboolean fu_thunderbolt_image_controller_is_native (GBytes *controller_fw,
gboolean *is_native,
GError **error);
#endif /* __FU_THUNDERBOLT_IMAGE_H__ */