forked from koniifer/ableos
work done
This commit is contained in:
parent
d69ba91101
commit
c8455f9352
|
@ -2,9 +2,8 @@
|
||||||
target = "./json_targets/x86_64-ableos.json"
|
target = "./json_targets/x86_64-ableos.json"
|
||||||
|
|
||||||
[unstable]
|
[unstable]
|
||||||
build-std-features = ["compiler-builtins-mem"]
|
|
||||||
build-std = ["core", "compiler_builtins", "alloc"]
|
build-std = ["core", "compiler_builtins", "alloc"]
|
||||||
|
build-std-features = ["compiler-builtins-mem"]
|
||||||
|
|
||||||
|
|
||||||
[target.'cfg(target_arch = "x86_64")']
|
[target.'cfg(target_arch = "x86_64")']
|
||||||
|
|
122
ableos/Cargo.lock
generated
122
ableos/Cargo.lock
generated
|
@ -8,11 +8,11 @@ version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bootloader",
|
"bootloader",
|
||||||
"cpuio",
|
"cpuio",
|
||||||
|
"externc-libm",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"linked_list_allocator",
|
"linked_list_allocator",
|
||||||
"lliw",
|
"lliw",
|
||||||
"pic8259",
|
"pic8259",
|
||||||
"psp",
|
|
||||||
"qoi_rs",
|
"qoi_rs",
|
||||||
"spin",
|
"spin",
|
||||||
"uart_16550",
|
"uart_16550",
|
||||||
|
@ -41,32 +41,29 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bootloader"
|
name = "bootloader"
|
||||||
version = "0.9.19"
|
version = "0.9.20"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b7c452074efc3c0bfb241fb7bc87df04741c7c85e926f6a07c05f8fbd6008240"
|
checksum = "6b0718f186cd449b21f044683933284ed90fb83f3e13949ff0e03b0b6f02e38e"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cpuio"
|
name = "cpuio"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
source = "git+https://github.com/anyusernameworks/cpuio.git#3908ecab79df80670ee1c5121870fc131f07627b"
|
source = "git+https://github.com/anyusernameworks/cpuio.git#3908ecab79df80670ee1c5121870fc131f07627b"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "derivative"
|
|
||||||
version = "2.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "downcast-rs"
|
name = "downcast-rs"
|
||||||
version = "1.2.0"
|
version = "1.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650"
|
checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "externc-libm"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "git+https://github.com/HaruxOS/externc-libm#597110801cbcbbfb5d4731746d13014494deb39f"
|
||||||
|
dependencies = [
|
||||||
|
"libm",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lazy_static"
|
name = "lazy_static"
|
||||||
version = "1.4.0"
|
version = "1.4.0"
|
||||||
|
@ -142,52 +139,12 @@ dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "num_enum"
|
|
||||||
version = "0.5.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "3f9bd055fb730c4f8f4f57d45d35cd6b3f0980535b056dc7ff119cee6a66ed6f"
|
|
||||||
dependencies = [
|
|
||||||
"derivative",
|
|
||||||
"num_enum_derive",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "num_enum_derive"
|
|
||||||
version = "0.5.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "486ea01961c4a818096de679a8b740b26d9033146ac5291b1c98557658f8cdd9"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "parity-wasm"
|
name = "parity-wasm"
|
||||||
version = "0.42.2"
|
version = "0.42.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "be5e13c266502aadf83426d87d81a0f5d1ef45b8027f5a471c360abfe4bfae92"
|
checksum = "be5e13c266502aadf83426d87d81a0f5d1ef45b8027f5a471c360abfe4bfae92"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "paste"
|
|
||||||
version = "0.1.18"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "45ca20c77d80be666aef2b45486da86238fabe33e38306bd3118fe4af33fa880"
|
|
||||||
dependencies = [
|
|
||||||
"paste-impl",
|
|
||||||
"proc-macro-hack",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "paste-impl"
|
|
||||||
version = "0.1.18"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d95a7db200b97ef370c8e6de0088252f7e0dfff7d047a28528e47456c0fc98b6"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro-hack",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pic8259"
|
name = "pic8259"
|
||||||
version = "0.10.2"
|
version = "0.10.2"
|
||||||
|
@ -197,48 +154,12 @@ dependencies = [
|
||||||
"x86_64",
|
"x86_64",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "proc-macro-hack"
|
|
||||||
version = "0.5.19"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "proc-macro2"
|
|
||||||
version = "1.0.32"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43"
|
|
||||||
dependencies = [
|
|
||||||
"unicode-xid",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "psp"
|
|
||||||
version = "0.1.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0b3021953a10d1bc6735a606ab9d5a1510282df7a55a160a270e9ea3cf479669"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags",
|
|
||||||
"num_enum",
|
|
||||||
"num_enum_derive",
|
|
||||||
"paste",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "qoi_rs"
|
name = "qoi_rs"
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f7ac44f12a8cec33865a699b2257e8454499fb4c3b13835710ff35c66bb65669"
|
checksum = "f7ac44f12a8cec33865a699b2257e8454499fb4c3b13835710ff35c66bb65669"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "quote"
|
|
||||||
version = "1.0.10"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "scopeguard"
|
name = "scopeguard"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
|
@ -260,17 +181,6 @@ dependencies = [
|
||||||
"lock_api",
|
"lock_api",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "syn"
|
|
||||||
version = "1.0.81"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f2afee18b8beb5a596ecb4a2dce128c719b4ba399d34126b9e4396e3f9860966"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"unicode-xid",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "uart_16550"
|
name = "uart_16550"
|
||||||
version = "0.2.15"
|
version = "0.2.15"
|
||||||
|
@ -281,12 +191,6 @@ dependencies = [
|
||||||
"x86_64",
|
"x86_64",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "unicode-xid"
|
|
||||||
version = "0.2.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "volatile"
|
name = "volatile"
|
||||||
version = "0.2.7"
|
version = "0.2.7"
|
||||||
|
@ -325,9 +229,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "x86_64"
|
name = "x86_64"
|
||||||
version = "0.14.6"
|
version = "0.14.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bbc6ed1ed2cd4536b083c34041aff7b84448ee25ac4aa5e9d54802ce226f9815"
|
checksum = "fb611915c917c6296d11e23f71ff1ecfe49c5766daba92cd3df52df6b58285b6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bit_field",
|
"bit_field",
|
||||||
"bitflags",
|
"bitflags",
|
||||||
|
|
|
@ -1,41 +1,43 @@
|
||||||
[package]
|
[package]
|
||||||
|
edition = "2021"
|
||||||
name = "ableos"
|
name = "ableos"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
panic = "abort"
|
panic = "abort"
|
||||||
|
|
||||||
[package.metadata.bootimage]
|
[package.metadata.bootimage]
|
||||||
|
run-args = ["-serial", "stdio"]
|
||||||
test-args = [
|
test-args = [
|
||||||
"-device", "isa-debug-exit,iobase=0xf4,iosize=0x04", "-serial", "stdio"
|
"-device",
|
||||||
|
"isa-debug-exit,iobase=0xf4,iosize=0x04",
|
||||||
|
"-serial",
|
||||||
|
"stdio",
|
||||||
]
|
]
|
||||||
run-args=["-serial", "stdio"]
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
spin = "0.5.2"
|
|
||||||
linked_list_allocator = "0.9.0"
|
linked_list_allocator = "0.9.0"
|
||||||
lliw = "0.2.0"
|
lliw = "0.2.0"
|
||||||
qoi_rs = "*"
|
qoi_rs = "*"
|
||||||
|
spin = "0.5.2"
|
||||||
|
|
||||||
[dependencies.wasmi]
|
[dependencies.wasmi]
|
||||||
version = "*"
|
|
||||||
default-features = false
|
default-features = false
|
||||||
features = ["core"]
|
features = ["core"]
|
||||||
|
version = "*"
|
||||||
|
|
||||||
[dependencies.lazy_static]
|
[dependencies.lazy_static]
|
||||||
features = ["spin_no_std"]
|
features = ["spin_no_std"]
|
||||||
version = "1.0"
|
version = "1.0"
|
||||||
|
|
||||||
[target.'cfg(target_arch = "mips")'.dependencies]
|
[dependencies.externc-libm]
|
||||||
psp = "0.1.5"
|
git = "https://github.com/HaruxOS/externc-libm"
|
||||||
|
|
||||||
[target.'cfg(target_arch = "x86_64")'.dependencies]
|
[target.'cfg(target_arch = "x86_64")'.dependencies]
|
||||||
volatile = "0.2.6"
|
bootloader = { version = "0.9.8", features = ["map_physical_memory"] }
|
||||||
bootloader = {version = "0.9.8", features = ["map_physical_memory"]}
|
|
||||||
cpuio = { git = "https://github.com/anyusernameworks/cpuio.git" }
|
cpuio = { git = "https://github.com/anyusernameworks/cpuio.git" }
|
||||||
x86_64 = "*"
|
|
||||||
uart_16550 = "0.2.0"
|
|
||||||
pic8259 = "0.10.1"
|
pic8259 = "0.10.1"
|
||||||
|
uart_16550 = "0.2.0"
|
||||||
|
volatile = "0.2.6"
|
||||||
|
x86_64 = "*"
|
||||||
|
|
|
@ -1,13 +1,8 @@
|
||||||
use core::fmt::Arguments;
|
|
||||||
use core::fmt::Error;
|
|
||||||
|
|
||||||
/// Prints to the host through the serial interface.
|
/// Prints to the host through the serial interface.
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! serial_print {
|
macro_rules! serial_print {
|
||||||
($($arg:tt)*) => {
|
($($arg:tt)*) => {
|
||||||
|
crate::arch::drivers::serial::SERIAL.lock().out(format_args!($($arg)*))
|
||||||
crate::arch::drivers::serial::SERIAL.lock().out(format_args!($($arg)*))
|
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
/// Prints to the host through the serial interface, appending a newline.
|
/// Prints to the host through the serial interface, appending a newline.
|
||||||
|
@ -20,9 +15,6 @@ macro_rules! serial_println {
|
||||||
};
|
};
|
||||||
|
|
||||||
($($arg:tt)*) => ($crate::print!("{}\r\n", format_args!($($arg)*)));
|
($($arg:tt)*) => ($crate::print!("{}\r\n", format_args!($($arg)*)));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Serial123 {
|
pub struct Serial123 {
|
||||||
|
@ -38,10 +30,6 @@ impl Serial123 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use spin::Mutex;
|
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
pub static ref SERIAL: Mutex<Serial123> = {
|
pub static ref SERIAL: Mutex<Serial123> = {
|
||||||
let serial_port = Serial123 {
|
let serial_port = Serial123 {
|
||||||
|
@ -51,3 +39,9 @@ lazy_static! {
|
||||||
Mutex::new(serial_port)
|
Mutex::new(serial_port)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
use {
|
||||||
|
core::fmt::{Arguments, Error},
|
||||||
|
lazy_static::lazy_static,
|
||||||
|
spin::Mutex,
|
||||||
|
};
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#![allow(clippy::print_literal)]
|
#![allow(clippy::print_literal)]
|
||||||
use super::{gdt, interrupts};
|
use super::{gdt, interrupts};
|
||||||
use crate::{println, serial_println};
|
use crate::{println, serial_println};
|
||||||
|
|
||||||
pub fn init() {
|
pub fn init() {
|
||||||
gdt::init();
|
gdt::init();
|
||||||
interrupts::init_idt();
|
interrupts::init_idt();
|
||||||
|
|
|
@ -1,15 +1,19 @@
|
||||||
#![allow(clippy::empty_loop)]
|
#![allow(clippy::empty_loop)]
|
||||||
|
|
||||||
use crate::{
|
pub extern crate externc_libm as libm;
|
||||||
arch::{drivers::graphics::GraphicsBuffer, init, sloop},
|
|
||||||
driver_traits::graphics::Graphics,
|
|
||||||
experiments::systeminfo::{KERNEL_VERSION, RELEASE_TYPE},
|
|
||||||
keyboard::DecodedKey,
|
|
||||||
relib::math::rand::RAND_HANDLE,
|
|
||||||
};
|
|
||||||
|
|
||||||
use alloc::{boxed::Box, rc::Rc};
|
use {
|
||||||
use lazy_static::lazy_static;
|
crate::{
|
||||||
|
arch::{drivers::graphics::GraphicsBuffer, init, sloop},
|
||||||
|
driver_traits::graphics::Graphics,
|
||||||
|
experiments::systeminfo::{KERNEL_VERSION, RELEASE_TYPE},
|
||||||
|
keyboard::DecodedKey,
|
||||||
|
relib::math::rand::RAND_HANDLE,
|
||||||
|
scheduler::{test_fn, Thread, ThreadList},
|
||||||
|
},
|
||||||
|
alloc::{boxed::Box, rc::Rc, vec, vec::Vec},
|
||||||
|
lazy_static::lazy_static,
|
||||||
|
};
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
#[allow(unconditional_recursion)]
|
#[allow(unconditional_recursion)]
|
||||||
|
@ -22,55 +26,32 @@ pub extern "C" fn stack_overflow() -> u8 {
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
pub static ref KEY_BUFFER: [DecodedKey; 256] = [DecodedKey::RawKey(123); 256];
|
pub static ref KEY_BUFFER: [DecodedKey; 256] = [DecodedKey::RawKey(123); 256];
|
||||||
pub static ref KEY_BUFFER_POINTER: u8 = 0;
|
pub static ref KEY_BUFFER_POINTER: u8 = 0;
|
||||||
|
pub static ref THREAD_LIST: spin::Mutex<ThreadList> = spin::Mutex::new(vec![]);
|
||||||
|
pub static ref TICK: spin::Mutex<u64> = spin::Mutex::new(0);
|
||||||
}
|
}
|
||||||
// Defines the entry point
|
use alloc::format;
|
||||||
|
|
||||||
|
use crate::log::{self, Log};
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub fn kernel_main() -> ! {
|
pub fn kernel_main() -> ! {
|
||||||
init::init();
|
init::init();
|
||||||
|
let mut a_thread = Thread::new();
|
||||||
|
|
||||||
|
a_thread.new_task(test_fn);
|
||||||
|
a_thread.new_task(test_fn);
|
||||||
|
|
||||||
|
THREAD_LIST.lock().push(a_thread);
|
||||||
|
|
||||||
GraphicsBuffer::draw();
|
GraphicsBuffer::draw();
|
||||||
GraphicsBuffer::hide_cursor();
|
GraphicsBuffer::hide_cursor();
|
||||||
GraphicsBuffer::show_cursor();
|
GraphicsBuffer::show_cursor();
|
||||||
|
if false {
|
||||||
{
|
test_alloc();
|
||||||
use alloc::{vec, vec::Vec};
|
|
||||||
let x: Vec<u8> = vec![1];
|
|
||||||
println!("{:?}", x);
|
|
||||||
|
|
||||||
let heap_value = Box::new(41);
|
|
||||||
println!("heap_value at {:p}", heap_value);
|
|
||||||
|
|
||||||
// create a dynamically sized vector
|
|
||||||
let mut vec = Vec::new();
|
|
||||||
for i in 0..500 {
|
|
||||||
vec.push(i);
|
|
||||||
}
|
|
||||||
println!("vec at {:p}", vec.as_slice());
|
|
||||||
|
|
||||||
// create a reference counted vector -> will be freed when count reaches 0
|
|
||||||
let reference_counted = Rc::new(vec![1, 2, 3]);
|
|
||||||
let cloned_reference = reference_counted.clone();
|
|
||||||
println!(
|
|
||||||
"current reference count is {}",
|
|
||||||
Rc::strong_count(&cloned_reference)
|
|
||||||
);
|
|
||||||
core::mem::drop(reference_counted);
|
|
||||||
println!(
|
|
||||||
"reference count is {} now",
|
|
||||||
Rc::strong_count(&cloned_reference)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// crate::wasm::evaluate();
|
// crate::wasm::evaluate();
|
||||||
|
|
||||||
/* If AES is present then AES init rng as well
|
|
||||||
// Maybe via a cfg
|
|
||||||
AES::init_rng();
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
println!("{} v{}", RELEASE_TYPE, KERNEL_VERSION);
|
println!("{} v{}", RELEASE_TYPE, KERNEL_VERSION);
|
||||||
|
log::ANSISerialLogger::debug(&format!("{} v{}", RELEASE_TYPE, KERNEL_VERSION));
|
||||||
|
|
||||||
{
|
{
|
||||||
use crate::experiments::mail::MailBoxes;
|
use crate::experiments::mail::MailBoxes;
|
||||||
|
@ -85,9 +66,6 @@ pub fn kernel_main() -> ! {
|
||||||
sloop()
|
sloop()
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static! {
|
|
||||||
pub static ref TICK: spin::Mutex<u64> = spin::Mutex::new(0);
|
|
||||||
}
|
|
||||||
/// 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.lock();
|
let mut data = TICK.lock();
|
||||||
|
@ -98,3 +76,31 @@ pub fn tick() {
|
||||||
pub fn key_entropy(key: u8) {
|
pub fn key_entropy(key: u8) {
|
||||||
RAND_HANDLE.lock().seed_entropy_keyboard(key);
|
RAND_HANDLE.lock().seed_entropy_keyboard(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn test_alloc() {
|
||||||
|
let x: Vec<u8> = vec![1];
|
||||||
|
println!("{:?}", x);
|
||||||
|
|
||||||
|
let heap_value = Box::new(41);
|
||||||
|
println!("heap_value at {:p}", heap_value);
|
||||||
|
|
||||||
|
// create a dynamically sized vector
|
||||||
|
let mut vec = Vec::new();
|
||||||
|
for i in 0..500 {
|
||||||
|
vec.push(i);
|
||||||
|
}
|
||||||
|
println!("vec at {:p}", vec.as_slice());
|
||||||
|
|
||||||
|
// create a reference counted vector -> will be freed when count reaches 0
|
||||||
|
let reference_counted = Rc::new(vec![1, 2, 3]);
|
||||||
|
let cloned_reference = reference_counted.clone();
|
||||||
|
println!(
|
||||||
|
"current reference count is {}",
|
||||||
|
Rc::strong_count(&cloned_reference)
|
||||||
|
);
|
||||||
|
core::mem::drop(reference_counted);
|
||||||
|
println!(
|
||||||
|
"reference count is {} now",
|
||||||
|
Rc::strong_count(&cloned_reference)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ pub mod kmain;
|
||||||
pub mod log;
|
pub mod log;
|
||||||
pub mod panic;
|
pub mod panic;
|
||||||
pub mod relib;
|
pub mod relib;
|
||||||
|
pub mod scheduler;
|
||||||
pub mod wasm;
|
pub mod wasm;
|
||||||
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
pub trait Log {
|
pub trait Log {
|
||||||
fn debug();
|
fn debug(val: &str);
|
||||||
fn error();
|
fn error();
|
||||||
fn log();
|
fn info(val: &str);
|
||||||
fn trace();
|
fn trace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,16 +9,14 @@ use crate::serial_print;
|
||||||
use lliw::{Fg, Reset};
|
use lliw::{Fg, Reset};
|
||||||
pub struct ANSISerialLogger;
|
pub struct ANSISerialLogger;
|
||||||
impl Log for ANSISerialLogger {
|
impl Log for ANSISerialLogger {
|
||||||
fn debug() {
|
fn debug(val: &str) {
|
||||||
serial_print!("[{}Debug{}]", Fg::Blue, Reset);
|
serial_print!("[{}Debug{}] {}\n", Fg::Blue, Reset, val);
|
||||||
|
|
||||||
todo!();
|
|
||||||
}
|
}
|
||||||
fn error() {
|
fn error() {
|
||||||
todo!();
|
todo!();
|
||||||
}
|
}
|
||||||
fn log() {
|
fn info(val: &str) {
|
||||||
todo!();
|
serial_print!("[{}Info{}] {}\n", Fg::Blue, Reset, val);
|
||||||
}
|
}
|
||||||
fn trace() {
|
fn trace() {
|
||||||
todo!();
|
todo!();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use crate::relib::math::rand::RNG;
|
use crate::relib::math::rand::RNG;
|
||||||
|
|
||||||
pub struct LinearShiftRegister {
|
pub struct LinearShiftRegister {
|
||||||
reg: u64,
|
reg: u64,
|
||||||
}
|
}
|
||||||
// 64 bit
|
// 64 bit
|
||||||
// non-cryptographically secure
|
// non-cryptographically secure
|
||||||
|
@ -10,6 +11,7 @@ impl RNG for LinearShiftRegister {
|
||||||
}
|
}
|
||||||
fn rand(&mut self) -> u64 {
|
fn rand(&mut self) -> u64 {
|
||||||
let newbit = (self.reg >> 1) ^ (self.reg >> 2) ^ (self.reg >> 7);
|
let newbit = (self.reg >> 1) ^ (self.reg >> 2) ^ (self.reg >> 7);
|
||||||
|
|
||||||
self.reg = (self.reg >> 1) | (newbit << 3);
|
self.reg = (self.reg >> 1) | (newbit << 3);
|
||||||
newbit
|
newbit
|
||||||
}
|
}
|
||||||
|
@ -23,11 +25,6 @@ impl RNG for LinearShiftRegister {
|
||||||
let mult = shifted.wrapping_mul(multitude);
|
let mult = shifted.wrapping_mul(multitude);
|
||||||
let seeded_bit = seed / mult;
|
let seeded_bit = seed / mult;
|
||||||
|
|
||||||
if false {
|
|
||||||
// crate::serial_println!("Entropy {}", entropy);
|
|
||||||
// crate::serial_println!("Multitude {}", multitude);
|
|
||||||
// crate::serial_println!("Seeded Bit {}", seeded_bit);
|
|
||||||
}
|
|
||||||
for _ in 0..seeded_bit {
|
for _ in 0..seeded_bit {
|
||||||
self.rand();
|
self.rand();
|
||||||
}
|
}
|
||||||
|
|
79
ableos/src/scheduler.rs
Normal file
79
ableos/src/scheduler.rs
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
use core::cmp::Ordering;
|
||||||
|
|
||||||
|
use alloc::vec;
|
||||||
|
use alloc::vec::Vec;
|
||||||
|
|
||||||
|
use crate::kmain::THREAD_LIST;
|
||||||
|
|
||||||
|
pub type Pointer = fn();
|
||||||
|
pub type ThreadID = u64;
|
||||||
|
pub type TaskID = u64;
|
||||||
|
pub type ThreadList = Vec<Thread>;
|
||||||
|
|
||||||
|
#[derive(Eq, Debug)]
|
||||||
|
pub struct Task {
|
||||||
|
id: TaskID,
|
||||||
|
parent_thread: ThreadID,
|
||||||
|
fn_pointer: Pointer,
|
||||||
|
}
|
||||||
|
impl Task {
|
||||||
|
fn new(parent_thread: ThreadID, task_id: u64, function_pointer: fn()) -> Self {
|
||||||
|
Self {
|
||||||
|
id: task_id,
|
||||||
|
parent_thread,
|
||||||
|
fn_pointer: function_pointer,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Ord for Task {
|
||||||
|
fn cmp(&self, other: &Self) -> Ordering {
|
||||||
|
self.id.cmp(&other.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PartialOrd for Task {
|
||||||
|
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||||
|
Some(self.cmp(other))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PartialEq for Task {
|
||||||
|
fn eq(&self, other: &Self) -> bool {
|
||||||
|
self.id == other.id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct Thread {
|
||||||
|
pub id: ThreadID,
|
||||||
|
pub tasks: Vec<Task>,
|
||||||
|
}
|
||||||
|
impl Thread {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
let threads = &*THREAD_LIST.lock();
|
||||||
|
let mut final_threadid = 0;
|
||||||
|
match threads.last() {
|
||||||
|
Some(last_thread) => final_threadid = last_thread.id + 1,
|
||||||
|
None => {}
|
||||||
|
}
|
||||||
|
|
||||||
|
Self {
|
||||||
|
id: final_threadid,
|
||||||
|
tasks: vec![],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub fn sort_tasks(&mut self) {
|
||||||
|
self.tasks.sort();
|
||||||
|
}
|
||||||
|
pub fn new_task_id(&self) -> TaskID {
|
||||||
|
self.tasks.len().try_into().unwrap()
|
||||||
|
}
|
||||||
|
pub fn new_task(&mut self, function_pointer: fn()) {
|
||||||
|
let x = Task::new(self.id, self.new_task_id(), function_pointer);
|
||||||
|
self.tasks.push(x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn test_fn() {
|
||||||
|
println!("Hello");
|
||||||
|
}
|
|
@ -1,12 +1,15 @@
|
||||||
// use wabt;
|
use {
|
||||||
use wasmi::{
|
alloc::format,
|
||||||
Error, Externals, FuncInstance, FuncRef, ImportsBuilder, ModuleImportResolver, ModuleInstance,
|
wasm_sys::SysCall,
|
||||||
RuntimeArgs, RuntimeValue, Signature, Trap, ValueType,
|
wasmi::{
|
||||||
|
Error, Externals, FuncInstance, FuncRef, ImportsBuilder, ModuleImportResolver,
|
||||||
|
ModuleInstance, RuntimeArgs, RuntimeValue, Signature, Trap, ValueType,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
mod wasm_sys;
|
mod wasm_sys;
|
||||||
use alloc::format;
|
pub extern crate externc_libm as libm;
|
||||||
use wasm_sys::SysCall;
|
|
||||||
struct HostFunctions;
|
struct HostFunctions;
|
||||||
impl HostFunctions {
|
impl HostFunctions {
|
||||||
fn check_signature(&self, index: usize, signature: &Signature) -> bool {
|
fn check_signature(&self, index: usize, signature: &Signature) -> bool {
|
||||||
|
|
Loading…
Reference in a new issue