From d361c23224b91dbb30b4045ba5da36548a9fb869 Mon Sep 17 00:00:00 2001 From: tychovrahe Date: Wed, 25 Sep 2024 12:02:20 +0200 Subject: [PATCH] chore(core): remove SBU interface from python [no changelog] --- .../extmod/modtrezorio/modtrezorio-sbu.h | 66 ------------------- core/embed/extmod/modtrezorio/modtrezorio.c | 7 -- core/embed/trezorhal/sbu.h | 4 ++ core/embed/trezorhal/stm32f4/sbu.c | 4 ++ core/mocks/generated/trezorio/__init__.pyi | 15 ----- 5 files changed, 8 insertions(+), 88 deletions(-) delete mode 100644 core/embed/extmod/modtrezorio/modtrezorio-sbu.h diff --git a/core/embed/extmod/modtrezorio/modtrezorio-sbu.h b/core/embed/extmod/modtrezorio/modtrezorio-sbu.h deleted file mode 100644 index cbd87ba6c..000000000 --- a/core/embed/extmod/modtrezorio/modtrezorio-sbu.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * This file is part of the Trezor project, https://trezor.io/ - * - * Copyright (c) SatoshiLabs - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "sbu.h" - -/// package: trezorio.__init__ - -/// class SBU: -/// """ -/// """ -typedef struct _mp_obj_SBU_t { - mp_obj_base_t base; -} mp_obj_SBU_t; - -/// def __init__(self) -> None: -/// """ -/// """ -STATIC mp_obj_t mod_trezorio_SBU_make_new(const mp_obj_type_t *type, - size_t n_args, size_t n_kw, - const mp_obj_t *args) { - mp_arg_check_num(n_args, n_kw, 0, 0, false); - mp_obj_SBU_t *o = mp_obj_malloc(mp_obj_SBU_t, type); - sbu_init(); - return MP_OBJ_FROM_PTR(o); -} - -/// def set(self, sbu1: bool, sbu2: bool) -> None: -/// """ -/// Sets SBU wires to sbu1 and sbu2 values respectively -/// """ -STATIC mp_obj_t mod_trezorio_SBU_set(mp_obj_t self, mp_obj_t sbu1, - mp_obj_t sbu2) { - sbu_set(sectrue * mp_obj_is_true(sbu1), sectrue * mp_obj_is_true(sbu2)); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_3(mod_trezorio_SBU_set_obj, - mod_trezorio_SBU_set); - -STATIC const mp_rom_map_elem_t mod_trezorio_SBU_locals_dict_table[] = { - {MP_ROM_QSTR(MP_QSTR_set), MP_ROM_PTR(&mod_trezorio_SBU_set_obj)}, -}; -STATIC MP_DEFINE_CONST_DICT(mod_trezorio_SBU_locals_dict, - mod_trezorio_SBU_locals_dict_table); - -STATIC const mp_obj_type_t mod_trezorio_SBU_type = { - {&mp_type_type}, - .name = MP_QSTR_SBU, - .make_new = mod_trezorio_SBU_make_new, - .locals_dict = (void *)&mod_trezorio_SBU_locals_dict, -}; diff --git a/core/embed/extmod/modtrezorio/modtrezorio.c b/core/embed/extmod/modtrezorio/modtrezorio.c index 7e63a81d6..74ad336ba 100644 --- a/core/embed/extmod/modtrezorio/modtrezorio.c +++ b/core/embed/extmod/modtrezorio/modtrezorio.c @@ -49,9 +49,6 @@ uint32_t last_touch_sample_time = 0; #include "modtrezorio-webusb.h" #include "modtrezorio-usb.h" // clang-format on -#ifdef USE_SBU -#include "modtrezorio-sbu.h" -#endif #ifdef USE_SD_CARD #include "modtrezorio-fatfs.h" #include "modtrezorio-sdcard.h" @@ -84,10 +81,6 @@ uint32_t last_touch_sample_time = 0; STATIC const mp_rom_map_elem_t mp_module_trezorio_globals_table[] = { {MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_trezorio)}, -#ifdef USE_SBU - {MP_ROM_QSTR(MP_QSTR_SBU), MP_ROM_PTR(&mod_trezorio_SBU_type)}, -#endif - #ifdef USE_SD_CARD {MP_ROM_QSTR(MP_QSTR_fatfs), MP_ROM_PTR(&mod_trezorio_fatfs_module)}, {MP_ROM_QSTR(MP_QSTR_sdcard), MP_ROM_PTR(&mod_trezorio_sdcard_module)}, diff --git a/core/embed/trezorhal/sbu.h b/core/embed/trezorhal/sbu.h index 09e45a289..fef077954 100644 --- a/core/embed/trezorhal/sbu.h +++ b/core/embed/trezorhal/sbu.h @@ -22,7 +22,11 @@ #include "secbool.h" +#if KERNEL_MODE + void sbu_init(void); void sbu_set(secbool sbu1, secbool sbu2); #endif + +#endif diff --git a/core/embed/trezorhal/stm32f4/sbu.c b/core/embed/trezorhal/stm32f4/sbu.c index 95ba8dede..0756c9e9e 100644 --- a/core/embed/trezorhal/stm32f4/sbu.c +++ b/core/embed/trezorhal/stm32f4/sbu.c @@ -21,6 +21,8 @@ #include "sbu.h" +#if KERNEL_MODE + void sbu_init(void) { GPIO_InitTypeDef GPIO_InitStructure = {0}; @@ -41,3 +43,5 @@ void sbu_set(secbool sbu1, secbool sbu2) { HAL_GPIO_WritePin(GPIOA, GPIO_PIN_3, sbu2 == sectrue ? GPIO_PIN_SET : GPIO_PIN_RESET); } + +#endif diff --git a/core/mocks/generated/trezorio/__init__.pyi b/core/mocks/generated/trezorio/__init__.pyi index 1828d18f3..d60c9f2ef 100644 --- a/core/mocks/generated/trezorio/__init__.pyi +++ b/core/mocks/generated/trezorio/__init__.pyi @@ -56,21 +56,6 @@ def poll(ifaces: Iterable[int], list_ref: list, timeout_ms: int) -> bool: """ -# extmod/modtrezorio/modtrezorio-sbu.h -class SBU: - """ - """ - - def __init__(self) -> None: - """ - """ - - def set(self, sbu1: bool, sbu2: bool) -> None: - """ - Sets SBU wires to sbu1 and sbu2 values respectively - """ - - # extmod/modtrezorio/modtrezorio-usb.h class USB: """