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

Refactor vga driver #688

Merged
merged 33 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
67ef7bd
Add blank command
vinc Oct 14, 2024
1613530
Move vga driver to module
vinc Oct 14, 2024
97b8940
Remove vga command
vinc Oct 14, 2024
4fdd5c7
Split vga module
vinc Oct 14, 2024
d655ee0
Rename vga device type
vinc Oct 14, 2024
6f7096d
Add /dev/vga/mode device file
vinc Oct 14, 2024
c5294e8
Restore font after mode change
vinc Oct 14, 2024
d24ab74
Remove cvs support for palette
vinc Oct 14, 2024
479632f
Refactor api::vga::color
vinc Oct 14, 2024
f94ae91
Move api::vga::color to sys::vga::color
vinc Oct 14, 2024
b106cf4
Move api::vga::palette to sys::vga::palette
vinc Oct 14, 2024
ad02e9b
Use 256 colors palette
vinc Oct 14, 2024
1f765d6
Refactor Color
vinc Oct 14, 2024
fcc555a
Rename Color#to_vga_reg to Color#register
vinc Oct 14, 2024
0f1777d
Add Palette#set
vinc Oct 14, 2024
72643c6
Add write-only /dev/vga/palette
vinc Oct 14, 2024
e194a77
Remove unused set_palette
vinc Oct 14, 2024
734fee7
Add read operation to /dev/vga/palette
vinc Oct 14, 2024
bdff7ab
Add palette backup and restore
vinc Oct 14, 2024
6249b09
Check for device presence
vinc Oct 14, 2024
6c8cc76
Backup palette only in 80x25 mode
vinc Oct 15, 2024
a9fd0fc
Clear screen on mode change
vinc Oct 15, 2024
8fab113
Make /dev/vga/mode readable
vinc Oct 15, 2024
3182e7f
Fix double buffer allocation
vinc Oct 15, 2024
465abaa
Add framebuffer:addr()
vinc Oct 15, 2024
674bac1
Add /dev/vga/buffer device
vinc Oct 15, 2024
7660af0
Reorder device files
vinc Oct 15, 2024
a34cfa2
Rename some functions
vinc Oct 15, 2024
bd9ed92
Move test
vinc Oct 15, 2024
e429639
Run clippy
vinc Oct 15, 2024
43ed03d
Add color test
vinc Oct 15, 2024
5971a69
Refactor code
vinc Oct 15, 2024
07bbab0
Move blank to userspace
vinc Oct 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ user-rust:
basename -s .rs src/bin/*.rs | xargs -I {} \
cargo rustc $(user-cargo-opts) --bin {}
cargo rustc $(user-cargo-opts) --bin exec -- $(linker-opts)
cargo rustc $(user-cargo-opts) --bin blank -- $(linker-opts)
cargo rustc $(user-cargo-opts) --bin hello -- $(linker-opts)
cargo rustc $(user-cargo-opts) --bin geocal -- $(linker-opts)
cargo rustc $(user-cargo-opts) --bin geodate -- $(linker-opts)
Expand Down
17 changes: 0 additions & 17 deletions dsk/ini/palettes/gruvbox-dark.csv

This file was deleted.

17 changes: 0 additions & 17 deletions dsk/ini/palettes/gruvbox-light.csv

This file was deleted.

1 change: 1 addition & 0 deletions dsk/var/pkg/blank
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/bin/blank
1 change: 1 addition & 0 deletions dsk/var/pkg/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
beep
blank
chess
exec
fonts
Expand Down
28 changes: 16 additions & 12 deletions src/api/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,20 +154,24 @@ fn device_buffer(name: &str) -> Result<Vec<u8>, ()> {
Ok(buf)
}

// TODO: Move this to sys::fs::device
fn device_type(name: &str) -> Result<DeviceType, ()> {
match name {
"null" => Ok(DeviceType::Null),
"file" => Ok(DeviceType::File),
"console" => Ok(DeviceType::Console),
"random" => Ok(DeviceType::Random),
"uptime" => Ok(DeviceType::Uptime),
"realtime" => Ok(DeviceType::Realtime),
"rtc" => Ok(DeviceType::RTC),
"tcp" => Ok(DeviceType::TcpSocket),
"udp" => Ok(DeviceType::UdpSocket),
"font" => Ok(DeviceType::VgaFont),
"ata" => Ok(DeviceType::Drive),
_ => Err(()),
"null" => Ok(DeviceType::Null),
"file" => Ok(DeviceType::File),
"console" => Ok(DeviceType::Console),
"random" => Ok(DeviceType::Random),
"uptime" => Ok(DeviceType::Uptime),
"realtime" => Ok(DeviceType::Realtime),
"rtc" => Ok(DeviceType::RTC),
"tcp" => Ok(DeviceType::TcpSocket),
"udp" => Ok(DeviceType::UdpSocket),
"vga-buffer" => Ok(DeviceType::VgaBuffer),
"vga-font" => Ok(DeviceType::VgaFont),
"vga-mode" => Ok(DeviceType::VgaMode),
"vga-palette" => Ok(DeviceType::VgaPalette),
"ata" => Ok(DeviceType::Drive),
_ => Err(()),
}
}

Expand Down
95 changes: 0 additions & 95 deletions src/api/vga/color.rs

This file was deleted.

19 changes: 15 additions & 4 deletions src/api/vga/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
pub mod color;
pub mod palette;
use crate::api::fs;

pub use color::Color;
pub use palette::Palette;
pub fn graphic_mode() {
let dev = "/dev/vga/mode";
if fs::is_device(dev) {
fs::write(dev, b"320x200").ok();
}
}

pub fn text_mode() {
let dev = "/dev/vga/mode";
if fs::is_device(dev) {
fs::write(dev, b"80x25").ok();
print!("\x1b[2J\x1b[1;1H"); // Clear screen and move to top
}
}
65 changes: 0 additions & 65 deletions src/api/vga/palette.rs

This file was deleted.

20 changes: 20 additions & 0 deletions src/bin/blank.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#![no_std]
#![no_main]

extern crate alloc;

use moros::print;
use moros::api::io;
use moros::api::vga;
use moros::entry_point;

entry_point!(main);

fn main(_args: &[&str]) {
vga::graphic_mode();
print!("\x1b]R\x1b[1A"); // Reset palette
while io::stdin().read_char().is_none() {
x86_64::instructions::hlt();
}
vga::text_mode();
}
Loading
Loading