diff options
author | Christian Cunningham <cc@localhost> | 2022-03-16 22:28:33 -0700 |
---|---|---|
committer | Christian Cunningham <cc@localhost> | 2022-03-16 22:28:33 -0700 |
commit | a9f63b8cdb930d079cc69d492fe44dc8224c1e03 (patch) | |
tree | c97c9f84f5caa2b0cc77850c21f33b9f5cefaecb /src/exceptions/svc.S | |
parent | a3732c11ad3bcd2c01a36d0a82a6f310fe8557af (diff) |
More comments
Diffstat (limited to 'src/exceptions/svc.S')
-rw-r--r-- | src/exceptions/svc.S | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/exceptions/svc.S b/src/exceptions/svc.S index 3fb534e..7c8a9cc 100644 --- a/src/exceptions/svc.S +++ b/src/exceptions/svc.S @@ -3,8 +3,10 @@ svc: cpsid aif stmfd sp!, {r0-r12,lr} + // Get the SVC Exception # ldr r0, [lr, #-4] bic r0, #0xFF000000 + // Jump to the appropriate Call cmp r0, #5 bgt svc_exit beq svc_000005 @@ -18,11 +20,11 @@ svc: beq svc_000001 cmp r0, #0 beq svc_000000 -svc_000000: +svc_000000: // SYS_YIELD bl yield ldmfd sp!, {r0-r12,lr} b schedule -svc_000001: // Get time +svc_000001: // SYS_TIME mov r2, #0x3004 movt r2, #0x3F00 ldr r0, [r2, #4] // <- SYS_TIMER_CLO @@ -50,13 +52,15 @@ svc_000004: // Lock Lock (usr_r0 = struct Lock*) 1: clrex ldrex r2, [r0, #0] cmp r2, #0 + // If it is not available, wait-queue the thread bne svc_000004_delay_mutex + // Otherwise lock it strexeq r2, r1, [r0, #0] teq r2, #0 bne 1b dmb b svc_exit -svc_000004_delay_mutex: +svc_000004_delay_mutex: // Wait-queue the current thread // r0 = struct Lock* m bl sched_mutex_yield ldmfd sp!, {r0-r12,lr} @@ -65,9 +69,11 @@ svc_000005: // Release Lock ldr r0, [sp, #0] // struct Lock* m mov r1, #0 dmb + // Unlock str r1, [r0, #0] dsb sev + // Awake any threads waiting for this lock bl sched_mutex_resurrect ldmfd sp!, {r0-r12,lr} b schedule |