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 system_error::SystemError;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
driver::serial::serial8250::send_to_default_serial8250_port,
|
||||||
libs::{
|
libs::{
|
||||||
rwlock::{RwLock, RwLockReadGuard, RwLockUpgradableGuard, RwLockWriteGuard},
|
rwlock::{RwLock, RwLockReadGuard, RwLockUpgradableGuard, RwLockWriteGuard},
|
||||||
spinlock::{SpinLock, SpinLockGuard},
|
spinlock::{SpinLock, SpinLockGuard},
|
||||||
@ -72,6 +73,13 @@ impl TtyCore {
|
|||||||
self.line_discipline.clone()
|
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> {
|
pub fn reopen(&self) -> Result<(), SystemError> {
|
||||||
let tty_core = self.core();
|
let tty_core = self.core();
|
||||||
let driver = tty_core.driver();
|
let driver = tty_core.driver();
|
||||||
@ -404,6 +412,7 @@ impl TtyOperation for TtyCore {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn write(&self, tty: &TtyCoreData, buf: &[u8], nr: usize) -> Result<usize, SystemError> {
|
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);
|
return self.core().tty_driver.driver_funcs().write(tty, buf, nr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
driver::{
|
driver::{
|
||||||
serial::serial8250::send_to_default_serial8250_port,
|
serial::serial8250::send_to_default_serial8250_port,
|
||||||
tty::{
|
tty::{tty_port::TTY_PORTS, virtual_terminal::virtual_console::CURRENT_VCNUM},
|
||||||
tty_driver::TtyOperation, tty_port::TTY_PORTS,
|
|
||||||
virtual_terminal::virtual_console::CURRENT_VCNUM,
|
|
||||||
},
|
|
||||||
video::video_refresh_manager,
|
video::video_refresh_manager,
|
||||||
},
|
},
|
||||||
kdebug, kinfo,
|
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();
|
let tty = port.port_data().tty();
|
||||||
if tty.is_some() {
|
if tty.is_some() {
|
||||||
let tty = tty.unwrap();
|
let tty = tty.unwrap();
|
||||||
|
send_to_default_serial8250_port(&[character]);
|
||||||
return tty
|
return tty
|
||||||
.write(tty.core(), buf.as_bytes(), buf.len())
|
.write_without_serial(buf.as_bytes(), buf.len())
|
||||||
.map(|_| 0)
|
.map(|_| 0)
|
||||||
.unwrap_or_else(|e| e.to_posix_errno());
|
.unwrap_or_else(|e| e.to_posix_errno());
|
||||||
}
|
}
|
||||||
|
@ -8,12 +8,9 @@ use alloc::string::ToString;
|
|||||||
use super::lib_ui::textui::{textui_putstr, FontColor};
|
use super::lib_ui::textui::{textui_putstr, FontColor};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
driver::{
|
driver::tty::{
|
||||||
serial::serial8250::send_to_default_serial8250_port,
|
tty_driver::TtyOperation, tty_port::TTY_PORTS,
|
||||||
tty::{
|
virtual_terminal::virtual_console::CURRENT_VCNUM,
|
||||||
tty_driver::TtyOperation, tty_port::TTY_PORTS,
|
|
||||||
virtual_terminal::virtual_console::CURRENT_VCNUM,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
filesystem::procfs::{
|
filesystem::procfs::{
|
||||||
kmsg::KMSG,
|
kmsg::KMSG,
|
||||||
@ -109,7 +106,6 @@ impl PrintkWriter {
|
|||||||
if tty.is_some() {
|
if tty.is_some() {
|
||||||
let tty = tty.unwrap();
|
let tty = tty.unwrap();
|
||||||
let _ = tty.write(tty.core(), s.as_bytes(), s.len());
|
let _ = tty.write(tty.core(), s.as_bytes(), s.len());
|
||||||
send_to_default_serial8250_port(s.as_bytes());
|
|
||||||
} else {
|
} else {
|
||||||
let _ = textui_putstr(s, FontColor::WHITE, FontColor::BLACK);
|
let _ = textui_putstr(s, FontColor::WHITE, FontColor::BLACK);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user