From: Tilman Sauerbeck Date: Sat, 16 Nov 2019 12:16:39 +0000 (+0100) Subject: bootloader: Sanitize global interrupt handling. X-Git-Url: http://git.code-monkey.de/?a=commitdiff_plain;ds=sidebyside;h=2e15e18237f50ba61acc861a4bd23560d973e943;p=gps-watch.git bootloader: Sanitize global interrupt handling. We now disable interrupts before jumping to application, as overwriting the VTOR with interrupts enabled is rather risky. Also don't assume that interrupts are enabled when the bootloader is run -- enable them explicitly when we need them. --- diff --git a/src/bootloader/main.rs b/src/bootloader/main.rs index ca459fd..afd28dc 100644 --- a/src/bootloader/main.rs +++ b/src/bootloader/main.rs @@ -40,6 +40,9 @@ use common::usb_serial; type Reg32 = register::Register; extern { + fn enable_interrupts(); + fn disable_interrupts(); + fn jump_to_application(address: u32); } @@ -84,6 +87,8 @@ pub unsafe extern fn main() { port::set_af(port::PORTE, 24, 1); port::set_pull(port::PORTE, 24, port::Pull::Up); + enable_interrupts(); + if application_missing() || bootloader_requested() { usb_serial::init(0xf055, USB_PID); @@ -95,5 +100,7 @@ pub unsafe extern fn main() { usb_serial::shutdown(); } + disable_interrupts(); + jump_to_application(APPLICATION_ADDR); }