1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-15 20:19:23 +00:00

feat(core): record interrupts with systemview

[no changelog]
This commit is contained in:
cepetr 2024-10-15 16:48:26 +02:00 committed by cepetr
parent 2589d48c8b
commit a1ab50017d
5 changed files with 40 additions and 0 deletions

View File

@ -26,6 +26,7 @@
#include "i2c_bus.h"
#include "irq.h"
#include "mpu.h"
#include "systemview.h"
#include "systimer.h"
#ifdef KERNEL_MODE
@ -910,43 +911,55 @@ static void i2c_bus_er_handler(i2c_bus_t* bus) {
#ifdef I2C_INSTANCE_0
void I2C_INSTANCE_0_EV_IRQHandler(void) {
SEGGER_SYSVIEW_RecordEnterISR();
mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_DEFAULT);
i2c_bus_ev_handler(&g_i2c_bus_driver[0]);
mpu_restore(mpu_mode);
SEGGER_SYSVIEW_RecordExitISR();
}
void I2C_INSTANCE_0_ER_IRQHandler(void) {
SEGGER_SYSVIEW_RecordEnterISR();
mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_DEFAULT);
i2c_bus_er_handler(&g_i2c_bus_driver[0]);
mpu_restore(mpu_mode);
SEGGER_SYSVIEW_RecordExitISR();
}
#endif
#ifdef I2C_INSTANCE_1
void I2C_INSTANCE_1_EV_IRQHandler(void) {
SEGGER_SYSVIEW_RecordEnterISR();
mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_DEFAULT);
i2c_bus_ev_handler(&g_i2c_bus_driver[1]);
mpu_restore(mpu_mode);
SEGGER_SYSVIEW_RecordExitISR();
}
void I2C_INSTANCE_1_ER_IRQHandler(void) {
SEGGER_SYSVIEW_RecordEnterISR();
mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_DEFAULT);
i2c_bus_er_handler(&g_i2c_bus_driver[1]);
mpu_restore(mpu_mode);
SEGGER_SYSVIEW_RecordExitISR();
}
#endif
#ifdef I2C_INSTANCE_2
void I2C_INSTANCE_2_EV_IRQHandler(void) {
SEGGER_SYSVIEW_RecordEnterISR();
mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_DEFAULT);
i2c_bus_ev_handler(&g_i2c_bus_driver[2]);
mpu_restore(mpu_mode);
SEGGER_SYSVIEW_RecordExitISR();
}
void I2C_INSTANCE_2_ER_IRQHandler(void) {
SEGGER_SYSVIEW_RecordEnterISR();
mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_DEFAULT);
i2c_bus_er_handler(&g_i2c_bus_driver[2]);
mpu_restore(mpu_mode);
SEGGER_SYSVIEW_RecordExitISR();
}
#endif

View File

@ -29,6 +29,7 @@
#include "syscall.h"
#include "systask.h"
#include "system.h"
#include "systemview.h"
#ifdef KERNEL_MODE
@ -347,6 +348,8 @@ __attribute((no_stack_protector, used)) static uint32_t scheduler_pendsv(
uint32_t sp, uint32_t sp_lim, uint32_t exc_return) {
systask_scheduler_t* scheduler = &g_systask_scheduler;
SEGGER_SYSVIEW_RecordEnterISR();
// Save the current task context
systask_t* prev_task = scheduler->active_task;
prev_task->sp = sp;
@ -375,6 +378,8 @@ __attribute((no_stack_protector, used)) static uint32_t scheduler_pendsv(
// Setup the MPU for the new task
mpu_reconfig(next_task->mpu_mode);
SEGGER_SYSVIEW_RecordExitISR();
return (uint32_t)next_task;
}
@ -470,6 +475,8 @@ __attribute__((naked, no_stack_protector)) void PendSV_Handler(void) {
__attribute__((no_stack_protector, used)) static uint32_t svc_handler(
uint32_t* stack, uint32_t* msp, uint32_t exc_return, uint32_t r4,
uint32_t r5, uint32_t r6) {
SEGGER_SYSVIEW_RecordEnterISR();
uint8_t svc_number = ((uint8_t*)stack[6])[-2];
#ifdef SYSCALL_DISPATCH
@ -501,6 +508,7 @@ __attribute__((no_stack_protector, used)) static uint32_t svc_handler(
}
mpu_restore(mpu_mode);
SEGGER_SYSVIEW_RecordExitISR();
return exc_return;
}

View File

@ -33,6 +33,7 @@
#include "gfx_bitblt.h"
#include "irq.h"
#include "mpu.h"
#include "systemview.h"
#ifndef BOARDLOADER
#include "bg_copy.h"
@ -138,9 +139,11 @@ static void display_te_interrupt_handler(void) {
}
void DISPLAY_TE_INTERRUPT_HANDLER(void) {
SEGGER_SYSVIEW_RecordEnterISR();
mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_DEFAULT);
display_te_interrupt_handler();
mpu_restore(mpu_mode);
SEGGER_SYSVIEW_RecordExitISR();
}
#endif

View File

@ -1,6 +1,7 @@
#include "bg_copy.h"
#include "irq.h"
#include "mpu.h"
#include "systemview.h"
#include STM32_HAL_H
@ -36,6 +37,7 @@ void HAL_DMA_XferCpltCallback(DMA_HandleTypeDef *hdma) {
}
void GPDMA1_Channel0_IRQHandler(void) {
SEGGER_SYSVIEW_RecordEnterISR();
mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_DEFAULT);
if ((DMA_Handle.Instance->CSR & DMA_CSR_TCF) == 0) {
@ -60,6 +62,7 @@ void GPDMA1_Channel0_IRQHandler(void) {
}
mpu_restore(mpu_mode);
SEGGER_SYSVIEW_RecordExitISR();
}
bool bg_copy_pending(void) { return dma_transfer_remaining > 0; }

View File

@ -26,6 +26,7 @@
#include "i2c_bus.h"
#include "irq.h"
#include "mpu.h"
#include "systemview.h"
#include "systimer.h"
#ifdef KERNEL_MODE
@ -868,43 +869,55 @@ static void i2c_bus_er_handler(i2c_bus_t* bus) {
#ifdef I2C_INSTANCE_0
void I2C_INSTANCE_0_EV_IRQHandler(void) {
SEGGER_SYSVIEW_RecordEnterISR();
mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_DEFAULT);
i2c_bus_ev_handler(&g_i2c_bus_driver[0]);
mpu_restore(mpu_mode);
SEGGER_SYSVIEW_RecordExitISR();
}
void I2C_INSTANCE_0_ER_IRQHandler(void) {
SEGGER_SYSVIEW_RecordEnterISR();
mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_DEFAULT);
i2c_bus_er_handler(&g_i2c_bus_driver[0]);
mpu_restore(mpu_mode);
SEGGER_SYSVIEW_RecordExitISR();
}
#endif
#ifdef I2C_INSTANCE_1
void I2C_INSTANCE_1_EV_IRQHandler(void) {
SEGGER_SYSVIEW_RecordEnterISR();
mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_DEFAULT);
i2c_bus_ev_handler(&g_i2c_bus_driver[1]);
mpu_restore(mpu_mode);
SEGGER_SYSVIEW_RecordExitISR();
}
void I2C_INSTANCE_1_ER_IRQHandler(void) {
SEGGER_SYSVIEW_RecordEnterISR();
mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_DEFAULT);
i2c_bus_er_handler(&g_i2c_bus_driver[1]);
mpu_restore(mpu_mode);
SEGGER_SYSVIEW_RecordExitISR();
}
#endif
#ifdef I2C_INSTANCE_2
void I2C_INSTANCE_2_EV_IRQHandler(void) {
SEGGER_SYSVIEW_RecordEnterISR();
mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_DEFAULT);
i2c_bus_ev_handler(&g_i2c_bus_driver[2]);
mpu_restore(mpu_mode);
SEGGER_SYSVIEW_RecordExitISR();
}
void I2C_INSTANCE_2_ER_IRQHandler(void) {
SEGGER_SYSVIEW_RecordEnterISR();
mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_DEFAULT);
i2c_bus_er_handler(&g_i2c_bus_driver[2]);
mpu_restore(mpu_mode);
SEGGER_SYSVIEW_RecordExitISR();
}
#endif