osi_section.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* Copyright (C) 2018 RDA Technologies Limited and/or its affiliates("RDA").
  2. * All rights reserved.
  3. *
  4. * This software is supplied "AS IS" without any warranties.
  5. * RDA assumes no responsibility or liability for the use of the software,
  6. * conveys no license or title under any patent, copyright, or mask work
  7. * right to the product. RDA reserves the right to make changes in the
  8. * software without notification. RDA also make no representation or
  9. * warranty that such application will be suitable for the specified use
  10. * without further testing or modification.
  11. */
  12. #ifndef _OSI_SECTION_H_
  13. #define _OSI_SECTION_H_
  14. #include "osi_compiler.h"
  15. // macro for load section, symbol naming style matches linker script
  16. #define OSI_LOAD_SECTION(name) \
  17. do \
  18. { \
  19. extern uint32_t __##name##_start[]; \
  20. extern uint32_t __##name##_end[]; \
  21. extern uint32_t __##name##_load_start[]; \
  22. uint32_t *p; \
  23. uint32_t *l; \
  24. for (p = __##name##_start, \
  25. l = __##name##_load_start; \
  26. p < __##name##_end;) \
  27. *p++ = *l++; \
  28. } while (0)
  29. // macro for clear section, symbol naming style matches linker script
  30. #define OSI_CLEAR_SECTION(name) \
  31. do \
  32. { \
  33. extern uint32_t __##name##_start[]; \
  34. extern uint32_t __##name##_end[]; \
  35. uint32_t *p; \
  36. for (p = __##name##_start; \
  37. p < __##name##_end;) \
  38. *p++ = 0; \
  39. } while (0)
  40. // macros for "known" sections
  41. #define OSI_SECTION_SRAM_BOOT_TEXT OSI_SECTION(.sramboottext)
  42. #define OSI_SECTION_SRAM_TEXT OSI_SECTION(.sramtext)
  43. #define OSI_SECTION_SRAM_DATA OSI_SECTION(.sramdata)
  44. #define OSI_SECTION_SRAM_BSS OSI_SECTION(.srambss)
  45. #define OSI_SECTION_SRAM_UNINIT OSI_SECTION(.sramuninit)
  46. #define OSI_SECTION_SRAM_UC_DATA OSI_SECTION(.sramucdata)
  47. #define OSI_SECTION_SRAM_UC_BSS OSI_SECTION(.sramucbss)
  48. #define OSI_SECTION_SRAM_UC_UNINIT OSI_SECTION(.sramucuninit)
  49. #define OSI_SECTION_RAM_TEXT OSI_SECTION(.ramtext)
  50. #define OSI_SECTION_RAM_DATA OSI_SECTION(.ramdata)
  51. #define OSI_SECTION_RAM_BSS OSI_SECTION(.rambss)
  52. #define OSI_SECTION_RAM_UNINIT OSI_SECTION(.ramuninit)
  53. #define OSI_SECTION_RAM_UC_DATA OSI_SECTION(.ramucdata)
  54. #define OSI_SECTION_RAM_UC_BSS OSI_SECTION(.ramucbss)
  55. #define OSI_SECTION_RAM_UC_UNINIT OSI_SECTION(.ramucuninit)
  56. #define OSI_SECTION_BOOT_TEXT OSI_SECTION(.boottext)
  57. #define OSI_SECTION_RO_KEEP __attribute__((used, section(".rokeep")))
  58. #define OSI_SECTION_RW_KEEP __attribute__((used, section(".rwkeep")))
  59. #ifndef OSI_SOURCE_FILE_ID
  60. #define OSI_SOURCE_FILE_ID ""
  61. #endif
  62. #define OSI_CODE_SECTION(code) __attribute__((section(OSI_STRINGFY(code) "." OSI_SOURCE_FILE_ID "." OSI_STRINGFY(__LINE__))))
  63. #define OSI_LOG_HOT_CODE OSI_CODE_SECTION(.text.log)
  64. #define OSI_KERNEL_HOT_CODE OSI_CODE_SECTION(.text.kernel)
  65. #define OSI_NL1C_HOT_CODE OSI_CODE_SECTION(.text.nl1c)
  66. #define OSI_NL1C_HOT_NOINLINE_CODE OSI_CODE_SECTION(.text.nl1c)
  67. #define OSI_RFD_HOT_CODE OSI_CODE_SECTION(.text.rfd)
  68. #define OSI_ERRC_HOT_CODE OSI_CODE_SECTION(.text.errc)
  69. #define OSI_EMAC_HOT_CODE OSI_CODE_SECTION(.text.emac)
  70. #define OSI_DBA_HOT_CODE OSI_CODE_SECTION(.text.dba)
  71. #define OSI_SECTION_LINE(s) __attribute__((section(OSI_STRINGFY(s) "." OSI_STRINGFY(__LINE__))))
  72. #endif