forked from AbleOS/ableos
Devices: Add block devices
This commit is contained in:
parent
ed68ef9fa0
commit
f5c4db98f9
|
@ -1,4 +1,4 @@
|
||||||
use kernel::device_interface::character::CharacterDevice;
|
use kernel::device_interface::CharacterDevice;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub struct DevNull;
|
pub struct DevNull;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use kernel::device_interface::character::CharacterDevice;
|
use kernel::device_interface::CharacterDevice;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct DevUnicode {
|
pub struct DevUnicode {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use kernel::device_interface::character::CharacterDevice;
|
use kernel::device_interface::CharacterDevice;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct DevZero;
|
pub struct DevZero;
|
||||||
|
|
|
@ -2,4 +2,4 @@ pub mod dev_null;
|
||||||
pub mod dev_unicode;
|
pub mod dev_unicode;
|
||||||
pub mod dev_zero;
|
pub mod dev_zero;
|
||||||
|
|
||||||
pub use kernel::device_interface::character::CharacterDevice;
|
pub use kernel::device_interface::CharacterDevice;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
use core::ops::Not;
|
use core::ops::Not;
|
||||||
use core::sync::atomic::AtomicU32;
|
use core::sync::atomic::AtomicU32;
|
||||||
use core::sync::atomic::Ordering;
|
use core::sync::atomic::Ordering;
|
||||||
use kernel::device_interface::character::CharacterDevice;
|
use kernel::device_interface::CharacterDevice;
|
||||||
|
|
||||||
use crate::pixel_format::Rgba64;
|
use crate::pixel_format::Rgba64;
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ pub use self::Device::*;
|
||||||
use crate::devices::dev_vterm::VTerm;
|
use crate::devices::dev_vterm::VTerm;
|
||||||
use character_devs::{dev_null::DevNull, dev_unicode::DevUnicode, dev_zero::DevZero};
|
use character_devs::{dev_null::DevNull, dev_unicode::DevUnicode, dev_zero::DevZero};
|
||||||
use hashbrown::HashMap;
|
use hashbrown::HashMap;
|
||||||
use kernel::device_interface::character::CharacterDevice;
|
use kernel::device_interface::{BlockDevice, CharacterDevice};
|
||||||
use spin::Lazy;
|
use spin::Lazy;
|
||||||
|
|
||||||
pub static DEVICE_TABLE: Lazy<spin::Mutex<DeviceTable>> =
|
pub static DEVICE_TABLE: Lazy<spin::Mutex<DeviceTable>> =
|
||||||
|
@ -19,6 +19,7 @@ pub static DEVICE_TABLE: Lazy<spin::Mutex<DeviceTable>> =
|
||||||
// FIXME: This is a hack to hold a device.
|
// FIXME: This is a hack to hold a device.
|
||||||
// #[derive(Debug)]
|
// #[derive(Debug)]
|
||||||
pub enum Device {
|
pub enum Device {
|
||||||
|
Block(Box<dyn BlockDevice>),
|
||||||
Character(Box<dyn CharacterDevice>),
|
Character(Box<dyn CharacterDevice>),
|
||||||
Vterm(Box<VTerm>),
|
Vterm(Box<VTerm>),
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use kernel::device_interface::character::CharacterDevice;
|
use kernel::device_interface::CharacterDevice;
|
||||||
|
|
||||||
pub struct Serial {
|
pub struct Serial {
|
||||||
pub base: usize,
|
pub base: usize,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use {
|
use {
|
||||||
crate::devices::Device::{Character, Vterm},
|
crate::devices::Device::{Block, Character, Vterm},
|
||||||
core::fmt::{Arguments, Error, Write},
|
core::fmt::{Arguments, Error, Write},
|
||||||
kernel::device_interface::character::CharacterDevice,
|
kernel::device_interface::CharacterDevice,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
@ -35,6 +35,7 @@ impl StdIo {
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Block(_) => todo!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,6 +55,7 @@ impl StdIo {
|
||||||
vterm.read_char().map(|c| buf.push(c));
|
vterm.read_char().map(|c| buf.push(c));
|
||||||
println!("{}", buf);
|
println!("{}", buf);
|
||||||
}
|
}
|
||||||
|
Block(_) => todo!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
6
kernel/src/device_interface/block.rs
Normal file
6
kernel/src/device_interface/block.rs
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
//! Block device interface
|
||||||
|
|
||||||
|
/// Block device interface
|
||||||
|
pub trait BlockDevice {
|
||||||
|
// TODO
|
||||||
|
}
|
|
@ -1 +0,0 @@
|
||||||
//!
|
|
|
@ -1,4 +1,7 @@
|
||||||
//! Platform Agnostic Device
|
//! Platform Agnostic Device
|
||||||
|
|
||||||
pub mod block;
|
mod block;
|
||||||
pub mod character;
|
mod character;
|
||||||
|
|
||||||
|
pub use block::BlockDevice;
|
||||||
|
pub use character::CharacterDevice;
|
||||||
|
|
Loading…
Reference in a new issue