-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support tty #103
support tty #103
Conversation
TheSayOL
commented
May 7, 2024
- add tty support.
- add application busybox.
In path |
api/ruxos_posix_api/src/imp/ioctl.rs
Outdated
debug!("sys_ioctl: tty TCGETS"); | ||
let data = data as *const u8 as *mut Termios; | ||
unsafe { | ||
const ICRNL: usize = 0x100; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try to move safe code out of unsafe block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of these codes like ICRNL
should be in C headers file.
@@ -0,0 +1,63 @@ | |||
//! Init |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add license information at the head of every source file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment for license information should be like below:
/* Copyright (c) [2023] [Syswonder Community]
* [Ruxos] is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
modules/ruxhal/src/lib.rs
Outdated
} | ||
} | ||
|
||
#[allow(unused)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try use #[cfg(feature=...)]
instead if possible.
if flags != 0 { | ||
return Err(LinuxError::EINVAL); | ||
const GRND_NONBLOCK: c_int = 1; | ||
const GRND_RANDOM: c_int = 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put this two argument into header files. Import them like other C variables.
api/ruxos_posix_api/src/imp/ioctl.rs
Outdated
@@ -27,6 +27,23 @@ pub struct ConsoleWinSize { | |||
pub ws_ypixel: u16, | |||
} | |||
|
|||
const NCCS: usize = 19; | |||
const ICANON: usize = 2; | |||
const ECHO: usize = 8; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put these three variables into C header files as well.
api/ruxos_posix_api/src/imp/ioctl.rs
Outdated
c_cc: [c_uchar; NCCS], /* control characters */ | ||
c_ispeed: c_uint, /* input speed */ | ||
c_ospeed: c_uint, /* output speed */ | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this struct as well.
api/ruxos_posix_api/src/imp/ioctl.rs
Outdated
|
||
// .c_cflag = B38400 | CS8 | CREAD | HUPCL, | ||
|
||
// .c_cc = INIT_C_CC, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove these comments.
apps/c/busybox/axbuild.mk
Outdated
ARGS = /bin/busybox,sh | ||
ENVS = | ||
V9P_PATH=${APP}/rootfs | ||
# make run ARCH=aarch64 A=apps/c/busybox V9P=y MUSL=y LOG=debug |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put this into README.
apps/c/busybox/README.md
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also write a document for RuxOS-Book
/// the operations a tty driver must implement. | ||
/// passed by driver when registering itself. | ||
#[derive(Debug)] | ||
pub struct TtyDriverOps { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is better to make it a trait.
crates/tty/src/driver.rs
Outdated
|
||
/// driver's devices. | ||
/// TODO: maybe use rwlock for dynamicly adding devices is better. | ||
ttys: SpinNoIrq<Vec<Arc<TtyStruct>>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about use BTreeMap
?
pub fn get_driver_by_index(index: usize) -> Option<Arc<TtyDriver>> { | ||
let lock = ALL_DRIVERS.lock(); | ||
for driver in lock.iter() { | ||
if driver.index == index { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that you can use index to get the driver directly? Why use an iter
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will lead to a type error if using an iter().find()
instead of iter, as the iterator returns a reference rather than a variable with owership. So it uses .clone()
to make it here correct.
396ac3e
to
b29ff0b
Compare
Is it OK to merge? @ken4647 I sort of forget the details. |
pub fn get_driver_by_index(index: usize) -> Option<Arc<TtyDriver>> { | ||
let lock = ALL_DRIVERS.lock(); | ||
for driver in lock.iter() { | ||
if driver.index == index { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will lead to a type error if using an iter().find()
instead of iter, as the iterator returns a reference rather than a variable with owership. So it uses .clone()
to make it here correct.