mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-09 11:16:47 +00:00
更改HPET的定时间隔为500us
This commit is contained in:
parent
defb9e769c
commit
4208c56074
@ -164,7 +164,7 @@ void HPET_enable()
|
|||||||
apic_make_rte_entry(&entry, 34, IO_APIC_FIXED, DEST_PHYSICAL, IDLE, POLARITY_HIGH, IRR_RESET, EDGE_TRIGGER, MASKED, 0);
|
apic_make_rte_entry(&entry, 34, IO_APIC_FIXED, DEST_PHYSICAL, IDLE, POLARITY_HIGH, IRR_RESET, EDGE_TRIGGER, MASKED, 0);
|
||||||
|
|
||||||
// 计算HPET0间隔多少个时钟周期触发一次中断
|
// 计算HPET0间隔多少个时钟周期触发一次中断
|
||||||
uint64_t clks_to_intr = 0.001 * HPET0_INTERVAL * HPET_freq;
|
uint64_t clks_to_intr = 0.000001 * HPET0_INTERVAL * HPET_freq;
|
||||||
// kdebug("clks_to_intr=%#ld", clks_to_intr);
|
// kdebug("clks_to_intr=%#ld", clks_to_intr);
|
||||||
if (clks_to_intr <= 0 || clks_to_intr > (HPET_freq * 8))
|
if (clks_to_intr <= 0 || clks_to_intr > (HPET_freq * 8))
|
||||||
{
|
{
|
||||||
@ -177,7 +177,7 @@ void HPET_enable()
|
|||||||
io_mfence();
|
io_mfence();
|
||||||
*(uint64_t *)(HPET_REG_BASE + TIM0_CONF) = 0x004c; // 设置定时器0为周期定时,边沿触发,默认投递到IO APIC的2号引脚(看conf寄存器的高32bit,哪一位被置1,则可以投递到哪一个I/O apic引脚)
|
*(uint64_t *)(HPET_REG_BASE + TIM0_CONF) = 0x004c; // 设置定时器0为周期定时,边沿触发,默认投递到IO APIC的2号引脚(看conf寄存器的高32bit,哪一位被置1,则可以投递到哪一个I/O apic引脚)
|
||||||
io_mfence();
|
io_mfence();
|
||||||
*(uint64_t *)(HPET_REG_BASE + TIM0_COMP) = clks_to_intr; // 5ms触发一次中断
|
*(uint64_t *)(HPET_REG_BASE + TIM0_COMP) = clks_to_intr;
|
||||||
|
|
||||||
io_mfence();
|
io_mfence();
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
#define E_HPET_INIT_FAILED 1
|
#define E_HPET_INIT_FAILED 1
|
||||||
|
|
||||||
#define HPET0_INTERVAL 5 // HPET0定时器的中断间隔为5ms
|
#define HPET0_INTERVAL 500 // HPET0定时器的中断间隔为500us
|
||||||
int HPET_init();
|
int HPET_init();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -7,7 +7,9 @@
|
|||||||
uint64_t volatile timer_jiffies = 0; // 系统时钟计数
|
uint64_t volatile timer_jiffies = 0; // 系统时钟计数
|
||||||
|
|
||||||
// 计算接下来n毫秒对应的系统时间片
|
// 计算接下来n毫秒对应的系统时间片
|
||||||
#define cal_next_n_ms_jiffies(expire_ms) (timer_jiffies + expire_ms / 5 + ((expire_ms % HPET0_INTERVAL) ? 1 : 0))
|
#define cal_next_n_ms_jiffies(expire_ms) (timer_jiffies + 1000*expire_ms / HPET0_INTERVAL + ((1000*expire_ms % HPET0_INTERVAL) ? 1 : 0))
|
||||||
|
// 计算接下来n微秒对应的系统时间片
|
||||||
|
#define cal_next_n_us_jiffies(expire_us) (timer_jiffies + expire_us / HPET0_INTERVAL + ((expire_us % HPET0_INTERVAL) ? 1 : 0))
|
||||||
|
|
||||||
void timer_init();
|
void timer_init();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user