From 52ad689d370c3452e6792b5354fa0b60573cfeda Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Mon, 14 Feb 2022 08:49:34 -0700 Subject: [PATCH] Notify debug: readers of new input after all input is processed --- src/arch/aarch64/device/uart_pl011.rs | 3 ++- src/arch/x86_64/interrupt/irq.rs | 4 +++- src/scheme/debug.rs | 4 ++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/arch/aarch64/device/uart_pl011.rs b/src/arch/aarch64/device/uart_pl011.rs index 91eeb04..38f74e8 100644 --- a/src/arch/aarch64/device/uart_pl011.rs +++ b/src/arch/aarch64/device/uart_pl011.rs @@ -2,7 +2,7 @@ use core::fmt::{self, Write}; use core::ptr; use crate::device::gic; -use crate::scheme::debug::debug_input; +use crate::scheme::debug::{debug_input, debug_notify}; bitflags! { /// UARTFR @@ -138,6 +138,7 @@ impl SerialPort { while self.line_sts().contains(UartFrFlags::RXFF) { debug_input(self.read_reg(self.data_reg) as u8); } + debug_notify(); } pub fn send(&mut self, data: u8) { diff --git a/src/arch/x86_64/interrupt/irq.rs b/src/arch/x86_64/interrupt/irq.rs index 3767904..b909f6e 100644 --- a/src/arch/x86_64/interrupt/irq.rs +++ b/src/arch/x86_64/interrupt/irq.rs @@ -7,7 +7,7 @@ use crate::context::timeout; use crate::device::{local_apic, ioapic, pic}; use crate::device::serial::{COM1, COM2}; use crate::ipi::{ipi, IpiKind, IpiTarget}; -use crate::scheme::debug::debug_input; +use crate::scheme::debug::{debug_input, debug_notify}; use crate::{context, time}; //resets to 0 in context::switch() @@ -208,6 +208,7 @@ interrupt!(com2, || { while let Some(c) = COM2.lock().receive() { debug_input(c); } + debug_notify(); eoi(3); }); @@ -215,6 +216,7 @@ interrupt!(com1, || { while let Some(c) = COM1.lock().receive() { debug_input(c); } + debug_notify(); eoi(4); }); diff --git a/src/scheme/debug.rs b/src/scheme/debug.rs index b470953..0aa6ee7 100644 --- a/src/scheme/debug.rs +++ b/src/scheme/debug.rs @@ -42,6 +42,10 @@ fn handles_mut() -> RwLockWriteGuard<'static, BTreeMap> { /// Add to the input queue pub fn debug_input(data: u8) { INPUT.call_once(init_input).send(data); +} + +// Notify readers of input updates +pub fn debug_notify() { for (id, _handle) in handles().iter() { event::trigger(SCHEME_ID.load(Ordering::SeqCst), *id, EVENT_READ); }