aboutsummaryrefslogtreecommitdiff
path: root/crates/qemu/src/lib.rs
blob: dc914653e4086e500d04e4e767465f947c5d8b1f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#![no_std]

use cortex_m_rt as _;
use lm3s6965 as _;

use rust_threadx_cortex_m as _;
use rust_threadx_stdio_semihosting as _;

pub fn exit_success() -> ! {
    use cortex_m_semihosting::debug::*;
    exit(EXIT_SUCCESS);
    unreachable!()
}

// Designed for ARMv6-M. Just enough to get the example
// running in QEMU with a meaningless system tick.
#[unsafe(no_mangle)]
pub extern "C" fn _tx_initialize_low_level() {
    use cortex_m::{Peripherals, peripheral::scb::SystemHandler};

    cortex_m::interrupt::disable();

    let Peripherals {
        mut SYST, mut SCB, ..
    } = Peripherals::take().unwrap();

    SYST.set_reload(80000 - 1);
    SYST.clear_current();
    SYST.enable_interrupt();
    SYST.enable_counter();

    unsafe {
        SCB.set_priority(SystemHandler::SysTick, 0x40);
        SCB.set_priority(SystemHandler::PendSV, 0xff);
        SCB.set_priority(SystemHandler::SVCall, 0xff);
    }
}