From a34cfa2178b4a3d6969a47bcc409f003dc84d4cf Mon Sep 17 00:00:00 2001 From: Vincent Ollivier Date: Tue, 15 Oct 2024 15:04:57 +0200 Subject: [PATCH] Rename some functions --- src/sys/vga/font.rs | 6 +++--- src/sys/vga/mod.rs | 2 +- src/sys/vga/palette.rs | 22 ++++++++++------------ 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/sys/vga/font.rs b/src/sys/vga/font.rs index 6fcb3524..64895878 100644 --- a/src/sys/vga/font.rs +++ b/src/sys/vga/font.rs @@ -26,7 +26,7 @@ impl FileIO for VgaFont { fn write(&mut self, buf: &[u8]) -> Result { if let Ok(font) = Font::try_from(buf) { *FONT.lock() = Some(font.clone()); - set_font(&font); + write_font(&font); Ok(buf.len()) // TODO: Use font.data.len() ? } else { Err(()) @@ -43,7 +43,7 @@ impl FileIO for VgaFont { } } -pub fn set_font(font: &Font) { +fn write_font(font: &Font) { interrupts::without_interrupts(|| WRITER.lock().set_font(font) ) @@ -51,6 +51,6 @@ pub fn set_font(font: &Font) { pub fn restore_font() { if let Some(ref font) = *FONT.lock() { - set_font(font); + write_font(font); } } diff --git a/src/sys/vga/mod.rs b/src/sys/vga/mod.rs index 2e61a470..f47c069d 100644 --- a/src/sys/vga/mod.rs +++ b/src/sys/vga/mod.rs @@ -196,7 +196,7 @@ pub fn init() { set_attr_ctrl_reg(0xE, 0x3E); set_attr_ctrl_reg(0xF, 0x3F); - Palette::default().set(); + Palette::default().write(); disable_blinking(); disable_underline(); diff --git a/src/sys/vga/palette.rs b/src/sys/vga/palette.rs index 0ff71ae6..1df106d1 100644 --- a/src/sys/vga/palette.rs +++ b/src/sys/vga/palette.rs @@ -45,17 +45,17 @@ impl Palette { palette } - pub fn get() -> Self { + pub fn read() -> Self { let mut palette = Palette::new(); for i in 0..256 { - palette.colors[i] = get_palette(i); + palette.colors[i] = read_palette(i); } palette } - pub fn set(&self) { + pub fn write(&self) { for (i, (r, g, b)) in self.colors.iter().enumerate() { - set_palette(i, *r, *g, *b); + write_palette(i, *r, *g, *b); } } @@ -92,7 +92,7 @@ impl TryFrom<&[u8]> for Palette { impl FileIO for VgaPalette { fn read(&mut self, buf: &mut [u8]) -> Result { - let res = Palette::get().to_bytes(); + let res = Palette::read().to_bytes(); if buf.len() < res.len() { return Err(()); } @@ -102,7 +102,7 @@ impl FileIO for VgaPalette { fn write(&mut self, buf: &[u8]) -> Result { let palette = Palette::try_from(buf)?; - palette.set(); + palette.write(); Ok(buf.len()) } @@ -116,15 +116,13 @@ impl FileIO for VgaPalette { } } -// TODO: Rename to `write_palette_index` -fn set_palette(i: usize, r: u8, g: u8, b: u8) { +fn write_palette(i: usize, r: u8, g: u8, b: u8) { interrupts::without_interrupts(|| WRITER.lock().set_palette(i, r, g, b) ) } -// TODO: Rename to `read_palette_index` -fn get_palette(i: usize) -> (u8, u8, u8) { +fn read_palette(i: usize) -> (u8, u8, u8) { interrupts::without_interrupts(|| WRITER.lock().palette(i) ) @@ -132,10 +130,10 @@ fn get_palette(i: usize) -> (u8, u8, u8) { pub fn restore_palette() { if let Some(ref palette) = *PALETTE.lock() { - palette.set(); + palette.write(); } } pub fn backup_palette() { - *PALETTE.lock() = Some(Palette::get()) + *PALETTE.lock() = Some(Palette::read()) }