Skip to content

Commit 04c334a

Browse files
ioannisgandrewboie
authored andcommitted
tests: kernel: userspace: replace inline assembly with C code
We replace an inline assembly block of code with CMSIS functions, to make it portable to ARMv6-M architecture. Signed-off-by: Ioannis Glaropoulos <[email protected]>
1 parent a92a35c commit 04c334a

File tree

1 file changed

+7
-8
lines changed
  • tests/kernel/mem_protect/userspace/src

1 file changed

+7
-8
lines changed

tests/kernel/mem_protect/userspace/src/main.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,13 @@ static void write_control(void)
125125

126126
expect_fault = false;
127127
BARRIER();
128-
__asm__ volatile (
129-
"mrs %0, CONTROL;\n\t"
130-
"bic %0, #1;\n\t"
131-
"msr CONTROL, %0;\n\t"
132-
"mrs %0, CONTROL;\n\t"
133-
: "=r" (msr_value)::
134-
);
135-
zassert_true((msr_value & 1),
128+
msr_value = __get_CONTROL();
129+
msr_value &= ~(CONTROL_nPRIV_Msk);
130+
__set_CONTROL(msr_value);
131+
__DSB();
132+
__ISB();
133+
msr_value = __get_CONTROL();
134+
zassert_true((msr_value & (CONTROL_nPRIV_Msk)),
136135
"Write to control register was successful");
137136
#elif defined(CONFIG_ARC)
138137
unsigned int er_status;

0 commit comments

Comments
 (0)