GNURX用のCCRXmachine.hとCCRXmachine.cというソースがe2 studioフォルダにありました(内容は概ね名前から予想される通りのものでした)

こんにちは。NoMaYです。

e2 studio v6.3.0がリリースされていたので、インストールして幾つかプロジェクトを作成して、いつものようにe2 studioのインストールフォルダを眺めていたら、CCRXmachine.hとCCRXmachine.cというファイルがあることに気付きました。中を見てみると、概ねファイル名から予想される通りのソースファイルでした。(今までのe2 studioのインストールフォルダを見直してみたところ、以前からあったことが分かりましたが、今まで気付きませんでした。) ただ、一部コメントアウトされているものがあったり、以前に別スレッド『GUNRX用プロジェクトのスマートコンフィグレータのBSPを見ていて気付いた変な移植コード』で話題にしたことと同じ元のコードの意図を理解していない書き換えがあったり、ちょっと惜しいような気もしました。

e2 studioインストールフォルダ\internal\projectgen\rx\Generate\CCRXConversion\inc\CCRXmachine.h



e2 studioインストールフォルダ\internal\projectgen\rx\Generate\CCRXConversion\inc\CCRXmachine.c



Parents
  • こんにちは。NoMaYです。

    こういう書き方も行われているのですね。真似てみようと思います。あと、今回の私のやり方では変数がレジスタに割り付けられていることを前提にしているので、CISCのRXマイコンではregister宣言を付けるようにするのが良いのかも知れません。(ちなみに、以下の__get_PSP()関数や__TZ_get_PSP_NS()関数のresult変数にregister宣言が付いているのは、メモリの無い領域をスタックポインタが指している状況を想定してのことかも知れませんね。他方、__set_PSP()関数や__TZ_set_PSP_NS()関数の前後でauto変数を使わないようにするのは自己責任でしょうね。)

    github.com/ARMmbed/mbed-os/blob/master/cmsis/TARGET_CORTEX_M/cmsis_gcc.h

    #ifndef   __ASM
      #define __ASM                                  __asm
    #endif
    #ifndef   __INLINE
      #define __INLINE                               inline
    #endif
    #ifndef   __STATIC_INLINE
      #define __STATIC_INLINE                        static inline
    #endif
    #ifndef   __STATIC_FORCEINLINE                 
      #define __STATIC_FORCEINLINE                   __attribute__((always_inline)) static inline
    #endif
    /**
      \brief   Get Process Stack Pointer
      \details Returns the current value of the Process Stack Pointer (PSP).
      \return               PSP Register value
     */
    __STATIC_FORCEINLINE uint32_t __get_PSP(void)
    {
      register uint32_t result;

      __ASM volatile ("MRS %0, psp"  : "=r" (result) );
      return(result);
    }

    #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
    /**
      \brief   Get Process Stack Pointer (non-secure)
      \details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state.
      \return               PSP Register value
     */
    __STATIC_FORCEINLINE uint32_t __TZ_get_PSP_NS(void)
    {
      register uint32_t result;

      __ASM volatile ("MRS %0, psp_ns"  : "=r" (result) );
      return(result);
    }
    #endif

    /**
      \brief   Set Process Stack Pointer
      \details Assigns the given value to the Process Stack Pointer (PSP).
      \param [in]    topOfProcStack  Process Stack Pointer value to set
     */
    __STATIC_FORCEINLINE void __set_PSP(uint32_t topOfProcStack)
    {
      __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : );
    }

    #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
    /**
      \brief   Set Process Stack Pointer (non-secure)
      \details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state.
      \param [in]    topOfProcStack  Process Stack Pointer value to set
     */
    __STATIC_FORCEINLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack)
    {
      __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : );
    }
    #endif

    TOPPERS/ATK2でも似たようなことが行われていました。

    dev.toppers.jp/trac_user/contrib/browser/atk2-sc3_fl850f1l/arch/gcc/Compiler.h

    #define INLINE          __inline__
    #define LOCAL_INLINE    static __inline__

    #define Asm             __asm__ volatile    /* インラインアセンブラ(最適化抑止)*/

    dev.toppers.jp/trac_user/contrib/browser/atk2-sc3_fl850f1l/arch/ccrh/Compiler.h

    /*
     *      CXでは,インライン関数は「#pragma」を利用して、関数定義の前に
     *      インライン化するシンボルを予め指定しなければならない.
     *      インライン化するシンボルは,"xxx_inline_symbol.h"にて定義し,
     *      そのため,「Inline」シンボルは空マクロとして実装する.
     */
    #define INLINE
    #define LOCAL_INLINE    static

    /* インライン指定シンボルの登録       */
    #include "target_inline_symbols.h"

    //#define asm           __asm
    //#define Asm           __asm  /* インラインアセンブラ(最適化抑止)*/

     

Reply
  • こんにちは。NoMaYです。

    こういう書き方も行われているのですね。真似てみようと思います。あと、今回の私のやり方では変数がレジスタに割り付けられていることを前提にしているので、CISCのRXマイコンではregister宣言を付けるようにするのが良いのかも知れません。(ちなみに、以下の__get_PSP()関数や__TZ_get_PSP_NS()関数のresult変数にregister宣言が付いているのは、メモリの無い領域をスタックポインタが指している状況を想定してのことかも知れませんね。他方、__set_PSP()関数や__TZ_set_PSP_NS()関数の前後でauto変数を使わないようにするのは自己責任でしょうね。)

    github.com/ARMmbed/mbed-os/blob/master/cmsis/TARGET_CORTEX_M/cmsis_gcc.h

    #ifndef   __ASM
      #define __ASM                                  __asm
    #endif
    #ifndef   __INLINE
      #define __INLINE                               inline
    #endif
    #ifndef   __STATIC_INLINE
      #define __STATIC_INLINE                        static inline
    #endif
    #ifndef   __STATIC_FORCEINLINE                 
      #define __STATIC_FORCEINLINE                   __attribute__((always_inline)) static inline
    #endif
    /**
      \brief   Get Process Stack Pointer
      \details Returns the current value of the Process Stack Pointer (PSP).
      \return               PSP Register value
     */
    __STATIC_FORCEINLINE uint32_t __get_PSP(void)
    {
      register uint32_t result;

      __ASM volatile ("MRS %0, psp"  : "=r" (result) );
      return(result);
    }

    #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
    /**
      \brief   Get Process Stack Pointer (non-secure)
      \details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state.
      \return               PSP Register value
     */
    __STATIC_FORCEINLINE uint32_t __TZ_get_PSP_NS(void)
    {
      register uint32_t result;

      __ASM volatile ("MRS %0, psp_ns"  : "=r" (result) );
      return(result);
    }
    #endif

    /**
      \brief   Set Process Stack Pointer
      \details Assigns the given value to the Process Stack Pointer (PSP).
      \param [in]    topOfProcStack  Process Stack Pointer value to set
     */
    __STATIC_FORCEINLINE void __set_PSP(uint32_t topOfProcStack)
    {
      __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : );
    }

    #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
    /**
      \brief   Set Process Stack Pointer (non-secure)
      \details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state.
      \param [in]    topOfProcStack  Process Stack Pointer value to set
     */
    __STATIC_FORCEINLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack)
    {
      __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : );
    }
    #endif

    TOPPERS/ATK2でも似たようなことが行われていました。

    dev.toppers.jp/trac_user/contrib/browser/atk2-sc3_fl850f1l/arch/gcc/Compiler.h

    #define INLINE          __inline__
    #define LOCAL_INLINE    static __inline__

    #define Asm             __asm__ volatile    /* インラインアセンブラ(最適化抑止)*/

    dev.toppers.jp/trac_user/contrib/browser/atk2-sc3_fl850f1l/arch/ccrh/Compiler.h

    /*
     *      CXでは,インライン関数は「#pragma」を利用して、関数定義の前に
     *      インライン化するシンボルを予め指定しなければならない.
     *      インライン化するシンボルは,"xxx_inline_symbol.h"にて定義し,
     *      そのため,「Inline」シンボルは空マクロとして実装する.
     */
    #define INLINE
    #define LOCAL_INLINE    static

    /* インライン指定シンボルの登録       */
    #include "target_inline_symbols.h"

    //#define asm           __asm
    //#define Asm           __asm  /* インラインアセンブラ(最適化抑止)*/

     

Children
No Data