Skip to content

Commit 9d0c024

Browse files
authored
Merge pull request #165 from heyuanjie87/last
核心升级到v1.13
2 parents afa08d9 + e05ad2f commit 9d0c024

File tree

175 files changed

+5648
-3559
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

175 files changed

+5648
-3559
lines changed

extmod/modussl_axtls.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,10 @@ STATIC const mp_obj_type_t ussl_socket_type = {
246246
STATIC mp_obj_t mod_ssl_wrap_socket(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
247247
// TODO: Implement more args
248248
static const mp_arg_t allowed_args[] = {
249-
{ MP_QSTR_key, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_rom_obj = MP_ROM_PTR(&mp_const_none_obj)} },
250-
{ MP_QSTR_cert, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_rom_obj = MP_ROM_PTR(&mp_const_none_obj)} },
249+
{ MP_QSTR_key, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_rom_obj = MP_ROM_NONE} },
250+
{ MP_QSTR_cert, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_rom_obj = MP_ROM_NONE} },
251251
{ MP_QSTR_server_side, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} },
252-
{ MP_QSTR_server_hostname, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_rom_obj = MP_ROM_PTR(&mp_const_none_obj)} },
252+
{ MP_QSTR_server_hostname, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_rom_obj = MP_ROM_NONE} },
253253
{ MP_QSTR_do_handshake, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = true} },
254254
};
255255

extmod/modussl_mbedtls.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,10 +346,10 @@ STATIC const mp_obj_type_t ussl_socket_type = {
346346
STATIC mp_obj_t mod_ssl_wrap_socket(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
347347
// TODO: Implement more args
348348
static const mp_arg_t allowed_args[] = {
349-
{ MP_QSTR_key, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_rom_obj = MP_ROM_PTR(&mp_const_none_obj)} },
350-
{ MP_QSTR_cert, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_rom_obj = MP_ROM_PTR(&mp_const_none_obj)} },
349+
{ MP_QSTR_key, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_rom_obj = MP_ROM_NONE} },
350+
{ MP_QSTR_cert, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_rom_obj = MP_ROM_NONE} },
351351
{ MP_QSTR_server_side, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} },
352-
{ MP_QSTR_server_hostname, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_rom_obj = MP_ROM_PTR(&mp_const_none_obj)} },
352+
{ MP_QSTR_server_hostname, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_rom_obj = MP_ROM_NONE} },
353353
{ MP_QSTR_do_handshake, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = true} },
354354
};
355355

extmod/vfs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,10 +297,10 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_vfs_umount_obj, mp_vfs_umount);
297297
mp_obj_t mp_vfs_open(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
298298
enum { ARG_file, ARG_mode, ARG_encoding };
299299
static const mp_arg_t allowed_args[] = {
300-
{ MP_QSTR_file, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_rom_obj = MP_ROM_PTR(&mp_const_none_obj)} },
300+
{ MP_QSTR_file, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_rom_obj = MP_ROM_NONE} },
301301
{ MP_QSTR_mode, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_QSTR(MP_QSTR_r)} },
302302
{ MP_QSTR_buffering, MP_ARG_INT, {.u_int = -1} },
303-
{ MP_QSTR_encoding, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_PTR(&mp_const_none_obj)} },
303+
{ MP_QSTR_encoding, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_NONE} },
304304
};
305305

306306
// parse args

extmod/vfs_fat_file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,9 @@ STATIC mp_uint_t file_obj_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_t arg,
154154
// Note: encoding is ignored for now; it's also not a valid kwarg for CPython's FileIO,
155155
// but by adding it here we can use one single mp_arg_t array for open() and FileIO's constructor
156156
STATIC const mp_arg_t file_open_args[] = {
157-
{ MP_QSTR_file, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_rom_obj = MP_ROM_PTR(&mp_const_none_obj)} },
157+
{ MP_QSTR_file, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_rom_obj = MP_ROM_NONE} },
158158
{ MP_QSTR_mode, MP_ARG_OBJ, {.u_obj = MP_OBJ_NEW_QSTR(MP_QSTR_r)} },
159-
{ MP_QSTR_encoding, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_PTR(&mp_const_none_obj)} },
159+
{ MP_QSTR_encoding, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_NONE} },
160160
};
161161
#define FILE_OPEN_NUM_ARGS MP_ARRAY_SIZE(file_open_args)
162162

extmod/vfs_posix_file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ mp_obj_t mp_vfs_posix_file_open(const mp_obj_type_t *type, mp_obj_t file_in, mp_
110110

111111
STATIC mp_obj_t vfs_posix_file_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
112112
static const mp_arg_t allowed_args[] = {
113-
{ MP_QSTR_file, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_rom_obj = MP_ROM_PTR(&mp_const_none_obj)} },
113+
{ MP_QSTR_file, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_rom_obj = MP_ROM_NONE} },
114114
{ MP_QSTR_mode, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_QSTR(MP_QSTR_r)} },
115115
};
116116

lib/utils/gchelper.h

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,21 @@
2828

2929
#include <stdint.h>
3030

31-
uintptr_t gc_helper_get_sp(void);
32-
uintptr_t gc_helper_get_regs_and_sp(uintptr_t *regs);
31+
#if MICROPY_GCREGS_SETJMP
32+
#include <setjmp.h>
33+
typedef jmp_buf gc_helper_regs_t;
34+
#else
35+
36+
#if defined(__x86_64__)
37+
typedef uintptr_t gc_helper_regs_t[6];
38+
#elif defined(__i386__)
39+
typedef uintptr_t gc_helper_regs_t[4];
40+
#elif defined(__thumb2__) || defined(__thumb__) || defined(__arm__)
41+
typedef uintptr_t gc_helper_regs_t[10];
42+
#endif
43+
44+
#endif
45+
46+
void gc_helper_collect_regs_and_stack(void);
3347

3448
#endif // MICROPY_INCLUDED_LIB_UTILS_GCHELPER_H

lib/utils/gchelper_m3.s

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,6 @@
3131
.section .text
3232
.align 2
3333

34-
.global gc_helper_get_sp
35-
.type gc_helper_get_sp, %function
36-
37-
@ uint gc_helper_get_sp(void)
38-
gc_helper_get_sp:
39-
@ return the sp
40-
mov r0, sp
41-
bx lr
42-
43-
.size gc_helper_get_sp, .-gc_helper_get_sp
44-
45-
4634
.global gc_helper_get_regs_and_sp
4735
.type gc_helper_get_regs_and_sp, %function
4836

lib/utils/interrupt_char.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,7 @@
3232
int mp_interrupt_char = -1;
3333

3434
void mp_hal_set_interrupt_char(int c) {
35-
if (c != -1) {
36-
mp_obj_exception_clear_traceback(MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception)));
37-
}
3835
mp_interrupt_char = c;
3936
}
4037

41-
void mp_keyboard_interrupt(void) {
42-
MP_STATE_VM(mp_pending_exception) = MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception));
43-
#if MICROPY_ENABLE_SCHEDULER
44-
if (MP_STATE_VM(sched_state) == MP_SCHED_IDLE) {
45-
MP_STATE_VM(sched_state) = MP_SCHED_PENDING;
46-
}
47-
#endif
48-
}
49-
5038
#endif

lib/utils/interrupt_char.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,5 @@
2828

2929
extern int mp_interrupt_char;
3030
void mp_hal_set_interrupt_char(int c);
31-
void mp_keyboard_interrupt(void);
3231

3332
#endif // MICROPY_INCLUDED_LIB_UTILS_INTERRUPT_CHAR_H

lib/utils/mpirq.c

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@
3131
#include "py/gc.h"
3232
#include "lib/utils/mpirq.h"
3333

34+
#if MICROPY_ENABLE_SCHEDULER
35+
3436
/******************************************************************************
3537
DECLARE PUBLIC DATA
3638
******************************************************************************/
3739

3840
const mp_arg_t mp_irq_init_args[] = {
39-
{ MP_QSTR_handler, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_PTR(&mp_const_none_obj)} },
41+
{ MP_QSTR_handler, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_NONE} },
4042
{ MP_QSTR_trigger, MP_ARG_INT, {.u_int = 0} },
4143
{ MP_QSTR_hard, MP_ARG_BOOL, {.u_bool = false} },
4244
};
@@ -51,19 +53,25 @@ const mp_arg_t mp_irq_init_args[] = {
5153

5254
mp_irq_obj_t *mp_irq_new(const mp_irq_methods_t *methods, mp_obj_t parent) {
5355
mp_irq_obj_t *self = m_new0(mp_irq_obj_t, 1);
56+
mp_irq_init(self, methods, parent);
57+
return self;
58+
}
59+
60+
void mp_irq_init(mp_irq_obj_t *self, const mp_irq_methods_t *methods, mp_obj_t parent) {
5461
self->base.type = &mp_irq_type;
55-
self->methods = (mp_irq_methods_t*)methods;
62+
self->methods = (mp_irq_methods_t *)methods;
5663
self->parent = parent;
5764
self->handler = mp_const_none;
5865
self->ishard = false;
59-
return self;
6066
}
6167

6268
void mp_irq_handler(mp_irq_obj_t *self) {
6369
if (self->handler != mp_const_none) {
6470
if (self->ishard) {
65-
// When executing code within a handler we must lock the GC to prevent
66-
// any memory allocations.
71+
// When executing code within a handler we must lock the scheduler to
72+
// prevent any scheduled callbacks from running, and lock the GC to
73+
// prevent any memory allocations.
74+
mp_sched_lock();
6775
gc_lock();
6876
nlr_buf_t nlr;
6977
if (nlr_push(&nlr) == 0) {
@@ -77,6 +85,7 @@ void mp_irq_handler(mp_irq_obj_t *self) {
7785
mp_obj_print_exception(&mp_plat_print, MP_OBJ_FROM_PTR(nlr.ret_val));
7886
}
7987
gc_unlock();
88+
mp_sched_unlock();
8089
} else {
8190
// Schedule call to user function
8291
mp_sched_schedule(self->handler, self->parent);
@@ -120,5 +129,7 @@ const mp_obj_type_t mp_irq_type = {
120129
{ &mp_type_type },
121130
.name = MP_QSTR_irq,
122131
.call = mp_irq_call,
123-
.locals_dict = (mp_obj_dict_t*)&mp_irq_locals_dict,
132+
.locals_dict = (mp_obj_dict_t *)&mp_irq_locals_dict,
124133
};
134+
135+
#endif // MICROPY_ENABLE_SCHEDULER

0 commit comments

Comments
 (0)