mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-21 05:36:31 +00:00
🆕 HPET驱动
This commit is contained in:
@ -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();
|
||||
|
@ -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);
|
Reference in New Issue
Block a user