mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-08 18:26:48 +00:00
将tty输出接入串口 (#555)
This commit is contained in:
parent
cf45dede2e
commit
f3b05a97ec
@ -4,6 +4,7 @@ use alloc::{string::String, sync::Arc, vec::Vec};
|
||||
use system_error::SystemError;
|
||||
|
||||
use crate::{
|
||||
driver::serial::serial8250::send_to_default_serial8250_port,
|
||||
libs::{
|
||||
rwlock::{RwLock, RwLockReadGuard, RwLockUpgradableGuard, RwLockWriteGuard},
|
||||
spinlock::{SpinLock, SpinLockGuard},
|
||||
@ -72,6 +73,13 @@ impl TtyCore {
|
||||
self.line_discipline.clone()
|
||||
}
|
||||
|
||||
pub fn write_without_serial(&self, buf: &[u8], nr: usize) -> Result<usize, SystemError> {
|
||||
self.core
|
||||
.driver()
|
||||
.driver_funcs()
|
||||
.write(self.core(), buf, nr)
|
||||
}
|
||||
|
||||
pub fn reopen(&self) -> Result<(), SystemError> {
|
||||
let tty_core = self.core();
|
||||
let driver = tty_core.driver();
|
||||
@ -404,6 +412,7 @@ impl TtyOperation for TtyCore {
|
||||
|
||||
#[inline]
|
||||
fn write(&self, tty: &TtyCoreData, buf: &[u8], nr: usize) -> Result<usize, SystemError> {
|
||||
send_to_default_serial8250_port(buf);
|
||||
return self.core().tty_driver.driver_funcs().write(tty, buf, nr);
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,7 @@
|
||||
use crate::{
|
||||
driver::{
|
||||
serial::serial8250::send_to_default_serial8250_port,
|
||||
tty::{
|
||||
tty_driver::TtyOperation, tty_port::TTY_PORTS,
|
||||
virtual_terminal::virtual_console::CURRENT_VCNUM,
|
||||
},
|
||||
tty::{tty_port::TTY_PORTS, virtual_terminal::virtual_console::CURRENT_VCNUM},
|
||||
video::video_refresh_manager,
|
||||
},
|
||||
kdebug, kinfo,
|
||||
@ -1006,8 +1003,9 @@ pub extern "C" fn rs_textui_putchar(character: u8, fr_color: u32, bk_color: u32)
|
||||
let tty = port.port_data().tty();
|
||||
if tty.is_some() {
|
||||
let tty = tty.unwrap();
|
||||
send_to_default_serial8250_port(&[character]);
|
||||
return tty
|
||||
.write(tty.core(), buf.as_bytes(), buf.len())
|
||||
.write_without_serial(buf.as_bytes(), buf.len())
|
||||
.map(|_| 0)
|
||||
.unwrap_or_else(|e| e.to_posix_errno());
|
||||
}
|
||||
|
@ -8,13 +8,10 @@ use alloc::string::ToString;
|
||||
use super::lib_ui::textui::{textui_putstr, FontColor};
|
||||
|
||||
use crate::{
|
||||
driver::{
|
||||
serial::serial8250::send_to_default_serial8250_port,
|
||||
tty::{
|
||||
driver::tty::{
|
||||
tty_driver::TtyOperation, tty_port::TTY_PORTS,
|
||||
virtual_terminal::virtual_console::CURRENT_VCNUM,
|
||||
},
|
||||
},
|
||||
filesystem::procfs::{
|
||||
kmsg::KMSG,
|
||||
log::{LogLevel, LogMessage},
|
||||
@ -109,7 +106,6 @@ impl PrintkWriter {
|
||||
if tty.is_some() {
|
||||
let tty = tty.unwrap();
|
||||
let _ = tty.write(tty.core(), s.as_bytes(), s.len());
|
||||
send_to_default_serial8250_port(s.as_bytes());
|
||||
} else {
|
||||
let _ = textui_putstr(s, FontColor::WHITE, FontColor::BLACK);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user