📄 tct.asm
字号:
;/*************************************************************************/
;/* */
;/* Copyright (c) 1993-1998 Accelerated Technology, Inc. */
;/* */
;/* PROPRIETARY RIGHTS of Accelerated Technology are involved in the */
;/* subject matter of this material. All manufacturing, reproduction, */
;/* use, and sales rights pertaining to this subject matter are governed */
;/* by the license agreement. The recipient of this software implicitly */
;/* accepts the terms of the license. */
;/* */
;/*************************************************************************/
;
;/*************************************************************************/
;/* */
;/* FILE NAME VERSION */
;/* */
;/* tct.asm PLUS/C3XB/D 1.8 */
;/* */
;/* COMPONENT */
;/* */
;/* TC - Thread Control */
;/* */
;/* DESCRIPTION */
;/* */
;/* This file contains the target processor dependent routines for */
;/* performing target-dependent scheduling functions. */
;/* */
;/* AUTHOR */
;/* */
;/* William E. Lamie, Accelerated Technology, Inc. */
;/* */
;/* DATA STRUCTURES */
;/* */
;/* None */
;/* */
;/* FUNCTIONS */
;/* */
;/* TCT_Control_Interrupts Enable / disable interrupts */
;/* TCT_Local_Control_Interrupts Local enable / disable ints */
;/* TCT_Restore_Interrupts Restore global interrupts */
;/* TCT_Build_Task_Stack Build initial task stack */
;/* TCT_Build_HISR_Stack Build initial HISR stack */
;/* TCT_Build_Signal_Frame Build signal handler frame */
;/* TCT_Check_Stack Check current stack */
;/* TCT_Schedule Schedule the next thread */
;/* TCT_Control_To_Thread Transfer control to a thread */
;/* TCT_Control_To_System Transfer control from thread */
;/* TCT_Signal_Exit Exit from signal handler */
;/* TCT_Protect Protect critical section */
;/* TCT_Unprotect Unprotect critical section */
;/* TCT_Unprotect_Specific Release specific protection */
;/* TCT_Set_Current_Protect Set the thread's current */
;/* protection field */
;/* TCT_Protect_Switch Switch to protected thread */
;/* TCT_Schedule_Protected Schedule the protected thread*/
;/* TCT_Interrupt_Context_Save Save interrupted context */
;/* TCT_Interrupt_Context_Restore Restore interrupted context */
;/* TCT_Activate_HISR Activate a HISR */
;/* TCT_HISR_Shell HISR execution shell */
;/* */
;/* DEPENDENCIES */
;/* */
;/* cs_extr.h Common Service functions */
;/* tc_extr.h Thread Control functions */
;/* */
;/* HISTORY */
;/* */
;/* NAME DATE REMARKS */
;/* */
;/* J. Trippi 03-11-1997 Modified for large memory model */
;/* M. Trippi 03-12-1997 Released initial version 1.0 */
;/* M. Trippi 05-18-199 Registered LISRs now work. */
;/* (SPR284) */
;/* M. Trippi 05-25-1997 IE register is now used to */
;/* control interrupts instead of */
;/* the GIE bit in the ST. */
;/* M. Trippi 05-25-1997 Released version 1.1 */
;/* M. Trippi 06-02-1997 Added conditional assembler */
;/* statments to allow user to */
;/* configure for SMALL memory */
;/* model. */
;/* M. Trippi 06-03-1997 Released version 1.2 */
;/* M. Trippi 06-21-1997 Corrected Small memory model */
;/* support so that it allows */
;/* .text to be larger than 64k. */
;/* M. Trippi 07-01-1997 Released version 1.3 */
;/* M. Trippi 07-09-1997 Added support for the REGISTER */
;/* argument model. */
;/* M. Trippi 07-09-1997 Released version 1.4 */
;/* M. Trippi 11-06-1997 TCT_Activate_HISR now returns */
;/* NU_SUCCESS. (SPR312) */
;/* M. Trippi 11-06-1997 Added support for Microcomputer */
;/* mode. */
;/* M. Trippi 11-07-1997 Released version 1.5 */
;/* M. Trippi 11-14-1997 Stopped using the GIE bit to */
;/* mask out interrupts and used */
;/* the IE register which is now */
;/* configurable by the user. */
;/* M. Trippi 11-14-1997 Removed the code to SUBI and */
;/* ADDI to the SP since this */
;/* would cause the saved DP to */
;/* be destroyed. */
;/* M. Trippi 11-14-1997 Protected the "PUSH ST" instr. */
;/* by disabling interrupts */
;/* temporarily. */
;/* M. Trippi 11-14-1997 Initialized variables where not */
;/* being setup properly. */
;/* M. Trippi 11-14-1997 Saved/Restored the IE register */
;/* in Context_Save/Restore when */
;/* in a nested interrupt state. */
;/* This will allow */
;/* TCT_Local_Control_Interrupts */
;/* to function properly in this */
;/* case. */
;/* M. Trippi 11-21-1997 Released version 1.6 */
;/* M. Trippi 02-24-1998 Released version 1.7 using */
;/* version 5.00 tools. */
;/* K. Pontzloff 04-03-1998 Released version 1.8 */
;/* ZhangXA 03-28-2000 Modifi POP IOF replace SUBI 1,SP*/
;/* */
;/*************************************************************************/
;
;NU_C30 .set 1 ; 1 to enable C30 support (PICK ONE) (DEFAULT)
;NU_C32 .set 0 ; 1 to enable C32 support (PICK ONE)
;;modify by jin 2000.12.11
NU_C30 .set 0 ; 1 to enable C30 support (PICK ONE) (DEFAULT)
NU_C32 .set 1 ; 1 to enable C32 support (PICK ONE)
; Both 0 to enable C31 support (PICK ONE)
;
NU_BIG .set 1 ; 1 to enable BIG memory model support (DEFAULT)
; 0 to enable SMALL memory model support
;
NU_STACK .set 1 ; 1 to enable STACK argument model support (DEFAULT)
; 0 to enable REGISTER argument model support
;
NU_MCBL .set 0 ; 1 to enable Microcomputer/Boot Loader mode
; 0 to enable Microprocessor mode (DEFAULT)
; NOTE: C31 or C32 MUST also be selected for MCBL mode
;
;#include "cs_extr.h" /* Common service functions */
;#include "tc_extr.h" /* Thread control functions */
;
;
;/* Define external inner-component global data references. */
;
;extern TC_TCB *TCD_Execute_Task;
;extern TC_HCB *TCD_Execute_HISR;
;extern VOID *TCD_Current_Thread;
;extern VOID *TCD_System_Stack;
;extern INT TCD_Interrupt_Count;
;extern TC_HCB *TCD_Active_HISR_Heads[TC_HISR_PRIORITIES];
;extern TC_HCB *TCD_Active_HISR_Tails[TC_HISR_PRIORITIES];
;extern INT TCD_Interrupt_Level;
;extern UNSIGNED TMD_Time_Slice;
;extern INT TMD_Time_Slice_State;
;
.global _TCD_Execute_Task
.global _TCD_Execute_HISR
.global _TCD_Current_Thread
.global _TCD_System_Stack
.global _TCD_Interrupt_Count
.global _TCD_Active_HISR_Heads
.global _TCD_Active_HISR_Tails
.global _TCD_Interrupt_Level
.global _TMD_Time_Slice
.global _TMD_Time_Slice_State
.global _INT_IEinit
;
;/* Define external function references. */
;
.global _TCC_Task_Shell
.global _TCC_Signal_Shell
.global _ERC_System_Error
;
;/* Define interrupt bit masks in the status register */
;
GIEMASK equ 2000h ; mask to isolate GIE bit in STatus register
.if NU_C32
GIENOT equ 0DFFFh ; mask to clear GIE bit in STatus register
.else
GIENOT equ 01FFFh ; mask to clear GIE bit in STatus register
.endif
;
;/* Include constants defined in tm_defs.h */
;
TM_ACTIVE equ 0
TM_NOT_ACTIVE equ 1
TM_EXPIRED equ 2
;
;/* Define stack sizes for tasks, HISR's and signals */
;
REGSAVSIZE equ 31 ; save regs except AR3, IE, IF, ST
STKSAVSIZE equ REGSAVSIZE + 5 ; size of stack for saving all regs
; plus 2 return addresses, stack type
; and AR3 and ST registers
MINREGSAVSIZE equ 14
MINSTKSAVSIZE equ MINREGSAVSIZE+2 ; size of stack for saving minimum
; context: regs, return address
; and stack type
;
;/* Define frame pointer register
FP .set AR3 ; frame pointer
;
;
;/* Define offsets in TCB (task control block) */
;
TCB_SCHEDULED equ 16 ; tc_scheduled
TCB_CURTIMESLC equ 17 ; tc_cur_time_slice
TCB_STKSTART equ 18 ; tc_stack_start
TCB_STKEND equ 19 ; tc_stack_end
TCB_STKPTR equ 20 ; tc_stack_pointer
TCB_STKSIZE equ 21 ; tc_stack_size
TCB_STKMIN equ 22 ; tc_stack_minimum
TCB_CURPROT equ 23 ; tc_current_protect
TCB_SAVEDSTKPTR equ 24 ; tc_saved_stack_pointer
TCB_TIMESLC equ 25 ; tc_time_slice
;
;
;/* Define offsets in HCB (HISR control block) */
;
HCB_PRIORITY equ 14 ; tc_priority
HCB_STKSTART equ 18 ; tc_stack_start
HCB_STKEND equ 19 ; tc_stack_end
HCB_STKPTR equ 20 ; tc_stack_pointer
HCB_STKSIZE equ 21 ; tc_stack_size
HCB_STKMIN equ 22 ; tc_stack_minimum
HCB_ACTNEXT equ 24 ; tc_active_next
HCB_ACTCNT equ 25 ; tc_activation_count
HCB_ENTRY equ 26 ; tc_entry
;
;/* Define local variables */
;
.sect ".cinit"
;
.globl _TCT_Save_Ret_Addr
.bss _TCT_Save_Ret_Addr,1
;
.globl _TCT_Task_Shell_Addr
.word 1,_TCT_Task_Shell_Addr
.word _TCC_Task_Shell+0
.bss _TCT_Task_Shell_Addr,1
;
.globl _TCT_HISR_Shell_Addr
.word 1,_TCT_HISR_Shell_Addr
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -