basic CMOS clock
This commit is contained in:
parent
3c3cd08ebb
commit
96d50ab941
|
@ -33,6 +33,23 @@ name = "cast"
|
|||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "chrono"
|
||||
version = "0.4.9"
|
||||
source = "git+https://tulpa.dev/xeos/chrono#918cff1f724305d3d1b126abf49425c653a4a201"
|
||||
dependencies = [
|
||||
"num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cmos"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cpuio 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "compiler_builtins"
|
||||
version = "0.1.19"
|
||||
|
@ -146,18 +163,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
[[package]]
|
||||
name = "wasmi"
|
||||
version = "0.5.1"
|
||||
source = "git+https://tulpa.dev/xeos/wasmi#0b6dd64219cc73e8fc58cfdfdd89a314b1d41596"
|
||||
dependencies = [
|
||||
"libm 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"memory_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-rational 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-wasm 0.40.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasmi-validation 0.2.0",
|
||||
"wasmi-validation 0.2.0 (git+https://tulpa.dev/xeos/wasmi)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmi-validation"
|
||||
version = "0.2.0"
|
||||
source = "git+https://tulpa.dev/xeos/wasmi#0b6dd64219cc73e8fc58cfdfdd89a314b1d41596"
|
||||
dependencies = [
|
||||
"parity-wasm 0.40.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
@ -179,6 +198,8 @@ name = "xe_os"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bootloader 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"chrono 0.4.9 (git+https://tulpa.dev/xeos/chrono)",
|
||||
"cmos 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"compiler_builtins 0.1.19 (git+https://github.com/rust-lang/compiler-builtins)",
|
||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"linked_list_allocator 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -187,7 +208,7 @@ dependencies = [
|
|||
"spin 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"uart_16550 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"volatile 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasmi 0.5.1",
|
||||
"wasmi 0.5.1 (git+https://tulpa.dev/xeos/wasmi)",
|
||||
"x86_64 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
@ -198,6 +219,8 @@ dependencies = [
|
|||
"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
|
||||
"checksum bootloader 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "abfbe6cdea6367860818facc8e4a184f003cb83d7d004acaaf57baebf1949da0"
|
||||
"checksum cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "926013f2860c46252efceabb19f4a6b308197505082c609025aa6706c011d427"
|
||||
"checksum chrono 0.4.9 (git+https://tulpa.dev/xeos/chrono)" = "<none>"
|
||||
"checksum cmos 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0a5377a95644e12ea6460d19d59692c40a5fc65d0eb2ad34390c12cbb5a64095"
|
||||
"checksum compiler_builtins 0.1.19 (git+https://github.com/rust-lang/compiler-builtins)" = "<none>"
|
||||
"checksum cpuio 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "22b8e308ccfc5acf3b82f79c0eac444cf6114cb2ac67a230ca6c177210068daa"
|
||||
"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||
|
@ -215,4 +238,6 @@ dependencies = [
|
|||
"checksum uart_16550 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "803ea8cb602dbb32c1a657a866d2dd79fe7dbeab0fb2ac667cb4dcc7de12a58b"
|
||||
"checksum ux 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "88dfeb711b61ce620c0cb6fd9f8e3e678622f0c971da2a63c4b3e25e88ed012f"
|
||||
"checksum volatile 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "6af0edf5b4faacc31fc51159244d78d65ec580f021afcef7bd53c04aeabc7f29"
|
||||
"checksum wasmi 0.5.1 (git+https://tulpa.dev/xeos/wasmi)" = "<none>"
|
||||
"checksum wasmi-validation 0.2.0 (git+https://tulpa.dev/xeos/wasmi)" = "<none>"
|
||||
"checksum x86_64 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)" = "997837f3913aac8f67164683258756d712376849906c8d609f844084bc03ef84"
|
||||
|
|
|
@ -15,11 +15,10 @@ uart_16550 = "0.2.0"
|
|||
pic8259_simple = "0.1.1"
|
||||
pc-keyboard = "0.3.1"
|
||||
linked_list_allocator = "0.6.4"
|
||||
wasmi = {version = "*", default-features=false, features = ["core"]}
|
||||
wasmi = {git = "https://tulpa.dev/xeos/wasmi", default-features=false, features = ["core"] }
|
||||
compiler_builtins = { git = "https://github.com/rust-lang/compiler-builtins" }
|
||||
|
||||
[patch.crates-io]
|
||||
wasmi = { path = "/Users/within/Code/xeos_forks/wasmi" }
|
||||
chrono = { git = "https://tulpa.dev/xeos/chrono", default-features=false, features = ["alloc"] }
|
||||
cmos = "0.1.1"
|
||||
|
||||
[dependencies.lazy_static]
|
||||
version = "1.0"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use crate::println;
|
||||
use alloc::alloc::{GlobalAlloc, Layout};
|
||||
use bootloader::BootInfo;
|
||||
use core::ptr::null_mut;
|
||||
|
@ -7,7 +8,6 @@ use x86_64::{
|
|||
},
|
||||
VirtAddr,
|
||||
};
|
||||
use crate::{println};
|
||||
|
||||
pub struct Dummy;
|
||||
|
||||
|
@ -55,7 +55,7 @@ pub fn init_heap(
|
|||
|
||||
pub fn init(boot_info: &'static BootInfo) {
|
||||
use crate::memory::{self, BootInfoFrameAllocator};
|
||||
|
||||
|
||||
let phys_mem_offset = VirtAddr::new(boot_info.physical_memory_offset);
|
||||
let mut mapper = unsafe { memory::init(phys_mem_offset) };
|
||||
let mut frame_allocator = unsafe { BootInfoFrameAllocator::init(&boot_info.memory_map) };
|
||||
|
|
|
@ -26,8 +26,8 @@ fn alloc_error_handler(layout: alloc::alloc::Layout) -> ! {
|
|||
panic!("allocation error: {:?}", layout)
|
||||
}
|
||||
|
||||
use core::panic::PanicInfo;
|
||||
use bootloader::BootInfo;
|
||||
use core::panic::PanicInfo;
|
||||
|
||||
pub fn init(boot_info: &'static BootInfo) {
|
||||
println!("XeOS booting:");
|
||||
|
|
13
src/main.rs
13
src/main.rs
|
@ -13,16 +13,27 @@ use xe_os::println;
|
|||
entry_point!(kernel_main);
|
||||
|
||||
fn kernel_main(boot_info: &'static BootInfo) -> ! {
|
||||
use cmos::{CMOSCenturyHandler, CMOS};
|
||||
// Create a CMOS object (unsafe due to the use of port I/O)
|
||||
let mut cmos = unsafe { CMOS::new() };
|
||||
|
||||
xe_os::init(&boot_info);
|
||||
|
||||
#[cfg(test)]
|
||||
test_main();
|
||||
|
||||
// Read the rtc date time using this year
|
||||
let rtc = cmos.read_rtc(CMOSCenturyHandler::CurrentYear(2019));
|
||||
println!(
|
||||
"current time: {}:{}:{} {} M{} {}",
|
||||
rtc.hour, rtc.minute, rtc.second, rtc.year, rtc.month, rtc.day
|
||||
);
|
||||
|
||||
println!("Running WASM:");
|
||||
|
||||
xe_os::wasm::run();
|
||||
println!("[ ] success");
|
||||
|
||||
|
||||
xe_os::hlt_loop();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,20 +1,34 @@
|
|||
#[no_mangle]
|
||||
extern "C" fn fmod(_x: f64, _y: f64) -> f64 { unimplemented!(); }
|
||||
extern "C" fn fmod(_x: f64, _y: f64) -> f64 {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
extern "C" fn fmodf(_x: f32, _y: f32) -> f32 { unimplemented!(); }
|
||||
extern "C" fn fmodf(_x: f32, _y: f32) -> f32 {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
extern "C" fn fmin(_x: f64, _y: f64) -> f64 { unimplemented!(); }
|
||||
extern "C" fn fmin(_x: f64, _y: f64) -> f64 {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
extern "C" fn fminf(_x: f32, _y: f32) -> f32 { unimplemented!(); }
|
||||
extern "C" fn fminf(_x: f32, _y: f32) -> f32 {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
extern "C" fn fmax(_x: f64, _y: f64) -> f64 { unimplemented!(); }
|
||||
extern "C" fn fmax(_x: f64, _y: f64) -> f64 {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
extern "C" fn fmaxf(_x: f32, _y: f32) -> f32 { unimplemented!(); }
|
||||
extern "C" fn fmaxf(_x: f32, _y: f32) -> f32 {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
extern "C" fn __truncdfsf2(_x: f64) -> f32 { unimplemented!(); }
|
||||
extern "C" fn __truncdfsf2(_x: f64) -> f32 {
|
||||
unimplemented!();
|
||||
}
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
use wasmi::{
|
||||
Error as InterpreterError, Externals, FuncInstance, FuncRef, ImportsBuilder,
|
||||
ModuleImportResolver, ModuleInstance, RuntimeArgs, RuntimeValue, Signature, Trap,
|
||||
ValueType,
|
||||
};
|
||||
use crate::{print, println};
|
||||
use wasmi::{
|
||||
Error as InterpreterError, Externals, FuncInstance, FuncRef, ImportsBuilder,
|
||||
ModuleImportResolver, ModuleInstance, RuntimeArgs, RuntimeValue, Signature, Trap, ValueType,
|
||||
};
|
||||
|
||||
#[cfg(test)]
|
||||
use crate::{serial_print, serial_println};
|
||||
|
@ -66,10 +65,7 @@ impl ModuleImportResolver for H {
|
|||
_signature: &Signature,
|
||||
) -> Result<FuncRef, InterpreterError> {
|
||||
let func_ref = match field_name {
|
||||
"h" => FuncInstance::alloc_host(
|
||||
Signature::new(&[ValueType::I32][..], None),
|
||||
H_FUNC,
|
||||
),
|
||||
"h" => FuncInstance::alloc_host(Signature::new(&[ValueType::I32][..], None), H_FUNC),
|
||||
_ => panic!("unknwon function asked for"),
|
||||
};
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
#![test_runner(xe_os::test_runner)]
|
||||
#![reexport_test_harness_main = "test_main"]
|
||||
|
||||
use core::panic::PanicInfo;
|
||||
use bootloader::{entry_point, BootInfo};
|
||||
use core::panic::PanicInfo;
|
||||
use xe_os::{println, serial_print, serial_println};
|
||||
|
||||
entry_point!(kmain);
|
||||
|
|
|
@ -23,8 +23,8 @@ fn panic(info: &PanicInfo) -> ! {
|
|||
xe_os::test_panic_handler(info)
|
||||
}
|
||||
|
||||
use xe_os::{serial_print, serial_println};
|
||||
use alloc::boxed::Box;
|
||||
use xe_os::{serial_print, serial_println};
|
||||
|
||||
#[test_case]
|
||||
fn simple_allocation() {
|
||||
|
|
Loading…
Reference in New Issue