device: give device state variables a linker section
This groups the device state variables in their own linker section. This is needed for demand paging as these variables are needed during boot where the paging mechanism has not been initialized. These variables need to be in the pinned section so they can be accessed during boot. Note that if device PM is not enabled, the device state variables are put into BSS. So we need to pin these. Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
parent
e6f168c1bc
commit
54c4525094
|
@ -27,6 +27,7 @@
|
|||
*/
|
||||
|
||||
#include <init.h>
|
||||
#include <linker/sections.h>
|
||||
#include <pm/device.h>
|
||||
#include <sys/device_mmio.h>
|
||||
#include <sys/util.h>
|
||||
|
@ -835,7 +836,8 @@ BUILD_ASSERT(sizeof(device_handle_t) == 2, "fix the linker scripts");
|
|||
* is associated with the device
|
||||
*/
|
||||
#define Z_DEVICE_STATE_DEFINE(node_id, dev_name) \
|
||||
static struct device_state Z_DEVICE_STATE_NAME(dev_name) = { \
|
||||
static struct device_state Z_DEVICE_STATE_NAME(dev_name) \
|
||||
__attribute__((__section__(".z_devstate"))) = { \
|
||||
.pm = { \
|
||||
.flags = ATOMIC_INIT(COND_CODE_1( \
|
||||
DT_NODE_EXISTS(node_id), \
|
||||
|
@ -851,6 +853,7 @@ BUILD_ASSERT(sizeof(device_handle_t) == 2, "fix the linker scripts");
|
|||
.pm = &Z_DEVICE_STATE_NAME(dev_name).pm,
|
||||
#else
|
||||
#define Z_DEVICE_STATE_DEFINE(node_id, dev_name) \
|
||||
__pinned_bss \
|
||||
static struct device_state Z_DEVICE_STATE_NAME(dev_name);
|
||||
#define Z_DEVICE_DEFINE_PM_INIT(dev_name, pm_control_fn)
|
||||
#endif
|
||||
|
|
|
@ -23,6 +23,15 @@
|
|||
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
|
||||
#endif
|
||||
|
||||
SECTION_DATA_PROLOGUE(device_states,,)
|
||||
{
|
||||
/* Device states used by the device objects. */
|
||||
__device_states_start = .;
|
||||
KEEP(*(".z_devstate"));
|
||||
KEEP(*(".z_devstate.*"));
|
||||
__device_states_end = .;
|
||||
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
|
||||
|
||||
#if CONFIG_PM_DEVICE
|
||||
SECTION_DATA_PROLOGUE(pm_device_slots, (NOLOAD),)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue