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)]
|
||||
pub struct DevNull;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use kernel::device_interface::character::CharacterDevice;
|
||||
use kernel::device_interface::CharacterDevice;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct DevUnicode {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use kernel::device_interface::character::CharacterDevice;
|
||||
use kernel::device_interface::CharacterDevice;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct DevZero;
|
||||
|
|
|
@ -2,4 +2,4 @@ pub mod dev_null;
|
|||
pub mod dev_unicode;
|
||||
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::sync::atomic::AtomicU32;
|
||||
use core::sync::atomic::Ordering;
|
||||
use kernel::device_interface::character::CharacterDevice;
|
||||
use kernel::device_interface::CharacterDevice;
|
||||
|
||||
use crate::pixel_format::Rgba64;
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ pub use self::Device::*;
|
|||
use crate::devices::dev_vterm::VTerm;
|
||||
use character_devs::{dev_null::DevNull, dev_unicode::DevUnicode, dev_zero::DevZero};
|
||||
use hashbrown::HashMap;
|
||||
use kernel::device_interface::character::CharacterDevice;
|
||||
use kernel::device_interface::{BlockDevice, CharacterDevice};
|
||||
use spin::Lazy;
|
||||
|
||||
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.
|
||||
// #[derive(Debug)]
|
||||
pub enum Device {
|
||||
Block(Box<dyn BlockDevice>),
|
||||
Character(Box<dyn CharacterDevice>),
|
||||
Vterm(Box<VTerm>),
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use kernel::device_interface::character::CharacterDevice;
|
||||
use kernel::device_interface::CharacterDevice;
|
||||
|
||||
pub struct Serial {
|
||||
pub base: usize,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use {
|
||||
crate::devices::Device::{Character, Vterm},
|
||||
crate::devices::Device::{Block, Character, Vterm},
|
||||
core::fmt::{Arguments, Error, Write},
|
||||
kernel::device_interface::character::CharacterDevice,
|
||||
kernel::device_interface::CharacterDevice,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
@ -35,6 +35,7 @@ impl StdIo {
|
|||
}
|
||||
Ok(())
|
||||
}
|
||||
Block(_) => todo!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,6 +55,7 @@ impl StdIo {
|
|||
vterm.read_char().map(|c| buf.push(c));
|
||||
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
|
||||
|
||||
pub mod block;
|
||||
pub mod character;
|
||||
mod block;
|
||||
mod character;
|
||||
|
||||
pub use block::BlockDevice;
|
||||
pub use character::CharacterDevice;
|
||||
|
|
Loading…
Reference in a new issue