-
-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into heyicong-patch-thread
- Loading branch information
Showing
40 changed files
with
2,180 additions
and
403 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,21 @@ | ||
use super::setup::setup_arch; | ||
use crate::time::TimeArch; | ||
|
||
use super::{driver::tsc::TSCManager, setup::setup_arch, CurrentTimeArch}; | ||
|
||
#[no_mangle] | ||
unsafe extern "C" fn rs_setup_arch() -> i32 { | ||
return setup_arch() | ||
.map(|_| 0) | ||
.unwrap_or_else(|e| e.to_posix_errno()); | ||
} | ||
|
||
/// 获取当前的时间戳 | ||
#[no_mangle] | ||
unsafe extern "C" fn rs_get_cycles() -> u64 { | ||
return CurrentTimeArch::get_cycles() as u64; | ||
} | ||
|
||
#[no_mangle] | ||
unsafe extern "C" fn rs_tsc_get_cpu_khz() -> u64 { | ||
return TSCManager::cpu_khz(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use super::{ | ||
hpet::{hpet_init, hpet_instance}, | ||
tsc::TSCManager, | ||
}; | ||
|
||
#[no_mangle] | ||
unsafe extern "C" fn rs_hpet_init() -> i32 { | ||
hpet_init() | ||
.map(|_| 0) | ||
.unwrap_or_else(|e| e.to_posix_errno()) | ||
} | ||
|
||
#[no_mangle] | ||
unsafe extern "C" fn rs_hpet_enable() -> i32 { | ||
hpet_instance() | ||
.hpet_enable() | ||
.map(|_| 0) | ||
.unwrap_or_else(|e| e.to_posix_errno()) | ||
} | ||
|
||
#[no_mangle] | ||
unsafe extern "C" fn rs_tsc_init() -> i32 { | ||
TSCManager::init() | ||
.map(|_| 0) | ||
.unwrap_or_else(|e| e.to_posix_errno()) | ||
} | ||
|
||
#[no_mangle] | ||
unsafe extern "C" fn rs_handle_hpet_irq(timer_num: u32) { | ||
hpet_instance().handle_irq(timer_num); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include <common/glib.h> | ||
#include <common/kprint.h> | ||
#include <driver/interrupt/apic/apic.h> | ||
|
||
extern void rs_handle_hpet_irq(uint32_t timer_num); | ||
|
||
hardware_intr_controller HPET_intr_controller = | ||
{ | ||
.enable = apic_ioapic_enable, | ||
.disable = apic_ioapic_disable, | ||
.install = apic_ioapic_install, | ||
.uninstall = apic_ioapic_uninstall, | ||
.ack = apic_ioapic_edge_ack, | ||
}; | ||
|
||
void HPET_handler(uint64_t number, uint64_t param, struct pt_regs *regs) | ||
{ | ||
rs_handle_hpet_irq(param); | ||
} | ||
|
||
void c_hpet_register_irq() | ||
{ | ||
struct apic_IO_APIC_RTE_entry entry; | ||
apic_make_rte_entry(&entry, 34, IO_APIC_FIXED, DEST_PHYSICAL, IDLE, POLARITY_HIGH, IRR_RESET, EDGE_TRIGGER, MASKED, 0); | ||
irq_register(34, &entry, &HPET_handler, 0, &HPET_intr_controller, "HPET0"); | ||
} |
Oops, something went wrong.