@@ -117,12 +117,12 @@ static size_t PLACE_IN_DTCM_BSS(_pystack[CIRCUITPY_PYSTACK_SIZE / sizeof(size_t)
117
117
#endif
118
118
119
119
static void reset_devices (void ) {
120
- #if CIRCUITPY_BLEIO_HCI
120
+ #if CIRCUITPY_BLEIO_HCI
121
121
bleio_reset ();
122
- #endif
122
+ #endif
123
123
}
124
124
125
- STATIC void start_mp (supervisor_allocation * heap ) {
125
+ STATIC void start_mp (supervisor_allocation * heap ) {
126
126
autoreload_stop ();
127
127
supervisor_workflow_reset ();
128
128
@@ -135,13 +135,13 @@ STATIC void start_mp(supervisor_allocation* heap) {
135
135
}
136
136
137
137
138
- #if MICROPY_MAX_STACK_USAGE
138
+ #if MICROPY_MAX_STACK_USAGE
139
139
// _ezero (same as _ebss) is an int, so start 4 bytes above it.
140
140
if (stack_get_bottom () != NULL ) {
141
141
mp_stack_set_bottom (stack_get_bottom ());
142
142
mp_stack_fill_with_sentinel ();
143
143
}
144
- #endif
144
+ #endif
145
145
146
146
// Sync the file systems in case any used RAM from the GC to cache. As soon
147
147
// as we re-init the GC all bets are off on the cache.
@@ -201,8 +201,8 @@ STATIC void stop_mp(void) {
201
201
202
202
// Look for the first file that exists in the list of filenames, using mp_import_stat().
203
203
// Return its index. If no file found, return -1.
204
- STATIC const char * first_existing_file_in_list (const char * const * filenames ) {
205
- for (int i = 0 ; filenames [i ] != (char * )"" ; i ++ ) {
204
+ STATIC const char * first_existing_file_in_list (const char * const * filenames ) {
205
+ for (int i = 0 ; filenames [i ] != (char * )"" ; i ++ ) {
206
206
mp_import_stat_t stat = mp_import_stat (filenames [i ]);
207
207
if (stat == MP_IMPORT_STAT_FILE ) {
208
208
return filenames [i ];
@@ -211,8 +211,8 @@ STATIC const char* first_existing_file_in_list(const char * const * filenames) {
211
211
return NULL ;
212
212
}
213
213
214
- STATIC bool maybe_run_list (const char * const * filenames , pyexec_result_t * exec_result ) {
215
- const char * filename = first_existing_file_in_list (filenames );
214
+ STATIC bool maybe_run_list (const char * const * filenames , pyexec_result_t * exec_result ) {
215
+ const char * filename = first_existing_file_in_list (filenames );
216
216
if (filename == NULL ) {
217
217
return false;
218
218
}
@@ -226,10 +226,10 @@ STATIC bool maybe_run_list(const char * const * filenames, pyexec_result_t* exec
226
226
}
227
227
228
228
STATIC void count_strn (void * data , const char * str , size_t len ) {
229
- * (size_t * )data += len ;
229
+ * (size_t * )data += len ;
230
230
}
231
231
232
- STATIC void cleanup_after_vm (supervisor_allocation * heap , mp_obj_t exception ) {
232
+ STATIC void cleanup_after_vm (supervisor_allocation * heap , mp_obj_t exception ) {
233
233
// Get the traceback of any exception from this run off the heap.
234
234
// MP_OBJ_SENTINEL means "this run does not contribute to traceback storage, don't touch it"
235
235
// MP_OBJ_NULL (=0) means "this run completed successfully, clear any stored traceback"
@@ -249,13 +249,12 @@ STATIC void cleanup_after_vm(supervisor_allocation* heap, mp_obj_t exception) {
249
249
// making it fail, but at this point I believe they are not worth spending code on.
250
250
if (prev_traceback_allocation != NULL ) {
251
251
vstr_t vstr ;
252
- vstr_init_fixed_buf (& vstr , traceback_len , (char * )prev_traceback_allocation -> ptr );
252
+ vstr_init_fixed_buf (& vstr , traceback_len , (char * )prev_traceback_allocation -> ptr );
253
253
mp_print_t print = {& vstr , (mp_print_strn_t )vstr_add_strn };
254
254
mp_obj_print_exception (& print , exception );
255
- ((char * )prev_traceback_allocation -> ptr )[traceback_len ] = '\0' ;
255
+ ((char * )prev_traceback_allocation -> ptr )[traceback_len ] = '\0' ;
256
256
}
257
- }
258
- else {
257
+ } else {
259
258
prev_traceback_allocation = NULL ;
260
259
}
261
260
}
@@ -335,17 +334,17 @@ STATIC bool run_code_py(safe_mode_t safe_mode) {
335
334
uint8_t next_code_stickiness_situation = SUPERVISOR_NEXT_CODE_OPT_NEWLY_SET ;
336
335
337
336
if (safe_mode == NO_SAFE_MODE ) {
338
- static const char * const supported_filenames [] = STRING_LIST (
337
+ static const char * const supported_filenames [] = STRING_LIST (
339
338
"code.txt" , "code.py" , "main.py" , "main.txt" );
340
339
#if CIRCUITPY_FULL_BUILD
341
- static const char * const double_extension_filenames [] = STRING_LIST (
340
+ static const char * const double_extension_filenames [] = STRING_LIST (
342
341
"code.txt.py" , "code.py.txt" , "code.txt.txt" ,"code.py.py" ,
343
342
"main.txt.py" , "main.py.txt" , "main.txt.txt" ,"main.py.py" );
344
343
#endif
345
344
346
345
stack_resize ();
347
346
filesystem_flush ();
348
- supervisor_allocation * heap = allocate_remaining_memory ();
347
+ supervisor_allocation * heap = allocate_remaining_memory ();
349
348
350
349
// Prepare the VM state. Includes an alarm check/reset for sleep.
351
350
start_mp (heap );
@@ -356,14 +355,14 @@ STATIC bool run_code_py(safe_mode_t safe_mode) {
356
355
357
356
// Check if a different run file has been allocated
358
357
if (next_code_allocation ) {
359
- ((next_code_info_t * )next_code_allocation -> ptr )-> options &= ~SUPERVISOR_NEXT_CODE_OPT_NEWLY_SET ;
360
- next_code_options = ((next_code_info_t * )next_code_allocation -> ptr )-> options ;
361
- if (((next_code_info_t * )next_code_allocation -> ptr )-> filename [0 ] != '\0' ) {
362
- const char * next_list [] = {((next_code_info_t * )next_code_allocation -> ptr )-> filename , "" };
358
+ ((next_code_info_t * )next_code_allocation -> ptr )-> options &= ~SUPERVISOR_NEXT_CODE_OPT_NEWLY_SET ;
359
+ next_code_options = ((next_code_info_t * )next_code_allocation -> ptr )-> options ;
360
+ if (((next_code_info_t * )next_code_allocation -> ptr )-> filename [0 ] != '\0' ) {
361
+ const char * next_list [] = {((next_code_info_t * )next_code_allocation -> ptr )-> filename , "" };
363
362
// This is where the user's python code is actually executed:
364
363
found_main = maybe_run_list (next_list , & result );
365
364
if (!found_main ) {
366
- serial_write (((next_code_info_t * )next_code_allocation -> ptr )-> filename );
365
+ serial_write (((next_code_info_t * )next_code_allocation -> ptr )-> filename );
367
366
serial_write_compressed (translate (" not found.\n" ));
368
367
}
369
368
}
@@ -374,14 +373,14 @@ STATIC bool run_code_py(safe_mode_t safe_mode) {
374
373
found_main = maybe_run_list (supported_filenames , & result );
375
374
// If that didn't work, double check the extensions
376
375
#if CIRCUITPY_FULL_BUILD
377
- if (!found_main ){
376
+ if (!found_main ) {
378
377
found_main = maybe_run_list (double_extension_filenames , & result );
379
378
if (found_main ) {
380
379
serial_write_compressed (translate ("WARNING: Your code filename has two extensions\n" ));
381
380
}
382
381
}
383
382
#else
384
- (void ) found_main ;
383
+ (void )found_main ;
385
384
#endif
386
385
}
387
386
@@ -400,7 +399,7 @@ STATIC bool run_code_py(safe_mode_t safe_mode) {
400
399
// the options because it can be treated like any other reason-for-stickiness bit. The
401
400
// source is different though: it comes from the options that will apply to the next run,
402
401
// while the rest of next_code_options is what applied to this run.
403
- if (next_code_allocation != NULL && (((next_code_info_t * )next_code_allocation -> ptr )-> options & SUPERVISOR_NEXT_CODE_OPT_NEWLY_SET )) {
402
+ if (next_code_allocation != NULL && (((next_code_info_t * )next_code_allocation -> ptr )-> options & SUPERVISOR_NEXT_CODE_OPT_NEWLY_SET )) {
404
403
next_code_options |= SUPERVISOR_NEXT_CODE_OPT_NEWLY_SET ;
405
404
}
406
405
@@ -562,7 +561,7 @@ STATIC bool run_code_py(safe_mode_t safe_mode) {
562
561
}
563
562
564
563
#if !CIRCUITPY_STATUS_LED
565
- port_interrupt_after_ticks (time_to_epaper_refresh );
564
+ port_interrupt_after_ticks (time_to_epaper_refresh );
566
565
#endif
567
566
#endif
568
567
@@ -645,17 +644,17 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) {
645
644
&& safe_mode == NO_SAFE_MODE
646
645
&& MP_STATE_VM (vfs_mount_table ) != NULL ;
647
646
648
- static const char * const boot_py_filenames [] = STRING_LIST ("boot.py" , "boot.txt" );
647
+ static const char * const boot_py_filenames [] = STRING_LIST ("boot.py" , "boot.txt" );
649
648
650
649
// Do USB setup even if boot.py is not run.
651
650
652
- supervisor_allocation * heap = allocate_remaining_memory ();
651
+ supervisor_allocation * heap = allocate_remaining_memory ();
653
652
start_mp (heap );
654
653
655
- #if CIRCUITPY_USB
654
+ #if CIRCUITPY_USB
656
655
// Set up default USB values after boot.py VM starts but before running boot.py.
657
656
usb_set_defaults ();
658
- #endif
657
+ #endif
659
658
660
659
pyexec_result_t result = {0 , MP_OBJ_NULL , 0 };
661
660
@@ -670,12 +669,12 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) {
670
669
mp_printf (& mp_plat_print , "%s\nBoard ID:%s\n" , MICROPY_FULL_VERSION_INFO , CIRCUITPY_BOARD_ID );
671
670
672
671
bool found_boot = maybe_run_list (boot_py_filenames , & result );
673
- (void ) found_boot ;
672
+ (void )found_boot ;
674
673
675
674
676
675
#ifdef CIRCUITPY_BOOT_OUTPUT_FILE
677
676
// Get the base filesystem.
678
- fs_user_mount_t * vfs = (fs_user_mount_t * ) MP_STATE_VM (vfs_mount_table )-> obj ;
677
+ fs_user_mount_t * vfs = (fs_user_mount_t * )MP_STATE_VM (vfs_mount_table )-> obj ;
679
678
FATFS * fs = & vfs -> fatfs ;
680
679
681
680
boot_output = NULL ;
@@ -684,7 +683,7 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) {
684
683
if (f_open (fs , & boot_output_file , CIRCUITPY_BOOT_OUTPUT_FILE , FA_READ ) == FR_OK ) {
685
684
char * file_contents = m_new (char , boot_text .alloc );
686
685
UINT chars_read ;
687
- if (f_read (& boot_output_file , file_contents , 1 + boot_text .len , & chars_read ) == FR_OK ) {
686
+ if (f_read (& boot_output_file , file_contents , 1 + boot_text .len , & chars_read ) == FR_OK ) {
688
687
write_boot_output =
689
688
(chars_read != boot_text .len ) || (memcmp (boot_text .buf , file_contents , chars_read ) != 0 );
690
689
}
@@ -708,7 +707,7 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) {
708
707
#endif
709
708
}
710
709
711
- #if CIRCUITPY_USB
710
+ #if CIRCUITPY_USB
712
711
// Some data needs to be carried over from the USB settings in boot.py
713
712
// to the next VM, while the heap is still available.
714
713
// Its size can vary, so save it temporarily on the stack,
@@ -717,21 +716,21 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) {
717
716
size_t size = usb_boot_py_data_size ();
718
717
uint8_t usb_boot_py_data [size ];
719
718
usb_get_boot_py_data (usb_boot_py_data , size );
720
- #endif
719
+ #endif
721
720
722
721
cleanup_after_vm (heap , result .exception );
723
722
724
- #if CIRCUITPY_USB
723
+ #if CIRCUITPY_USB
725
724
// Now give back the data we saved from the heap going away.
726
725
usb_return_boot_py_data (usb_boot_py_data , size );
727
- #endif
726
+ #endif
728
727
}
729
728
730
729
STATIC int run_repl (void ) {
731
730
int exit_code = PYEXEC_FORCED_EXIT ;
732
731
stack_resize ();
733
732
filesystem_flush ();
734
- supervisor_allocation * heap = allocate_remaining_memory ();
733
+ supervisor_allocation * heap = allocate_remaining_memory ();
735
734
start_mp (heap );
736
735
737
736
#if CIRCUITPY_USB
@@ -876,7 +875,7 @@ void gc_collect(void) {
876
875
877
876
// This collects root pointers from the VFS mount table. Some of them may
878
877
// have lost their references in the VM even though they are mounted.
879
- gc_collect_root ((void * * )& MP_STATE_VM (vfs_mount_table ), sizeof (mp_vfs_mount_t ) / sizeof (mp_uint_t ));
878
+ gc_collect_root ((void * * )& MP_STATE_VM (vfs_mount_table ), sizeof (mp_vfs_mount_t ) / sizeof (mp_uint_t ));
880
879
881
880
background_callback_gc_collect ();
882
881
@@ -906,18 +905,20 @@ void gc_collect(void) {
906
905
907
906
// This naively collects all object references from an approximate stack
908
907
// range.
909
- gc_collect_root ((void * * )sp , ((uint32_t )port_stack_get_top () - sp ) / sizeof (uint32_t ));
908
+ gc_collect_root ((void * * )sp , ((uint32_t )port_stack_get_top () - sp ) / sizeof (uint32_t ));
910
909
gc_collect_end ();
911
910
}
912
911
913
912
void NORETURN nlr_jump_fail (void * val ) {
914
913
reset_into_safe_mode (MICROPY_NLR_JUMP_FAIL );
915
- while (true) {}
914
+ while (true) {
915
+ }
916
916
}
917
917
918
918
void NORETURN __fatal_error (const char * msg ) {
919
919
reset_into_safe_mode (MICROPY_FATAL_ERROR );
920
- while (true) {}
920
+ while (true) {
921
+ }
921
922
}
922
923
923
924
#ifndef NDEBUG
0 commit comments