On Fri, Mar 26, 2021 at 11:41 AM Gregory Nutt <spudan...@gmail.com> wrote:

> Missing bit of logic:
>
> >> Speaking of the linker, is there a way to use a combination of the
> >> linker script and __attribute__ incantations in the code to detect
> >> automatically the size that g_sram4_reserve should be and entirely
> >> eliminate the need for the user to specify the start and end of each
> >> region in Kconfig?
> >
> > Are you thinking of something like this in the linker script:
> >
> >     .sram4_reserve :
> >     {
> >       _sram4_reserve_begin = ABSOLUTE(.);
> >       *(.sram4)
> >       _sram4_reserve_end = ABSOLUTE(.);
> >     }
> >
> > And in the C code:
> >
> We need to lie to C and tell it what to think those symbols are:
>
>     EXTERN const uint32_t _sram4_reserve_begin
>     EXTERN const uint32_t _sram4_reserve_begin



Ah, yes, otherwise those symbols would be undefined. Later the linker will
resolve them to the correct addresses.


>     #define SRAM4_RESERVE_BEGIN &_sram4_reserve_begin
> >     #define SRAM4_RESERVE_END &_sram4_reserve_end
> >
> > The implied size depends on the size of all .sram4 sections.  I assume
> > this would be positioned at the beginning of SRAM4 and the size of the
> > region that could be added to the heap would be SRAM4_RESERVE_END
> > through SRAM_END.
> >
> You can see this same kind of thing in, for example,
> arch/arm/src/common/arm_internal.h



Great! Thanks

Nathan

Reply via email to