📄 tct.s
字号:
TCT_Skip_Stack_Check:
#
# }
# else
#
# /* Set the remaining bytes to 0. */
# remaining = 0;
#
li r9,0
#
TCT_Check_Stack_Exit:
#
# /* Return the remaining number of bytes on the stack. */
# return(remaining);
#
ori r3,r9,0
#
# /* restore the SP and LR for return */
#
lwz r0,20(r1)
mtspr LR,r0
addi r1,r1,16
blr
#
#}
#
#/*************************************************************************/
#/* */
#/* FUNCTION */
#/* */
#/* TCT_Schedule */
#/* */
#/* DESCRIPTION */
#/* */
#/* This function waits for a thread to become ready. Once a thread */
#/* is ready, this function initiates a transfer of control to that */
#/* thread. */
#/* */
#/* AUTHOR */
#/* */
#/* Barry Sellew, Accelerated Technology, Inc. */
#/* */
#/* CALLED BY */
#/* */
#/* INC_Initialize Main initialization routine */
#/* */
#/* CALLS */
#/* */
#/* TCT_Control_To_Thread Transfer control to a thread */
#/* */
#/* INPUTS */
#/* */
#/* None. */
#/* */
#/* OUTPUTS */
#/* */
#/* None */
#/* */
#/* HISTORY */
#/* */
#/* NAME DATE REMARKS */
#/* */
#/* Barry Sellew 06-24-1996 Created initial version 1.0 */
#/* */
#/*************************************************************************/
#VOID TCT_Schedule(VOID)
#{
.text
.align 2
TCT_Schedule:
#
# /* Will not need to store the SP and LR for return because this is
# called from the INC_Initialize the first time only as a subroutine.
# All other calls are actully jumps, from inside TCT.S file. */
#
# /* Restore interrupts according to the value contained in
# TCD_Interrupt_Level. */
#
addis r12,0,TCD_Interrupt_Level@ha
lwz r12,TCD_Interrupt_Level@l(r12)
mfmsr r11 # get current MSR value
rlwinm r11,r11,0,17,15 # mask off MSR[EE] bit
or r11,r11,r12 # or in the interrupt bits
mtmsr r11 # write current interrupt status
#
# /* Wait until a thread (task or HISR) is available to execute. */
# do
# {
#
TCT_Schedule_Loop:
# } while ((!TCD_Execute_HISR) && (!TCD_Execute_Task));
#
addis r3,0,TCD_Execute_HISR@ha
lwz r3,TCD_Execute_HISR@l(r3) # Save TCD_Execute_HISR in r3
# for TCT_Control_To_Thread
cmpli 0,r3,0
bne TCT_Schedule_Thread # HISR pointer is not zero
addis r3,0,TCD_Execute_Task@ha
lwz r3,TCD_Execute_Task@l(r3) # Save TCD_Execute_Task in r3
# for TCT_Control_To_Thread
cmpli 0,r3,0
beq TCT_Schedule_Loop # wait for HISR/Task pointer
#
# /* Yes, either a task or an HISR is ready to execute. Lockout
# interrupts while the thread is transferred to. */
#
TCT_Schedule_Thread:
#
mfmsr r11 # get current MSR value
rlwinm r11,r11,0,17,15 # mask off MSR[EE] bit
mtmsr r11 # write current interrupt status
#
# /* Transfer control to the thread by falling through to the following
# routine. */
#
#}
#
#/*************************************************************************/
#/* */
#/* FUNCTION */
#/* */
#/* TCT_Control_To_Thread */
#/* */
#/* DESCRIPTION */
#/* */
#/* This function transfers control to the specified thread. Each */
#/* time control is transferred to a thread, its scheduled counter */
#/* is incremented. Additionally, time-slicing for task threads is */
#/* enabled in this routine. The TCD_Current_Thread pointer is */
#/* setup by this function. */
#/* */
#/* AUTHOR */
#/* */
#/* Barry Sellew, Accelerated Technology, Inc. */
#/* */
#/* CALLED BY */
#/* */
#/* TCT_Schedule Indirectly called */
#/* TCT_Schedule_Protected */
#/* */
#/* CALLS */
#/* */
#/* None */
#/* */
#/* INPUTS */
#/* */
#/* thread (argument in r3) Thread control block pointer */
#/* */
#/* OUTPUTS */
#/* */
#/* None */
#/* */
#/* HISTORY */
#/* */
#/* NAME DATE REMARKS */
#/* */
#/* Barry Sellew 06-24-1996 Created initial version 1.0 */
#/* */
#/*************************************************************************/
#VOID TCT_Control_To_Thread(TC_TCB *thread)
#{
.text
.align 2
TCT_Control_To_Thread:
#
# /* Setup the current thread pointer. */
# TCD_Current_Thread = (VOID *) thread;
#
addis r12,0,TCD_Current_Thread@ha
stw r3,TCD_Current_Thread@l(r12)
#
# /* Increment the thread scheduled counter. */
# thread -> tc_scheduled++;
#
lwz r11,40(r3)
addi r11,r11,1
stw r11,40(r3)
#
# /* Check for time slice option. */
# if (thread -> tc_cur_time_slice)
# {
#
lwz r10,44(r3)
cmpli 0,r10,0
beq TCT_No_Start_TS # time slice = zero
#
# /* Start a time slice. */
# TMD_Time_Slice = thread -> tc_cur_time_slice;
#
addis r12,0,TMD_Time_Slice@ha
stw r10,TMD_Time_Slice@l(r12)
#
# TMD_Time_Slice_State = 0;
#
addis r10,0,TMD_Time_Slice_State@ha
li r9,0
stw r9,TMD_Time_Slice_State@l(r10)
#
# }
#
TCT_No_Start_TS:
#
# /* Pickup the stack pointer and resume the thread. */
# REG_Stack_Ptr = thread -> tc_stack_pointer;
#
lwz r1,56(r3)
#
# /* Pop off the saved information associated with the thread. After we
# determine which type of stack is present. A 1 on the top of the
# stack indicates an interrupt stack, while a 0 on the top of the
# stack indicates a solicited type of stack. */
#
# /* Remember that the interrupt level that is restored must represent
# the interrupt level in TCD_Interrupt_Level. */
#
addi r1,r1,12 # reset top of stack, strip off
# space for DIAB/DATA stuff.
lwz r4,0(r1) # read stack type from stack top
cmpli 0,r4,0x1 # See if it is an interrupt stack
beq TCT_Interrupt_Return # if so, an interrupt resume of
# the thread is required
#
# /* Must be a solicited stack frame */
#
# /* Restore r14 - r31 GPR's */
#
addi r1,r1,4 # adjust stack pointer
lwzu r14,4(r1) # restore GPR14
lwzu r15,4(r1) # restore GPR15
lwzu r16,4(r1) # restore GPR16
lwzu r17,4(r1) # restore GPR17
lwzu r18,4(r1) # restore GPR18
lwzu r19,4(r1) # restore GPR19
lwzu r20,4(r1) # restore GPR20
lwzu r21,4(r1) # restore GPR21
lwzu r22,4(r1) # restore GPR22
lwzu r23,4(r1) # restore GPR23
lwzu r24,4(r1) # restore GPR24
lwzu r2
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -