commit f9584892ede82f88c87a567f79f8e11fed42cdfa
parent e7760c1a36c1865d4df268b65cd8d53a126a7d3d
Author: Matsuda Kenji <info@mtkn.jp>
Date: Wed, 27 Mar 2024 07:43:12 +0900
change sp from msp to psp. something weird
Diffstat:
2 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/ex3/main.c b/ex3/main.c
@@ -9,6 +9,7 @@ void wfi(void);
void print_sp(void);
void *memcpy(void *s1, void *s2, long n);
void restore_context(unsigned int [17]);
+void set_psp(void);
// A proc represents a process in execution.
typedef struct proc {
@@ -64,6 +65,8 @@ main(void) {
p1.r[16] = 0;
p1.next = NULL;
+ set_psp();
+
proc0();
return 0;
diff --git a/ex3/proc.s b/ex3/proc.s
@@ -163,3 +163,14 @@ restore_context:
msr xpsr, r1
ldm r0, {r0-r7}
bx r8
+
+ // void set_psp(void);
+ // Set_psp changes the stack to use to psp and set it to 0x20000100
+ // TODO: ISB barrier?
+ .global set_psp
+set_psp:
+ mov r0, #2
+ msr control, r0
+ ldr r0, =0x20000100
+ mov sp, r0
+ bx lr
+\ No newline at end of file