Commit 9270d850 authored by Astro's avatar Astro
Browse files

Merge branch 'panic' into 'master'

sys: write panic message to uart

See merge request !23
parents b7885881 5b7757dd
Pipeline #4507 failed with stage
in 12 minutes and 27 seconds
......@@ -89,7 +89,6 @@ version = "1.10.0"
dependencies = [
"bindgen 0.52.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)",
"panic-abort 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"r0 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
......@@ -252,11 +251,6 @@ dependencies = [
"version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "panic-abort"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "peeking_take_while"
version = "0.1.2"
......@@ -441,7 +435,6 @@ dependencies = [
"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7"
"checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e"
"checksum nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6"
"checksum panic-abort 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4e20e6499bbbc412f280b04a42346b356c6fa0753d5fd22b7bd752ff34c778ee"
"checksum peeking_take_while 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
"checksum proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9c9e470a8dc4aeae2dee2f335e8f533e2d4b347e1434e5671afc49b054592f27"
"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0"
......
......@@ -30,5 +30,5 @@ macro_rules! println {
#[doc(hidden)]
pub fn _print(args: core::fmt::Arguments) {
crate::UART.write_fmt(args);
crate::UART.write_fmt(args).ok();
}
......@@ -52,7 +52,6 @@ exclude = [
]
[dependencies]
panic-abort = "^0.3"
r0 = "^0.2"
[build-dependencies]
......
......@@ -5,8 +5,45 @@
#![allow(non_camel_case_types)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![feature(core_intrinsics)]
#![feature(panic_info_message)]
use panic_abort as _;
use core::fmt::Write;
use core::intrinsics;
use core::panic::PanicInfo;
pub struct Uart;
impl Write for Uart {
fn write_str(&mut self, s: &str) -> core::fmt::Result {
unsafe {
epic_uart_write_str(s.as_ptr(), s.len());
}
Ok(())
}
}
#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
write!(Uart, "panicked").ok();
if let Some(message) = info.message() {
write!(Uart, " at '{}'", message).ok();
}
if let Some(location) = info.location() {
write!(
Uart,
", {}:{}:{}",
location.file(),
location.line(),
location.column()
)
.ok();
}
writeln!(Uart, "\r").ok();
unsafe { intrinsics::abort() }
}
global_asm!(include_str!(concat!(env!("OUT_DIR"), "/crt.s")));
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment