📄 timer.c
字号:
/* ============================================================ */
/* File: TIMER.C */
/* */
/* Copyright (C) 2001, Daniel W. Lewis and Prentice-Hall */
/* */
/* Purpose: Library routines for access to the 8253 timer. */
/* See file LIBEPC.H for function descriptions. */
/* */
/* Designed for use with the DJGPP port of the GNU C/C++ */
/* protected mode 386 compiler. */
/* */
/* Modification History: */
/* */
/* ============================================================ */
#include "libepc.h"
extern void TimerTickISR(void) __asm__("TimerTickISR") ;
extern DWORD32 msec __asm__("msec") ;
extern ISR old_tick_isr __asm__("old_tick_isr") ;
PRIVATE void InstallTimerTickISR(void)
{
static BOOL virgin = TRUE ;
if (virgin)
{
old_tick_isr = GetISR(IRQ2INT(IRQ_TICK)) ;
SetISR(IRQ2INT(IRQ_TICK), TimerTickISR) ;
outportb(0x21, inportb(0x21) & ~0x01) ;
STI ;
virgin = FALSE ;
}
}
DWORD32 Milliseconds(void)
{
InstallTimerTickISR() ;
return msec ;
}
DWORD32 Now_Plus(int seconds)
{
InstallTimerTickISR() ;
return msec + 1000 * seconds ;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -