1
0
Fork 0
forked from AbleOS/ableos

modularizing the kernel

This commit is contained in:
Able 2022-03-02 08:38:22 -06:00
parent 6c3a67e6b5
commit beba2ae0ad
16 changed files with 78 additions and 20 deletions

8
ableos/Cargo.lock generated
View file

@ -273,9 +273,10 @@ checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35"
[[package]] [[package]]
name = "kernel" name = "kernel"
version = "0.1.1" version = "0.1.2"
dependencies = [ dependencies = [
"lazy_static", "lazy_static",
"versioning",
] ]
[[package]] [[package]]
@ -775,6 +776,11 @@ version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
name = "versioning"
version = "0.1.2"
source = "git+https://git.ablecorp.us/able/versioning#ef472283e6e7a2e395ee56434087b3a6fad53ff2"
[[package]] [[package]]
name = "vga" name = "vga"
version = "0.2.7" version = "0.2.7"

View file

@ -1,6 +1,4 @@
use alloc::string::String; use kernel::device_interface::character::CharacterDevice;
use crate::character_device::CharacterDevice;
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
@ -22,4 +20,12 @@ impl CharacterDevice for DevNull {
fn write_char(&mut self, _: char) -> bool { fn write_char(&mut self, _: char) -> bool {
true true
} }
fn reset(&mut self) {
todo!()
}
fn initialize(&mut self) -> bool {
todo!()
}
} }

View file

@ -1,4 +1,4 @@
use crate::character_device::CharacterDevice; use kernel::device_interface::character::CharacterDevice;
#[derive(Debug)] #[derive(Debug)]
pub struct DevUnicode { pub struct DevUnicode {
@ -29,6 +29,15 @@ impl CharacterDevice for DevUnicode {
true true
} }
fn reset(&mut self) {
self.next_write_char = 0x00 as char;
self.next_read_char = 0x00 as char;
}
fn initialize(&mut self) -> bool {
true
}
} }
fn add1_char(c: char) -> char { fn add1_char(c: char) -> char {

View file

@ -1,4 +1,4 @@
use crate::character_device::CharacterDevice; use kernel::device_interface::character::CharacterDevice;
#[derive(Debug)] #[derive(Debug)]
pub struct DevZero; pub struct DevZero;
@ -19,4 +19,10 @@ impl CharacterDevice for DevZero {
fn write_char(&mut self, _: char) -> bool { fn write_char(&mut self, _: char) -> bool {
true true
} }
fn reset(&mut self) {}
fn initialize(&mut self) -> bool {
true
}
} }

View file

@ -1,3 +1,5 @@
pub mod dev_null; 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;

View file

@ -9,7 +9,7 @@ use alloc::{
use hashbrown::HashMap; use hashbrown::HashMap;
use pci::PCIDevice; use pci::PCIDevice;
use crate::character_device::CharacterDevice; use kernel::device_interface::character::CharacterDevice;
// FIXME: This is a hack to hold a device. // FIXME: This is a hack to hold a device.
// #[derive(Debug)] // #[derive(Debug)]

View file

@ -1,4 +1,2 @@
pub mod graphics; pub mod graphics;
pub mod serial; pub mod serial;
pub mod character_device;

8
kernel/Cargo.lock generated
View file

@ -4,9 +4,10 @@ version = 3
[[package]] [[package]]
name = "kernel" name = "kernel"
version = "0.1.1" version = "0.1.2"
dependencies = [ dependencies = [
"lazy_static", "lazy_static",
"versioning",
] ]
[[package]] [[package]]
@ -14,3 +15,8 @@ name = "lazy_static"
version = "1.4.0" version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "versioning"
version = "0.1.2"
source = "git+https://git.ablecorp.us/able/versioning#ef472283e6e7a2e395ee56434087b3a6fad53ff2"

View file

@ -1,8 +1,13 @@
[package] [package]
edition = "2021" edition = "2021"
name = "kernel" name = "kernel"
version = "0.1.1" version = "0.1.2"
[dependencies] [dependencies]
lazy_static = "*" [dependencies.lazy_static]
version = "1.4.0"
default-features = false
[dependencies.versioning]
git = "https://git.ablecorp.us/able/versioning"

View file

@ -0,0 +1 @@
//!

View file

@ -1,3 +1,6 @@
//!
/// Character device interface.
pub trait CharacterDevice { pub trait CharacterDevice {
/// Returns true if the device can be read from. /// Returns true if the device can be read from.
fn can_read(&self) -> bool; fn can_read(&self) -> bool;
@ -7,4 +10,8 @@ pub trait CharacterDevice {
fn read_char(&mut self) -> Option<char>; fn read_char(&mut self) -> Option<char>;
/// Writes a single character to the device and returns true if the write was successful /// Writes a single character to the device and returns true if the write was successful
fn write_char(&mut self, c: char) -> bool; fn write_char(&mut self, c: char) -> bool;
/// Reset the device to its initial state
fn reset(&mut self);
/// initializes the device, returns true if successful
fn initialize(&mut self) -> bool;
} }

View file

@ -0,0 +1,4 @@
//! Platform Agnostic Device
pub mod block;
pub mod character;

View file

@ -2,15 +2,16 @@
#![no_std] #![no_std]
//! The ableOS kernel. //! The ableOS kernel.
pub mod kernel_time; pub mod device_interface;
pub mod messaging; pub mod messaging;
pub mod proccess;
// #[cfg(no_std)]
pub mod panic; pub mod panic;
pub mod proccess;
pub mod time;
use core::sync::atomic::{AtomicU64, Ordering::Relaxed}; use core::sync::atomic::{AtomicU64, Ordering::Relaxed};
use versioning::Version;
/// called by arch specific timers to tick up all kernel related functions /// called by arch specific timers to tick up all kernel related functions
pub fn tick() { pub fn tick() {
let mut data = TICK.load(Relaxed); let mut data = TICK.load(Relaxed);
@ -23,3 +24,10 @@ lazy_static::lazy_static! {
/// The number of ticks since the first CPU was started /// The number of ticks since the first CPU was started
pub static ref TICK: AtomicU64 = AtomicU64::new(0); pub static ref TICK: AtomicU64 = AtomicU64::new(0);
} }
///
pub const KERNEL_VERSION: Version = Version {
major: 0,
minor: 1,
patch: 2,
};

View file

@ -1,14 +1,14 @@
//! Interprocess communication. //! Interprocess communication.
use crate::{kernel_time::Time, proccess::PID}; use crate::{proccess::PID, time::Time};
/// 128 Bytes /// 128 Bytes
pub type Tiny = [u8; 128]; pub type Tiny = [u8; 128];
/// 1 KibiByte /// 1 KiB
pub type Small = [u8; 1024]; pub type Small = [u8; 1024];
/// 65.536 KibiBytes /// 65.536 KiB
pub type Medium = [u8; 65536]; pub type Medium = [u8; 65536];
/// 1MiB /// 1MiB

View file

@ -3,6 +3,6 @@
use core::panic::PanicInfo; use core::panic::PanicInfo;
#[panic_handler] #[panic_handler]
fn panic(_info: &PanicInfo) -> ! { fn panic_handler(_info: &PanicInfo) -> ! {
loop {} loop {}
} }