📄 tct.s
字号:
stwu r8,-4(r9) # store r18 for space only
stwu r8,-4(r9) # store r17 for space only
stwu r8,-4(r9) # store r16 for space only
stwu r8,-4(r9) # store r15 for space only
stwu r8,-4(r9) # store r14 for space only
#
# /* Store the MSR value for compatibility with SingleStep MTD */
#
stwu r12,-4(r9)
stwu r8,-4(r9) # store solicited stack type
#
# /* Allocate the extra space for the DIAB/DATA C to ASM interface */
#
addi r9,r9,-12
#
# /* Save the new stack pointer into the task's control block. */
# task -> tc_stack_pointer = (VOID *) REG_Stack_Ptr;
#
stw r9,56(r3)
#
# /* Return to caller */
#
blr
#
#}
#
#/*************************************************************************/
#/* */
#/* FUNCTION */
#/* */
#/* TCT_Check_Stack */
#/* */
#/* DESCRIPTION */
#/* */
#/* This function checks the current stack for overflow conditions. */
#/* Additionally, this function keeps track of the minimum amount */
#/* of stack space for the calling thread and returns the current */
#/* available stack space. */
#/* */
#/* CALLED BY */
#/* */
#/* TCC_Send_Signals Send signals to a task */
#/* */
#/* CALLS */
#/* */
#/* ERC_System_Error System error handler */
#/* */
#/* INPUTS */
#/* */
#/* None */
#/* */
#/* OUTPUTS */
#/* */
#/* available bytes in stack (returned in r3) */
#/* */
#/* HISTORY */
#/* */
#/* NAME DATE REMARKS */
#/* */
#/* Barry Sellew 06-24-1996 Created initial version 1.0 */
#/* D Spisak 11-01-2000 SPR786 updated minimum stack */
#/* size to 424 bytes. rel 1.11.2 */
#/* */
#/*************************************************************************/
#UNSIGNED TCT_Check_Stack(VOID)
#{
#
.text
.align 2
TCT_Check_Stack:
#
# /* Save the SP and LR for the return */
#
stwu r1,-16(r1)
mfspr r0,LR
stw r0,20(r1)
#
# /* Pickup the current task/HISR pointer. */
# thread = (TC_TCB *) TCD_Current_Thread;
#
addis r10,0,TCD_Current_Thread@ha
lwz r10,TCD_Current_Thread@l(r10)
#
# /* Determine if there is a current thread. */
# if (thread)
# {
#
cmpi 0,r10,0
beq TCT_Skip_Stack_Check # equal to zero
#
# /* Determine if the stack pointers are out of range. */
# if (( ((int *) current_stack < ((int *) thread -> tc_stack_start))
# || (((int *) current_stack) > ((int *) thread -> tc_stack_end)))
#
lwz r11,48(r10) # tc_stack_start
cmp 0,r1,r11 # current_stack < tc_stack_start
blt TCT_Stack_Range_Error
lwz r11,52(r10) # tc_stack_end
cmp 0,r1,r11 # current_stack < tc_stack_end
blt TCT_Stack_Range_Okay
TCT_Stack_Range_Error:
#
# /* Stack overflow condition exits. */
# ERC_System_Error(NU_STACK_OVERFLOW);
#
li r3,3
bl ERC_System_Error
TCT_Stack_Range_Okay:
#
# /* Calculate the amount of available space on the stack. */
# remaining = (BYTE_PTR) current_stack -
# (BYTE_PTR) thread -> tc_stack_start;
lwz r11,48(r10)
subf r9,r11,r1
#
# /* Determine if there is enough memory on the stack to save all of the
# registers. Note: The amount of the stack space must be enough
# for the interrupt frame. */
# if (remaining < 424)
#
cmpi 0,r9,424
bgt TCT_No_Stack_Error # remaining > 424
#
# /* Stack overflow condition is about to happen. */
# ERC_System_Error(NU_STACK_OVERFLOW);
#
li r3,3
bl ERC_System_Error
TCT_No_Stack_Error:
#
# /* Determine if this is a new minimum amount of stack space. */
# if (remaining < thread -> tc_stack_minimum)
#
lwz r12,64(r10)
cmpl 0,r9,r12
bgt TCT_Check_Stack_Exit # minimum > remaining
#
# /* Save the new stack minimum. */
# thread -> tc_stack_minimum = remaining;
#
stw r9,64(r10)
b TCT_Check_Stack_Exit
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. */
#/* */
#/* 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:
#
# Begin ProView specific
#
.ifdef INCLUDE_PROVIEW
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
bne TCT_Schedule_Thread # thread pointer is not zero
bl _NU_Idle_Hook
.endif
#
# End ProView specific
#
#
# /* 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
mtm
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -