From e6d97e8a0be1f7795f8c93b30ec7655c9ca09a7c Mon Sep 17 00:00:00 2001 From: Damien George Date: Tue, 12 Feb 2019 14:11:21 +1100 Subject: stm32: Move gchelper assembler code to lib/utils for use by other ports. --- lib/utils/gchelper_m0.s | 61 ++++++++++++++++++++++++++++++++++++++++++++++ lib/utils/gchelper_m3.s | 62 +++++++++++++++++++++++++++++++++++++++++++++++ ports/stm32/Makefile | 4 +-- ports/stm32/gchelper.s | 62 ----------------------------------------------- ports/stm32/gchelper_m0.s | 61 ---------------------------------------------- 5 files changed, 125 insertions(+), 125 deletions(-) create mode 100644 lib/utils/gchelper_m0.s create mode 100644 lib/utils/gchelper_m3.s delete mode 100644 ports/stm32/gchelper.s delete mode 100644 ports/stm32/gchelper_m0.s diff --git a/lib/utils/gchelper_m0.s b/lib/utils/gchelper_m0.s new file mode 100644 index 000000000..db0d9738d --- /dev/null +++ b/lib/utils/gchelper_m0.s @@ -0,0 +1,61 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Damien P. George + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + + .syntax unified + .cpu cortex-m0 + .thumb + + .section .text + .align 2 + + .global gc_helper_get_regs_and_sp + .type gc_helper_get_regs_and_sp, %function + +@ uint gc_helper_get_regs_and_sp(r0=uint regs[10]) +gc_helper_get_regs_and_sp: + @ store registers into given array + str r4, [r0, #0] + str r5, [r0, #4] + str r6, [r0, #8] + str r7, [r0, #12] + mov r1, r8 + str r1, [r0, #16] + mov r1, r9 + str r1, [r0, #20] + mov r1, r10 + str r1, [r0, #24] + mov r1, r11 + str r1, [r0, #28] + mov r1, r12 + str r1, [r0, #32] + mov r1, r13 + str r1, [r0, #36] + + @ return the sp + mov r0, sp + bx lr + + .size gc_helper_get_regs_and_sp, .-gc_helper_get_regs_and_sp diff --git a/lib/utils/gchelper_m3.s b/lib/utils/gchelper_m3.s new file mode 100644 index 000000000..6baedcdd0 --- /dev/null +++ b/lib/utils/gchelper_m3.s @@ -0,0 +1,62 @@ + .syntax unified + .cpu cortex-m4 + .thumb + .text + .align 2 + +@ uint gc_helper_get_regs_and_sp(r0=uint regs[10]) + .global gc_helper_get_regs_and_sp + .thumb + .thumb_func + .type gc_helper_get_regs_and_sp, %function +gc_helper_get_regs_and_sp: + @ store registers into given array + str r4, [r0], #4 + str r5, [r0], #4 + str r6, [r0], #4 + str r7, [r0], #4 + str r8, [r0], #4 + str r9, [r0], #4 + str r10, [r0], #4 + str r11, [r0], #4 + str r12, [r0], #4 + str r13, [r0], #4 + + @ return the sp + mov r0, sp + bx lr + + +@ this next function is now obsolete + + .size gc_helper_get_regs_and_clean_stack, .-gc_helper_get_regs_and_clean_stack +@ void gc_helper_get_regs_and_clean_stack(r0=uint regs[10], r1=heap_end) + .global gc_helper_get_regs_and_clean_stack + .thumb + .thumb_func + .type gc_helper_get_regs_and_clean_stack, %function +gc_helper_get_regs_and_clean_stack: + @ store registers into given array + str r4, [r0], #4 + str r5, [r0], #4 + str r6, [r0], #4 + str r7, [r0], #4 + str r8, [r0], #4 + str r9, [r0], #4 + str r10, [r0], #4 + str r11, [r0], #4 + str r12, [r0], #4 + str r13, [r0], #4 + + @ clean the stack from given pointer up to current sp + movs r0, #0 + mov r2, sp + b.n .entry +.loop: + str r0, [r1], #4 +.entry: + cmp r1, r2 + bcc.n .loop + bx lr + + .size gc_helper_get_regs_and_clean_stack, .-gc_helper_get_regs_and_clean_stack diff --git a/ports/stm32/Makefile b/ports/stm32/Makefile index ee4de61cc..c7dc99fd7 100644 --- a/ports/stm32/Makefile +++ b/ports/stm32/Makefile @@ -275,13 +275,13 @@ SRC_O = \ $(STARTUP_FILE) \ system_stm32f0.o \ resethandler_m0.o \ - gchelper_m0.o + lib/utils/gchelper_m0.o else SRC_O = \ $(STARTUP_FILE) \ system_stm32.o \ resethandler.o \ - gchelper.o + lib/utils/gchelper_m3.o endif SRC_HAL = $(addprefix $(HAL_DIR)/Src/stm32$(MCU_SERIES)xx_,\ diff --git a/ports/stm32/gchelper.s b/ports/stm32/gchelper.s deleted file mode 100644 index 6baedcdd0..000000000 --- a/ports/stm32/gchelper.s +++ /dev/null @@ -1,62 +0,0 @@ - .syntax unified - .cpu cortex-m4 - .thumb - .text - .align 2 - -@ uint gc_helper_get_regs_and_sp(r0=uint regs[10]) - .global gc_helper_get_regs_and_sp - .thumb - .thumb_func - .type gc_helper_get_regs_and_sp, %function -gc_helper_get_regs_and_sp: - @ store registers into given array - str r4, [r0], #4 - str r5, [r0], #4 - str r6, [r0], #4 - str r7, [r0], #4 - str r8, [r0], #4 - str r9, [r0], #4 - str r10, [r0], #4 - str r11, [r0], #4 - str r12, [r0], #4 - str r13, [r0], #4 - - @ return the sp - mov r0, sp - bx lr - - -@ this next function is now obsolete - - .size gc_helper_get_regs_and_clean_stack, .-gc_helper_get_regs_and_clean_stack -@ void gc_helper_get_regs_and_clean_stack(r0=uint regs[10], r1=heap_end) - .global gc_helper_get_regs_and_clean_stack - .thumb - .thumb_func - .type gc_helper_get_regs_and_clean_stack, %function -gc_helper_get_regs_and_clean_stack: - @ store registers into given array - str r4, [r0], #4 - str r5, [r0], #4 - str r6, [r0], #4 - str r7, [r0], #4 - str r8, [r0], #4 - str r9, [r0], #4 - str r10, [r0], #4 - str r11, [r0], #4 - str r12, [r0], #4 - str r13, [r0], #4 - - @ clean the stack from given pointer up to current sp - movs r0, #0 - mov r2, sp - b.n .entry -.loop: - str r0, [r1], #4 -.entry: - cmp r1, r2 - bcc.n .loop - bx lr - - .size gc_helper_get_regs_and_clean_stack, .-gc_helper_get_regs_and_clean_stack diff --git a/ports/stm32/gchelper_m0.s b/ports/stm32/gchelper_m0.s deleted file mode 100644 index db0d9738d..000000000 --- a/ports/stm32/gchelper_m0.s +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2018 Damien P. George - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - - .syntax unified - .cpu cortex-m0 - .thumb - - .section .text - .align 2 - - .global gc_helper_get_regs_and_sp - .type gc_helper_get_regs_and_sp, %function - -@ uint gc_helper_get_regs_and_sp(r0=uint regs[10]) -gc_helper_get_regs_and_sp: - @ store registers into given array - str r4, [r0, #0] - str r5, [r0, #4] - str r6, [r0, #8] - str r7, [r0, #12] - mov r1, r8 - str r1, [r0, #16] - mov r1, r9 - str r1, [r0, #20] - mov r1, r10 - str r1, [r0, #24] - mov r1, r11 - str r1, [r0, #28] - mov r1, r12 - str r1, [r0, #32] - mov r1, r13 - str r1, [r0, #36] - - @ return the sp - mov r0, sp - bx lr - - .size gc_helper_get_regs_and_sp, .-gc_helper_get_regs_and_sp -- cgit v1.2.3