📄 do_timer.c
字号:
//////////////////////////////////////////////////////////////////////////
#include "general.h"
#include "inb_outb.h"
#include "hd_info_struct.h"
#include "dir_entry.h"
#include "msdos_dir_entry.h"
#include "d_inode.h"
#include "m_inode.h"
#include "buffer_head.h"
#include "fat_cache.h"
#include "file.h"
#include "hd_request_struct.h"
#include "super_block.h"
#include "common_head.h"
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
void inc_datetime(void)
{
current_datetime_sec++;
if (current_datetime_sec < 60)
return;
current_datetime_sec = 0;
current_datetime_min++;
if (current_datetime_min < 60)
return;
current_datetime_min = 0;
current_datetime_hour++;
if (current_datetime_hour < 24)
return;
current_datetime_hour = 0;
current_datetime_mday++;
if (current_datetime_mday < current_monthdays)
return;
current_datetime_mday = 0;
current_datetime_mon++;
if (current_datetime_mon == 12)
current_datetime_mon = 0;
current_monthdays = month_days[current_datetime_mon];
if (current_datetime_mon == 1)
current_monthdays = current_monthdays + leapyear_flag;
if (current_datetime_mon)
return;
current_datetime_year++;
if (current_datetime_year == 100)
{
current_datetime_year = 0;
current_datetime_100Y++;
}
leapyear_flag = 1;
if ((current_datetime_year & 0x03) || ((current_datetime_100Y == 21) && (current_datetime_year == 00)))
leapyear_flag = 0;
return;
}
void do_timer(void)
{
sys_datetime_ms++;
if (sys_datetime_ms == 100)
{
sys_datetime_ms = 0;
sys_datetime_s = sys_datetime_s ^ 0x01;
sys_datetime++;
inc_datetime();
if (!sys_datetime_s)
file_datetime = ((current_datetime_100Y * 100 + current_datetime_year - 1980) << 25)|
((current_datetime_mon + 1) << 21) |
((current_datetime_mday + 1) << 16) |
(current_datetime_hour << 11) |
(current_datetime_min << 5) |
(current_datetime_sec >> 1);
}
if (floppy_timerval)
{
floppy_timerval--;
if (!floppy_timerval)
{
if (floppy_state == 3)
{
floppy_state = 5;
floppy_timerval = FD_DRIVER_DOWN;
output_byte(FD_RECALIBRATE);
output_byte(0x00);
}
else
{
floppy_state = 2;
floppy_errors = 0;
floppy_rwerrors = 0;
floppy_finishedflag = 0;
outb_p(0x0c,FD_DOR);
}
return;
}
}
return;
}
///////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -