drivers/platform/x86/intel/wmi/sbl-fw-update.c
Source file repositories/reference/linux-study-clean/drivers/platform/x86/intel/wmi/sbl-fw-update.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/platform/x86/intel/wmi/sbl-fw-update.c- Extension
.c- Size
- 3222 bytes
- Lines
- 129
- Domain
- Driver Families
- Bucket
- drivers/platform
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/device.hlinux/module.hlinux/slab.hlinux/sysfs.hlinux/wmi.h
Detected Declarations
function Bootloaderfunction set_fwu_requestfunction firmware_update_request_showfunction firmware_update_request_storefunction intel_wmi_sbl_fw_update_probefunction intel_wmi_sbl_fw_update_remove
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Slim Bootloader(SBL) firmware update signaling driver
*
* Slim Bootloader is a small, open-source, non UEFI compliant, boot firmware
* optimized for running on certain Intel platforms.
*
* SBL exposes an ACPI-WMI device via /sys/bus/wmi/devices/<INTEL_WMI_SBL_GUID>.
* This driver further adds "firmware_update_request" device attribute.
* This attribute normally has a value of 0 and userspace can signal SBL
* to update firmware, on next reboot, by writing a value of 1.
*
* More details of SBL firmware update process is available at:
* https://slimbootloader.github.io/security/firmware-update.html
*/
#include <linux/device.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/sysfs.h>
#include <linux/wmi.h>
#define INTEL_WMI_SBL_GUID "44FADEB1-B204-40F2-8581-394BBDC1B651"
static int get_fwu_request(struct device *dev, u32 *out)
{
struct wmi_buffer buffer;
__le32 *result;
int ret;
ret = wmidev_query_block(to_wmi_device(dev), 0, &buffer, sizeof(*result));
if (ret < 0)
return ret;
result = buffer.data;
*out = le32_to_cpu(*result);
kfree(result);
return 0;
}
static int set_fwu_request(struct device *dev, u32 in)
{
__le32 value = cpu_to_le32(in);
struct wmi_buffer buffer = {
.length = sizeof(value),
.data = &value,
};
return wmidev_set_block(to_wmi_device(dev), 0, &buffer);
}
static ssize_t firmware_update_request_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
u32 val;
int ret;
ret = get_fwu_request(dev, &val);
if (ret)
return ret;
return sprintf(buf, "%d\n", val);
}
static ssize_t firmware_update_request_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
unsigned int val;
int ret;
ret = kstrtouint(buf, 0, &val);
if (ret)
return ret;
/* May later be extended to support values other than 0 and 1 */
if (val > 1)
return -ERANGE;
ret = set_fwu_request(dev, val);
if (ret)
return ret;
return count;
}
static DEVICE_ATTR_RW(firmware_update_request);
static struct attribute *firmware_update_attrs[] = {
Annotation
- Immediate include surface: `linux/device.h`, `linux/module.h`, `linux/slab.h`, `linux/sysfs.h`, `linux/wmi.h`.
- Detected declarations: `function Bootloader`, `function set_fwu_request`, `function firmware_update_request_show`, `function firmware_update_request_store`, `function intel_wmi_sbl_fw_update_probe`, `function intel_wmi_sbl_fw_update_remove`.
- Atlas domain: Driver Families / drivers/platform.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.