refactor(core): move notify module to io layer
What changed, and why it matters
This commit is a pure code reorganization: it moves the 'notify' module from one directory to another and updates all references. No functionality was changed, no bugs were fixed, and no security behavior was altered.
No action needed; this is a benign refactor with no security relevance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change relocates the notify module from core/embed/sys/notify/ to core/embed/io/notify/, updating include paths from
Changed components
core/embed/io/notifycore/embed/sys/notifycore/embed/projects/bootloadercore/embed/projects/firmwarecore/embed/sys/syscall/stm32core/embed/upymod/modtrezorutilscore/site_scons/modelsInspect captured patch +168 / −168
diff --git a/core/embed/io/notify/inc/io/notify.h b/core/embed/io/notify/inc/io/notify.h
new file mode 100644
index 00000000..c074ec04
--- /dev/null
+++ b/core/embed/io/notify/inc/io/notify.h
@@ -0,0 +1,102 @@
+/*
+ * This file is part of the Trezor project, https://trezor.io/
+ *
+ * Copyright (c) SatoshiLabs
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * @file notify.h
+ * @brief Device-to-host push notification system
+ *
+ * This module provides functionality for sending push notifications from the
+ * Trezor device to a connected host. It allows the device to proactively
+ * communicate status changes, events, and other important information without
+ * waiting for host requests.
+ */
+
+#pragma once
+
+#include <trezor_types.h>
+
+/**
+ * @brief Enumeration of notification event types
+ *
+ * Defines the various types of events that can trigger push notifications
+ * from the device to the connected host.
+ */
+
+typedef enum {
+ NOTIFY_BOOT = 0, /**< Device boot/startup notification */
+ NOTIFY_UNLOCK = 1, /**< Device unlocked and ready to accept messages */
+ NOTIFY_LOCK = 2, /**< Device hard-locked and won't accept messages */
+ NOTIFY_DISCONNECT = 3, /**< User-initiated disconnect from host */
+ NOTIFY_SETTING_CHANGE = 4, /**< Change of settings */
+ NOTIFY_SOFTLOCK =
+ 5, /**< Device soft-locked (e.g., after clicking power button) */
+ NOTIFY_SOFTUNLOCK =
+ 6, /**< Device soft-unlocked (e.g., after successful pin entry) */
+ NOTIFY_PIN_CHANGE = 7, /**< Pin changed on the device */
+ NOTIFY_WIPE = 8, /**< Factory reset (wipe) invoked */
+ NOTIFY_UNPAIR = 9, /**< BLE bonding for current connection deleted */
+ NOTIFY_POWER_STATUS_CHANGE =
+ 10, /**< Power status changed, i.e. charging started */
+ // Additional notification types can be added here as needed
+} notification_event_t;
+
+/**
+ * @brief Notification data structure
+ *
+ * Contains the event type and associated flags/data that will be sent
+ * to the host as part of the push notification.
+ */
+typedef struct {
+ uint8_t version; /**< Version of the notification data structure */
+ uint8_t event; /**< Event type from notification_event_t enum */
+
+ /**
+ * @brief Event-specific flags and data
+ *
+ * Union allows for flexible data representation - can be accessed
+ * as structured flags or as a single byte value.
+ */
+ union {
+ /**
+ * @brief Structured flag representation
+ *
+ * Provides bit-level access to individual flags within the data byte.
+ */
+ struct {
+ uint8_t bootloader : 1; /**< Set if device is in bootloader mode */
+ uint8_t reserved : 7; /**< Reserved bits for future use */
+ } flags;
+
+ uint8_t all_flags; /**< Raw byte access to all flags */
+ } flags;
+
+} notification_data_t;
+
+/**
+ * @brief Send a push notification to the connected host
+ *
+ * Transmits a notification event to the host, allowing the device to
+ * proactively communicate status changes or important events.
+ *
+ * @param event The type of notification event to send
+ *
+ * @note This function handles the underlying communication protocol
+ * and data formatting automatically based on the event type.
+ */
+void notify_send(notification_event_t event);
diff --git a/core/embed/io/notify/notify.c b/core/embed/io/notify/notify.c
new file mode 100644
index 00000000..d5bbedae
--- /dev/null
+++ b/core/embed/io/notify/notify.c
@@ -0,0 +1,50 @@
+/*
+ * This file is part of the Trezor project, https://trezor.io/
+ *
+ * Copyright (c) SatoshiLabs
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef KERNEL_MODE
+
+#include <trezor_model.h>
+#include <trezor_rtl.h>
+
+#include <io/notify.h>
+
+#define NOTIFICATION_VERSION 1
+
+#ifdef USE_BLE
+#include <io/ble.h>
+#endif
+
+void notify_send(notification_event_t event) {
+ notification_data_t data = {0};
+
+ data.version = NOTIFICATION_VERSION;
+ data.event = event;
+
+#ifdef BOOTLOADER
+ data.flags.flags.bootloader = 1;
+#endif
+
+#ifdef USE_BLE
+ ble_notify((uint8_t*)&data, sizeof(data));
+#endif
+
+ (void)data;
+}
+
+#endif
diff --git a/core/embed/io/power_manager/stm32u5/power_monitoring.c b/core/embed/io/power_manager/stm32u5/power_monitoring.c
index f8040798..6f25960d 100644
--- a/core/embed/io/power_manager/stm32u5/power_monitoring.c
+++ b/core/embed/io/power_manager/stm32u5/power_monitoring.c
@@ -18,10 +18,10 @@
*/
#ifdef KERNEL_MODE
+#include <io/notify.h>
#include <io/pmic.h>
#include <sec/backup_ram.h>
#include <sys/irq.h>
-#include <sys/notify.h>
#include <sys/systick.h>
#include <trezor_rtl.h>
diff --git a/core/embed/projects/bootloader/main.c b/core/embed/projects/bootloader/main.c
index f34bd531..5bf68ea4 100644
--- a/core/embed/projects/bootloader/main.c
+++ b/core/embed/projects/bootloader/main.c
@@ -22,12 +22,12 @@
#include <io/display.h>
#include <io/display_utils.h>
+#include <io/notify.h>
#include <io/usb_config.h>
#include <sec/random_delays.h>
#include <sec/secret.h>
#include <sys/bootargs.h>
#include <sys/bootutils.h>
-#include <sys/notify.h>
#include <sys/system.h>
#include <sys/systick.h>
#include <sys/types.h>
diff --git a/core/embed/projects/bootloader/workflow/wf_auto_update.c b/core/embed/projects/bootloader/workflow/wf_auto_update.c
index bb1ca2b9..aea067dd 100644
--- a/core/embed/projects/bootloader/workflow/wf_auto_update.c
+++ b/core/embed/projects/bootloader/workflow/wf_auto_update.c
@@ -21,7 +21,7 @@
#include <trezor_model.h>
#include <trezor_rtl.h>
-#include <sys/notify.h>
+#include <io/notify.h>
#include <util/image.h>
#include "bootui.h"
diff --git a/core/embed/projects/bootloader/workflow/wf_bootloader.c b/core/embed/projects/bootloader/workflow/wf_bootloader.c
index 458c3919..b92c682d 100644
--- a/core/embed/projects/bootloader/workflow/wf_bootloader.c
+++ b/core/embed/projects/bootloader/workflow/wf_bootloader.c
@@ -20,7 +20,7 @@
#include <trezor_model.h>
#include <trezor_rtl.h>
-#include <sys/notify.h>
+#include <io/notify.h>
#include <sys/types.h>
#include <util/image.h>
diff --git a/core/embed/projects/bootloader/workflow/wf_empty_device.c b/core/embed/projects/bootloader/workflow/wf_empty_device.c
index 52e208ba..7d5704f6 100644
--- a/core/embed/projects/bootloader/workflow/wf_empty_device.c
+++ b/core/embed/projects/bootloader/workflow/wf_empty_device.c
@@ -20,7 +20,7 @@
#include <trezor_model.h>
#include <trezor_rtl.h>
-#include <sys/notify.h>
+#include <io/notify.h>
#include <sys/systick.h>
#include <sys/types.h>
#include <util/flash_utils.h>
diff --git a/core/embed/projects/bootloader/workflow/wf_wipe_device.c b/core/embed/projects/bootloader/workflow/wf_wipe_device.c
index d806162e..d367d4ca 100644
--- a/core/embed/projects/bootloader/workflow/wf_wipe_device.c
+++ b/core/embed/projects/bootloader/workflow/wf_wipe_device.c
@@ -20,7 +20,7 @@
#include <trezor_model.h>
#include <trezor_rtl.h>
-#include <sys/notify.h>
+#include <io/notify.h>
#include <util/flash_utils.h>
#ifdef USE_BLE
diff --git a/core/embed/projects/firmware/main.c b/core/embed/projects/firmware/main.c
index 293c3dee..3e4dcfcc 100644
--- a/core/embed/projects/firmware/main.c
+++ b/core/embed/projects/firmware/main.c
@@ -34,9 +34,9 @@
#include "ports/stm32/pendsv.h"
#include <io/display.h>
+#include <io/notify.h>
#include <sys/linker_utils.h>
#include <sys/logging.h>
-#include <sys/notify.h>
#include <sys/systask.h>
#include <sys/system.h>
#include <util/boot_image.h>
diff --git a/core/embed/sys/notify/inc/sys/notify.h b/core/embed/sys/notify/inc/sys/notify.h
deleted file mode 100644
index c074ec04..00000000
--- a/core/embed/sys/notify/inc/sys/notify.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * This file is part of the Trezor project, https://trezor.io/
- *
- * Copyright (c) SatoshiLabs
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/**
- * @file notify.h
- * @brief Device-to-host push notification system
- *
- * This module provides functionality for sending push notifications from the
- * Trezor device to a connected host. It allows the device to proactively
- * communicate status changes, events, and other important information without
- * waiting for host requests.
- */
-
-#pragma once
-
-#include <trezor_types.h>
-
-/**
- * @brief Enumeration of notification event types
- *
- * Defines the various types of events that can trigger push notifications
- * from the device to the connected host.
- */
-
-typedef enum {
- NOTIFY_BOOT = 0, /**< Device boot/startup notification */
- NOTIFY_UNLOCK = 1, /**< Device unlocked and ready to accept messages */
- NOTIFY_LOCK = 2, /**< Device hard-locked and won't accept messages */
- NOTIFY_DISCONNECT = 3, /**< User-initiated disconnect from host */
- NOTIFY_SETTING_CHANGE = 4, /**< Change of settings */
- NOTIFY_SOFTLOCK =
- 5, /**< Device soft-locked (e.g., after clicking power button) */
- NOTIFY_SOFTUNLOCK =
- 6, /**< Device soft-unlocked (e.g., after successful pin entry) */
- NOTIFY_PIN_CHANGE = 7, /**< Pin changed on the device */
- NOTIFY_WIPE = 8, /**< Factory reset (wipe) invoked */
- NOTIFY_UNPAIR = 9, /**< BLE bonding for current connection deleted */
- NOTIFY_POWER_STATUS_CHANGE =
- 10, /**< Power status changed, i.e. charging started */
- // Additional notification types can be added here as needed
-} notification_event_t;
-
-/**
- * @brief Notification data structure
- *
- * Contains the event type and associated flags/data that will be sent
- * to the host as part of the push notification.
- */
-typedef struct {
- uint8_t version; /**< Version of the notification data structure */
- uint8_t event; /**< Event type from notification_event_t enum */
-
- /**
- * @brief Event-specific flags and data
- *
- * Union allows for flexible data representation - can be accessed
- * as structured flags or as a single byte value.
- */
- union {
- /**
- * @brief Structured flag representation
- *
- * Provides bit-level access to individual flags within the data byte.
- */
- struct {
- uint8_t bootloader : 1; /**< Set if device is in bootloader mode */
- uint8_t reserved : 7; /**< Reserved bits for future use */
- } flags;
-
- uint8_t all_flags; /**< Raw byte access to all flags */
- } flags;
-
-} notification_data_t;
-
-/**
- * @brief Send a push notification to the connected host
- *
- * Transmits a notification event to the host, allowing the device to
- * proactively communicate status changes or important events.
- *
- * @param event The type of notification event to send
- *
- * @note This function handles the underlying communication protocol
- * and data formatting automatically based on the event type.
- */
-void notify_send(notification_event_t event);
diff --git a/core/embed/sys/notify/notify.c b/core/embed/sys/notify/notify.c
deleted file mode 100644
index 2aca7d2a..00000000
--- a/core/embed/sys/notify/notify.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * This file is part of the Trezor project, https://trezor.io/
- *
- * Copyright (c) SatoshiLabs
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifdef KERNEL_MODE
-
-#include <trezor_model.h>
-#include <trezor_rtl.h>
-
-#include <sys/notify.h>
-
-#define NOTIFICATION_VERSION 1
-
-#ifdef USE_BLE
-#include <io/ble.h>
-#endif
-
-void notify_send(notification_event_t event) {
- notification_data_t data = {0};
-
- data.version = NOTIFICATION_VERSION;
- data.event = event;
-
-#ifdef BOOTLOADER
- data.flags.flags.bootloader = 1;
-#endif
-
-#ifdef USE_BLE
- ble_notify((uint8_t*)&data, sizeof(data));
-#endif
-
- (void)data;
-}
-
-#endif
diff --git a/core/embed/sys/syscall/stm32/syscall_dispatch.c b/core/embed/sys/syscall/stm32/syscall_dispatch.c
index 7e7bc222..3095c5ea 100644
--- a/core/embed/sys/syscall/stm32/syscall_dispatch.c
+++ b/core/embed/sys/syscall/stm32/syscall_dispatch.c
@@ -25,13 +25,13 @@
#include <gfx/dma2d_bitblt.h>
#include <io/display.h>
+#include <io/notify.h>
#include <io/usb.h>
#include <sec/rng_strong.h>
#include <sec/secret.h>
#include <sec/secret_keys.h>
#include <sys/bootutils.h>
#include <sys/irq.h>
-#include <sys/notify.h>
#include <sys/sysevent.h>
#include <sys/systask.h>
#include <sys/system.h>
diff --git a/core/embed/sys/syscall/stm32/syscall_stubs.c b/core/embed/sys/syscall/stm32/syscall_stubs.c
index ea0ffc33..fbf1a269 100644
--- a/core/embed/sys/syscall/stm32/syscall_stubs.c
+++ b/core/embed/sys/syscall/stm32/syscall_stubs.c
@@ -181,7 +181,7 @@ void reboot_device(void) {
// notify.h
// =============================================================================
-#include <sys/notify.h>
+#include <io/notify.h>
void notify_send(notification_event_t event) {
syscall_invoke1((uint32_t)event, SYSCALL_NOTIFY_SEND);
diff --git a/core/embed/upymod/modtrezorutils/modtrezorutils.c b/core/embed/upymod/modtrezorutils/modtrezorutils.c
index d91f31c0..789eb317 100644
--- a/core/embed/upymod/modtrezorutils/modtrezorutils.c
+++ b/core/embed/upymod/modtrezorutils/modtrezorutils.c
@@ -37,9 +37,9 @@
#include <io/usb.h>
#include <sys/logging.h>
+#include <io/notify.h>
#include <sec/secret_keys.h>
#include <sys/bootutils.h>
-#include <sys/notify.h>
#include <util/fwutils.h>
#include <util/scm_revision.h>
#include <util/unit_properties.h>
diff --git a/core/site_scons/models/stm32f4_common.py b/core/site_scons/models/stm32f4_common.py
index 9c081614..54d0e4ec 100644
--- a/core/site_scons/models/stm32f4_common.py
+++ b/core/site_scons/models/stm32f4_common.py
@@ -11,6 +11,7 @@ def stm32f4_common_files(env, features_wanted, defines, sources, paths):
]
paths += [
+ "embed/io/notify/inc",
"embed/sec/monoctr/inc",
"embed/sec/random_delays/inc",
"embed/sec/rng/inc",
@@ -21,7 +22,6 @@ def stm32f4_common_files(env, features_wanted, defines, sources, paths):
"embed/sys/irq/inc",
"embed/sys/linker/inc",
"embed/sys/mpu/inc",
- "embed/sys/notify/inc",
"embed/sys/pvd/inc",
"embed/sys/rng/inc",
"embed/sec/secret/inc",
@@ -66,6 +66,7 @@ def stm32f4_common_files(env, features_wanted, defines, sources, paths):
]
sources += [
+ "embed/io/notify/notify.c",
"embed/sec/monoctr/stm32f4/monoctr.c",
"embed/sec/random_delays/stm32/random_delays.c",
"embed/sec/rng/rng_strong.c",
@@ -77,7 +78,6 @@ def stm32f4_common_files(env, features_wanted, defines, sources, paths):
"embed/sys/irq/stm32/irq.c",
"embed/sys/linker/linker_utils.c",
"embed/sys/mpu/stm32f4/mpu.c",
- "embed/sys/notify/notify.c",
"embed/sys/pvd/stm32/pvd.c",
"embed/sys/rng/stm32/rng.c",
"embed/sys/stack/stm32/stack_utils.c",
diff --git a/core/site_scons/models/stm32u5_common.py b/core/site_scons/models/stm32u5_common.py
index 7dc3560b..85672265 100644
--- a/core/site_scons/models/stm32u5_common.py
+++ b/core/site_scons/models/stm32u5_common.py
@@ -11,6 +11,7 @@ def stm32u5_common_files(env, features_wanted, defines, sources, paths):
]
paths += [
+ "embed/io/notify/inc",
"embed/sec/hash_processor/inc",
"embed/sec/monoctr/inc",
"embed/sec/random_delays/inc",
@@ -24,7 +25,6 @@ def stm32u5_common_files(env, features_wanted, defines, sources, paths):
"embed/sys/irq/inc",
"embed/sys/linker/inc",
"embed/sys/mpu/inc",
- "embed/sys/notify/inc",
"embed/sys/pvd/inc",
"embed/sys/rng/inc",
"embed/sys/stack/inc",
@@ -88,6 +88,7 @@ def stm32u5_common_files(env, features_wanted, defines, sources, paths):
]
sources += [
+ "embed/io/notify/notify.c",
"embed/sec/hash_processor/stm32u5/hash_processor.c",
"embed/sec/monoctr/stm32u5/monoctr.c",
"embed/sec/random_delays/stm32/random_delays.c",
@@ -103,7 +104,6 @@ def stm32u5_common_files(env, features_wanted, defines, sources, paths):
"embed/sys/irq/stm32/irq.c",
"embed/sys/linker/linker_utils.c",
"embed/sys/mpu/stm32u5/mpu.c",
- "embed/sys/notify/notify.c",
"embed/sys/pvd/stm32/pvd.c",
"embed/sys/rng/stm32/rng.c",
"embed/sys/smcall/stm32/smcall_dispatch.c",
diff --git a/core/site_scons/models/unix_common.py b/core/site_scons/models/unix_common.py
index f0eecbfd..32ff222d 100644
--- a/core/site_scons/models/unix_common.py
+++ b/core/site_scons/models/unix_common.py
@@ -10,6 +10,7 @@ def unix_common_files(env, features_wanted, defines, sources, paths):
]
paths += [
+ "embed/io/notify/inc",
"embed/io/display/inc",
"embed/sec/random_delays/inc",
"embed/sec/time_estimate/inc",
@@ -20,7 +21,6 @@ def unix_common_files(env, features_wanted, defines, sources, paths):
"embed/sec/secret/inc",
"embed/sys/irq/inc",
"embed/sys/mpu/inc",
- "embed/sys/notify/inc",
"embed/sys/rng/inc",
"embed/sys/startup/inc",
"embed/sys/task/inc",
@@ -34,6 +34,7 @@ def unix_common_files(env, features_wanted, defines, sources, paths):
sources += [
"embed/io/display/unix/display_driver.c",
+ "embed/io/notify/notify.c",
"embed/io/usb/unix/sock.c",
"embed/sec/random_delays/unix/random_delays.c",
"embed/sec/secret/unix/secret.c",
@@ -44,7 +45,6 @@ def unix_common_files(env, features_wanted, defines, sources, paths):
"embed/sec/rng/rng_strong.c",
"embed/sec/time_estimate/unix/time_estimate.c",
"embed/sys/mpu/unix/mpu.c",
- "embed/sys/notify/notify.c",
"embed/sys/rng/unix/rng.c",
"embed/sys/startup/unix/bootutils.c",
"embed/sys/task/sysevent.c",
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.