📄 tmc.c
字号:
/*************************************************************************/
/* */
/* Copyright Mentor Graphics Corporation 2002 */
/* All Rights Reserved. */
/* */
/* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS */
/* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS */
/* SUBJECT TO LICENSE TERMS. */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* FILE NAME VERSION */
/* */
/* tmc.c Nucleus PLUS 1.14 */
/* */
/* COMPONENT */
/* */
/* TM - Timer Management */
/* */
/* DESCRIPTION */
/* */
/* This file contains the core routines for the timer management */
/* component. */
/* */
/* DATA STRUCTURES */
/* */
/* None */
/* */
/* FUNCTIONS */
/* */
/* TMC_Init_Task_Timer Initialize task timer */
/* TMC_Start_Task_Timer Start task timer */
/* TMC_Stop_Task_Timer Stop task timer */
/* TMC_Start_Timer Actually start a timer */
/* TMC_Stop_Timer Actually stop a timer */
/* TMC_Timer_HISR Timer High-Level Interrupt */
/* Service Routine (HISR) */
/* TMC_Timer_Expiration Timer expiration function */
/* */
/* DEPENDENCIES */
/* */
/* cs_extr.h Common Service functions */
/* tc_extr.h Thread Control functions */
/* tm_extr.h Timer functions */
/* hi_extr.h History functions */
/* */
/* HISTORY */
/* */
/* DATE REMARKS */
/* */
/* 03-01-1993 Created initial version 1.0 */
/* 04-19-1993 Verified version 1.0 */
/* 08-09-1993 Corrected the following problems */
/* - Moved sleep, timeout, and */
/* application timer expiration */
/* processing to system timer */
/* HISR. Removed timer task */
/* logic */
/* - Corrected a disable timer */
/* problem that caused a delay */
/* in subsequent timer */
/* expiration */
/* - Corrected the application */
/* timer ID returned by the */
/* timer information service */
/* Corrected the loop to return */
/* all application timer */
/* pointers */
/* - Corrected timer expiration */
/* while accessing from an LISR */
/* - Using the task time slice ptr */
/* instead of the time slice */
/* state flag */
/* Modifications resulted in */
/* version 1.0a */
/* 08-09-1993 Verified version 1.0a */
/* 03-01-1994 Moved non-core functions into */
/* supplemental files, modified */
/* protection logic to use system */
/* protect mechanism, removed the */
/* disable timer logic in start */
/* timer, insured valid time- */
/* slice task pointer, added */
/* register logic, resulting */
/* in version 1.1 */
/* */
/* 3-18-1994 Verified version 1.1 */
/* 08-25-95 Made the following changes */
/* */
/* +INT type = 0; Type of expiration */
/* +VOID *pointer = NU_NULL; Pointer type */
/* +UNSIGNED id = 0; Application timer ID */
/* -INT type; Type of expiration */
/* -VOID *pointer; Pointer type */
/* -UNSIGNED id; Application timer ID */
/* Expiration routine ptr */
/* +VOID (*expiration_routine)(UNSIGNED)= NU_NULL; */
/* -VOID (*expiration_routine)(UNSIGNED); */
/* 04-17-1996 updated to version 1.2 */
/* 03-24-1998 Released version 1.3. */
/* 03-26-1999 Released 1.11m (new release */
/* numbering scheme) */
/* 04-17-2002 Released version 1.13m */
/* 11-07-2002 Released version 1.14 */
/*************************************************************************/
#define NU_SOURCE_FILE
#include "cs_extr.h" /* Common service functions */
#include "tc_extr.h" /* Thread control functions */
#include "tm_extr.h" /* Timer functions */
#include "hi_extr.h" /* History functions */
/* Define external inner-component global data references. */
extern TM_TCB *TMD_Active_Timers_List;
extern INT TMD_Active_List_Busy;
extern UNSIGNED TMD_System_Clock;
extern UNSIGNED TMD_Timer_Start;
extern UNSIGNED TMD_Timer;
extern INT TMD_Timer_State;
extern UNSIGNED TMD_Time_Slice;
extern TC_TCB *TMD_Time_Slice_Task;
extern INT TMD_Time_Slice_State;
/* Define internal function prototypes. */
VOID TMC_Start_Timer(TM_TCB *timer, UNSIGNED time);
VOID TMC_Stop_Timer(TM_TCB *timer);
VOID TMC_Timer_Expiration(VOID);
UNSIGNED TMT_Read_Timer(VOID);
VOID TMT_Enable_Timer(UNSIGNED time);
VOID TMT_Disable_Timer(VOID);
/*************************************************************************/
/* */
/* FUNCTION */
/* */
/* TMC_Init_Task_Timer */
/* */
/* DESCRIPTION */
/* */
/* This function is responsible for initializing the supplied task */
/* timer. This routine must be called from Supervisor mode in a */
/* Supervisor/User mode switching kernel. */
/* */
/* CALLED BY */
/* */
/* TCC_Create_Task Task create function */
/* */
/* CALLS */
/* */
/* None */
/* */
/* INPUTS */
/* */
/* timer Timer control block pointer */
/* information Information pointer - always */
/* the task pointer */
/* */
/* OUTPUTS */
/* */
/* None */
/* */
/* HISTORY */
/* */
/* DATE REMARKS */
/* */
/* 03-01-1993 Created initial version 1.0 */
/* 04-19-1993 Verified version 1.0 */
/* */
/*************************************************************************/
VOID TMC_Init_Task_Timer(TM_TCB *timer, VOID *information)
{
/* Initialize the task timer. */
timer -> tm_timer_type = TM_TASK_TIMER;
timer -> tm_information = information;
timer -> tm_next_timer = NU_NULL;
timer -> tm_previous_timer = NU_NULL;
}
/*************************************************************************/
/* */
/* FUNCTION */
/* */
/* TMC_Start_Task_Timer */
/* */
/* DESCRIPTION */
/* */
/* This function is responsible for starting a task timer. Note */
/* that there are some special protection considerations since */
/* this function is called from the task control component. This */
/* routine must be called from Supervisor mode in a Supervisor/User */
/* mode switching kernel. */
/* */
/* CALLED BY */
/* */
/* TCC_Suspend_Task Suspend task with a timeout */
/* */
/* CALLS */
/* */
/* TMC_Start_Timer Start the timer */
/* */
/* INPUTS */
/* */
/* timer Timer control block pointer */
/* time Time associated with timer */
/* */
/* OUTPUTS */
/* */
/* None */
/* */
/* HISTORY */
/* */
/* DATE REMARKS */
/* */
/* 03-01-1993 Created initial version 1.0 */
/* 04-19-1993 Verified version 1.0 */
/* 03-01-1994 Removed protection logic since */
/* system protect is in force at */
/* the time this function is */
/* called, resulting in */
/* version 1.1 */
/* */
/* 03-18-1994 Verified version 1.1 */
/* */
/*************************************************************************/
VOID TMC_Start_Task_Timer(TM_TCB *timer, UNSIGNED time)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -