PebbleOS v4.47.0-512-g5285d4236
Loading...
Searching...
No Matches
Code and data placement

Placement of code and data in special sections. More...

Macros

#define PBL_SECTION_RAM
 Run the function from RAM; also prevents inlining it into flash code.
 
#define PBL_SECTION_RAM_RODATA
 Place the constant in RAM, for tables used by PBL_SECTION_RAM functions.
 
#define PBL_ITERABLE_SECTION(type, tag, key)    PBL_USED PBL_ALIGNED(alignof(type)) PBL_SECTION_IMPL(".i_" #tag "." key)
 Add the object to an iterable section, a table gathered at link time from any file.
 
#define PBL_ITERABLE_SECTION_DECLARE(type, tag)
 Declare the bounds of an iterable section.
 
#define PBL_ITERABLE_SECTION_START(tag)   __start_i_##tag
 First entry of an iterable section declared with PBL_ITERABLE_SECTION_DECLARE.
 
#define PBL_ITERABLE_SECTION_END(tag)   __stop_i_##tag
 End of an iterable section declared with PBL_ITERABLE_SECTION_DECLARE.
 
#define PBL_ITERABLE_SECTION_FOREACH(type, tag, var)    for (type *var = PBL_ITERABLE_SECTION_START(tag); var < PBL_ITERABLE_SECTION_END(tag); var++)
 Loop over the entries of an iterable section.
 

Detailed Description

Placement of code and data in special sections.

SoCs that need code to run while flash is unavailable select CONFIG_RAMFUNC, which adds a .ramfunc section loaded from flash and copied to RAM at boot. Without it these markers are no-ops and everything stays in flash.

static const uint8_t s_table[] PBL_SECTION_RAM_RODATA = {1, 2, 4, 8};
PBL_SECTION_RAM void prv_enter_sleep(void) {
// flash is off here
}
#define PBL_SECTION_RAM_RODATA
Place the constant in RAM, for tables used by PBL_SECTION_RAM functions.
Definition section.h:42
#define PBL_SECTION_RAM
Run the function from RAM; also prevents inlining it into flash code.
Definition section.h:41

Macro Definition Documentation

◆ PBL_ITERABLE_SECTION

#define PBL_ITERABLE_SECTION (   type,
  tag,
  key 
)     PBL_USED PBL_ALIGNED(alignof(type)) PBL_SECTION_IMPL(".i_" #tag "." key)

Add the object to an iterable section, a table gathered at link time from any file.

Where the firmware linker script gathers the section, the entries are sorted by key, or kept in link order if the section is registered as unsorted; elsewhere they come in no particular order. The section is registered with pbl_iterable_section() in CMake, and may be empty. Objects must be constant.

// where the table is walked
PBL_ITERABLE_SECTION_DECLARE(const struct foo, foos);
PBL_ITERABLE_SECTION_FOREACH(const struct foo, foos, foo) {
...
}
// any file
static const struct foo s_foo PBL_ITERABLE_SECTION(struct foo, foos, "bar") = {...};
#define PBL_ITERABLE_SECTION(type, tag, key)
Add the object to an iterable section, a table gathered at link time from any file.
Definition section.h:124
#define PBL_ITERABLE_SECTION_FOREACH(type, tag, var)
Loop over the entries of an iterable section.
Definition section.h:104
#define PBL_ITERABLE_SECTION_DECLARE(type, tag)
Declare the bounds of an iterable section.
Definition section.h:126
Parameters
typeType of the entries.
tagTable name, a C identifier of at most 14 characters. Its section is named after it with an i_ prefix, which fits the 16 characters Mach-O allows.
keySort key, a string.

◆ PBL_ITERABLE_SECTION_DECLARE

#define PBL_ITERABLE_SECTION_DECLARE (   type,
  tag 
)
Value:
extern type PBL_ITERABLE_SECTION_START(tag)[]; \
extern type PBL_ITERABLE_SECTION_END(tag)[]
#define PBL_ITERABLE_SECTION_END(tag)
End of an iterable section declared with PBL_ITERABLE_SECTION_DECLARE.
Definition section.h:94
#define PBL_ITERABLE_SECTION_START(tag)
First entry of an iterable section declared with PBL_ITERABLE_SECTION_DECLARE.
Definition section.h:86

Declare the bounds of an iterable section.

Parameters
typeType of the entries.
tagSection name.

◆ PBL_ITERABLE_SECTION_END

#define PBL_ITERABLE_SECTION_END (   tag)    __stop_i_##tag

End of an iterable section declared with PBL_ITERABLE_SECTION_DECLARE.

Parameters
tagSection name.

◆ PBL_ITERABLE_SECTION_FOREACH

#define PBL_ITERABLE_SECTION_FOREACH (   type,
  tag,
  var 
)     for (type *var = PBL_ITERABLE_SECTION_START(tag); var < PBL_ITERABLE_SECTION_END(tag); var++)

Loop over the entries of an iterable section.

Parameters
typeType of the entries.
tagSection name.
varName of the loop variable, a pointer to the entry.

◆ PBL_ITERABLE_SECTION_START

#define PBL_ITERABLE_SECTION_START (   tag)    __start_i_##tag

First entry of an iterable section declared with PBL_ITERABLE_SECTION_DECLARE.

Parameters
tagSection name.

◆ PBL_SECTION_RAM

#define PBL_SECTION_RAM

Run the function from RAM; also prevents inlining it into flash code.

◆ PBL_SECTION_RAM_RODATA

#define PBL_SECTION_RAM_RODATA

Place the constant in RAM, for tables used by PBL_SECTION_RAM functions.