Skip to content
This repository was archived by the owner on Jan 24, 2022. It is now read-only.

Commit 2278a1f

Browse files
committed
document vector table symbols
1 parent cd0f4e2 commit 2278a1f

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

src/lib.rs

+23-5
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
//! - The memory layout of the program. In particular, it populates the vector table so the device
1111
//! can boot correctly, and properly dispatch exceptions and interrupts.
1212
//!
13-
//! - Initializing `static` variables before the user entry point.
13+
//! - Initializing `static` variables before the program entry point.
1414
//!
15-
//! - Enabling the FPU before the user entry point if the target is `thumbv7em-none-eabihf`.
15+
//! - Enabling the FPU before the program entry point if the target is `thumbv7em-none-eabihf`.
1616
//!
1717
//! This crate also provides a mechanism to set exception handlers: see the [`exception!`] macro.
1818
//!
@@ -215,6 +215,22 @@
215215
//! - `UserHardFault`. This is the user defined hard fault handler. This function will contain, or
216216
//! call, the function you declared in the second argument of `exception!(HardFault, ..)`
217217
//!
218+
//! - `__STACK_START`. This is the first entry in the `.vector_table` section. This symbol contains
219+
//! the initial value of the stack pointer; this is where the stack will be located -- the stack
220+
//! grows downwards towards smaller addresses.
221+
//!
222+
//! - `__RESET_VECTOR`. This is the reset vector, a pointer into the `Reset` handler. This vector is
223+
//! located in the `.vector_table` section after `__STACK_START`.
224+
//!
225+
//! - `__EXCEPTIONS`. This is the core exceptions portion of the vector table; it's an array of 14
226+
//! exception vectors, which includes exceptions like `HardFault` and `SysTick`. This array is
227+
//! located after `__RESET_VECTOR` in the `.vector_table` section.
228+
//!
229+
//! - `__EXCEPTIONS`. This is the device specific interrupt portion of the vector table; its exact
230+
//! size depends on the target device but if the `"device"` feature has not been enabled it will
231+
//! have a size of 32 vectors (on ARMv6-M) or 240 vectors (on ARMv7-M). This array is located after
232+
//! `__EXCEPTIONS` in the `.vector_table` section.
233+
//!
218234
//! If you override any exception handler you'll find it as an unmangled symbol, e.g. `SysTick` or
219235
//! `SVCall`, in the output of `objdump`,
220236
//!
@@ -669,6 +685,8 @@ pub static __INTERRUPTS: [unsafe extern "C" fn(); 32] = [{
669685
///
670686
/// (b) Only available on ARMv8-M
671687
///
688+
/// # Usage
689+
///
672690
/// `exception!(HardFault, ..)` sets the hard fault handler. The handler must have signature
673691
/// `fn(&ExceptionFrame) -> !`. This handler is not allowed to return as that can cause undefined
674692
/// behavior. It's mandatory to set the `HardFault` handler somewhere in the dependency graph of an
@@ -686,7 +704,7 @@ pub static __INTERRUPTS: [unsafe extern "C" fn(); 32] = [{
686704
///
687705
/// # Examples
688706
///
689-
/// Setting the `HardFault` handler
707+
/// - Setting the `HardFault` handler
690708
///
691709
/// ```
692710
/// #[macro_use(exception)]
@@ -704,7 +722,7 @@ pub static __INTERRUPTS: [unsafe extern "C" fn(); 32] = [{
704722
/// # fn main() {}
705723
/// ```
706724
///
707-
/// Setting the default handler
725+
/// - Setting the default handler
708726
///
709727
/// ```
710728
/// #[macro_use(exception)]
@@ -719,7 +737,7 @@ pub static __INTERRUPTS: [unsafe extern "C" fn(); 32] = [{
719737
/// # fn main() {}
720738
/// ```
721739
///
722-
/// Overriding the `SysTick` handler
740+
/// - Overriding the `SysTick` handler
723741
///
724742
/// ```
725743
/// #[macro_use(exception)]

0 commit comments

Comments
 (0)