pub struct TtyDevice {Show 14 fields
name: &'static str,
uart_device_id: usize,
input_buffer: Arc<Mutex<VecDeque<u8>>>,
input_waker: Waker,
canonical_mode: AtomicBool,
echo_enabled: AtomicBool,
read_min_ready_bytes: AtomicU16,
read_timeout_ms: AtomicU16,
winsize_cols: Mutex<u16>,
winsize_rows: Mutex<u16>,
debug_enabled: AtomicBool,
kb_mode: AtomicU8,
esc_state: Mutex<u8>,
nonblocking: AtomicBool,
}Expand description
TTY device implementation.
This device provides terminal functionality including line discipline, echo, and basic terminal I/O operations.
Fields§
§name: &'static str§uart_device_id: usize§input_buffer: Arc<Mutex<VecDeque<u8>>>§input_waker: Waker§canonical_mode: AtomicBool§echo_enabled: AtomicBool§read_min_ready_bytes: AtomicU16§read_timeout_ms: AtomicU16§winsize_cols: Mutex<u16>§winsize_rows: Mutex<u16>§debug_enabled: AtomicBool§kb_mode: AtomicU8§esc_state: Mutex<u8>§nonblocking: AtomicBoolImplementations§
Source§impl TtyDevice
impl TtyDevice
pub fn new(name: &'static str, uart_device_id: usize) -> Self
Sourcepub fn wait_until_readable(&self, trapframe: &mut Trapframe)
pub fn wait_until_readable(&self, trapframe: &mut Trapframe)
Block until the TTY input buffer becomes non-empty. Used by polling syscalls (e.g. pselect6) to implement blocking semantics.
Sourcepub fn wake_input(&self)
pub fn wake_input(&self)
Wake all tasks waiting for TTY input readiness. This is used by timeout handlers to preempt a blocking wait.
Sourcepub fn wait_until_readable_with_timeout_ticks(
&self,
trapframe: &mut Trapframe,
ticks: u64,
) -> bool
pub fn wait_until_readable_with_timeout_ticks( &self, trapframe: &mut Trapframe, ticks: u64, ) -> bool
Wait until readable with a timeout (in ticks). Returns true if timed out, false if input became available.
Sourcepub fn input_len(&self) -> usize
pub fn input_len(&self) -> usize
Current buffered input length (for diagnostics / readiness debugging)
Sourcepub fn is_read_ready_for_select(&self) -> bool
pub fn is_read_ready_for_select(&self) -> bool
Read readiness for select/poll semantics.
- Canonical mode: ready only when a full line (ending with ‘\n’) exists.
- Non-canonical: honor read_min_ready_bytes; in RAW mode head 0xE0 requires a pair.
Sourcefn handle_input_byte(&self, byte: u8)
fn handle_input_byte(&self, byte: u8)
Handle input byte from UART device.
This method processes incoming bytes and applies line discipline.
Sourcefn echo_backspace(&self)
fn echo_backspace(&self)
Echo backspace sequence.
Trait Implementations§
Source§impl CharDevice for TtyDevice
impl CharDevice for TtyDevice
Source§fn write_byte(&self, byte: u8) -> Result<(), &'static str>
fn write_byte(&self, byte: u8) -> Result<(), &'static str>
Write a single byte to the device Read more
Source§fn write(&self, buffer: &[u8]) -> Result<usize, &'static str>
fn write(&self, buffer: &[u8]) -> Result<usize, &'static str>
Write multiple bytes to the device Read more
Source§fn read_at(
&self,
_position: u64,
buffer: &mut [u8],
) -> Result<usize, &'static str>
fn read_at( &self, _position: u64, buffer: &mut [u8], ) -> Result<usize, &'static str>
Read data from a specific position in the device Read more
Source§impl ControlOps for TtyDevice
impl ControlOps for TtyDevice
Source§impl Device for TtyDevice
impl Device for TtyDevice
fn device_type(&self) -> DeviceType
fn name(&self) -> &'static str
fn as_any(&self) -> &dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
Source§fn as_char_device(&self) -> Option<&dyn CharDevice>
fn as_char_device(&self) -> Option<&dyn CharDevice>
Cast to CharDevice if this device is a character device
Source§fn capabilities(&self) -> &'static [DeviceCapability]
fn capabilities(&self) -> &'static [DeviceCapability]
Optional capabilities exposed by this device (default: none)
Source§fn as_event_capable(&self) -> Option<&dyn EventCapableDevice>
fn as_event_capable(&self) -> Option<&dyn EventCapableDevice>
Cast to EventCapableDevice if this device can emit events
Source§fn as_block_device(&self) -> Option<&dyn BlockDevice>
fn as_block_device(&self) -> Option<&dyn BlockDevice>
Cast to BlockDevice if this device is a block device
Source§fn as_graphics_device(&self) -> Option<&dyn GraphicsDevice>
fn as_graphics_device(&self) -> Option<&dyn GraphicsDevice>
Cast to GraphicsDevice if this device is a graphics device
Source§fn as_network_device(&self) -> Option<&dyn NetworkDevice>
fn as_network_device(&self) -> Option<&dyn NetworkDevice>
Cast to NetworkDevice if this device is a network device
Source§fn into_block_device(self: Arc<Self>) -> Option<Arc<dyn BlockDevice>>
fn into_block_device(self: Arc<Self>) -> Option<Arc<dyn BlockDevice>>
Cast Arc to Arc if this device is a block device
This allows direct ownership of the block device for efficient I/O operations
Source§fn into_char_device(self: Arc<Self>) -> Option<Arc<dyn CharDevice>>
fn into_char_device(self: Arc<Self>) -> Option<Arc<dyn CharDevice>>
Cast Arc to Arc if this device is a character device
This allows direct ownership of the char device for efficient I/O operations
Source§fn into_graphics_device(self: Arc<Self>) -> Option<Arc<dyn GraphicsDevice>>
fn into_graphics_device(self: Arc<Self>) -> Option<Arc<dyn GraphicsDevice>>
Cast Arc to Arc if this device is a graphics device
This allows direct ownership of the graphics device for efficient operations
Source§fn into_network_device(self: Arc<Self>) -> Option<Arc<dyn NetworkDevice>>
fn into_network_device(self: Arc<Self>) -> Option<Arc<dyn NetworkDevice>>
Cast Arc to Arc if this device is a network device
This allows direct ownership of the network device for efficient operations
Source§impl DeviceEventListener for TtyDevice
impl DeviceEventListener for TtyDevice
fn on_device_event(&self, event: &dyn DeviceEvent)
fn interested_in(&self, event_type: &str) -> bool
Source§impl MemoryMappingOps for TtyDevice
impl MemoryMappingOps for TtyDevice
Source§fn get_mapping_info(
&self,
_offset: usize,
_length: usize,
) -> Result<(usize, usize, bool), &'static str>
fn get_mapping_info( &self, _offset: usize, _length: usize, ) -> Result<(usize, usize, bool), &'static str>
Get mapping information for a region of the object Read more
Source§fn on_mapped(
&self,
_vaddr: usize,
_paddr: usize,
_length: usize,
_offset: usize,
)
fn on_mapped( &self, _vaddr: usize, _paddr: usize, _length: usize, _offset: usize, )
Notification that a mapping has been created Read more
Source§fn on_unmapped(&self, _vaddr: usize, _length: usize)
fn on_unmapped(&self, _vaddr: usize, _length: usize)
Notification that a mapping has been removed Read more
Source§fn supports_mmap(&self) -> bool
fn supports_mmap(&self) -> bool
Check if memory mapping is supported Read more
Source§fn get_mapping_info_with(
&self,
offset: usize,
length: usize,
_is_shared: bool,
) -> Result<(usize, usize, bool), &'static str>
fn get_mapping_info_with( &self, offset: usize, length: usize, _is_shared: bool, ) -> Result<(usize, usize, bool), &'static str>
Get mapping information with sharing intent. Read more
Source§fn mmap_owner_name(&self) -> String
fn mmap_owner_name(&self) -> String
Diagnostic helper: return a short owner name for logging Read more
fn resolve_fault( &self, access: &AccessKind, map: &VirtualMemoryMap, ) -> Result<ResolveFaultResult, ResolveFaultError>
Source§impl Selectable for TtyDevice
impl Selectable for TtyDevice
Source§fn current_ready(&self, interest: ReadyInterest) -> ReadySet
fn current_ready(&self, interest: ReadyInterest) -> ReadySet
Return current readiness for the given interest set.
Source§fn wait_until_ready(
&self,
interest: ReadyInterest,
trapframe: &mut Trapframe,
timeout_ticks: Option<u64>,
) -> SelectWaitOutcome
fn wait_until_ready( &self, interest: ReadyInterest, trapframe: &mut Trapframe, timeout_ticks: Option<u64>, ) -> SelectWaitOutcome
Block the current task using the provided trapframe until the interest
becomes ready or the optional timeout (in ticks) expires. Read more
Source§fn set_nonblocking(&self, enabled: bool)
fn set_nonblocking(&self, enabled: bool)
Enable or disable non-blocking I/O semantics on this object. Read more
Source§fn is_nonblocking(&self) -> bool
fn is_nonblocking(&self) -> bool
Query whether non-blocking I/O semantics are enabled on this object.
Source§impl TtyControl for TtyDevice
impl TtyControl for TtyDevice
Source§fn is_echo_enabled(&self) -> bool
fn is_echo_enabled(&self) -> bool
Returns whether local echo is enabled.
Source§fn set_canonical(&self, enabled: bool)
fn set_canonical(&self, enabled: bool)
Enable or disable canonical (line) mode.
Source§fn is_canonical(&self) -> bool
fn is_canonical(&self) -> bool
Returns whether canonical (line) mode is enabled.
Source§fn set_winsize(&self, cols: u16, rows: u16)
fn set_winsize(&self, cols: u16, rows: u16)
Set terminal window size in character cells.
Source§fn get_winsize(&self) -> (u16, u16)
fn get_winsize(&self) -> (u16, u16)
Get terminal window size in character cells.
Auto Trait Implementations§
impl !Freeze for TtyDevice
impl !RefUnwindSafe for TtyDevice
impl Send for TtyDevice
impl Sync for TtyDevice
impl Unpin for TtyDevice
impl !UnwindSafe for TtyDevice
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more