• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2022 The ChromiumOS Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 use std::io;
6 
7 use base::Event;
8 use base::FileSync;
9 use base::RawDescriptor;
10 
11 use crate::serial_device::SerialInput;
12 use crate::virtio::console::Console;
13 use crate::virtio::console::ConsoleInput;
14 use crate::virtio::ProtectionType;
15 use crate::SerialDevice;
16 
17 impl SerialDevice for Console {
new( protection_type: ProtectionType, _event: Event, input: Option<Box<dyn SerialInput>>, out: Option<Box<dyn io::Write + Send>>, _sync: Option<Box<dyn FileSync + Send>>, _out_timestamp: bool, keep_rds: Vec<RawDescriptor>, ) -> Console18     fn new(
19         protection_type: ProtectionType,
20         _event: Event,
21         input: Option<Box<dyn SerialInput>>,
22         out: Option<Box<dyn io::Write + Send>>,
23         // TODO(b/171331752): connect filesync functionality.
24         _sync: Option<Box<dyn FileSync + Send>>,
25         _out_timestamp: bool,
26         keep_rds: Vec<RawDescriptor>,
27     ) -> Console {
28         Console::new(
29             protection_type,
30             input.map(ConsoleInput::FromRead),
31             out,
32             keep_rds,
33         )
34     }
35 }
36 
37 /// Platform-specific function to add a delay for reading rx.
38 ///
39 /// On Unix, this function does nothing.
read_delay_if_needed()40 pub(crate) fn read_delay_if_needed() {}
41 
is_a_fatal_input_error(e: &io::Error) -> bool42 pub(in crate::virtio::console) fn is_a_fatal_input_error(e: &io::Error) -> bool {
43     e.kind() != io::ErrorKind::Interrupted
44 }
45