O1能跑的代码

This commit is contained in:
fslongjin
2022-08-01 19:43:21 +08:00
parent 28e282d157
commit 58681fd34a
19 changed files with 71 additions and 28 deletions

View File

@ -10,6 +10,8 @@
#include <process/process.h>
#include <sched/sched.h>
#pragma GCC push_options
#pragma GCC optimize("O0")
// 导出定义在irq.c中的中段门表
extern void (*interrupt_table[24])(void);
@ -650,6 +652,7 @@ void apic_ioapic_edge_ack(ul irq_num) // 边沿触发
*
* @param irq_num
*/
void apic_local_apic_edge_ack(ul irq_num)
{
// 向EOI寄存器写入0x00表示结束中断
@ -660,6 +663,7 @@ void apic_local_apic_edge_ack(ul irq_num)
: "memory");
}
/**
* @brief 读取指定类型的 Interrupt Control Structure
*
@ -734,4 +738,5 @@ void apic_make_rte_entry(struct apic_IO_APIC_RTE_entry *entry, uint8_t vector, u
entry->destination.logical.logical_dest = dest_apicID;
entry->destination.logical.reserved1 = 0;
}
}
}
#pragma GCC pop_options

View File

@ -4,6 +4,8 @@
#include <common/kprint.h>
#include <sched/sched.h>
// #pragma GCC push_options
// #pragma GCC optimize("O0")
uint64_t apic_timer_ticks_result = 0;
void apic_timer_enable(uint64_t irq_num)

View File

@ -10,6 +10,8 @@ extern uint64_t apic_timer_ticks_result;
#define APIC_TIMER_IRQ_NUM 151
#pragma GCC push_options
#pragma GCC optimize("O0")
/**
* @brief 设置apic定时器的分频计数
*
@ -78,4 +80,6 @@ extern uint64_t apic_timer_ticks_result;
* @brief 初始化local APIC定时器
*
*/
void apic_timer_init();
void apic_timer_init();
#pragma GCC optimize("O0")

View File

@ -122,7 +122,7 @@ void HPET_measure_freq()
// 使用I/O APIC 的IRQ2接收hpet定时器0的中断
apic_make_rte_entry(&entry, 34, IO_APIC_FIXED, DEST_PHYSICAL, IDLE, POLARITY_HIGH, IRR_RESET, EDGE_TRIGGER, MASKED, 0);
// 计算HPET0间隔多少个时钟周期触发一次中断
uint64_t clks_to_intr = 0.001 * interval * HPET_freq;
// kdebug("clks_to_intr=%#ld", clks_to_intr);
@ -158,9 +158,9 @@ void HPET_measure_freq()
// 顺便测定tsc频率
test_tsc_start = rdtsc();
io_mfence();
while (measure_apic_timer_flag == false)
;
kdebug("wait done");
irq_unregister(34);

View File

@ -9,6 +9,9 @@
#include <exception/irq.h>
#include <driver/interrupt/apic/apic.h>
#pragma GCC push_options
#pragma GCC optimize("O0")
spinlock_t xhci_controller_init_lock = {0}; // xhci控制器初始化锁(在usb_init中被初始化)
static int xhci_ctrl_count = 0; // xhci控制器计数
@ -921,4 +924,5 @@ failed:;
failed_exceed_max:;
kerror("Failed to initialize controller: bus=%d, dev=%d, func=%d", dev_hdr->header.bus, dev_hdr->header.device, dev_hdr->header.func);
spin_unlock(&xhci_controller_init_lock);
}
}
#pragma GCC optimize("O0")

View File

@ -2,7 +2,7 @@
#include <driver/usb/usb.h>
#include <driver/pci/pci.h>
#include <driver/pci/msi.h>
// #pragma GCC optimize("O0")
#define XHCI_MAX_HOST_CONTROLLERS 4 // 本驱动程序最大支持4个xhci root hub controller
#define XHCI_MAX_ROOT_HUB_PORTS 128 // 本驱动程序最大支持127个root hub 端口第0个保留