mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-23 21:02:23 +00:00
feat(core/rust): use MODEL_FULL_NAME from build system
[no changelog]
This commit is contained in:
parent
d913181079
commit
193a53f22b
@ -84,6 +84,7 @@ fn prepare_bindings() -> bindgen::Builder {
|
||||
"-I../../vendor/micropython/lib/uzlib",
|
||||
"-I../lib",
|
||||
"-I../trezorhal",
|
||||
"-I../models",
|
||||
format!("-D{}", mcu_type()).as_str(),
|
||||
format!("-DTREZOR_MODEL_{}", model()).as_str(),
|
||||
format!("-DTREZOR_BOARD=\"{}\"", board()).as_str(),
|
||||
@ -259,6 +260,9 @@ fn generate_trezorhal_bindings() {
|
||||
|
||||
let bindings = prepare_bindings()
|
||||
.header("trezorhal.h")
|
||||
// model
|
||||
.allowlist_var("MODEL_INTERNAL_NAME")
|
||||
.allowlist_var("MODEL_FULL_NAME")
|
||||
// common
|
||||
.allowlist_var("HW_ENTROPY_DATA")
|
||||
// secbool
|
||||
|
@ -8,6 +8,7 @@ pub mod display;
|
||||
pub mod dma2d;
|
||||
mod ffi;
|
||||
pub mod io;
|
||||
pub mod model;
|
||||
pub mod random;
|
||||
#[cfg(feature = "rgb_led")]
|
||||
pub mod rgb_led;
|
||||
|
14
core/embed/rust/src/trezorhal/model.rs
Normal file
14
core/embed/rust/src/trezorhal/model.rs
Normal file
@ -0,0 +1,14 @@
|
||||
use super::ffi::{MODEL_FULL_NAME, MODEL_INTERNAL_NAME};
|
||||
|
||||
// TODO: get bindgen to do this for us more safely
|
||||
// https://github.com/rust-lang/rust-bindgen/issues/1401
|
||||
|
||||
const unsafe fn ascii_const_to_str_unchecked(s: &[u8]) -> &str {
|
||||
unsafe {
|
||||
let strip_nul = core::slice::from_raw_parts(s.as_ptr(), s.len() - 1);
|
||||
core::str::from_utf8_unchecked(strip_nul)
|
||||
}
|
||||
}
|
||||
|
||||
pub const FULL_NAME: &str = unsafe { ascii_const_to_str_unchecked(MODEL_FULL_NAME) };
|
||||
pub const INTERNAL_NAME: &str = unsafe { ascii_const_to_str_unchecked(MODEL_INTERNAL_NAME) };
|
@ -11,8 +11,6 @@ pub const LOADER_OUTER: i16 = 32;
|
||||
pub const LOADER_INNER: i16 = 18;
|
||||
pub const LOADER_ICON_MAX_SIZE: i16 = 8;
|
||||
|
||||
pub const MODEL_NAME: &str = "Trezor Model R";
|
||||
|
||||
pub const fn size() -> Offset {
|
||||
Offset::new(WIDTH, HEIGHT)
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ use crate::{
|
||||
util,
|
||||
},
|
||||
strutil::StringType,
|
||||
trezorhal::model,
|
||||
ui::{
|
||||
component::{
|
||||
base::Component,
|
||||
@ -1548,7 +1549,7 @@ extern "C" fn new_show_homescreen(n_args: usize, args: *const Obj, kwargs: *mut
|
||||
let label: StrBuffer = kwargs
|
||||
.get(Qstr::MP_QSTR_label)?
|
||||
.try_into_option()?
|
||||
.unwrap_or_else(|| constant::MODEL_NAME.into());
|
||||
.unwrap_or_else(|| model::FULL_NAME.into());
|
||||
let notification: Option<StrBuffer> =
|
||||
kwargs.get(Qstr::MP_QSTR_notification)?.try_into_option()?;
|
||||
let notification_level: u8 = kwargs.get_or(Qstr::MP_QSTR_notification_level, 0)?;
|
||||
@ -1569,7 +1570,7 @@ extern "C" fn new_show_lockscreen(n_args: usize, args: *const Obj, kwargs: *mut
|
||||
let label: StrBuffer = kwargs
|
||||
.get(Qstr::MP_QSTR_label)?
|
||||
.try_into_option()?
|
||||
.unwrap_or_else(|| constant::MODEL_NAME.into());
|
||||
.unwrap_or_else(|| model::FULL_NAME.into());
|
||||
let bootscreen: bool = kwargs.get(Qstr::MP_QSTR_bootscreen)?.try_into()?;
|
||||
let skip_first_paint: bool = kwargs.get(Qstr::MP_QSTR_skip_first_paint)?.try_into()?;
|
||||
|
||||
|
@ -11,7 +11,7 @@ const ICON_TOP_MARGIN: i16 = 48;
|
||||
#[cfg(not(feature = "bootloader"))]
|
||||
const MODEL_NAME_FONT: display::Font = display::Font::DEMIBOLD;
|
||||
#[cfg(not(feature = "bootloader"))]
|
||||
use crate::ui::{constant::MODEL_NAME, display};
|
||||
use crate::{trezorhal::model, ui::display};
|
||||
|
||||
pub struct WelcomeScreen {
|
||||
area: Rect,
|
||||
@ -54,7 +54,7 @@ impl Component for WelcomeScreen {
|
||||
#[cfg(not(feature = "bootloader"))]
|
||||
display::text_center(
|
||||
self.area.bottom_center() - Offset::y(TEXT_BOTTOM_MARGIN),
|
||||
MODEL_NAME,
|
||||
model::FULL_NAME,
|
||||
MODEL_NAME_FONT,
|
||||
theme::FG,
|
||||
theme::BG,
|
||||
@ -74,6 +74,6 @@ impl crate::trace::Trace for WelcomeScreen {
|
||||
fn trace(&self, t: &mut dyn crate::trace::Tracer) {
|
||||
t.component("WelcomeScreen");
|
||||
#[cfg(not(feature = "bootloader"))]
|
||||
t.string("model", MODEL_NAME);
|
||||
t.string("model", model::FULL_NAME);
|
||||
}
|
||||
}
|
||||
|
@ -11,8 +11,6 @@ pub const LOADER_OUTER: i16 = 60;
|
||||
pub const LOADER_INNER: i16 = 42;
|
||||
pub const LOADER_ICON_MAX_SIZE: i16 = 64;
|
||||
|
||||
pub const MODEL_NAME: &str = "Trezor Model T";
|
||||
|
||||
pub const fn size() -> Offset {
|
||||
Offset::new(WIDTH, HEIGHT)
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ use crate::{
|
||||
util,
|
||||
},
|
||||
strutil::StringType,
|
||||
trezorhal::model,
|
||||
ui::{
|
||||
component::{
|
||||
base::ComponentExt,
|
||||
@ -1596,7 +1597,7 @@ extern "C" fn new_show_homescreen(n_args: usize, args: *const Obj, kwargs: *mut
|
||||
let label: StrBuffer = kwargs
|
||||
.get(Qstr::MP_QSTR_label)?
|
||||
.try_into_option()?
|
||||
.unwrap_or_else(|| constant::MODEL_NAME.into());
|
||||
.unwrap_or_else(|| model::FULL_NAME.into());
|
||||
let notification: Option<StrBuffer> =
|
||||
kwargs.get(Qstr::MP_QSTR_notification)?.try_into_option()?;
|
||||
let notification_level: u8 = kwargs.get_or(Qstr::MP_QSTR_notification_level, 0)?;
|
||||
@ -1618,7 +1619,7 @@ extern "C" fn new_show_lockscreen(n_args: usize, args: *const Obj, kwargs: *mut
|
||||
let label: StrBuffer = kwargs
|
||||
.get(Qstr::MP_QSTR_label)?
|
||||
.try_into_option()?
|
||||
.unwrap_or_else(|| constant::MODEL_NAME.into());
|
||||
.unwrap_or_else(|| model::FULL_NAME.into());
|
||||
let bootscreen: bool = kwargs.get(Qstr::MP_QSTR_bootscreen)?.try_into()?;
|
||||
let skip_first_paint: bool = kwargs.get(Qstr::MP_QSTR_skip_first_paint)?.try_into()?;
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "dma2d.h"
|
||||
#include "flash.h"
|
||||
#include "fonts/fonts.h"
|
||||
#include "model.h"
|
||||
#include "rgb_led.h"
|
||||
#include "secbool.h"
|
||||
#include "storage.h"
|
||||
|
Loading…
Reference in New Issue
Block a user