cmake: extend linker snippets for pinned sections

This extends the linker snippet code to cover pinned
sections.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
Daniel Leung 2022-07-26 13:14:05 -07:00 committed by Carles Cufí
commit 1ace8efb8a

View file

@ -1148,6 +1148,11 @@ endfunction(zephyr_check_compiler_flag_hardcoded)
# RAMFUNC_SECTION Inside the RAMFUNC RAMABLE_REGION GROUP, not initialized.
# SECTIONS Near the end of the file. Don't use this when linking into
# RAMABLE_REGION, use RAM_SECTIONS instead.
# PINNED_RODATA Similar to RODATA but pinned in memory.
# PINNED_RAM_SECTIONS
# Similar to RAM_SECTIONS but pinned in memory.
# PINNED_DATA_SECTIONS
# Similar to DATA_SECTIONS but pinned in memory.
# <sort_key> is an optional key to sort by inside of each location. The key must
# be alphanumeric, and the keys are sorted alphabetically. If no key is
# given, the key 'default' is used. Keys are case-sensitive.
@ -1191,6 +1196,10 @@ function(zephyr_linker_sources location)
set(rodata_path "${snippet_base}/snippets-rodata.ld")
set(ramfunc_path "${snippet_base}/snippets-ramfunc-section.ld")
set(pinned_ram_sections_path "${snippet_base}/snippets-pinned-ram-sections.ld")
set(pinned_data_sections_path "${snippet_base}/snippets-pinned-data-sections.ld")
set(pinned_rodata_path "${snippet_base}/snippets-pinned-rodata.ld")
# Clear destination files if this is the first time the function is called.
get_property(cleared GLOBAL PROPERTY snippet_files_cleared)
if (NOT DEFINED cleared)
@ -1202,6 +1211,9 @@ function(zephyr_linker_sources location)
file(WRITE ${rwdata_path} "")
file(WRITE ${rodata_path} "")
file(WRITE ${ramfunc_path} "")
file(WRITE ${pinned_ram_sections_path} "")
file(WRITE ${pinned_data_sections_path} "")
file(WRITE ${pinned_rodata_path} "")
set_property(GLOBAL PROPERTY snippet_files_cleared true)
endif()
@ -1222,6 +1234,12 @@ function(zephyr_linker_sources location)
set(snippet_path "${rodata_path}")
elseif("${location}" STREQUAL "RAMFUNC_SECTION")
set(snippet_path "${ramfunc_path}")
elseif("${location}" STREQUAL "PINNED_RAM_SECTIONS")
set(snippet_path "${pinned_ram_sections_path}")
elseif("${location}" STREQUAL "PINNED_DATA_SECTIONS")
set(snippet_path "${pinned_data_sections_path}")
elseif("${location}" STREQUAL "PINNED_RODATA")
set(snippet_path "${pinned_rodata_path}")
else()
message(fatal_error "Must choose valid location for linker snippet.")
endif()