mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-07-11 07:03:23 +00:00
实现gettimeofday()系统调用和clocksource+timekeeping子模块 (#278)
- 实现gettimeofday()系统调用 - 实现clocksource+timekeeping子模块部分功能 - 实现了timespec转换成日期时间
This commit is contained in:
@ -207,12 +207,13 @@ void HPET_enable()
|
||||
// kdebug("[HPET0] conf register after modify=%#018lx", ((*(uint64_t *)(HPET_REG_BASE + TIM0_CONF))));
|
||||
// kdebug("[HPET1] conf register =%#018lx", ((*(uint64_t *)(HPET_REG_BASE + TIM1_CONF))));
|
||||
|
||||
kinfo("HPET0 enabled.");
|
||||
|
||||
__write8b(HPET_REG_BASE + GEN_CONF, 3); // 置位旧设备中断路由兼容标志位、定时器组使能标志位
|
||||
io_mfence();
|
||||
// 注册中断
|
||||
irq_register(34, &entry, &HPET_handler, 0, &HPET_intr_controller, "HPET0");
|
||||
io_mfence();
|
||||
__write8b(HPET_REG_BASE + GEN_CONF, 3); // 置位旧设备中断路由兼容标志位、定时器组使能标志位
|
||||
kinfo("HPET0 enabled.");
|
||||
|
||||
io_mfence();
|
||||
}
|
||||
|
||||
int HPET_init()
|
||||
|
@ -1,5 +1,6 @@
|
||||
use crate::{
|
||||
arch::interrupt::{cli, sti},
|
||||
arch::CurrentIrqArch,
|
||||
exception::InterruptArch,
|
||||
include::bindings::bindings::{io_in8, io_out8},
|
||||
syscall::SystemError,
|
||||
};
|
||||
@ -33,7 +34,7 @@ impl RtcTime {
|
||||
///@return int 成功则为0
|
||||
pub fn get(&mut self) -> Result<i32, SystemError> {
|
||||
// 为防止中断请求打断该过程,需要先关中断
|
||||
cli();
|
||||
let irq_guard = unsafe { CurrentIrqArch::save_and_disable_irq() };
|
||||
//0x0B
|
||||
let status_register_b: u8 = read_cmos(0x0B); // 读取状态寄存器B
|
||||
let is_24h: bool = if (status_register_b & 0x02) != 0 {
|
||||
@ -81,7 +82,7 @@ impl RtcTime {
|
||||
self.hour = ((self.hour & 0x7f) + 12) % 24;
|
||||
} // 将十二小时制转为24小时
|
||||
|
||||
sti();
|
||||
drop(irq_guard);
|
||||
|
||||
return Ok(0);
|
||||
}
|
||||
|
Reference in New Issue
Block a user