Skip to content

Commit ba94780

Browse files
dcpleungcfriedt
authored andcommitted
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 <[email protected]>
1 parent 802b55b commit ba94780

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

tests/kernel/device/src/main.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <ztest.h>
1111
#include <sys/printk.h>
1212
#include <pm/device_runtime.h>
13+
#include <linker/sections.h>
1314
#include "abstract_driver.h"
1415

1516

@@ -130,14 +131,17 @@ static void test_null_dynamic_name(void)
130131
#endif
131132
}
132133

134+
__pinned_bss
133135
static struct init_record {
134136
bool pre_kernel;
135137
bool is_in_isr;
136138
bool is_pre_kernel;
137139
} init_records[4];
138140

141+
__pinned_data
139142
static struct init_record *rp = init_records;
140143

144+
__pinned_func
141145
static int add_init_record(bool pre_kernel)
142146
{
143147
rp->pre_kernel = pre_kernel;
@@ -147,11 +151,13 @@ static int add_init_record(bool pre_kernel)
147151
return 0;
148152
}
149153

154+
__pinned_func
150155
static int pre1_fn(const struct device *dev)
151156
{
152157
return add_init_record(true);
153158
}
154159

160+
__pinned_func
155161
static int pre2_fn(const struct device *dev)
156162
{
157163
return add_init_record(true);

tests/kernel/device/src/test_driver_init.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <device.h>
99
#include <init.h>
1010
#include <ztest.h>
11+
#include <linker/sections.h>
1112

1213

1314
/**
@@ -36,10 +37,10 @@
3637

3738

3839
/* this is for storing sequence during initializtion */
39-
int init_level_sequence[4] = {0};
40-
int init_priority_sequence[4] = {0};
41-
unsigned int seq_level_cnt;
42-
unsigned int seq_priority_cnt;
40+
__pinned_bss int init_level_sequence[4] = {0};
41+
__pinned_bss int init_priority_sequence[4] = {0};
42+
__pinned_bss unsigned int seq_level_cnt;
43+
__pinned_bss unsigned int seq_priority_cnt;
4344

4445
/* define driver type 1: for testing initialize levels and priorites */
4546
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 = {
5859
};
5960

6061
/* driver init function of testing level */
62+
__pinned_func
6163
static int my_driver_lv_1_init(const struct device *dev)
6264
{
6365
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)
6668
return 0;
6769
}
6870

71+
__pinned_func
6972
static int my_driver_lv_2_init(const struct device *dev)
7073
{
7174
init_level_sequence[seq_level_cnt] = LEVEL_PRE_KERNEL_2;

0 commit comments

Comments
 (0)