⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timerint.c

📁 实时多重作业操作系统内核(RTMK)。简单实时多重作业操作系统内核源程序。RTMK支持消息和事件
💻 C
字号:
/************************************************************************
*
*  Module name         : TIMERINT.C
*
*  Module description  :
*     Timer interrupt handler.
*
*  Project             : RTMK
*
*  Target platform     : DOS
*
*  Compiler & Library  : BC++ 3.1
*
*  Author              : Richard Shen
*
*  Creation date       : 30 August, 1995
*
************************************************************************/
#ifdef __DOS__

#include <dos.h>
#include <types.h>
#include <timerint.h>
#include "rtmkloc.h"

/************************************************************************
*                 F U N T I O N    P R O T O T Y P E S                  *
************************************************************************/
static void interrupt   TimerIntHandler(__CPPARGS);

/************************************************************************
*                    S T A T I C    V A R I A B L E S                   *
************************************************************************/
static void interrupt   (*OriginalInt1C)(__CPPARGS) = NULL;
static void             (*ApplTimerFunc)(void)      = NULL;

/************************************************************************
*  Function name   : SetTimerInt
*  Description     : Install timer interrupt handler (int 1cH)
*                  :
*  Parameters      : -
*  Returns         : -
*  Author          : Richard Shen
* -----------------------------------------------------------------------
*  Date     By      Description
* -----------------------------------------------------------------------
*  30Aug95  RCS     Created.
************************************************************************/
void SetTimerInt(void)
{
   disable();
   OriginalInt1C = getvect(0x1c);
   ApplTimerFunc = NULL;
   setvect(0x1c, TimerIntHandler);
   enable();
} /* SetTimerInt() */

/************************************************************************
*  Function name   : RestoreTimerInt
*  Description     : Restore timer interrupt handler (int 1cH)
*                  :
*  Parameters      : -
*  Returns         : -
*  Author          : Richard Shen
* -----------------------------------------------------------------------
*  Date     By      Description
* -----------------------------------------------------------------------
*  30Aug95  RCS     Created.
************************************************************************/
void RestoreTimerInt(void)
{
   disable();
   if (OriginalInt1C)
   {
      setvect(0x1c, OriginalInt1C);
      ApplTimerFunc = NULL;
   } /* end of if */

   enable();
} /* RestoreTimerInt() */

/************************************************************************
*  Function name   : TimerIntHandler
*  Description     : Timer interrupt handler
*                  :
*  Parameters      : -
*  Returns         : -
*  Author          : Richard Shen
* -----------------------------------------------------------------------
*  Date     By      Description
* -----------------------------------------------------------------------
*  30Aug95  RCS     Created.
************************************************************************/
static void interrupt TimerIntHandler(__CPPARGS)
{
   disable();
   servingInt++;
   if (ApplTimerFunc != NULL)
      ApplTimerFunc();

   servingInt--;
   outport(0x20, 0x20);                /* Inform PIC end of interrupt */
   enable();
} /* TimerIntHandler() */

/************************************************************************
*  Function name   : SetApplTimerHandler
*  Description     : Set up application timer service routine
*                  :
*  Parameters      : applHandler - Application service routine
*  Returns         : -
*  Author          : Richard Shen
* -----------------------------------------------------------------------
*  Date     By      Description
* -----------------------------------------------------------------------
*  30Aug95  RCS     Created.
************************************************************************/
void SetApplTimerHandler(void (*applHandler)(void))
{
   disable();
   ApplTimerFunc = applHandler;
   enable();
} /* SetApplTimerHandler() */

#endif /* __DOS__ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -