1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-03-03 16:56:07 +00:00

refactor(core): use memset_reg in asm code only

[no changelog]
This commit is contained in:
cepetr 2025-01-29 21:34:20 +01:00 committed by cepetr
parent c30233b832
commit 2ecf335349
2 changed files with 5 additions and 11 deletions

View File

@ -45,13 +45,6 @@ void __attribute__((noreturn)) reboot_and_upgrade(const uint8_t hash[32]);
// unrecoverable error state. // unrecoverable error state.
void __attribute__((noreturn)) secure_shutdown(void); void __attribute__((noreturn)) secure_shutdown(void);
// Alternative memset with slightly different arguments
//
// This function writes a 32-bit value to a range of memory addresses.
// The range is defined by the start and stop pointers and must
// be aligned to 4 bytes.
void memset_reg(volatile void *start, volatile void *stop, uint32_t val);
// Jumps to the next booting stage (e.g. bootloader to firmware). // Jumps to the next booting stage (e.g. bootloader to firmware).
// `address` points to the flash at the vector table of the next stage. // `address` points to the flash at the vector table of the next stage.
// //

View File

@ -240,10 +240,11 @@ __attribute((used)) void clear_otg_hs_memory(void) {
__HAL_RCC_USB_OTG_HS_CLK_ENABLE(); // enable USB_OTG_HS peripheral clock so __HAL_RCC_USB_OTG_HS_CLK_ENABLE(); // enable USB_OTG_HS peripheral clock so
// that the peripheral memory is // that the peripheral memory is
// accessible // accessible
memset_reg( __IO uint32_t* usb_fifo_ram = (__IO uint32_t*)USB_OTG_HS_DATA_FIFO_RAM;
(volatile void *)USB_OTG_HS_DATA_FIFO_RAM,
(volatile void *)(USB_OTG_HS_DATA_FIFO_RAM + USB_OTG_HS_DATA_FIFO_SIZE), for (uint32_t i = 0; i < USB_OTG_HS_DATA_FIFO_SIZE / 4; i++) {
0); usb_fifo_ram[i] = 0;
}
__HAL_RCC_USB_OTG_HS_CLK_DISABLE(); // disable USB OTG_HS peripheral clock as __HAL_RCC_USB_OTG_HS_CLK_DISABLE(); // disable USB OTG_HS peripheral clock as
// the peripheral is not needed right now // the peripheral is not needed right now