中斷與切換

撰寫中 ....

切換

範例 6 : context_switch.S

.thumb
.syntax unified

.type svc_handler, %function
.global svc_handler
svc_handler:
    /* save user state */
    mrs r0, psp
    stmdb r0!, {r4, r5, r6, r7, r8, r9, r10, r11, lr}

    /* load kernel state */
    pop {r4, r5, r6, r7, r8, r9, r10, r11, ip, lr}
    msr psr, ip

    bx lr

.global activate
activate:
    /* save kernel state */
    mrs ip, psr
    push {r4, r5, r6, r7, r8, r9, r10, r11, ip, lr}

    /* switch to process stack */
    msr psp, r0
    mov r0, #3
    msr control, r0

    /* load user state */
    pop {r4, r5, r6, r7, r8, r9, r10, r11, lr}

    /* jump to user task */
    bx lr

系統呼叫

範例 7 : syscall.S

.thumb
.syntax unified

.global syscall
syscall:
    svc 0
    nop
    bx lr

results matching ""

    No results matching ""