mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-07-03 13:22:33 +00:00

Features `micropython` and `protobuf` are defined. Protobuf implies micropython because our protobuf impl is pretty much _for_ micropython. The respective subdirs are included only if the matching feature is defined. util.rs is moved to micropython because it mostly concerns micropython interop ResultExt, useful only for ui_debug, is moved to ui::util. A new module `trezorhal::time` is provided. It mirrors functionality of `micropython::time` via stmlib functions. The intended use is to always use functions from `trezorhal::time`. The right micropython variants are used when micropython is available, otherwise the pure stmlib versions are called. ui::*::layout is conditional for micropython feature, because it only concerns micropython layouts. If we want to reuse layouts defined there, we will need to export them to not depend on Objs and Qstrs etc.
42 lines
1.2 KiB
Rust
42 lines
1.2 KiB
Rust
#![cfg_attr(not(test), no_std)]
|
|
#![deny(clippy::all)]
|
|
#![allow(clippy::new_without_default)]
|
|
#![deny(unsafe_op_in_unsafe_fn)]
|
|
#![allow(dead_code)]
|
|
|
|
mod error;
|
|
#[cfg(feature = "micropython")]
|
|
#[macro_use]
|
|
mod micropython;
|
|
#[cfg(feature = "protobuf")]
|
|
mod protobuf;
|
|
mod time;
|
|
#[cfg(feature = "ui_debug")]
|
|
mod trace;
|
|
mod trezorhal;
|
|
|
|
#[cfg(feature = "ui")]
|
|
#[macro_use]
|
|
pub mod ui;
|
|
|
|
#[cfg(not(test))]
|
|
#[cfg(any(not(feature = "test"), feature = "clippy"))]
|
|
#[panic_handler]
|
|
fn panic(_info: &core::panic::PanicInfo) -> ! {
|
|
use cstr_core::CStr;
|
|
|
|
// 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.
|
|
let empty = unsafe { CStr::from_bytes_with_nul_unchecked(b"\0") };
|
|
let msg = unsafe { CStr::from_bytes_with_nul_unchecked(b"rs\0") };
|
|
|
|
// TODO: Ideally we would take the file and line info out of
|
|
// `PanicInfo::location()`.
|
|
trezorhal::common::fatal_error(empty, msg, empty, 0, empty);
|
|
}
|