Advertisement
Mike057

startup.h

Jun 8th, 2025
390
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 5.94 KB | None | 0 0
  1. /*
  2.  * Copyright 2013 - 2014, Freescale Semiconductor, Inc.
  3.  * Copyright 2016-2021, 2023 NXP
  4.  *                                                                                                                                                                                                                                                    
  5.  * SPDX-License-Identifier: BSD-3-Clause
  6.  */
  7.  
  8. #ifndef STARTUP_H
  9. #define STARTUP_H
  10.  
  11. #include <stdint.h>
  12. #include "device_registers.h"
  13. /**
  14.  * @page misra_violations MISRA-C:2012 violations
  15.  *
  16.  * @section [global]
  17.  * Violates MISRA 2012 Advisory Rule 2.5, Local macro not referenced.
  18.  * The defined macro is used as include guard.
  19.  *
  20.  * @section [global]
  21.  * Violates MISRA 2012 Advisory Rule 8.9, An object should be defined at block
  22.  * scope if its identifier only appears in a single function.
  23.  * All variables with this problem are defined in the linker files.
  24.  *
  25.  */
  26.  
  27. /*******************************************************************************
  28.  * API
  29.  ******************************************************************************/
  30.  
  31. /*!
  32.  * @brief define symbols that specific start and end addres of some basic sections.
  33.  */
  34. #if (defined(S32K14x_SERIES) || defined(S32K11x_SERIES) || defined(S32V234_SERIES) || \
  35.      defined(MPC574x_SERIES) || defined(S32R_SERIES) || defined(S32MTV_SERIES) || \
  36.      defined(SJA1110_SERIES)) || defined (S32K144W_M4_SERIES) || defined (S32K142W_M4_SERIES)
  37.     #if (defined(__ICCARM__))
  38.         #define INTERRUPTS_SECTION_START               __section_begin(".intvec")
  39.         #define INTERRUPTS_SECTION_END                 __section_end(".intvec")
  40.         #define BSS_SECTION_START                      __section_begin(".bss")
  41.         #define BSS_SECTION_END                        __section_end(".bss")
  42.         #define DATA_SECTION_START                     __section_begin(".data")
  43.         #define DATA_SECTION_END                       __section_end(".data")
  44.         #define CUSTOMSECTION_SECTION_START            __section_begin(".customSection")
  45.         #define CUSTOMSECTION_SECTION_END              __section_end(".customSection")
  46.         #define CODE_RAM_SECTION_START                 __section_begin("__CODE_RAM")
  47.         #define CODE_RAM_SECTION_END                   __section_end("__CODE_RAM")
  48.         #define DATA_INIT_SECTION_START                __section_begin(".data_init")
  49.         #define DATA_INIT_SECTION_END                  __section_end(".data_init")
  50.         #define CODE_ROM_SECTION_START                 __section_begin("__CODE_ROM")
  51.         #define CODE_ROM_SECTION_END                   __section_end("__CODE_ROM")
  52.  
  53.     #elif (defined(__ARMCC_VERSION))
  54.         #define INTERRUPTS_SECTION_START               (uint8_t *)__VECTOR_ROM_START
  55.         #define INTERRUPTS_SECTION_END                 (uint8_t *)__VECTOR_ROM_END
  56.         #define BSS_SECTION_START                      (uint8_t *)__BSS_START
  57.         #define BSS_SECTION_END                        (uint8_t *)__BSS_END
  58.         #define DATA_SECTION_START                     (uint8_t *)__DATA_RAM_START
  59.         #define DATA_SECTION_END                       (uint8_t *)__DATA_RAM_END
  60.         #define CUSTOMSECTION_SECTION_START            (uint8_t *)__CUSTOM_SECTION_START
  61.         #define CUSTOMSECTION_SECTION_END              (uint8_t *)__CUSTOM_SECTION_END
  62.         #define CODE_RAM_SECTION_START                 (uint8_t *)__CODE_RAM_START
  63.         #define CODE_RAM_SECTION_END                   (uint8_t *)__CODE_RAM_END
  64.  
  65.         extern uint32_t __VECTOR_ROM_START;
  66.         extern uint32_t __VECTOR_ROM_END;
  67.         extern uint32_t __BSS_START;
  68.         extern uint32_t __BSS_END;
  69.         extern uint32_t __DATA_RAM_START;
  70.         extern uint32_t __DATA_RAM_END;
  71.         extern uint32_t __CUSTOM_SECTION_START;
  72.         extern uint32_t __CUSTOM_SECTION_END;
  73.         extern uint32_t __CODE_RAM_START;
  74.         extern uint32_t __CODE_RAM_END;
  75.     #else
  76.         #define INTERRUPTS_SECTION_START               (uint8_t *)&__interrupts_start__
  77.         #define INTERRUPTS_SECTION_END                 (uint8_t *)&__interrupts_end__
  78.         #define BSS_SECTION_START                      (uint8_t *)&__bss_start__
  79.         #define BSS_SECTION_END                        (uint8_t *)&__bss_end__
  80.         #define DATA_SECTION_START                     (uint8_t *)&__data_start__
  81.         #define DATA_SECTION_END                       (uint8_t *)&__data_end__
  82.         #define CUSTOMSECTION_SECTION_START            (uint8_t *)&__customSection_start__
  83.         #define CUSTOMSECTION_SECTION_END              (uint8_t *)&__customSection_end__
  84.         #define CODE_RAM_SECTION_START                 (uint8_t *)&__code_ram_start__
  85.         #define CODE_RAM_SECTION_END                   (uint8_t *)&__code_ram_end__
  86.  
  87.         extern uint32_t __interrupts_start__;
  88.         extern uint32_t __interrupts_end__;
  89.         extern uint32_t __bss_start__;
  90.         extern uint32_t __bss_end__;
  91.         extern uint32_t __data_start__;
  92.         extern uint32_t __data_end__;
  93.         extern uint32_t __customSection_start__;
  94.         extern uint32_t __customSection_end__;
  95.         extern uint32_t __code_ram_start__;
  96.         extern uint32_t __code_ram_end__;
  97.     #endif
  98. #endif
  99.  
  100. #if (defined(__ICCARM__))
  101.     #pragma section = ".data"
  102.     #pragma section = ".data_init"
  103.     #pragma section = ".bss"
  104.     #pragma section = ".intvec"
  105.     #pragma section = ".customSection"
  106.     #pragma section = ".customSection_init"
  107.     #pragma section = "__CODE_RAM"
  108.     #pragma section = "__CODE_ROM"
  109. #endif
  110.  
  111. /*!
  112.  * @brief Make necessary initializations for RAM.
  113.  *
  114.  * - Copy initialized data from ROM to RAM.
  115.  * - Clear the zero-initialized data section.
  116.  * - Copy the vector table from ROM to RAM. This could be an option.
  117.  */
  118. void init_data_bss(void);
  119.  
  120. #endif /* STARTUP_H*/
  121. /*******************************************************************************
  122.  * EOF
  123.  ******************************************************************************/
  124.  
  125.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement