mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-07-05 06:12:34 +00:00
feat(core): reduce overhead of syscall invocation
[no changelog]
This commit is contained in:
parent
19ba854c69
commit
45417bf3bd
@ -17,12 +17,18 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Turning off the stack protector for this file improves
|
||||||
|
// the performance of drawing operations when called frequently.
|
||||||
|
#pragma GCC optimize("no-stack-protector")
|
||||||
|
|
||||||
#include <gfx/gfx_bitblt.h>
|
#include <gfx/gfx_bitblt.h>
|
||||||
|
|
||||||
#if USE_DMA2D
|
#if USE_DMA2D
|
||||||
#include <gfx/dma2d_bitblt.h>
|
#include <gfx/dma2d_bitblt.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
volatile uint64_t g_gfx_cycles;
|
||||||
|
|
||||||
void gfx_rgb565_fill(const gfx_bitblt_t* bb) {
|
void gfx_rgb565_fill(const gfx_bitblt_t* bb) {
|
||||||
#if defined(USE_DMA2D) && !defined(TREZOR_EMULATOR)
|
#if defined(USE_DMA2D) && !defined(TREZOR_EMULATOR)
|
||||||
if (!dma2d_rgb565_fill(bb))
|
if (!dma2d_rgb565_fill(bb))
|
||||||
|
@ -17,6 +17,10 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Turning off the stack protector for this file improves
|
||||||
|
// the performance of drawing operations when called frequently.
|
||||||
|
#pragma GCC optimize("no-stack-protector")
|
||||||
|
|
||||||
#ifdef KERNEL_MODE
|
#ifdef KERNEL_MODE
|
||||||
|
|
||||||
#include <trezor_bsp.h>
|
#include <trezor_bsp.h>
|
||||||
|
@ -17,6 +17,10 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Turning off the stack protector for this file significantly improves
|
||||||
|
// the performance of the syscall dispatching and interrupt handling.
|
||||||
|
#pragma GCC optimize("no-stack-protector")
|
||||||
|
|
||||||
#include <trezor_bsp.h>
|
#include <trezor_bsp.h>
|
||||||
#include <trezor_model.h>
|
#include <trezor_model.h>
|
||||||
#include <trezor_rtl.h>
|
#include <trezor_rtl.h>
|
||||||
@ -71,6 +75,19 @@ _Static_assert(NORCOW_SECTOR_SIZE == STORAGE_1_MAXSIZE, "norcow misconfigured");
|
|||||||
_Static_assert(NORCOW_SECTOR_SIZE == STORAGE_2_MAXSIZE, "norcow misconfigured");
|
_Static_assert(NORCOW_SECTOR_SIZE == STORAGE_2_MAXSIZE, "norcow misconfigured");
|
||||||
_Static_assert(NORCOW_SECTOR_SIZE == SIZE_64K, "norcow misconfigured");
|
_Static_assert(NORCOW_SECTOR_SIZE == SIZE_64K, "norcow misconfigured");
|
||||||
|
|
||||||
|
static inline void mpu_disable(void) {
|
||||||
|
__DMB();
|
||||||
|
SCB->SHCSR &= ~SCB_SHCSR_MEMFAULTENA_Msk;
|
||||||
|
MPU->CTRL = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void mpu_enable(void) {
|
||||||
|
MPU->CTRL = LL_MPU_CTRL_HARDFAULT_NMI | MPU_CTRL_ENABLE_Msk;
|
||||||
|
SCB->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk;
|
||||||
|
__DSB();
|
||||||
|
__ISB();
|
||||||
|
}
|
||||||
|
|
||||||
static void mpu_init_fixed_regions(void) {
|
static void mpu_init_fixed_regions(void) {
|
||||||
// Regions #0 to #4 are fixed for all targets
|
// Regions #0 to #4 are fixed for all targets
|
||||||
|
|
||||||
@ -178,7 +195,7 @@ void mpu_init(void) {
|
|||||||
|
|
||||||
irq_key_t irq_key = irq_lock();
|
irq_key_t irq_key = irq_lock();
|
||||||
|
|
||||||
HAL_MPU_Disable();
|
mpu_disable();
|
||||||
|
|
||||||
mpu_init_fixed_regions();
|
mpu_init_fixed_regions();
|
||||||
|
|
||||||
@ -235,7 +252,7 @@ mpu_mode_t mpu_reconfig(mpu_mode_t mode) {
|
|||||||
|
|
||||||
irq_key_t irq_key = irq_lock();
|
irq_key_t irq_key = irq_lock();
|
||||||
|
|
||||||
HAL_MPU_Disable();
|
mpu_disable();
|
||||||
|
|
||||||
// Region #5 and #6 are banked
|
// Region #5 and #6 are banked
|
||||||
|
|
||||||
@ -361,7 +378,7 @@ mpu_mode_t mpu_reconfig(mpu_mode_t mode) {
|
|||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
if (mode != MPU_MODE_DISABLED) {
|
if (mode != MPU_MODE_DISABLED) {
|
||||||
HAL_MPU_Enable(LL_MPU_CTRL_HARDFAULT_NMI);
|
mpu_enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
mpu_mode_t prev_mode = drv->mode;
|
mpu_mode_t prev_mode = drv->mode;
|
||||||
|
@ -17,6 +17,10 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Turning off the stack protector for this file significantly improves
|
||||||
|
// the performance of the syscall dispatching and interrupt handling.
|
||||||
|
#pragma GCC optimize("no-stack-protector")
|
||||||
|
|
||||||
#include <trezor_bsp.h>
|
#include <trezor_bsp.h>
|
||||||
#include <trezor_model.h>
|
#include <trezor_model.h>
|
||||||
#include <trezor_rtl.h>
|
#include <trezor_rtl.h>
|
||||||
@ -175,6 +179,19 @@ mpu_driver_t g_mpu_driver = {
|
|||||||
.mode = MPU_MODE_DISABLED,
|
.mode = MPU_MODE_DISABLED,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static inline void mpu_disable(void) {
|
||||||
|
__DMB();
|
||||||
|
SCB->SHCSR &= ~SCB_SHCSR_MEMFAULTENA_Msk;
|
||||||
|
MPU->CTRL = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void mpu_enable(void) {
|
||||||
|
MPU->CTRL = LL_MPU_CTRL_HARDFAULT_NMI | MPU_CTRL_ENABLE_Msk;
|
||||||
|
SCB->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk;
|
||||||
|
__DSB();
|
||||||
|
__ISB();
|
||||||
|
}
|
||||||
|
|
||||||
static void mpu_init_fixed_regions(void) {
|
static void mpu_init_fixed_regions(void) {
|
||||||
// Regions #0 to #5 are fixed for all targets
|
// Regions #0 to #5 are fixed for all targets
|
||||||
|
|
||||||
@ -240,7 +257,7 @@ void mpu_init(void) {
|
|||||||
|
|
||||||
irq_key_t irq_key = irq_lock();
|
irq_key_t irq_key = irq_lock();
|
||||||
|
|
||||||
HAL_MPU_Disable();
|
mpu_disable();
|
||||||
|
|
||||||
mpu_set_attributes();
|
mpu_set_attributes();
|
||||||
|
|
||||||
@ -308,7 +325,7 @@ mpu_mode_t mpu_reconfig(mpu_mode_t mode) {
|
|||||||
|
|
||||||
irq_key_t irq_key = irq_lock();
|
irq_key_t irq_key = irq_lock();
|
||||||
|
|
||||||
HAL_MPU_Disable();
|
mpu_disable();
|
||||||
|
|
||||||
// Region #5 is banked
|
// Region #5 is banked
|
||||||
|
|
||||||
@ -394,7 +411,7 @@ mpu_mode_t mpu_reconfig(mpu_mode_t mode) {
|
|||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
if (mode != MPU_MODE_DISABLED) {
|
if (mode != MPU_MODE_DISABLED) {
|
||||||
HAL_MPU_Enable(LL_MPU_CTRL_HARDFAULT_NMI);
|
mpu_enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
mpu_mode_t prev_mode = drv->mode;
|
mpu_mode_t prev_mode = drv->mode;
|
||||||
|
@ -17,6 +17,10 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Turning off the stack protector for this file improves
|
||||||
|
// the performance of syscall dispatching.
|
||||||
|
#pragma GCC optimize("no-stack-protector")
|
||||||
|
|
||||||
#include <trezor_model.h>
|
#include <trezor_model.h>
|
||||||
|
|
||||||
#include <sys/applet.h>
|
#include <sys/applet.h>
|
||||||
|
@ -17,6 +17,10 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Turning off the stack protector for this file improves
|
||||||
|
// the performance of syscall dispatching.
|
||||||
|
#pragma GCC optimize("no-stack-protector")
|
||||||
|
|
||||||
#include <trezor_rtl.h>
|
#include <trezor_rtl.h>
|
||||||
|
|
||||||
#include <sys/systask.h>
|
#include <sys/systask.h>
|
||||||
|
Loading…
Reference in New Issue
Block a user