tests: device: pin symbols for testing with demand paging

There are quite a few symbols which are needed before the paging
mechanism is initialized. So they need to be pinned in memory
to prevent page fault early in the boot process.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
Daniel Leung 2021-07-19 14:14:37 -07:00 committed by Christopher Friedt
commit ba94780662
2 changed files with 13 additions and 4 deletions

View file

@ -10,6 +10,7 @@
#include <ztest.h>
#include <sys/printk.h>
#include <pm/device_runtime.h>
#include <linker/sections.h>
#include "abstract_driver.h"
@ -130,14 +131,17 @@ static void test_null_dynamic_name(void)
#endif
}
__pinned_bss
static struct init_record {
bool pre_kernel;
bool is_in_isr;
bool is_pre_kernel;
} init_records[4];
__pinned_data
static struct init_record *rp = init_records;
__pinned_func
static int add_init_record(bool pre_kernel)
{
rp->pre_kernel = pre_kernel;
@ -147,11 +151,13 @@ static int add_init_record(bool pre_kernel)
return 0;
}
__pinned_func
static int pre1_fn(const struct device *dev)
{
return add_init_record(true);
}
__pinned_func
static int pre2_fn(const struct device *dev)
{
return add_init_record(true);

View file

@ -8,6 +8,7 @@
#include <device.h>
#include <init.h>
#include <ztest.h>
#include <linker/sections.h>
/**
@ -36,10 +37,10 @@
/* this is for storing sequence during initializtion */
int init_level_sequence[4] = {0};
int init_priority_sequence[4] = {0};
unsigned int seq_level_cnt;
unsigned int seq_priority_cnt;
__pinned_bss int init_level_sequence[4] = {0};
__pinned_bss int init_priority_sequence[4] = {0};
__pinned_bss unsigned int seq_level_cnt;
__pinned_bss unsigned int seq_priority_cnt;
/* define driver type 1: for testing initialize levels and priorites */
typedef int (*my_api_configure_t)(const struct device *dev, int dev_config);
@ -58,6 +59,7 @@ static const struct my_driver_api funcs_my_drivers = {
};
/* driver init function of testing level */
__pinned_func
static int my_driver_lv_1_init(const struct device *dev)
{
init_level_sequence[seq_level_cnt] = LEVEL_PRE_KERNEL_1;
@ -66,6 +68,7 @@ static int my_driver_lv_1_init(const struct device *dev)
return 0;
}
__pinned_func
static int my_driver_lv_2_init(const struct device *dev)
{
init_level_sequence[seq_level_cnt] = LEVEL_PRE_KERNEL_2;