Skip to content

Commit 310c2bd

Browse files
author
DragonOS Dev
committed
fix(tty): restore B3500000/B4000000 to baud_rate() and tidy constants
C1: B3500000 (0x0000100e) and B4000000 (0x0000100f) were accidentally dropped from ControlMode::baud_rate() during the v1→v2 dedup refactor. Restore them — both speeds are defined in the bitflags and covered by the CBAUD mask, so baud_rate() must handle them or the constants should be removed (the former is correct). L1: Move CIBAUD_SHIFT from between bitflags! and impl ControlMode to the constant area near NCC / INIT_C_LINE_ABI. L2: Merge duplicate header comment block in test_tty_termios.c into a single clean file-level doc.
1 parent 39f9060 commit 310c2bd

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

kernel/src/driver/tty/termios.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,6 @@ bitflags! {
363363
}
364364

365365

366-
/// Shift to extract input baud rate bits from c_cflag (CIBAUD = 0x100f0000).
367-
pub const CIBAUD_SHIFT: u32 = 16;
368366

369367
impl ControlMode {
370368
/// 获取波特率
@@ -400,6 +398,8 @@ impl ControlMode {
400398
Self::B2000000 => Some(2000000),
401399
Self::B2500000 => Some(2500000),
402400
Self::B3000000 => Some(3000000),
401+
Self::B3500000 => Some(3500000),
402+
Self::B4000000 => Some(4000000),
403403
_ => None,
404404
}
405405
}
@@ -417,6 +417,9 @@ impl ControlMode {
417417

418418
pub const NCC: usize = 8;
419419

420+
/// Shift to extract input baud rate bits from c_cflag (CIBAUD = 0x100f0000).
421+
pub const CIBAUD_SHIFT: u32 = 16;
422+
420423
/// Default c_line ABI value (N_TTY = 0).
421424
pub const INIT_C_LINE_ABI: u8 = 0;
422425

user/apps/c_unitest/test_tty_termios.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
// test_tty_termios.c — quick smoke test for TTY termios/termio ioctls.
2-
//
3-
// This file intentionally overlaps with dunitest/suites/normal/tty_termios.cc.
4-
// The C version is a fast, self-contained static binary for QEMU serial-console
5-
// smoke testing. The C++ gtest version is the full CI regression suite.
6-
// Keep both: the C test catches regressions in environments where dunitest
7-
// (which requires gtest, a runner, and a rootfs) cannot run.
81
// test_tty_termios.c — verify TCSAFLUSH / TCSADRAIN and legacy termio ioctls
92
// on a valid TTY fd (PTY slave).
103
//
114
// Regression coverage for: "tcsetattr(0, TCSAFLUSH, &t) fails with ENOTTY"
125
// and TCSETA/TCSETAW/TCSETAF/TCGETA returning ENOIOCTLCMD.
6+
//
7+
// This file intentionally overlaps with dunitest/suites/normal/tty_termios.cc.
8+
// The C version is a fast, self-contained static binary for QEMU smoke testing.
9+
// The C++ gtest version is the full CI regression suite. Keep both: the C test
10+
// catches regressions in environments where dunitest cannot run.
1311

1412
#include <errno.h>
1513
#include <fcntl.h>

0 commit comments

Comments
 (0)