1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-07-29 18:08:19 +00:00

feat(core): add pm_get_events syscall

[no changelog]
This commit is contained in:
tychovrahe 2025-05-03 08:29:38 +02:00 committed by kopecdav
parent 6e82c2415f
commit e3be94d599
5 changed files with 29 additions and 0 deletions

View File

@ -745,6 +745,11 @@ __attribute((no_stack_protector)) void syscall_handler(uint32_t *args,
pm_state_t *status = (pm_state_t *)args[0];
args[0] = pm_get_state__verified(status);
}
case SYSCALL_POWER_MANAGER_GET_EVENTS: {
pm_event_t *status = (pm_event_t *)args[0];
args[0] = pm_get_events__verified(status);
}
#endif
#ifdef USE_HW_JPEG_DECODER

View File

@ -152,6 +152,7 @@ typedef enum {
SYSCALL_POWER_MANAGER_SUSPEND,
SYSCALL_POWER_MANAGER_HIBERNATE,
SYSCALL_POWER_MANAGER_GET_STATE,
SYSCALL_POWER_MANAGER_GET_EVENTS,
SYSCALL_JPEGDEC_OPEN,
SYSCALL_JPEGDEC_CLOSE,

View File

@ -700,6 +700,11 @@ pm_status_t pm_get_status(pm_state_t *status) {
SYSCALL_POWER_MANAGER_GET_STATE);
}
bool pm_get_events(pm_event_t *events) {
return (bool)syscall_invoke1((uint32_t)events,
SYSCALL_POWER_MANAGER_GET_EVENTS);
}
#endif // USE_POWER_MANAGER
// =============================================================================

View File

@ -835,6 +835,22 @@ access_violation:
return PM_ERROR;
}
bool pm_get_events__verified(pm_event_t *event) {
if (!probe_write_access(event, sizeof(*event))) {
goto access_violation;
}
pm_event_t event_copy = {0};
bool retval = pm_get_events(&event_copy);
*event = event_copy;
return retval;
access_violation:
apptask_access_violation();
return false;
}
#endif
// ---------------------------------------------------------------------

View File

@ -215,6 +215,8 @@ secbool ble_read__verified(uint8_t *data, size_t len);
pm_status_t pm_get_state__verified(pm_state_t *status);
bool pm_get_events__verified(pm_event_t *event);
#endif
// ---------------------------------------------------------------------