Skip to content

Commit daa1a45

Browse files
committed
stmhal: Remove custom mod_machine_mem_get_{read,write}_addr functions.
They are no longer needed because stm constants can now be 32 bits wide.
1 parent 2621f8a commit daa1a45

2 files changed

Lines changed: 0 additions & 39 deletions

File tree

stmhal/modmachine.c

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -419,42 +419,6 @@ STATIC mp_obj_t machine_reset_cause(void) {
419419
STATIC MP_DEFINE_CONST_FUN_OBJ_0(machine_reset_cause_obj, machine_reset_cause);
420420
#endif
421421

422-
// To use compile-time constants we are restricted to 31-bit numbers (a small int,
423-
// so it fits in a Micro Python object pointer). Thus, when extracting a constant
424-
// from an object, we must clear the MSB.
425-
426-
uintptr_t mod_machine_mem_get_read_addr(mp_obj_t addr_o, uint align) {
427-
uint32_t addr = mp_obj_get_int_truncated(addr_o);
428-
if (MP_OBJ_IS_SMALL_INT(addr_o)) {
429-
addr &= 0x7fffffff;
430-
}
431-
/*
432-
if (addr < 0x10000000) {
433-
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "cannot read from address %08x", addr));
434-
}
435-
*/
436-
if ((addr & (align - 1)) != 0) {
437-
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "address %08x is not aligned to %d bytes", addr, align));
438-
}
439-
return addr;
440-
}
441-
442-
uintptr_t mod_machine_mem_get_write_addr(mp_obj_t addr_o, uint align) {
443-
uint32_t addr = mp_obj_get_int_truncated(addr_o);
444-
if (MP_OBJ_IS_SMALL_INT(addr_o)) {
445-
addr &= 0x7fffffff;
446-
}
447-
if (addr < 0x10000000) {
448-
// Everything below 0x10000000 is either ROM or aliased to something higher, so we don't
449-
// lose anything by restricting writes to this area, and we gain some safety.
450-
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "cannot write to address %08x", addr));
451-
}
452-
if ((addr & (align - 1)) != 0) {
453-
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "address %08x is not aligned to %d bytes", addr, align));
454-
}
455-
return addr;
456-
}
457-
458422
STATIC const mp_map_elem_t machine_module_globals_table[] = {
459423
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_umachine) },
460424
{ MP_OBJ_NEW_QSTR(MP_QSTR_info), (mp_obj_t)&machine_info_obj },

stmhal/mpconfigport.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,7 @@
8585
#define MICROPY_PY_URE (1)
8686
#define MICROPY_PY_UHEAPQ (1)
8787
#define MICROPY_PY_UHASHLIB (1)
88-
8988
#define MICROPY_PY_MACHINE (1)
90-
#define MICROPY_MACHINE_MEM_GET_READ_ADDR mod_machine_mem_get_read_addr
91-
#define MICROPY_MACHINE_MEM_GET_WRITE_ADDR mod_machine_mem_get_write_addr
9289

9390
#define MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF (1)
9491
#define MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE (0)

0 commit comments

Comments
 (0)