# HG changeset patch # User jld # Date 1393835432 0 # Node ID 0e7f32e78b4d1f8a05d802785f8a28b357bbc00b # Parent 8cd345c99e6bae7b49d926bd9702292280ffedad * src/mcount.S: Add mcount functions for call-graph profiling. * cdl/hal_cortexm.cdl: Add option to build mcount functions. [ Bugzilla 1001954 ] diff --git a/packages/NEWS b/packages/NEWS --- a/packages/NEWS +++ b/packages/NEWS @@ -1,4 +1,13 @@ +* Cortex-M call-graph profiling support by John Dallaway. +* Complex number math library port from newlib by Ilija Kocho. +* Single-precision floating point math library port from newlib by + Ilija Kocho and Visar Zejnullahu. +* Freescale Kinetis TWR-K60F120M platform HAL by Mike Jones. * STMicroelectronics STM32F4-Discovery platform HAL by John Dallaway. +* Freescale I2C driver by Tomas Frydrych. +* STMicroelectronics STM32 ethernet driver by Jerzy Dyrda. +* Freescale Kinetis TWR-K70F120M port by Ilija Kocho. +* Microchip ENC424J600 ethernet driver by Ilija Stanislevik. * Cortex-M STM32 F2 processor support with board support for STM3220G-EVAL and STM3240G-EVAL, along with many STM32 improvements. Contributed by eCosCentric Limited. diff --git a/packages/hal/cortexm/arch/current/ChangeLog b/packages/hal/cortexm/arch/current/ChangeLog --- a/packages/hal/cortexm/arch/current/ChangeLog +++ b/packages/hal/cortexm/arch/current/ChangeLog @@ -1,3 +1,9 @@ +2014-02-28 John Dallaway + + * src/mcount.S: Add mcount functions for call-graph profiling. + * cdl/hal_cortexm.cdl: Add option to build mcount functions. + [ Bugzilla 1001954 ] + 2013-08-25 Ilija Kocho * cdl/hal_cortexm_fpu.cdl, include/fpv4_sp_d16_libm.h: Define Cortex-M4F @@ -187,7 +193,7 @@ 2008-10-06 Nick Garnett + +/* +// GCC inserts mcount code at the start of every function when compiling +// with "-pg". For GCC prior to version 4.4 targeting Cortex-M, +// the following code is inserted: +// +// mov r12, lr +// bl mcount +// .word +// +// For GCC version 4.4 and later targeting Cortex-M, the following code is +// inserted: +// +// push { lr } +// bl __gnu_mcount_nc +// +// We provide implementations of both mcount() and __gnu_mcount_nc() to +// call the eCos __profile_mcount() function. +*/ + + .syntax unified + .globl mcount + .section .text.mcount + .thumb_func +mcount: + // resume execution beyond the data pointer on return to caller + add lr, lr, #4 + + // caller assumes r0-r3 will be preserved (non-AAPCS), we use + // r6 and must preserve lr across our __profile_mcount() call + push { r0, r1, r2, r3, r6, lr } + + // set up parameters for __profile_mcount() + sub r0, r12, #2 + bic r0, r0, #1 + bic r1, lr, #1 + + // disable interrupts + mov r2, #CYGNUM_HAL_CORTEXM_PRIORITY_MAX + mrs r6, basepri + msr basepri, r2 + + // call eCos __profile_mcount() + // r6 is preserved across the call per AAPCS + bl __profile_mcount + + // restore interrupts + msr basepri, r6 + + // restore registers and return + pop { r0, r1, r2, r3, r6, pc } + + + .globl __gnu_mcount_nc + .section .text.__gnu_mcount_nc + .thumb_func +__gnu_mcount_nc: + // caller assumes r0-r3 will be preserved (non-AAPCS), we use + // r6 and must preserve lr across our __profile_mcount() call + push { r0, r1, r2, r3, r6, lr } + + // set up parameters for __profile_mcount() + ldr r0, [ sp, #24 ] + sub r0, r0, #2 + bic r0, r0, #1 + bic r1, lr, #1 + + // disable interrupts + mov r2, #CYGNUM_HAL_CORTEXM_PRIORITY_MAX + mrs r6, basepri + msr basepri, r2 + + // call eCos __profile_mcount() + // r6 is preserved across the call per AAPCS + bl __profile_mcount + + // restore interrupts + msr basepri, r6 + + // restore registers and return + pop { r0, r1, r2, r3, r6, r12, lr } + bx r12 + +//========================================================================== +// end of mcount.S