Patch| Logging repaired

This commit is contained in:
Able 2022-03-11 15:14:35 -06:00
parent 4b6dae5fd1
commit d2638b1fb4
13 changed files with 78 additions and 108 deletions

2
.gitignore vendored
View file

@ -6,5 +6,3 @@ shadeable/target
qprofiler qprofiler
userland/*/target userland/*/target
kernel/target kernel/target
kernel/target

View file

@ -1,5 +1,6 @@
[build] [build]
target = "riscv64gc-unknown-none-elf" # target = "riscv64gc-unknown-none-elf"
target = "json_targets/x86_64-ableos.json"
[unstable] [unstable]
build-std = ["core", "compiler_builtins", "alloc"] build-std = ["core", "compiler_builtins", "alloc"]

44
ableos/Cargo.lock generated
View file

@ -34,7 +34,7 @@ dependencies = [
"externc-libm", "externc-libm",
"facepalm", "facepalm",
"genfs", "genfs",
"hashbrown 0.11.2", "hashbrown 0.7.2",
"kernel", "kernel",
"lazy_static", "lazy_static",
"libwasm", "libwasm",
@ -56,6 +56,7 @@ dependencies = [
"toml", "toml",
"uart_16550", "uart_16550",
"unicode-width", "unicode-width",
"vga",
"volatile 0.2.7", "volatile 0.2.7",
"wasmi", "wasmi",
"watson", "watson",
@ -143,6 +144,21 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "conquer-once"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c6d3a9775a69f6d1fe2cc888999b67ed30257d3da4d2af91984e722f2ec918a"
dependencies = [
"conquer-util",
]
[[package]]
name = "conquer-util"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e763eef8846b13b380f37dfecda401770b0ca4e56e95170237bd7c25c7db3582"
[[package]] [[package]]
name = "const-random" name = "const-random"
version = "0.1.13" version = "0.1.13"
@ -223,6 +239,12 @@ version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]]
name = "font8x8"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "875488b8711a968268c7cf5d139578713097ca4635a76044e8fe8eedf831d07e"
[[package]] [[package]]
name = "genfs" name = "genfs"
version = "0.1.4" version = "0.1.4"
@ -250,12 +272,6 @@ dependencies = [
"autocfg", "autocfg",
] ]
[[package]]
name = "hashbrown"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
[[package]] [[package]]
name = "hashbrown" name = "hashbrown"
version = "0.12.0" version = "0.12.0"
@ -788,6 +804,20 @@ name = "versioning"
version = "0.1.2" version = "0.1.2"
source = "git+https://git.ablecorp.us/able/versioning#ef472283e6e7a2e395ee56434087b3a6fad53ff2" source = "git+https://git.ablecorp.us/able/versioning#ef472283e6e7a2e395ee56434087b3a6fad53ff2"
[[package]]
name = "vga"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67cbcb7bfff998d176ffb8f2c3dfd6cb0fe62740e36dee6c64fc3928c01001bf"
dependencies = [
"bitflags",
"conquer-once",
"font8x8",
"num-traits",
"spinning_top",
"x86_64",
]
[[package]] [[package]]
name = "volatile" name = "volatile"
version = "0.2.7" version = "0.2.7"

View file

@ -93,11 +93,16 @@ features = ["derive", "alloc"]
[dependencies.hashbrown] [dependencies.hashbrown]
version = "0.11.2" version = "0.7.2"
default-features = false default-features = false
features = ["inline-more"] features = ["inline-more"]
[dependencies.rkyv] [dependencies.rkyv]
version = "0.7.29" version = "0.7.29"
default-features = false default-features = false
@ -159,3 +164,4 @@ uart_16550 = "0.2.0"
volatile = "0.2.6" volatile = "0.2.6"
x86_64 = "*" x86_64 = "*"
pc-beeper = {git = "https://github.com/AbleOS/pc-beeper"} pc-beeper = {git = "https://github.com/AbleOS/pc-beeper"}
vga = "*"

View file

@ -3,7 +3,7 @@ system_processes = []
user_processes = ["shell"] user_processes = ["shell"]
[logging] [logging]
enabled = false enabled = true
level = "Trace" level = "Trace"
[tests] [tests]

View file

@ -144,11 +144,11 @@ macro_rules! sprint
macro_rules! sprintln macro_rules! sprintln
{ {
() => ({ () => ({
print!("\r\n") sprint!("\r\n")
}); });
($fmt:expr) => (print!(concat!($fmt, "\r\n"))); ($fmt:expr) => (sprint!(concat!($fmt, "\r\n")));
($fmt:expr, $($args:tt)+) => ({ ($fmt:expr, $($args:tt)+) => ({
print!(concat!($fmt, "\r\n"), $($args)+) sprint!(concat!($fmt, "\r\n"), $($args)+)
}); });
} }

View file

@ -1,5 +1,5 @@
// #![allow(clippy::print_literal)] // #![allow(clippy::print_literal)]
use crate::{logger, SCHEDULER}; use crate::{logger, scheduler::SCHEDULER, serial_println};
use super::{gdt, interrupts}; use super::{gdt, interrupts};
@ -13,7 +13,9 @@ pub fn init() {
let result = logger::init(); let result = logger::init();
match result { match result {
Ok(_) => {} Ok(_) => {
serial_println!("Logger initialized");
}
Err(err) => error!("{}", err), Err(err) => error!("{}", err),
} }
gdt::init(); gdt::init();

View file

@ -57,5 +57,6 @@ pub struct TestsConfig {
#[derive(Serialize, Debug, Deserialize)] #[derive(Serialize, Debug, Deserialize)]
pub struct BootConfig { pub struct BootConfig {
pub processes: Vec<String>, pub system_processes: Vec<String>,
pub user_processes: Vec<String>,
} }

View file

@ -1,4 +1,5 @@
// TODO improve tokenizer/parser // TODO improve tokenizer/parser
pub fn colorify(eval: &str) { pub fn colorify(eval: &str) {
let y = eval.split("$"); let y = eval.split("$");
for z in y { for z in y {

View file

@ -8,14 +8,8 @@
use { use {
crate::{ crate::{
arch::{init, sloop}, arch::{init, sloop},
relib::network::socket::{SimpleSock, Socket}, relib::network::socket::{SimpleSock, Socket},
// scheduler::SCHEDULER,
// VgaBuffer,
// SCREEN_BUFFER,
scratchpad, scratchpad,
// SCHEDULER,
SCREEN_BUFFER,
}, },
facepalm::start_facepalm, facepalm::start_facepalm,
lazy_static::lazy_static, lazy_static::lazy_static,
@ -36,89 +30,18 @@ pub fn kernel_main() -> ! {
} else { } else {
log::set_max_level(log::LevelFilter::Off); log::set_max_level(log::LevelFilter::Off);
} }
let mut scheduler = SCHEDULER.lock(); let mut scheduler = SCHEDULER.lock();
/*
use crate::scheduler::Priority::*; use crate::scheduler::Priority::*;
let mut process_1 = scheduler.new_process(High); let mut process_1 = scheduler.new_process(High);
process_1.capabilities.files = FileAccess::Some(vec![PathRep { process_1.capabilities.files = FileAccess::Some(vec![]);
location: FileLocations::Home,
file_name: "test".to_string(),
}]);
scheduler.add_process(process_1); scheduler.add_process(process_1);
for ref_process in &scheduler.list { for ref_process in &scheduler.list {
trace!("{:?}", ref_process); trace!("{:?}", ref_process);
} }
drop(scheduler); drop(scheduler);
*/
// use crate::proto_filetable::file::FileLocations;
/*
if false {
let mut sock_print_id = SimpleSock::new();
sock_print_id.register_protocol("Screen Printer".to_string());
sock_print_id.write(format!("🐑").into());
let mut mode = SCREEN_BUFFER.lock();
mode.force_redraw();
for current in (*String::from_utf8_lossy(&sock_print_id.peek().unwrap())).chars() {
// mode.draw_char(0, 0, current, from_vga_16(Color16::Red));
}
// mode.copy_to_buffer();
}
<<<<<<< HEAD
*/
/*
// TODO: create a scratchpad module
if false {
// Currently not implemented
let acpi_handler = AcpiStruct {};
let mut table;
unsafe {
table = AcpiTables::search_for_rsdp_bios(acpi_handler);
}
}
=======
mode.copy_to_buffer();
}
start_facepalm();
scratchpad();
>>>>>>> master
*/
// start_facepalm(); // start_facepalm();
// scratchpad(); scratchpad();
/*
if false {
// disable();
let mut mode = SCREEN_BUFFER.lock();
mode.force_redraw();
// mode.copy_to_buffer();
mode.clear();
mode.draw_char(0, 0, 'v', 0xff00ffff);
// mode.copy_to_buffer();
drop(mode);
// enable()
// sloop::halt();
}
*/
sloop() sloop()
} }
@ -176,4 +99,10 @@ impl acpi::AcpiHandler for AcpiStruct {
use kernel::KERNEL_VERSION; use kernel::KERNEL_VERSION;
use crate::{boot_conf::KernelConfig, scheduler::SCHEDULER, systeminfo::RELEASE_TYPE}; use crate::{
boot_conf::KernelConfig,
kprint,
scheduler::{capabilities::FileAccess, SCHEDULER},
serial_print, serial_println,
systeminfo::RELEASE_TYPE,
};

View file

@ -87,11 +87,9 @@ pub use virtio::*;
// pub mod alias_table; // pub mod alias_table;
// pub use alias_table::*; // pub use alias_table::*;
#[cfg(target_arch = "x86_64")]
pub mod tests;
#[cfg(target_arch = "x86_64")] // pub mod tests;
pub use tests::*; // pub use tests::*;
pub mod scratchpad; pub mod scratchpad;
pub use scratchpad::*; pub use scratchpad::*;

View file

@ -1,7 +1,7 @@
use core::sync::atomic::Ordering; use core::sync::atomic::Ordering;
use crate::network::socket::{SimpleSock, Socket}; use crate::network::socket::{SimpleSock, Socket};
// use crate::serial_println; use crate::{kprint, serial_println};
use kernel::TICK; use kernel::TICK;
use lliw::{Fg, Reset}; use lliw::{Fg, Reset};
@ -19,8 +19,9 @@ impl log::Log for SimpleLogger {
fn log(&self, record: &Record) { fn log(&self, record: &Record) {
if self.enabled(record.metadata()) { if self.enabled(record.metadata()) {
let color; let color;
disable();
let time = TICK.load(Ordering::Relaxed) as f64; let time = TICK.load(Ordering::Relaxed) as f64;
enable();
let time_float = time; let time_float = time;
match record.level() { match record.level() {
@ -37,9 +38,10 @@ impl log::Log for SimpleLogger {
time_float, time_float,
record.args() record.args()
); );
// kprint!("{}", msg);
// NOTE: This needs to be fixed before merge // NOTE: This needs to be fixed before merge
println!(
serial_println!(
"[{}{}{}][{}{}{}] {}", "[{}{}{}][{}{}{}] {}",
color.0, color.0,
record.level(), record.level(),
@ -64,6 +66,7 @@ impl log::Log for SimpleLogger {
} }
use log::{LevelFilter, SetLoggerError}; use log::{LevelFilter, SetLoggerError};
use x86_64::instructions::interrupts::{disable, enable};
static LOGGER: SimpleLogger = SimpleLogger; static LOGGER: SimpleLogger = SimpleLogger;

View file

@ -1,10 +1,11 @@
use acpi::AcpiTables; use acpi::AcpiTables;
use crate::rhai_shell::rhai_shell; use crate::{kprintln, rhai_shell::rhai_shell, serial_println};
/// Experimental scratchpad for testing. /// Experimental scratchpad for testing.
pub fn scratchpad() { pub fn scratchpad() {
pci_fun(); // pci_fun();
rhai_shell(); rhai_shell();
} }