📄 adviotmr.c
字号:
//********************************************************************
// ATA LOW LEVEL I/O DRIVER -- ADVIOTMR.C
//
// by Hale Landis (hlandis@ata-atapi.com)
//
// There is no copyright and there are no restrictions on the use
// of this ATA Low Level I/O Driver code. It is distributed to
// help other programmers understand how the ATA device interface
// works and it is distributed without any warranty. Use this
// code at your own risk.
//
// Compile with one of the Borland C or C++ compilers.
//
// This C source file contains functions to access the BIOS
// Time of Day information and to set and check the command
// time out period.
//********************************************************************
#include <dos.h>
#include "advio.h"
//*************************************************************
//
// tmr_read_bios_timer() - function to read the BIOS timer
//
//**************************************************************
long tmr_read_bios_timer( void )
{
long curTime;
// Pointer to the low order word
// of the BIOS time of day counter at
// location 40:6C in the BIOS data area.
static volatile long far * todPtr = MK_FP( 0x40, 0x6c );
// loop so we get a valid value without
// turning interrupts off and on again
do
{
curTime = * todPtr;
} while ( curTime != * todPtr );
return curTime;
}
//*************************************************************
//
// tmr_set_timeout() - get the command start time
//
//**************************************************************
void tmr_set_timeout( void )
{
// get the command start time
ADP->tmr_cmd_start_time = tmr_read_bios_timer();
}
//*************************************************************
//
// tmr_chk_timeout() - check for command timeout.
//
// Gives non-zero return if command has timed out.
//
//**************************************************************
int tmr_chk_timeout( void )
{
long curTime;
// get current time
curTime = tmr_read_bios_timer();
// if we have passed midnight, restart
if ( curTime < ADP->tmr_cmd_start_time )
{
ADP->tmr_cmd_start_time = curTime;
return 0;
}
// timed out yet ?
if ( curTime >= ( ADP->tmr_cmd_start_time + ( ADP->tmr_time_out * 18L ) ) )
return 1; // yes
// no timeout yet
return 0;
}
// end adviotmr.c
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -