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]]
name = "kernel"
version = "0.1.1"
version = "0.1.2"
dependencies = [
"lazy_static",
"versioning",
]
[[package]]
@ -775,6 +776,11 @@ version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
name = "versioning"
version = "0.1.2"
source = "git+https://git.ablecorp.us/able/versioning#ef472283e6e7a2e395ee56434087b3a6fad53ff2"
[[package]]
name = "vga"
version = "0.2.7"

View file

@ -1,6 +1,4 @@
use alloc::string::String;
use crate::character_device::CharacterDevice;
use kernel::device_interface::character::CharacterDevice;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
@ -22,4 +20,12 @@ impl CharacterDevice for DevNull {
fn write_char(&mut self, _: char) -> bool {
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)]
pub struct DevUnicode {
@ -29,6 +29,15 @@ impl CharacterDevice for DevUnicode {
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 {

View file

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

View file

@ -1,3 +1,5 @@
pub mod dev_null;
pub mod dev_unicode;
pub mod dev_zero;
pub use kernel::device_interface::character::CharacterDevice;

View file

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

View file

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

8
kernel/Cargo.lock generated
View file

@ -4,9 +4,10 @@ version = 3
[[package]]
name = "kernel"
version = "0.1.1"
version = "0.1.2"
dependencies = [
"lazy_static",
"versioning",
]
[[package]]
@ -14,3 +15,8 @@ name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
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]
edition = "2021"
name = "kernel"
version = "0.1.1"
version = "0.1.2"
[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 {
/// Returns true if the device can be read from.
fn can_read(&self) -> bool;
@ -7,4 +10,8 @@ pub trait CharacterDevice {
fn read_char(&mut self) -> Option<char>;
/// Writes a single character to the device and returns true if the write was successful
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]
//! The ableOS kernel.
pub mod kernel_time;
pub mod device_interface;
pub mod messaging;
pub mod proccess;
// #[cfg(no_std)]
pub mod panic;
pub mod proccess;
pub mod time;
use core::sync::atomic::{AtomicU64, Ordering::Relaxed};
use versioning::Version;
/// called by arch specific timers to tick up all kernel related functions
pub fn tick() {
let mut data = TICK.load(Relaxed);
@ -23,3 +24,10 @@ lazy_static::lazy_static! {
/// The number of ticks since the first CPU was started
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.
use crate::{kernel_time::Time, proccess::PID};
use crate::{proccess::PID, time::Time};
/// 128 Bytes
pub type Tiny = [u8; 128];
/// 1 KibiByte
/// 1 KiB
pub type Small = [u8; 1024];
/// 65.536 KibiBytes
/// 65.536 KiB
pub type Medium = [u8; 65536];
/// 1MiB

View file

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