2021-03-23 12:14:33 +00:00
|
|
|
#![cfg_attr(not(test), no_std)]
|
|
|
|
#![deny(clippy::all)]
|
2021-10-06 21:21:47 +00:00
|
|
|
#![allow(clippy::new_without_default)]
|
2021-03-23 12:14:33 +00:00
|
|
|
#![deny(unsafe_op_in_unsafe_fn)]
|
|
|
|
#![allow(dead_code)]
|
|
|
|
|
|
|
|
mod error;
|
2022-06-08 08:31:23 +00:00
|
|
|
#[cfg(feature = "micropython")]
|
2021-03-23 12:14:33 +00:00
|
|
|
#[macro_use]
|
|
|
|
mod micropython;
|
2022-06-08 08:31:23 +00:00
|
|
|
#[cfg(feature = "protobuf")]
|
2021-03-23 12:30:03 +00:00
|
|
|
mod protobuf;
|
2021-10-24 09:29:44 +00:00
|
|
|
mod time;
|
2021-06-08 11:29:03 +00:00
|
|
|
#[cfg(feature = "ui_debug")]
|
|
|
|
mod trace;
|
2021-03-23 12:14:33 +00:00
|
|
|
mod trezorhal;
|
2021-06-08 11:29:03 +00:00
|
|
|
|
|
|
|
#[cfg(feature = "ui")]
|
|
|
|
#[macro_use]
|
2022-02-11 14:01:29 +00:00
|
|
|
pub mod ui;
|
2021-03-23 12:14:33 +00:00
|
|
|
|
2022-02-11 14:01:29 +00:00
|
|
|
#[cfg(not(test))]
|
2022-05-10 13:03:20 +00:00
|
|
|
#[cfg(any(not(feature = "test"), feature = "clippy"))]
|
2021-03-23 12:14:33 +00:00
|
|
|
#[panic_handler]
|
2021-10-06 21:21:47 +00:00
|
|
|
fn panic(_info: &core::panic::PanicInfo) -> ! {
|
|
|
|
use cstr_core::CStr;
|
|
|
|
|
2021-03-23 12:14:33 +00:00
|
|
|
// Although it would be ideal to use the original error message, ignoring it
|
|
|
|
// lets us avoid the `fmt` machinery and its code size and is also important for
|
|
|
|
// security reasons, as we do not always controls the message contents. We
|
|
|
|
// should also avoid printing "panic" or "rust" on the user screen to avoid any
|
|
|
|
// confusion.
|
|
|
|
|
|
|
|
// SAFETY: Safe because we are passing in \0-terminated literals.
|
2021-06-08 11:29:03 +00:00
|
|
|
let empty = unsafe { CStr::from_bytes_with_nul_unchecked(b"\0") };
|
|
|
|
let msg = unsafe { CStr::from_bytes_with_nul_unchecked(b"rs\0") };
|
2021-03-23 12:14:33 +00:00
|
|
|
|
|
|
|
// TODO: Ideally we would take the file and line info out of
|
|
|
|
// `PanicInfo::location()`.
|
2021-09-22 16:15:40 +00:00
|
|
|
trezorhal::common::fatal_error(empty, msg, empty, 0, empty);
|
2021-03-23 12:14:33 +00:00
|
|
|
}
|