Skip to content
This repository was archived by the owner on Jan 24, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ r0 = "0.2.1"

[dependencies.cortex-m]
optional = true
version = "0.2.0"
version = "0.2.2"

[dependencies.cortex-m-semihosting]
optional = true
Expand All @@ -19,6 +19,9 @@ features = ["mem"]
git = "https://github.com/rust-lang-nursery/compiler-builtins"

[features]
default = ["exceptions"]
# handle exceptions using the default handler
exceptions = ["cortex-m"]
linker-script = []
panic-over-itm = ["cortex-m"]
panic-over-semihosting = ["cortex-m-semihosting"]
4 changes: 2 additions & 2 deletions link.x
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ SECTIONS
LONG(ORIGIN(RAM) + LENGTH(RAM));

KEEP(*(.rodata.reset_handler));
KEEP(*(.rodata._EXCEPTIONS));
KEEP(*(.rodata.exceptions));
__exceptions = .;

KEEP(*(.rodata._INTERRUPTS));
KEEP(*(.rodata.interrupts));
__interrupts = .;

*(.text.*);
Expand Down
19 changes: 13 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
#![feature(used)]
#![no_std]

#[cfg(feature = "panic-over-itm")]
#[macro_use]
#[cfg(any(feature = "panic-over-itm", feature = "exceptions"))]
#[cfg_attr(feature = "panic-over-itm", macro_use)]
extern crate cortex_m;
extern crate compiler_builtins;
#[cfg(feature = "panic-over-semihosting")]
Expand All @@ -45,6 +45,9 @@ extern crate r0;

mod lang_items;

#[cfg(feature = "exceptions")]
use cortex_m::exception;

/// The reset handler
///
/// This is the entry point of all programs
Expand All @@ -57,14 +60,10 @@ unsafe extern "C" fn reset_handler() -> ! {
static mut _sdata: u32;

static _sidata: u32;

static _init_array_start: extern "C" fn();
static _init_array_end: extern "C" fn();
}

::r0::zero_bss(&mut _sbss, &mut _ebss);
::r0::init_data(&mut _sdata, &mut _edata, &_sidata);
::r0::run_init_array(&_init_array_start, &_init_array_end);

// NOTE `rustc` forces this signature on us. See `src/lang_items.rs`
extern "C" {
Expand All @@ -86,3 +85,11 @@ unsafe extern "C" fn reset_handler() -> ! {
#[used]
#[link_section = ".rodata.reset_handler"]
static RESET_HANDLER: unsafe extern "C" fn() -> ! = reset_handler;

#[allow(dead_code)]
#[cfg(feature = "exceptions")]
#[link_section = ".rodata.exceptions"]
#[used]
static EXCEPTIONS: exception::Handlers = exception::Handlers {
..exception::DEFAULT_HANDLERS
};