forked from koniifer/ableos
upgrades people upgrades
destroying erins clean code
This commit is contained in:
parent
ddfbd579e3
commit
51c841e2de
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -56,6 +56,7 @@ dependencies = [
|
|||
"toml",
|
||||
"uart_16550",
|
||||
"unicode-width",
|
||||
"versioning",
|
||||
"vga",
|
||||
"volatile 0.2.7",
|
||||
"wasmi",
|
||||
|
|
|
@ -18,7 +18,7 @@ run-args = [
|
|||
"-smp",
|
||||
"cores=2",
|
||||
|
||||
"-device", #"ati-vga",
|
||||
"-device",
|
||||
"cirrus-vga",
|
||||
|
||||
# "-device",
|
||||
|
@ -27,8 +27,8 @@ run-args = [
|
|||
# "-drive",
|
||||
# "file=disk.qcow2,if=none,id=drive0",
|
||||
|
||||
# "-device",
|
||||
# "virtio-rng",
|
||||
"-device",
|
||||
"virtio-rng",
|
||||
|
||||
"-qmp",
|
||||
"unix:../qmp-sock,server,nowait"
|
||||
|
@ -56,6 +56,7 @@ rhai = "1.6.0"
|
|||
libwasm = {git="https://git.ablecorp.us:443/able/libwasm.git"}
|
||||
acpi = "4.1.0"
|
||||
axel = { git = "https://git.ablecorp.us/able/aos_userland" }
|
||||
versioning = { git = "https://git.ablecorp.us/able/aos_userland" }
|
||||
|
||||
[dependencies.logos]
|
||||
version = "0.12"
|
||||
|
|
1
ableos/src/arch/riscv/drivers/sysinfo.rs
Normal file
1
ableos/src/arch/riscv/drivers/sysinfo.rs
Normal file
|
@ -0,0 +1 @@
|
|||
pub fn sysinfo() {}
|
|
@ -51,6 +51,25 @@ extern "C" fn _start() -> ! {
|
|||
uart.put('\r' as u8);
|
||||
}
|
||||
|
||||
91 => {
|
||||
if let Some(ch) = uart.get() {
|
||||
match ch as char {
|
||||
'A' => {
|
||||
serial_println!("That's the up arrow!");
|
||||
}
|
||||
'B' => {
|
||||
serial_println!("That's the down arrow!");
|
||||
}
|
||||
'C' => {
|
||||
serial_println!("That's the right arrow!");
|
||||
}
|
||||
'D' => {
|
||||
serial_println!("That's the left arrow!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_ => {
|
||||
uart.put(c);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
pub mod allocator;
|
||||
pub mod graphics;
|
||||
pub mod serial;
|
||||
pub mod sysinfo;
|
||||
pub mod timer;
|
||||
|
||||
#[deprecated(note = "The use of hardware specific drivers for VGA is discouraged")]
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
not(any(target_arch = "x86_64", target_arch = "x86")),
|
||||
allow(dead_code)
|
||||
)]
|
||||
pub fn sysinfo() {}
|
||||
|
||||
use core::arch::asm;
|
||||
use core::ops::Deref;
|
0
ableos/src/arch/x86_64/drivers/virtio/mod.rs
Normal file
0
ableos/src/arch/x86_64/drivers/virtio/mod.rs
Normal file
|
@ -1,26 +1,25 @@
|
|||
use core::fmt::Display;
|
||||
|
||||
use crate::{arch::drivers::sysinfo::master, ALLOCATOR};
|
||||
|
||||
use super::systeminfo::SystemMemory;
|
||||
use versioning::Version;
|
||||
use x86_64::instructions::interrupts::{disable, enable};
|
||||
|
||||
// NOTE: Move to somewhere else
|
||||
pub static KINFO: KernelInfo = KernelInfo {
|
||||
kernel_version: SemanticVersion {
|
||||
major: 0,
|
||||
minor: 0,
|
||||
patch: 0,
|
||||
},
|
||||
memory: SystemMemory { used: 0, total: 0 },
|
||||
};
|
||||
|
||||
// Can be standardized
|
||||
// NOTE: Move this to relib
|
||||
pub struct SemanticVersion {
|
||||
pub major: u8,
|
||||
pub minor: u8,
|
||||
pub patch: u8,
|
||||
pub enum CpuType {
|
||||
RiscV(String),
|
||||
X86_64(String),
|
||||
}
|
||||
|
||||
impl core::fmt::Display for SemanticVersion {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
|
||||
write!(f, "v{}.{}.{}", self.major, self.minor, self.patch)
|
||||
impl Display for CpuType {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"{}",
|
||||
match self {
|
||||
CpuType::RiscV(s) => s,
|
||||
CpuType::X86_64(s) => s,
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,8 +27,51 @@ impl core::fmt::Display for SemanticVersion {
|
|||
pub struct KernelInfo {
|
||||
// os: String,
|
||||
// host: String,
|
||||
pub kernel_version: SemanticVersion,
|
||||
// cpu: String,
|
||||
pub kernel_version: Version,
|
||||
pub cpu: CpuType,
|
||||
// gpu: String,
|
||||
pub memory: SystemMemory,
|
||||
}
|
||||
|
||||
impl KernelInfo {
|
||||
pub fn get() -> KernelInfo {
|
||||
disable();
|
||||
let allocator = ALLOCATOR.lock();
|
||||
let total = allocator.size();
|
||||
let used = allocator.used();
|
||||
enable();
|
||||
|
||||
let cpu = CpuType::X86_64(master().unwrap().brand_string().unwrap().to_string());
|
||||
|
||||
KernelInfo {
|
||||
kernel_version: Version {
|
||||
major: 0,
|
||||
minor: 0,
|
||||
patch: 0,
|
||||
},
|
||||
cpu,
|
||||
memory: SystemMemory { total, used },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for KernelInfo {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"
|
||||
OS: AbleOS
|
||||
Host: {{}}
|
||||
Kernel: {}.{}.{}
|
||||
CPU: {}
|
||||
Memory: {}/{}
|
||||
",
|
||||
self.kernel_version.major,
|
||||
self.kernel_version.minor,
|
||||
self.kernel_version.patch,
|
||||
self.cpu,
|
||||
self.memory.used,
|
||||
self.memory.total
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
pub mod absi;
|
||||
pub mod clip;
|
||||
pub mod futex;
|
||||
pub mod info;
|
||||
pub mod kinfo;
|
||||
pub mod mail;
|
||||
pub mod server;
|
||||
|
|
|
@ -10,8 +10,8 @@ pub const RELEASE_TYPE: &str = "debug";
|
|||
pub const RELEASE_TYPE: &str = "release";
|
||||
|
||||
pub struct SystemMemory {
|
||||
pub used: u64,
|
||||
pub total: u64,
|
||||
pub used: usize,
|
||||
pub total: usize,
|
||||
}
|
||||
|
||||
impl core::fmt::Display for SystemMemory {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#![allow(clippy::empty_loop)]
|
||||
|
||||
use crate::info::master;
|
||||
use crate::arch::drivers::sysinfo::master;
|
||||
use crate::scheduler::SCHEDULER;
|
||||
use crate::{
|
||||
arch::{init, sloop},
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
#![feature(abi_x86_interrupt)]
|
||||
#![feature(alloc_error_handler)]
|
||||
#![feature(prelude_import)]
|
||||
// Needed for riscv
|
||||
#![feature(asm_sym)]
|
||||
#![feature(naked_functions)]
|
||||
|
||||
#[macro_use]
|
||||
pub extern crate log;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use crate::arch::drivers::sysinfo::{master, sysinfo};
|
||||
|
||||
use crate::filesystem::FILE_SYSTEM;
|
||||
use crate::info::master;
|
||||
use crate::time::fetch_time;
|
||||
use crate::wasm_jumploader::interp;
|
||||
use crate::ALLOCATOR;
|
||||
|
@ -90,14 +91,13 @@ pub fn set_hostname(name: String) {
|
|||
|
||||
/// Examine a memory pointer
|
||||
pub fn peek_memory(ptr: i64) -> i64 {
|
||||
println!(">:(");
|
||||
unsafe { *(ptr as *const u8) as _ }
|
||||
}
|
||||
|
||||
pub fn poke_memory(ptr: i64, val: i64) {
|
||||
match val.try_into() {
|
||||
Ok(val) => unsafe { *(ptr as *mut u8) = val },
|
||||
Err(_) => println!("Error: {val} cannot be converted into u8"),
|
||||
Err(_) => error!("{val} cannot be converted into u8"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -147,6 +147,7 @@ impl Externals for HostExternals {
|
|||
GET_TIME_INDEX => {
|
||||
use core::sync::atomic::Ordering::*;
|
||||
trace!("SYSCALL: get time");
|
||||
|
||||
x86_64::instructions::interrupts::disable();
|
||||
let tick_time = kernel::TICK.load(Relaxed);
|
||||
x86_64::instructions::interrupts::enable();
|
||||
|
|
Loading…
Reference in a new issue