Skip to content

Commit

Permalink
Reorder device files
Browse files Browse the repository at this point in the history
  • Loading branch information
vinc committed Oct 15, 2024
1 parent 674bac1 commit 7660af0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/api/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ fn device_type(name: &str) -> Result<DeviceType, ()> {
"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),
"vga-buffer" => Ok(DeviceType::VgaBuffer),
"ata" => Ok(DeviceType::Drive),
_ => Err(()),
}
Expand Down
30 changes: 15 additions & 15 deletions src/sys/fs/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ pub enum DeviceType {
TcpSocket = 7,
UdpSocket = 8,
Drive = 9,
VgaFont = 10,
VgaMode = 11,
VgaPalette = 12,
VgaBuffer = 13,
VgaBuffer = 10,
VgaFont = 11,
VgaMode = 12,
VgaPalette = 13,
}

impl TryFrom<&[u8]> for DeviceType {
Expand All @@ -51,10 +51,10 @@ impl TryFrom<&[u8]> for DeviceType {
7 => Ok(DeviceType::TcpSocket),
8 => Ok(DeviceType::UdpSocket),
9 => Ok(DeviceType::Drive),
10 => Ok(DeviceType::VgaFont),
11 => Ok(DeviceType::VgaMode),
12 => Ok(DeviceType::VgaPalette),
13 => Ok(DeviceType::VgaBuffer),
10 => Ok(DeviceType::VgaBuffer),
11 => Ok(DeviceType::VgaFont),
12 => Ok(DeviceType::VgaMode),
13 => Ok(DeviceType::VgaPalette),
_ => Err(()),
}
}
Expand All @@ -73,9 +73,9 @@ impl DeviceType {
DeviceType::TcpSocket => TcpSocket::size(),
DeviceType::UdpSocket => UdpSocket::size(),
DeviceType::Drive => Drive::size(),
DeviceType::VgaBuffer => VgaBuffer::size(),
DeviceType::VgaMode => VgaMode::size(),
DeviceType::VgaPalette => VgaPalette::size(),
DeviceType::VgaBuffer => VgaBuffer::size(),
_ => 1,
};
let mut res = vec![0; len];
Expand All @@ -95,10 +95,10 @@ pub enum Device {
RTC(RTC),
TcpSocket(TcpSocket),
UdpSocket(UdpSocket),
VgaBuffer(VgaBuffer),
VgaFont(VgaFont),
VgaMode(VgaMode),
VgaPalette(VgaPalette),
VgaBuffer(VgaBuffer),
Drive(Drive),
}

Expand All @@ -116,10 +116,10 @@ impl TryFrom<&[u8]> for Device {
DeviceType::RTC => Ok(Device::RTC(RTC::new())),
DeviceType::TcpSocket => Ok(Device::TcpSocket(TcpSocket::new())),
DeviceType::UdpSocket => Ok(Device::UdpSocket(UdpSocket::new())),
DeviceType::VgaBuffer => Ok(Device::VgaBuffer(VgaBuffer::new())),
DeviceType::VgaFont => Ok(Device::VgaFont(VgaFont::new())),
DeviceType::VgaMode => Ok(Device::VgaMode(VgaMode::new())),
DeviceType::VgaPalette => Ok(Device::VgaPalette(VgaPalette::new())),
DeviceType::VgaBuffer => Ok(Device::VgaBuffer(VgaBuffer::new())),
DeviceType::Drive if buf.len() > 2 => {
let bus = buf[1];
let dsk = buf[2];
Expand Down Expand Up @@ -178,10 +178,10 @@ impl FileIO for Device {
Device::RTC(io) => io.read(buf),
Device::TcpSocket(io) => io.read(buf),
Device::UdpSocket(io) => io.read(buf),
Device::VgaBuffer(io) => io.read(buf),
Device::VgaFont(io) => io.read(buf),
Device::VgaMode(io) => io.read(buf),
Device::VgaPalette(io) => io.read(buf),
Device::VgaBuffer(io) => io.read(buf),
Device::Drive(io) => io.read(buf),
}
}
Expand All @@ -197,10 +197,10 @@ impl FileIO for Device {
Device::RTC(io) => io.write(buf),
Device::TcpSocket(io) => io.write(buf),
Device::UdpSocket(io) => io.write(buf),
Device::VgaBuffer(io) => io.write(buf),
Device::VgaFont(io) => io.write(buf),
Device::VgaMode(io) => io.write(buf),
Device::VgaPalette(io) => io.write(buf),
Device::VgaBuffer(io) => io.write(buf),
Device::Drive(io) => io.write(buf),
}
}
Expand All @@ -216,10 +216,10 @@ impl FileIO for Device {
Device::RTC(io) => io.close(),
Device::TcpSocket(io) => io.close(),
Device::UdpSocket(io) => io.close(),
Device::VgaBuffer(io) => io.close(),
Device::VgaFont(io) => io.close(),
Device::VgaMode(io) => io.close(),
Device::VgaPalette(io) => io.close(),
Device::VgaBuffer(io) => io.close(),
Device::Drive(io) => io.close(),
}
}
Expand All @@ -235,10 +235,10 @@ impl FileIO for Device {
Device::RTC(io) => io.poll(event),
Device::TcpSocket(io) => io.poll(event),
Device::UdpSocket(io) => io.poll(event),
Device::VgaBuffer(io) => io.poll(event),
Device::VgaFont(io) => io.poll(event),
Device::VgaMode(io) => io.poll(event),
Device::VgaPalette(io) => io.poll(event),
Device::VgaBuffer(io) => io.poll(event),
Device::Drive(io) => io.poll(event),
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/sys/vga/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ impl Buffer {
}

pub fn size() -> usize {
320 * 200 // FIXME
320 * 200
}
}

Expand All @@ -40,7 +40,7 @@ impl FileIO for Buffer {
fn poll(&mut self, event: IO) -> bool {
match event {
IO::Read => false, // TODO
IO::Write => false, // TODO
IO::Write => true,
}
}
}
2 changes: 1 addition & 1 deletion src/usr/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ pub fn copy_files(verbose: bool) {
create_dev("/dev/console", "console", verbose);
create_dev("/dev/net/tcp", "tcp", verbose);
create_dev("/dev/net/udp", "udp", verbose);
create_dev("/dev/vga/buffer", "vga-buffer", verbose);
create_dev("/dev/vga/font", "vga-font", verbose);
create_dev("/dev/vga/mode", "vga-mode", verbose);
create_dev("/dev/vga/palette", "vga-palette", verbose);
create_dev("/dev/vga/buffer", "vga-buffer", verbose);

copy_file!("/ini/banner.txt", verbose);
copy_file!("/ini/boot.sh", verbose);
Expand Down

0 comments on commit 7660af0

Please sign in to comment.