use a magic mapping

This commit is contained in:
heheda 2020-05-12 18:53:48 +08:00
parent 12b2c0830e
commit d304d2209e
3 changed files with 9 additions and 5 deletions

View File

@ -53,6 +53,7 @@ pub fn irq_handle(irq: u8) {
#[export_name = "hal_irq_add_handle"]
pub fn irq_add_handle(irq: u8, handle: Arc<dyn Fn() + Send + Sync>) -> bool {
info!("IRQ add handle {}", irq);
let irq = irq as usize;
let mut table = IRQ_TABLE.lock();
match table[irq] {
@ -66,6 +67,7 @@ pub fn irq_add_handle(irq: u8, handle: Arc<dyn Fn() + Send + Sync>) -> bool {
#[export_name = "hal_irq_remove_handle"]
pub fn irq_remove_handle(irq: u8) -> bool {
info!("IRQ remove handle {}", irq);
let irq = irq as usize;
let mut table = IRQ_TABLE.lock();
match table[irq] {

View File

@ -58,15 +58,16 @@ impl Interrupt {
}))
}
pub fn new_event(vector: usize, options: InterruptOptions) -> ZxResult<Arc<Self>> {
pub fn new_event(mut vector: usize, options: InterruptOptions) -> ZxResult<Arc<Self>> {
let mode = options.to_mode();
if mode != InterruptOptions::MODE_DEFAULT && mode != InterruptOptions::MODE_EDGE_HIGH {
unimplemented!();
}
// I don't know how to remap a vector
// if options.contains(InterruptOptions::REMAP_IRQ) {
// vector = EventInterrupt::remap(vector);
// }
// I don't know the real mapping, +16 only to avoid conflict
if options.contains(InterruptOptions::REMAP_IRQ) {
vector = vector + 16;
// vector = EventInterrupt::remap(vector);
}
let event_interrupt = Arc::new(Interrupt {
base: KObjectBase::new(),
hasvcpu: false,

View File

@ -210,6 +210,7 @@ impl Syscall<'_> {
Sys::CPRNG_DRAW_ONCE => self.sys_cprng_draw_once(a0 as _, a1 as _),
Sys::NANOSLEEP => self.sys_nanosleep(a0.into()).await,
Sys::CLOCK_GET => self.sys_clock_get(a0 as _, a1.into()),
Sys::CLOCK_ADJUST => self.sys_clock_adjust(a0 as _, a1 as _, a2 as _),
Sys::TIMER_CREATE => self.sys_timer_create(a0 as _, a1 as _, a2.into()),
Sys::DEBUG_WRITE => self.sys_debug_write(a0.into(), a1 as _),
Sys::DEBUGLOG_CREATE => self.sys_debuglog_create(a0 as _, a1 as _, a2.into()),