mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
devices: Add utility functions for the serial output buffer
In preparation for reorganizing how the serial output is constructed add methods to the serial devices for setting the out buffer after the device is created. Also add a method to enable flushing the output buffer to be used to write the buffer to the PTY fd once the PTY is writable. Signed-off-by: William Douglas <william.douglas@intel.com>
This commit is contained in:
committed by
Rob Bradford
parent
f9dd0aaf8a
commit
0066ddefe1
@@ -138,6 +138,10 @@ impl Pl011 {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_out(&mut self, out: Box<dyn io::Write + Send>) {
|
||||
self.out = Some(out);
|
||||
}
|
||||
|
||||
fn state(&self) -> Pl011State {
|
||||
Pl011State {
|
||||
flags: self.flags,
|
||||
@@ -192,6 +196,13 @@ impl Pl011 {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn flush_output(&mut self) -> result::Result<(), io::Error> {
|
||||
if let Some(out) = self.out.as_mut() {
|
||||
out.flush()?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn pl011_get_baudrate(&self) -> u32 {
|
||||
if self.fbrd == 0 {
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user