mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-19 09:06:32 +00:00
o3能运行
This commit is contained in:
@ -96,27 +96,7 @@ void apic_io_apic_init()
|
||||
|
||||
// 不需要手动启动IO APIC,只要初始化了RTE寄存器之后,io apic就会自动启用了。
|
||||
// 而且不是每台电脑都有RCBA寄存器,因此不需要手动启用IO APIC
|
||||
/*
|
||||
// get RCBA address
|
||||
io_out32(0xcf8, 0x8000f8f0);
|
||||
uint x = io_in32(0xcfc);
|
||||
uint *p;
|
||||
printk_color(RED, BLACK, "Get RCBA Address:%#010x\n", x);
|
||||
x = x & 0xffffc000UL;
|
||||
printk_color(RED, BLACK, "Get RCBA Address:%#010x\n", x);
|
||||
|
||||
// get OIC address
|
||||
if (x > 0xfec00000 && x < 0xfee00000)
|
||||
{
|
||||
p = (unsigned int *)(x + 0x31feUL-apic_ioapic_map.addr_phys+apic_ioapic_map.virtual_index_addr);
|
||||
}
|
||||
|
||||
// enable IOAPIC
|
||||
x = (*p & 0xffffff00) | 0x100;
|
||||
io_mfence();
|
||||
*p = x;
|
||||
io_mfence();
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5,6 +5,9 @@
|
||||
#include <exception/irq.h>
|
||||
#include <mm/mm.h>
|
||||
|
||||
#pragma GCC push_options
|
||||
#pragma GCC optimize("O0")
|
||||
|
||||
#define APIC_SUCCESS 0
|
||||
#define APIC_E_NOTFOUND 1
|
||||
|
||||
@ -73,7 +76,7 @@
|
||||
// 分频配置寄存器(定时器专用)
|
||||
#define LOCAL_APIC_OFFSET_Local_APIC_CLKDIV 0x3e0
|
||||
|
||||
uint32_t RCBA_vaddr = 0;// RCBA寄存器的虚拟地址
|
||||
uint32_t RCBA_vaddr = 0; // RCBA寄存器的虚拟地址
|
||||
|
||||
/*
|
||||
|
||||
@ -318,4 +321,6 @@ void apic_local_apic_edge_ack(ul irq_num); // local apic边沿触发 应答
|
||||
* @param dest_apicID 目标apicID
|
||||
*/
|
||||
void apic_make_rte_entry(struct apic_IO_APIC_RTE_entry *entry, uint8_t vector, uint8_t deliver_mode, uint8_t dest_mode,
|
||||
uint8_t deliver_status, uint8_t polarity, uint8_t irr, uint8_t trigger, uint8_t mask, uint8_t dest_apicID);
|
||||
uint8_t deliver_status, uint8_t polarity, uint8_t irr, uint8_t trigger, uint8_t mask, uint8_t dest_apicID);
|
||||
|
||||
#pragma GCC pop_options
|
@ -11,9 +11,13 @@ uint64_t apic_timer_ticks_result = 0;
|
||||
void apic_timer_enable(uint64_t irq_num)
|
||||
{
|
||||
// 启动apic定时器
|
||||
io_mfence();
|
||||
uint64_t val = apic_timer_get_LVT();
|
||||
io_mfence();
|
||||
val &= (~APIC_LVT_INT_MASKED);
|
||||
io_mfence();
|
||||
apic_timer_write_LVT(val);
|
||||
io_mfence();
|
||||
}
|
||||
|
||||
void apic_timer_disable(uint64_t irq_num)
|
||||
@ -31,18 +35,24 @@ void apic_timer_disable(uint64_t irq_num)
|
||||
uint64_t apic_timer_install(ul irq_num, void *arg)
|
||||
{
|
||||
// 设置div16
|
||||
io_mfence();
|
||||
apic_timer_stop();
|
||||
io_mfence();
|
||||
apic_timer_set_div(APIC_TIMER_DIVISOR);
|
||||
io_mfence();
|
||||
|
||||
// 设置初始计数
|
||||
apic_timer_set_init_cnt(*(uint64_t *)arg);
|
||||
io_mfence();
|
||||
// 填写LVT
|
||||
apic_timer_set_LVT(APIC_TIMER_IRQ_NUM, 1, APIC_LVT_Timer_Periodic);
|
||||
io_mfence();
|
||||
}
|
||||
|
||||
void apic_timer_uninstall(ul irq_num)
|
||||
{
|
||||
apic_timer_write_LVT(APIC_LVT_INT_MASKED);
|
||||
io_mfence();
|
||||
}
|
||||
|
||||
hardware_intr_controller apic_timer_intr_controller =
|
||||
@ -65,6 +75,7 @@ void apic_timer_handler(uint64_t number, uint64_t param, struct pt_regs *regs)
|
||||
{
|
||||
|
||||
sched_update_jiffies();
|
||||
io_mfence();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -82,4 +82,4 @@ extern uint64_t apic_timer_ticks_result;
|
||||
*/
|
||||
void apic_timer_init();
|
||||
|
||||
#pragma GCC optimize("O0")
|
||||
#pragma GCC pop_options
|
Reference in New Issue
Block a user