forked from AbleOS/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",
|
"toml",
|
||||||
"uart_16550",
|
"uart_16550",
|
||||||
"unicode-width",
|
"unicode-width",
|
||||||
|
"versioning",
|
||||||
"vga",
|
"vga",
|
||||||
"volatile 0.2.7",
|
"volatile 0.2.7",
|
||||||
"wasmi",
|
"wasmi",
|
||||||
|
|
|
@ -18,7 +18,7 @@ run-args = [
|
||||||
"-smp",
|
"-smp",
|
||||||
"cores=2",
|
"cores=2",
|
||||||
|
|
||||||
"-device", #"ati-vga",
|
"-device",
|
||||||
"cirrus-vga",
|
"cirrus-vga",
|
||||||
|
|
||||||
# "-device",
|
# "-device",
|
||||||
|
@ -27,8 +27,8 @@ run-args = [
|
||||||
# "-drive",
|
# "-drive",
|
||||||
# "file=disk.qcow2,if=none,id=drive0",
|
# "file=disk.qcow2,if=none,id=drive0",
|
||||||
|
|
||||||
# "-device",
|
"-device",
|
||||||
# "virtio-rng",
|
"virtio-rng",
|
||||||
|
|
||||||
"-qmp",
|
"-qmp",
|
||||||
"unix:../qmp-sock,server,nowait"
|
"unix:../qmp-sock,server,nowait"
|
||||||
|
@ -56,6 +56,7 @@ rhai = "1.6.0"
|
||||||
libwasm = {git="https://git.ablecorp.us:443/able/libwasm.git"}
|
libwasm = {git="https://git.ablecorp.us:443/able/libwasm.git"}
|
||||||
acpi = "4.1.0"
|
acpi = "4.1.0"
|
||||||
axel = { git = "https://git.ablecorp.us/able/aos_userland" }
|
axel = { git = "https://git.ablecorp.us/able/aos_userland" }
|
||||||
|
versioning = { git = "https://git.ablecorp.us/able/aos_userland" }
|
||||||
|
|
||||||
[dependencies.logos]
|
[dependencies.logos]
|
||||||
version = "0.12"
|
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);
|
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);
|
uart.put(c);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
pub mod allocator;
|
pub mod allocator;
|
||||||
pub mod graphics;
|
pub mod graphics;
|
||||||
pub mod serial;
|
pub mod serial;
|
||||||
|
pub mod sysinfo;
|
||||||
pub mod timer;
|
pub mod timer;
|
||||||
|
|
||||||
#[deprecated(note = "The use of hardware specific drivers for VGA is discouraged")]
|
#[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")),
|
not(any(target_arch = "x86_64", target_arch = "x86")),
|
||||||
allow(dead_code)
|
allow(dead_code)
|
||||||
)]
|
)]
|
||||||
|
pub fn sysinfo() {}
|
||||||
|
|
||||||
use core::arch::asm;
|
use core::arch::asm;
|
||||||
use core::ops::Deref;
|
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 super::systeminfo::SystemMemory;
|
||||||
|
use versioning::Version;
|
||||||
|
use x86_64::instructions::interrupts::{disable, enable};
|
||||||
|
|
||||||
// NOTE: Move to somewhere else
|
pub enum CpuType {
|
||||||
pub static KINFO: KernelInfo = KernelInfo {
|
RiscV(String),
|
||||||
kernel_version: SemanticVersion {
|
X86_64(String),
|
||||||
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,
|
|
||||||
}
|
}
|
||||||
|
impl Display for CpuType {
|
||||||
impl core::fmt::Display for SemanticVersion {
|
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||||
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
|
write!(
|
||||||
write!(f, "v{}.{}.{}", self.major, self.minor, self.patch)
|
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 {
|
pub struct KernelInfo {
|
||||||
// os: String,
|
// os: String,
|
||||||
// host: String,
|
// host: String,
|
||||||
pub kernel_version: SemanticVersion,
|
pub kernel_version: Version,
|
||||||
// cpu: String,
|
pub cpu: CpuType,
|
||||||
// gpu: String,
|
// gpu: String,
|
||||||
pub memory: SystemMemory,
|
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 absi;
|
||||||
pub mod clip;
|
pub mod clip;
|
||||||
pub mod futex;
|
pub mod futex;
|
||||||
pub mod info;
|
|
||||||
pub mod kinfo;
|
pub mod kinfo;
|
||||||
pub mod mail;
|
pub mod mail;
|
||||||
pub mod server;
|
pub mod server;
|
||||||
|
|
|
@ -10,8 +10,8 @@ pub const RELEASE_TYPE: &str = "debug";
|
||||||
pub const RELEASE_TYPE: &str = "release";
|
pub const RELEASE_TYPE: &str = "release";
|
||||||
|
|
||||||
pub struct SystemMemory {
|
pub struct SystemMemory {
|
||||||
pub used: u64,
|
pub used: usize,
|
||||||
pub total: u64,
|
pub total: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl core::fmt::Display for SystemMemory {
|
impl core::fmt::Display for SystemMemory {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#![allow(clippy::empty_loop)]
|
#![allow(clippy::empty_loop)]
|
||||||
|
|
||||||
use crate::info::master;
|
use crate::arch::drivers::sysinfo::master;
|
||||||
use crate::scheduler::SCHEDULER;
|
use crate::scheduler::SCHEDULER;
|
||||||
use crate::{
|
use crate::{
|
||||||
arch::{init, sloop},
|
arch::{init, sloop},
|
||||||
|
|
|
@ -7,6 +7,9 @@
|
||||||
#![feature(abi_x86_interrupt)]
|
#![feature(abi_x86_interrupt)]
|
||||||
#![feature(alloc_error_handler)]
|
#![feature(alloc_error_handler)]
|
||||||
#![feature(prelude_import)]
|
#![feature(prelude_import)]
|
||||||
|
// Needed for riscv
|
||||||
|
#![feature(asm_sym)]
|
||||||
|
#![feature(naked_functions)]
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
pub extern crate log;
|
pub extern crate log;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
|
use crate::arch::drivers::sysinfo::{master, sysinfo};
|
||||||
|
|
||||||
use crate::filesystem::FILE_SYSTEM;
|
use crate::filesystem::FILE_SYSTEM;
|
||||||
use crate::info::master;
|
|
||||||
use crate::time::fetch_time;
|
use crate::time::fetch_time;
|
||||||
use crate::wasm_jumploader::interp;
|
use crate::wasm_jumploader::interp;
|
||||||
use crate::ALLOCATOR;
|
use crate::ALLOCATOR;
|
||||||
|
@ -90,14 +91,13 @@ pub fn set_hostname(name: String) {
|
||||||
|
|
||||||
/// Examine a memory pointer
|
/// Examine a memory pointer
|
||||||
pub fn peek_memory(ptr: i64) -> i64 {
|
pub fn peek_memory(ptr: i64) -> i64 {
|
||||||
println!(">:(");
|
|
||||||
unsafe { *(ptr as *const u8) as _ }
|
unsafe { *(ptr as *const u8) as _ }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn poke_memory(ptr: i64, val: i64) {
|
pub fn poke_memory(ptr: i64, val: i64) {
|
||||||
match val.try_into() {
|
match val.try_into() {
|
||||||
Ok(val) => unsafe { *(ptr as *mut u8) = val },
|
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 => {
|
GET_TIME_INDEX => {
|
||||||
use core::sync::atomic::Ordering::*;
|
use core::sync::atomic::Ordering::*;
|
||||||
trace!("SYSCALL: get time");
|
trace!("SYSCALL: get time");
|
||||||
|
|
||||||
x86_64::instructions::interrupts::disable();
|
x86_64::instructions::interrupts::disable();
|
||||||
let tick_time = kernel::TICK.load(Relaxed);
|
let tick_time = kernel::TICK.load(Relaxed);
|
||||||
x86_64::instructions::interrupts::enable();
|
x86_64::instructions::interrupts::enable();
|
||||||
|
|
Loading…
Reference in a new issue