mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-21 23:18:13 +00:00
trezor.storage -> trezor.config
This commit is contained in:
parent
0fb6fc05a5
commit
2576d9c3a4
66
extmod/modtrezorconfig/modtrezorconfig.c
Normal file
66
extmod/modtrezorconfig/modtrezorconfig.c
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) Pavol Rusnak, SatoshiLabs
|
||||
*
|
||||
* Licensed under Microsoft Reference Source License (Ms-RSL)
|
||||
* see LICENSE.md file for details
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "py/nlr.h"
|
||||
#include "py/runtime.h"
|
||||
#include "py/binary.h"
|
||||
#include "py/objstr.h"
|
||||
|
||||
#if MICROPY_PY_TREZORCONFIG
|
||||
|
||||
typedef struct _mp_obj_Config_t {
|
||||
mp_obj_base_t base;
|
||||
} mp_obj_Config_t;
|
||||
|
||||
STATIC mp_obj_t mod_TrezorConfig_Config_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_Config_t *o = m_new_obj(mp_obj_Config_t);
|
||||
o->base.type = type;
|
||||
return MP_OBJ_FROM_PTR(o);
|
||||
}
|
||||
|
||||
STATIC mp_obj_t mod_TrezorConfig_Config_get(mp_obj_t self, mp_obj_t app, mp_obj_t key) {
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_3(mod_TrezorConfig_Config_get_obj, mod_TrezorConfig_Config_get);
|
||||
|
||||
STATIC mp_obj_t mod_TrezorConfig_Config_set(size_t n_args, const mp_obj_t *args) {
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorConfig_Config_set_obj, 4, 4, mod_TrezorConfig_Config_set);
|
||||
|
||||
STATIC const mp_rom_map_elem_t mod_TrezorConfig_Config_locals_dict_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_get), MP_ROM_PTR(&mod_TrezorConfig_Config_get_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_set), MP_ROM_PTR(&mod_TrezorConfig_Config_set_obj) },
|
||||
};
|
||||
STATIC MP_DEFINE_CONST_DICT(mod_TrezorConfig_Config_locals_dict, mod_TrezorConfig_Config_locals_dict_table);
|
||||
|
||||
STATIC const mp_obj_type_t mod_TrezorConfig_Config_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_Config,
|
||||
.make_new = mod_TrezorConfig_Config_make_new,
|
||||
.locals_dict = (void*)&mod_TrezorConfig_Config_locals_dict,
|
||||
};
|
||||
|
||||
STATIC const mp_rom_map_elem_t mp_module_TrezorConfig_globals_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_TrezorConfig) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_Config), MP_ROM_PTR(&mod_TrezorConfig_Config_type) },
|
||||
};
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(mp_module_TrezorConfig_globals, mp_module_TrezorConfig_globals_table);
|
||||
|
||||
const mp_obj_module_t mp_module_TrezorConfig = {
|
||||
.base = { &mp_type_module },
|
||||
.name = MP_QSTR_TrezorConfig,
|
||||
.globals = (mp_obj_dict_t*)&mp_module_TrezorConfig_globals,
|
||||
};
|
||||
|
||||
#endif // MICROPY_PY_TREZORCONFIG
|
@ -1,68 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Pavol Rusnak, SatoshiLabs
|
||||
*
|
||||
* Licensed under Microsoft Reference Source License (Ms-RSL)
|
||||
* see LICENSE.md file for details
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "py/nlr.h"
|
||||
#include "py/runtime.h"
|
||||
#include "py/binary.h"
|
||||
#include "py/objstr.h"
|
||||
|
||||
#if MICROPY_PY_TREZORSTORAGE
|
||||
|
||||
#include "storage.h"
|
||||
|
||||
typedef struct _mp_obj_Storage_t {
|
||||
mp_obj_base_t base;
|
||||
} mp_obj_Storage_t;
|
||||
|
||||
STATIC mp_obj_t mod_TrezorStorage_Storage_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_Storage_t *o = m_new_obj(mp_obj_Storage_t);
|
||||
o->base.type = type;
|
||||
return MP_OBJ_FROM_PTR(o);
|
||||
}
|
||||
|
||||
STATIC mp_obj_t mod_TrezorStorage_Storage_get(mp_obj_t self, mp_obj_t key, mp_obj_t defval) {
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_3(mod_TrezorStorage_Storage_get_obj, mod_TrezorStorage_Storage_get);
|
||||
|
||||
STATIC mp_obj_t mod_TrezorStorage_Storage_set(mp_obj_t self, mp_obj_t key, mp_obj_t value) {
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_3(mod_TrezorStorage_Storage_set_obj, mod_TrezorStorage_Storage_set);
|
||||
|
||||
STATIC const mp_rom_map_elem_t mod_TrezorStorage_Storage_locals_dict_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_get), MP_ROM_PTR(&mod_TrezorStorage_Storage_get_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_set), MP_ROM_PTR(&mod_TrezorStorage_Storage_set_obj) },
|
||||
};
|
||||
STATIC MP_DEFINE_CONST_DICT(mod_TrezorStorage_Storage_locals_dict, mod_TrezorStorage_Storage_locals_dict_table);
|
||||
|
||||
STATIC const mp_obj_type_t mod_TrezorStorage_Storage_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_Storage,
|
||||
.make_new = mod_TrezorStorage_Storage_make_new,
|
||||
.locals_dict = (void*)&mod_TrezorStorage_Storage_locals_dict,
|
||||
};
|
||||
|
||||
STATIC const mp_rom_map_elem_t mp_module_TrezorStorage_globals_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_TrezorStorage) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_Storage), MP_ROM_PTR(&mod_TrezorStorage_Storage_type) },
|
||||
};
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(mp_module_TrezorStorage_globals, mp_module_TrezorStorage_globals_table);
|
||||
|
||||
const mp_obj_module_t mp_module_TrezorStorage = {
|
||||
.base = { &mp_type_module },
|
||||
.name = MP_QSTR_TrezorStorage,
|
||||
.globals = (mp_obj_dict_t*)&mp_module_TrezorStorage_globals,
|
||||
};
|
||||
|
||||
#endif // MICROPY_PY_TREZORSTORAGE
|
@ -1,8 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Pavol Rusnak, SatoshiLabs
|
||||
*
|
||||
* Licensed under Microsoft Reference Source License (Ms-RSL)
|
||||
* see LICENSE.md file for details
|
||||
*/
|
||||
|
||||
#include STM32_HAL_H
|
@ -1,6 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Pavol Rusnak, SatoshiLabs
|
||||
*
|
||||
* Licensed under Microsoft Reference Source License (Ms-RSL)
|
||||
* see LICENSE.md file for details
|
||||
*/
|
@ -1,12 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Pavol Rusnak, SatoshiLabs
|
||||
*
|
||||
* Licensed under Microsoft Reference Source License (Ms-RSL)
|
||||
* see LICENSE.md file for details
|
||||
*/
|
||||
|
||||
#if defined STM32_HAL_H
|
||||
#include "storage-stmhal.h"
|
||||
#else
|
||||
#include "storage-unix.h"
|
||||
#endif
|
@ -1,11 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Pavol Rusnak, SatoshiLabs
|
||||
*
|
||||
* Licensed under Microsoft Reference Source License (Ms-RSL)
|
||||
* see LICENSE.md file for details
|
||||
*/
|
||||
|
||||
#ifndef __STORAGE_H__
|
||||
#define __STORAGE_H__
|
||||
|
||||
#endif
|
10
src/trezor/config.py
Normal file
10
src/trezor/config.py
Normal file
@ -0,0 +1,10 @@
|
||||
from TrezorConfig import Config
|
||||
|
||||
_config = Config()
|
||||
|
||||
def get(app, key, default=None):
|
||||
v = _config.get(app, key)
|
||||
return v if v else default
|
||||
|
||||
def set(app, key, value):
|
||||
return _config.set(app, key, value)
|
@ -1,10 +0,0 @@
|
||||
from TrezorStorage import Storage
|
||||
|
||||
_storage = Storage()
|
||||
|
||||
def get(key, defval=None):
|
||||
return _storage.get(key, defval)
|
||||
|
||||
|
||||
def set(key, value):
|
||||
return _storage.set(key, value)
|
2
vendor/micropython
vendored
2
vendor/micropython
vendored
@ -1 +1 @@
|
||||
Subproject commit 9cee3cdb8fc0444e292308cbbabee12e98e2fd07
|
||||
Subproject commit 4509a515d6057d2fca4b642b055108c2ff6bf78b
|
Loading…
Reference in New Issue
Block a user