Skip to content

Commit

Permalink
Refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
vinc committed Jan 11, 2024
1 parent 8923d17 commit 8bd3c4c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
15 changes: 6 additions & 9 deletions src/sys/serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,15 @@ impl fmt::Write for Serial {
impl Perform for Serial {
fn csi_dispatch(&mut self, params: &Params, _: &[u8], _: bool, c: char) {
match c {
'h' => {
// Enable
'h' => { // Enable
for param in params.iter() {
match param[0] {
12 => sys::console::enable_echo(),
_ => return,
}
}
}
'l' => {
// Disable
'l' => { // Disable
for param in params.iter() {
match param[0] {
12 => sys::console::disable_echo(),
Expand All @@ -77,9 +75,9 @@ impl Perform for Serial {

#[doc(hidden)]
pub fn print_fmt(args: fmt::Arguments) {
interrupts::without_interrupts(|| {
SERIAL.lock().write_fmt(args).expect("Could not print to serial");
})
interrupts::without_interrupts(||
SERIAL.lock().write_fmt(args).expect("Could not print to serial")
)
}

pub fn init() {
Expand All @@ -89,8 +87,7 @@ pub fn init() {

fn interrupt_handler() {
let b = SERIAL.lock().read_byte();
if b == 0xFF {
// Ignore invalid bytes
if b == 0xFF { // Ignore invalid bytes
return;
}
let c = match b as char {
Expand Down
6 changes: 3 additions & 3 deletions src/sys/vga.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,9 +452,9 @@ impl fmt::Write for Writer {

#[doc(hidden)]
pub fn print_fmt(args: fmt::Arguments) {
interrupts::without_interrupts(|| {
WRITER.lock().write_fmt(args).expect("Could not print to VGA");
});
interrupts::without_interrupts(||
WRITER.lock().write_fmt(args).expect("Could not print to VGA")
)
}

pub fn cols() -> usize {
Expand Down

0 comments on commit 8bd3c4c

Please sign in to comment.