📄 uc_zsp_s.s
字号:
lddu r6, r4, 2
lddu r8, r4, 2
lddu r10, r4, 2
ldu r13, r4, 1
lddu r14, r4, 2
! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
!
! Now we can disable interrupts
!
! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
bitc %imask, 15
mov r12, r4 ! restore the normal SP from the FP
! and we can now use R4 as a "utility" register
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! !!
!! MASSAGE %IP0, %IMASK !!
!! !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
lddu r0, r12, 2 ! load the values from the stack
mov r4, IP0_SAVE_MASK ! mask off bits[11..0] of the saved IP0
and r0, r4 ! (r0 holds saved IP0 from stack)
not r5, r4 ! invert (one's-comp) the mask
mov r2, %ip0 ! load the current IP0...
and r2, r5 ! ...and mask off bits[15..12]
or r0, r2 ! OR the whole works together
mov r4, IMASK_SAVE_MASK ! mask off bits[13..0] of the saved IMASK
and r1, r4 ! (r1 holds saved IMASK from stack)
not r5, r4 ! invert (one's-comp) the mask
mov r3, %imask ! load the current IMASK...
and r3, r5 ! ...and mask off bits[15..14]
or r1, r3 ! OR the whole works together
bitc r1, 15 ! make sure we get thru the restore successfully
mov %ip0, r0
mov %imask, r1
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
lddu r0, r12, 2
mov %rpc, r0
mov %tpc, r1
lddu r4, r12, 2
lddu r0, r12, 2
ldu r2, r12, 1
add r12, 3
mov %hwflag, r0 ! restore %HWFLAG, %AMODE, & %FMODE
mov %amode, r1
mov %fmode, r2
ld r3, r12, -3
ld r2, r12, -2
ld r1, r12, -1
ld r0, r12, 0
reti
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! PERFORM A CONTEXT SWITCH (From an ISR)
!
! void OSIntCtxSw (void)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.walign ALIGN_MINOR
_OSIntCtxSw:
add r12, 4 ! ignore call to OSIntExit() -O0, 2, 3
! add r12, 3 ! ignore call to OSIntExit() -O1
lda r1, _OSTCBCur ! OSTCBCur->OSTCBStkPtr = SP
ld r0, r1 ! (save stack ptr in TCB)
st r12, r0
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! Profiler stuff
!
.ifdef PROFILER_SUPPORT
! has the profiler been activated ??
lda r2, _OSProfilerRunning
ld r4, r2
add r4, 0 ! if _OSProfilerRunning == 0, skip...
bz NoUpperIncrement_OSIntCtxSw
mov r4, r0 ! get the OSTCBCur pointer into R4
! increment OSTCBCtxSwitchCounter
add r4, 3 ! increment R4 to point to LSB of OSTCBCur->OSTCBCtxSwitchCounter
ld r2, r4 ! load the LSB of current value of OSTCBCtxSwitchCounter
add r2, 1
st r2, r4
bnc NoUpperIncrement_OSIntCtxSw
add r4, 1 ! increment R4 to point to MSB of OSTCBCur->OSTCBCtxSwitchCounter
ld r2, r4 ! load the MSB of current value of OSTCBCtxSwitchCounter
add r2, 1
st r2, r4
NoUpperIncrement_OSIntCtxSw:
.endif
!
!
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
lda r2, _OSTCBHighRdy ! OSTCBCur = OSTCBHighRdy
ld r0, r2
st r0, r1 ! (R1 still holds _OSTCBCur pointer)
ld r12, r0 ! SP = OSTCBCur->OSTCBStkPtr
lda r1, _OSPrioHighRdy ! OSPrioCur = OSPrioHighRdy
ld r0, r1
lda r1, _OSPrioCur
st r0, r1
mov r4, r12 ! make R4 a frame pointer to start the restore
add r4, 1 ! adjust the FP -- STDU/LDDU not complimentary
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! !!
!! MASSAGE %SMODE !!
!! !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ldu r2, r4, 1
mov r0, SMODE_SAVE_MASK ! mask off bits[15..4, 1..0] of the saved SMODE
and r2, r0 ! (r2 holds saved SMODE from stack)
not r5, r0 ! invert (one's-comp) the mask
mov r0, %smode ! load the current SMODE...
and r0, r5 ! ...and mask off bits[3..2]
or r2, r0 ! OR the whole works together
lddu r0, r4, 2
mov %smode, r2
mov %guard, r0
mov %vitr, r1
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
lddu r2, r4, 2
lddu r0, r4, 2
mov %loop0, r2
mov %loop1, r3
mov %loop2, r0
mov %loop3, r1
lddu r2, r4, 2
lddu r0, r4, 2
mov %cb0_beg, r2
mov %cb1_beg, r3
mov %cb0_end, r0
mov %cb1_end, r1
lddu r6, r4, 2
lddu r8, r4, 2
lddu r10, r4, 2
ldu r13, r4, 1
lddu r14, r4, 2
! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
!
! Now we can disable interrupts
!
! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
bitc %imask, 15
mov r12, r4 ! restore the normal SP from the FP
! and we can now use R4 as a "utility" register
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! !!
!! MASSAGE %IP0, %IMASK !!
!! !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
lddu r0, r12, 2 ! load the values from the stack
mov r4, IP0_SAVE_MASK ! mask off bits[11..0] of the saved IP0
and r0, r4 ! (r0 holds saved IP0 from stack)
not r5, r4 ! invert (one's-comp) the mask
mov r2, %ip0 ! load the current IP0...
and r2, r5 ! ...and mask off bits[15..12]
or r0, r2 ! OR the whole works together
mov r4, IMASK_SAVE_MASK ! mask off bits[13..0] of the saved IMASK
and r1, r4 ! (r1 holds saved IMASK from stack)
not r5, r4 ! invert (one's-comp) the mask
mov r3, %imask ! load the current IMASK...
and r3, r5 ! ...and mask off bits[15..14]
or r1, r3 ! OR the whole works together
bitc r1, 15 ! make sure we get thru the restore successfully
mov %ip0, r0
mov %imask, r1
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
lddu r0, r12, 2
mov %rpc, r0
mov %tpc, r1
lddu r4, r12, 2
lddu r0, r12, 2
ldu r2, r12, 1
add r12, 3
mov %hwflag, r0 ! restore %HWFLAG, %AMODE, & %FMODE
mov %amode, r1
mov %fmode, r2
ld r3, r12, -3
ld r2, r12, -2
ld r1, r12, -1
ld r0, r12, 0
reti
.walign ALIGN_MINOR
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! HANDLE TICK ISR
!
! void OSTickISR (void)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
_OSTickISR:
st r0, r12, 0 ! save R0 & R1
st r1, r12, -1
st r2, r12, -2 ! save R2 & R3
st r3, r12, -3
mov r2, %fmode ! save %FMODE, %AMODE, & %HWFLAG
mov r1, %amode
mov r0, %hwflag
mov %fmode, 0 ! shut off all of %FMODE's oddities
bitc %amode, 0 ! shut off bit reversal
bitc %amode, 1
add r12, -4 ! move the SP to below what we saved
stu r2, r12, -1 ! save %FMODE
stdu r0, r12, -2 ! save %AMODE and %HWFLAG
stdu r4, r12, -2 ! save R4 & R5 -- we'll use R4 for a
! frame pointer later
mov r1, %tpc ! save %TPC & %RPC
mov r0, %rpc
mov r3, %imask ! save %IMASK & %IP0
mov r2, %ip0
stdu r0, r12, -2
stdu r2, r12, -2
! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
!
! Now we can re-enable interrupts
!
! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
bits %imask, 15
stdu r14, r12, -2
stu r13, r12, -1
stdu r10, r12, -2
stdu r8, r12, -2
stdu r6, r12, -2
mov r1, %cb1_end
mov r0, %cb0_end
mov r3, %cb1_beg
mov r2, %cb0_beg
stdu r0, r12, -2
stdu r2, r12, -2
mov r1, %loop3
mov r0, %loop2
mov r3, %loop1
mov r2, %loop0
stdu r0, r12, -2
stdu r2, r12, -2
mov r1, %vitr
mov r0, %guard
mov r2, %smode
stdu r0, r12, -2
stu r2, r12, -1
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! Profiler stuff
!
.ifdef PROFILER_SUPPORT
! has the profiler been activated ??
lda r2, _OSProfilerRunning
ld r4, r2
add r4, 0 ! if _OSProfilerRunning == 0, skip...
bz NoUpperIncrement_OSTickISR
lda r1, _OSTCBCur ! OSTCBCur->OSTCBStkPtr = SP
ld r4, r1
! increment CPU_Usage
add r4, 1 ! increment R4 to point to LSB of OSTCBCur->OSTCBCPU_UsageCounter
ld r2, r4 ! load the LSB of current value of OSTCBCPU_UsageCounter
add r2, 1
st r2, r4
bnc NoUpperIncrement_OSTickISR
add r4, 1 ! increment R4 to point to MSB of OSTCBCur->OSTCBCPU_UsageCounter
ld r2, r4 ! load the MSB of current value of OSTCBCPU_UsageCounter
add r2, 1
st r2, r4
NoUpperIncrement_OSTickISR:
.endif
!
!
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! call OSIntEnter()
lda r0, _OSIntEnter
.walign ALIGN_MINOR
call r0
! call OSTimeTick()
lda r0, _OSTimeTick
.walign ALIGN_MINOR
call r0
! call OSIntExit()
lda r0, _OSIntExit
.walign ALIGN_MINOR
call r0
mov r4, r12 ! make R4 a frame pointer to start the restore
add r4, 1 ! adjust the FP -- STDU/LDDU not complimentary
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! !!
!! MASSAGE %SMODE !!
!! !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ldu r2, r4, 1
mov r0, SMODE_SAVE_MASK ! mask off bits[15..4, 1..0] of the saved SMODE
and r2, r0 ! (r2 holds saved SMODE from stack)
not r5, r0 ! invert (one's-comp) the mask
mov r0, %smode ! load the current SMODE...
and r0, r5 ! ...and mask off bits[3..2]
or r2, r0 ! OR the whole works together
lddu r0, r4, 2
mov %smode, r2
mov %guard, r0
mov %vitr, r1
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
lddu r2, r4, 2
lddu r0, r4, 2
mov %loop0, r2
mov %loop1, r3
mov %loop2, r0
mov %loop3, r1
lddu r2, r4, 2
lddu r0, r4, 2
mov %cb0_beg, r2
mov %cb1_beg, r3
mov %cb0_end, r0
mov %cb1_end, r1
lddu r6, r4, 2
lddu r8, r4, 2
lddu r10, r4, 2
ldu r13, r4, 1
lddu r14, r4, 2
! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
!
! Now we can disable interrupts
!
! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
bitc %imask, 15
mov r12, r4 ! restore the normal SP from the FP
! and we can now use R4 as a "utility" register
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! !!
!! MASSAGE %IP0, %IMASK !!
!! !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
lddu r0, r12, 2 ! load the values from the stack
mov r4, IP0_SAVE_MASK ! mask off bits[11..0] of the saved IP0
and r0, r4 ! (r0 holds saved IP0 from stack)
not r5, r4 ! invert (one's-comp) the mask
mov r2, %ip0 ! load the current IP0...
and r2, r5 ! ...and mask off bits[15..12]
or r0, r2 ! OR the whole works together
mov r4, IMASK_SAVE_MASK ! mask off bits[13..0] of the saved IMASK
and r1, r4 ! (r1 holds saved IMASK from stack)
not r5, r4 ! invert (one's-comp) the mask
mov r3, %imask ! load the current IMASK...
and r3, r5 ! ...and mask off bits[15..14]
or r1, r3 ! OR the whole works together
bitc r1, 15 ! make sure we get thru the restore successfully
mov %ip0, r0
mov %imask, r1
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
lddu r0, r12, 2
mov %rpc, r0
mov %tpc, r1
lddu r4, r12, 2
lddu r0, r12, 2
ldu r2, r12, 1
add r12, 3
mov %hwflag, r0 ! restore %HWFLAG, %AMODE, & %FMODE
mov %amode, r1
mov %fmode, r2
ld r3, r12, -3
ld r2, r12, -2
ld r1, r12, -1
ld r0, r12, 0
reti
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -