cederom commented on code in PR #16687:
URL: https://github.com/apache/nuttx/pull/16687#discussion_r2193596420


##########
arch/avr/src/avr/Kconfig:
##########
@@ -94,8 +110,76 @@ config AVR_HAS_MEMX_PTR
                pointers in arbitrary interaction with the kernel. Not all API
                functions have these qualifiers added to their parameters.
 
+config AVR_HAS_FLMAP
+       bool "Use memory-mapped access to flash"
+       depends on AVR_BOARD_HAS_FLMAP && AVR_CHIP_HAS_FLMAP
+       ---help---
+               Newer AVR chips - namely tinyAVR and AVR families - have (part 
of)
+               their program memory (flash) mapped into data memory address 
space.
+               The mapping is limited to 32kB window.
+
+               With this option enabled, const variables are kept in the 
program
+               memory and no copy to RAM is done. Yet it is still possible to 
use
+               such variables in any interaction with the kernel as they are
+               visible in data memory address space.
+
+               Note that this option only triggers some basic configuration
+               in the init function. It is the linker script of the board that 
needs
+               to ensure variables are placed correctly.
+
+               Beware that FLMAP bits in NVMCTRL.CTRLB I/O register which 
select
+               the segment of program memory to be mapped may not be changed 
freely
+               by the application. If the application needs to change the 
mapping,
+               it may only do so while observing these rules:
+
+               1. No kernel function must be called until the original value
+               is restored.
+
+               2. Interrupts must be disabled for as long as the value is 
changed.
+
+endchoice # Const variable placement
+
+config AVR_FLMAP_RODATA_SIZE
+       int "Size of .rodata FLMAP section"
+       depends on AVR_HAS_FLMAP
+       default 4096
+       ---help---
+               Specify size of .rodata memory section, ie. the section that 
stores
+               const variables. This will be passed as a parameter to the 
linker
+               to be used by the board's linker script.
+
+               Value must be divisible by 512 and no more than 32 kilobytes
+               is possible.
+
+config AVR_FLMAP_RODATA_OFFSET
+       int "Offset of .rodata FLMAP section"
+       depends on AVR_HAS_FLMAP
+       default 0
+       ---help---
+               Specify size of memory block between end of the .rodata section
+               (counting its full size as defined in AVR_FLMAP_RODATA_SIZE)
+               and the end of flash.
+
+               This value is intended to leave the end of the flash unused,
+               presumably for the purpose of placing APPDATA section in there
+               (see the chip documentation for details about subdividing
+               the program flash to BOOT, APPCODE and APPDATA sections.)
+
+               Note that this value is only passed to the linker to be used
+               by the linker script - the script then needs to place
+               the .rodata section accordingly.
+
+               Value must be divisible by 512 and no more than 31 kilobytes
+               is possible. Sum of this value and AVR_FLMAP_RODATA_SIZE must
+               also not exceed 32kB.
 
 config AVR_HAS_RAMPZ
        bool
 
+config AVR_BOARD_HAS_FLMAP
+       bool
+
+config AVR_CHIP_HAS_FLMAP

Review Comment:
   `ARCH_HAVE_AVR_FLMAP` ?  existing `ARCH_HAVE_` prefix aligns with existing 
nomenclature and allows easy filtering / sorting? :-)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to