🆕 HPET驱动

This commit is contained in:
fslongjin
2022-04-08 12:20:53 +08:00
parent 8bf4da2afa
commit d887f9a0f7
12 changed files with 259 additions and 36 deletions

View File

@ -2,12 +2,12 @@
#include <common/kprint.h>
/*置位0x70的第7位禁止不可屏蔽中断*/
/*
#define read_cmos(addr) ({ \
io_out8(0x70, 0x80 | addr); \
io_in8(0x71); \
})
*/
enum CMOSTimeSelector
{
T_SECOND = 0x0,
@ -18,14 +18,8 @@ enum CMOSTimeSelector
T_YEAR = 0x9,
};
int read_cmos(uint8_t addr)
{
io_out8(0x70, 0x80 | addr);
io_mfence();
return (uint8_t)(io_in8(0x71) & 0xff);
}
int rtc_get_cmos_time(struct time *t)
int rtc_get_cmos_time(struct rtc_time_t *t)
{
// 为防止中断请求打断该过程,需要先关中断
cli();

View File

@ -1,6 +1,6 @@
#pragma once
#include <common/glib.h>
struct time
struct rtc_time_t
{
int second;
int minute;
@ -8,7 +8,7 @@ struct time
int day;
int month;
int year;
};
}rtc_now; // rtc_now为墙上时钟由HPET定时器0维护
/**
* @brief 从主板cmos中获取时间
@ -16,5 +16,4 @@ struct time
* @param t time结构体
* @return int 成功则为0
*/
int rtc_get_cmos_time(struct time*t);
int get_cmos_time(struct time *time);
int rtc_get_cmos_time(struct rtc_time_t*t);