Skip to content
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

Merged
merged 1 commit into from
Jun 24, 2024
Merged

support tty #103

merged 1 commit into from
Jun 24, 2024

Conversation

TheSayOL
Copy link
Contributor

@TheSayOL TheSayOL commented May 7, 2024

  • add tty support.
  • add application busybox.

@ken4647
Copy link
Contributor

ken4647 commented May 8, 2024

In path apps/c/busybox/busybox, there is a binary. Is it executable? if it is, make sure that it is suitable for aarch64, x86_64 and riscv64. If it can not, add arch information on the name of the binary file(e.g. busybox_aarch64). And there is a empty "README.md", wich should be removed or completed.

debug!("sys_ioctl: tty TCGETS");
let data = data as *const u8 as *mut Termios;
unsafe {
const ICRNL: usize = 0x100;
Copy link
Contributor

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.

Copy link
Contributor

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
Copy link
Contributor

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.

Copy link
Contributor

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.
 */

}
}

#[allow(unused)]
Copy link
Contributor

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;
Copy link
Contributor

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.

@@ -27,6 +27,23 @@ pub struct ConsoleWinSize {
pub ws_ypixel: u16,
}

const NCCS: usize = 19;
const ICANON: usize = 2;
const ECHO: usize = 8;
Copy link
Contributor

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.

c_cc: [c_uchar; NCCS], /* control characters */
c_ispeed: c_uint, /* input speed */
c_ospeed: c_uint, /* output speed */
}
Copy link
Contributor

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.


// .c_cflag = B38400 | CS8 | CREAD | HUPCL,

// .c_cc = INIT_C_CC,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove these comments.

ARGS = /bin/busybox,sh
ENVS =
V9P_PATH=${APP}/rootfs
# make run ARCH=aarch64 A=apps/c/busybox V9P=y MUSL=y LOG=debug
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put this into README.

Copy link
Contributor

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 {
Copy link
Contributor

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.


/// driver's devices.
/// TODO: maybe use rwlock for dynamicly adding devices is better.
ttys: SpinNoIrq<Vec<Arc<TtyStruct>>>,
Copy link
Contributor

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 {
Copy link
Contributor

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?

Copy link
Contributor

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.

@TheSayOL TheSayOL force-pushed the tty2 branch 3 times, most recently from 396ac3e to b29ff0b Compare May 11, 2024 06:54
@coolyjg
Copy link
Contributor

coolyjg commented May 27, 2024

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 {
Copy link
Contributor

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.

@ken4647 ken4647 merged commit 5fd0f4c into syswonder:dev Jun 24, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants