Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move some cortex-m specific code to arch/ #962

Merged
merged 3 commits into from May 26, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions arch/cortex-m/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions arch/cortex-m/Cargo.toml
@@ -0,0 +1,4 @@
[package]
name = "cortexm"
version = "0.1.0"
authors = ["Tock Project Developers <tock-dev@googlegroups.com>"]
8 changes: 8 additions & 0 deletions arch/cortex-m/src/lib.rs
@@ -0,0 +1,8 @@
//! Generic support for all Cortex-M platforms.

#![crate_name = "cortexm"]
#![crate_type = "rlib"]
#![feature(asm, const_fn, naked_functions, lang_items)]
#![no_std]

pub mod support;
File renamed without changes.
11 changes: 11 additions & 0 deletions arch/cortex-m0/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions arch/cortex-m0/Cargo.toml
Expand Up @@ -5,3 +5,4 @@ authors = ["Tock Project Developers <tock-dev@googlegroups.com>"]

[dependencies]
kernel = { path = "../../kernel" }
cortexm = { path = "../cortex-m" }
5 changes: 5 additions & 0 deletions arch/cortex-m0/src/lib.rs
@@ -1,10 +1,15 @@
#![feature(asm, const_fn, naked_functions)]
#![no_std]

extern crate cortexm;
extern crate kernel;

pub mod nvic;

pub mod support {
pub use cortexm::support::*;
}

#[cfg(not(target_os = "none"))]
pub unsafe extern "C" fn generic_isr() {}

Expand Down
11 changes: 11 additions & 0 deletions arch/cortex-m3/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions arch/cortex-m3/Cargo.toml
Expand Up @@ -5,3 +5,4 @@ authors = ["Tock Project Developers <tock-dev@googlegroups.com>"]

[dependencies]
kernel = { path = "../../kernel" }
cortexm = { path = "../cortex-m" }
5 changes: 5 additions & 0 deletions arch/cortex-m3/src/lib.rs
Expand Up @@ -3,12 +3,17 @@

#[allow(unused_imports)]
#[macro_use(debug, debug_gpio, register_bitfields, register_bitmasks)]
extern crate cortexm;
extern crate kernel;

pub mod nvic;
pub mod scb;
pub mod systick;

pub mod support {
pub use cortexm::support::*;
}

#[no_mangle]
#[naked]
pub unsafe extern "C" fn systick_handler() {
Expand Down
5 changes: 5 additions & 0 deletions arch/cortex-m4/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions arch/cortex-m4/Cargo.toml
Expand Up @@ -5,3 +5,4 @@ authors = ["Tock Project Developers <tock-dev@googlegroups.com>"]

[dependencies]
kernel = { path = "../../kernel" }
cortexm = { path = "../cortex-m" }
29 changes: 29 additions & 0 deletions arch/cortex-m4/src/lib.rs
Expand Up @@ -8,12 +8,19 @@
#[allow(unused_imports)]
#[macro_use(debug, debug_gpio, register_bitfields, register_bitmasks)]
extern crate kernel;
extern crate cortexm;

pub mod mpu;
pub mod nvic;
pub mod scb;
pub mod systick;

// Re-export the base generic cortex-m functions here as they are
// valid on cortex-m4.
pub mod support {
pub use cortexm::support::*;
}

#[cfg(not(target_os = "none"))]
pub unsafe extern "C" fn systick_handler() {}

Expand Down Expand Up @@ -171,3 +178,25 @@ pub unsafe extern "C" fn switch_to_user(
: "r4","r5","r6","r7","r8","r9","r10","r11");
user_stack as *mut u8
}

// Table 2.5
// http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0553a/CHDBIBGJ.html
pub fn ipsr_isr_number_to_str(isr_number: usize) -> &'static str {
match isr_number {
0 => "Thread Mode",
1 => "Reserved",
2 => "NMI",
3 => "HardFault",
4 => "MemManage",
5 => "BusFault",
6 => "UsageFault",
7...10 => "Reserved",
11 => "SVCall",
12 => "Reserved for Debug",
13 => "Reserved",
14 => "PendSV",
15 => "SysTick",
16...255 => "IRQn",
_ => "(Unknown! Illegal value?)",
}
}
5 changes: 5 additions & 0 deletions boards/ek-tm4c1294xl/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions boards/hail/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion boards/hail/src/main.rs
Expand Up @@ -12,6 +12,7 @@ extern crate capsules;
#[allow(unused_imports)]
#[macro_use(debug, debug_gpio, static_init)]
extern crate kernel;
extern crate cortexm4;
extern crate sam4l;

use capsules::virtual_alarm::{MuxAlarm, VirtualMuxAlarm};
Expand Down Expand Up @@ -466,7 +467,7 @@ pub unsafe fn reset_handler() {
sam4l::gpio::PA[17].clear();
// minimum hold time is 200ns, ~20ns per instruction, so overshoot a bit
for _ in 0..10 {
kernel::support::nop();
cortexm4::support::nop();
}
sam4l::gpio::PA[17].set();

Expand Down
5 changes: 5 additions & 0 deletions boards/imix/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion boards/imix/src/main.rs
Expand Up @@ -12,6 +12,7 @@ extern crate capsules;
#[allow(unused_imports)]
#[macro_use(debug, debug_gpio, static_init)]
extern crate kernel;
extern crate cortexm4;
extern crate sam4l;

use capsules::alarm::AlarmDriver;
Expand Down Expand Up @@ -627,7 +628,7 @@ pub unsafe fn reset_handler() {
sam4l::gpio::PB[07].clear();
// minimum hold time is 200ns, ~20ns per instruction, so overshoot a bit
for _ in 0..10 {
kernel::support::nop();
cortexm4::support::nop();
}
sam4l::gpio::PB[07].set();

Expand Down
5 changes: 5 additions & 0 deletions boards/launchxl/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions boards/nordic/nrf51dk/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions boards/nordic/nrf52840dk/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions boards/nordic/nrf52dk/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions boards/nordic/nrf52dk_base/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions chips/cc26x2/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions chips/cc26x2/src/chip.rs
Expand Up @@ -6,7 +6,6 @@ use cc26xx::rtc;
use cc26xx::uart;
use cortexm4::{self, nvic};
use kernel;
use kernel::support;

pub struct Cc26X2 {
mpu: cortexm4::mpu::MPU,
Expand Down Expand Up @@ -60,7 +59,14 @@ impl kernel::Chip for Cc26X2 {

fn sleep(&self) {
unsafe {
support::wfi();
cortexm4::support::wfi();
}
}

unsafe fn atomic<F, R>(&self, f: F) -> R
where
F: FnOnce() -> R,
{
cortexm4::support::atomic(f)
}
}
11 changes: 9 additions & 2 deletions chips/nrf51/src/chip.rs
@@ -1,7 +1,7 @@
use cortexm0;
use cortexm0::nvic;
use i2c;
use kernel;
use kernel::support;
use nrf5x;
use nrf5x::peripheral_interrupts::*;
use radio;
Expand Down Expand Up @@ -88,7 +88,14 @@ impl kernel::Chip for NRF51 {

fn sleep(&self) {
unsafe {
support::wfi();
cortexm0::support::wfi();
}
}

unsafe fn atomic<F, R>(&self, f: F) -> R
where
F: FnOnce() -> R,
{
cortexm0::support::atomic(f)
}
}