Verified Commit 1fc84c5f authored by 4lDO2's avatar 4lDO2 🖖

Merge remote-tracking branch 'upstream/master' into io_uring

parents 29758890 2057b889
......@@ -18,11 +18,17 @@ version = "1.0.58"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9a06fb2e53271d7c279ec1efea6ab691c35a2ae67ec0d91d7acec0caf13b518"
[[package]]
name = "cfg-if"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]]
name = "either"
version = "1.5.3"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3"
checksum = "cd56b59865bce947ac5958779cfa508f6c3b9497cc762b7e24a12d11ccde2c4f"
[[package]]
name = "goblin"
......@@ -42,6 +48,7 @@ dependencies = [
"either",
"goblin",
"linked_list_allocator 0.8.4",
"log",
"paste",
"raw-cpuid",
"redox_syscall",
......@@ -78,6 +85,15 @@ dependencies = [
"scopeguard",
]
[[package]]
name = "log"
version = "0.4.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b"
dependencies = [
"cfg-if",
]
[[package]]
name = "paste"
version = "0.1.18"
......
......@@ -12,6 +12,7 @@ crate-type = ["staticlib"]
[dependencies]
bitflags = "1.2.1"
linked_list_allocator = "0.8.4"
log = { version = "0.4" }
raw-cpuid = "8.0.0"
redox_syscall = { path = "syscall" }
slab_allocator = { path = "slab_allocator", optional = true }
......
......@@ -12,6 +12,7 @@ use spin::RwLock;
use crate::stop::kstop;
use crate::log::info;
use crate::memory::Frame;
use crate::paging::{ActivePageTable, Page, PhysicalAddress, VirtualAddress};
use crate::paging::entry::EntryFlags;
......@@ -124,7 +125,7 @@ pub unsafe fn init(active_table: &mut ActivePageTable, already_supplied_rsdps: O
// Search for RSDP
if let Some(rsdp) = RSDP::get_rsdp(active_table, already_supplied_rsdps) {
println!("RSDP: {:?}", rsdp);
info!("RSDP: {:?}", rsdp);
let rxsdt = get_sdt(rsdp.sdt_address(), active_table);
for &c in rxsdt.signature.iter() {
......
......@@ -76,6 +76,7 @@ impl Drop for MapperFlushAll {
}
}
#[derive(Debug)]
pub struct Mapper {
p4: Unique<Table<Level4>>,
}
......
......@@ -374,6 +374,7 @@ pub unsafe fn init_ap(
init_tcb(cpu_id)
}
#[derive(Debug)]
pub struct ActivePageTable {
mapper: Mapper,
locked: bool,
......
......@@ -17,7 +17,7 @@ use crate::device;
use crate::gdt;
use crate::idt;
use crate::interrupt;
use crate::log;
use crate::log::{self, info};
use crate::memory;
use crate::paging;
......@@ -83,10 +83,23 @@ pub unsafe extern fn kstart(args_ptr: *const KernelArgs) -> ! {
KERNEL_BASE.store(kernel_base, Ordering::SeqCst);
KERNEL_SIZE.store(kernel_size, Ordering::SeqCst);
println!("Kernel: {:X}:{:X}", kernel_base, kernel_base + kernel_size);
println!("Stack: {:X}:{:X}", stack_base, stack_base + stack_size);
println!("Env: {:X}:{:X}", env_base, env_base + env_size);
println!("RSDPs: {:X}:{:X}", acpi_rsdps_base, acpi_rsdps_base + acpi_rsdps_size);
// Initialize logger
log::init_logger(|r| {
use core::fmt::Write;
let _ = write!(
crate::arch::x86_64::debug::Writer::new(),
"{}:{} -- {}\n",
r.target(),
r.level(),
r.args()
);
});
info!("Redox OS starting...");
info!("Kernel: {:X}:{:X}", kernel_base, kernel_base + kernel_size);
info!("Stack: {:X}:{:X}", stack_base, stack_base + stack_size);
info!("Env: {:X}:{:X}", env_base, env_base + env_size);
info!("RSDPs: {:X}:{:X}", acpi_rsdps_base, acpi_rsdps_base + acpi_rsdps_size);
let ext_mem_ranges = if args.acpi_rsdps_base != 0 && args.acpi_rsdps_size > 0 {
Some([(acpi_rsdps_base as usize, acpi_rsdps_size as usize)])
......
use alloc::collections::VecDeque;
use core::sync::atomic::{AtomicBool, Ordering};
use spin::Mutex;
pub static LOG: Mutex<Option<Log>> = Mutex::new(None);
......@@ -33,3 +34,42 @@ impl Log {
}
}
}
struct RedoxLogger {
log_func: fn(&log::Record),
pub initialized: AtomicBool,
}
impl ::log::Log for RedoxLogger {
fn enabled(&self, _: &log::Metadata<'_>) -> bool {
false
}
fn log(&self, record: &log::Record<'_>) {
(self.log_func)(&record)
}
fn flush(&self) {}
}
pub fn init_logger(func: fn(&log::Record)) {
unsafe {
match LOGGER.initialized.load(Ordering::SeqCst) {
false => {
::log::set_max_level(::log::LevelFilter::Info);
LOGGER.log_func = func;
match ::log::set_logger(&LOGGER) {
Ok(_) => ::log::info!("Logger initialized."),
Err(e) => println!("Logger setup failed! error: {}", e),
}
LOGGER.initialized.store(true, Ordering::SeqCst);
},
true => ::log::info!("Tried to reinitialize the logger, which is not possible. Ignoring."),
}
}
}
static mut LOGGER: RedoxLogger = RedoxLogger {
log_func: |_| {},
initialized: AtomicBool::new(false),
};
pub use log::{debug, error, info, set_max_level, warn};
//! # Memory management
//! Some code was borrowed from [Phil Opp's Blog](http://os.phil-opp.com/allocating-frames.html)
use crate::log::info;
pub use crate::paging::{PAGE_SIZE, PhysicalAddress};
use self::bump::BumpAllocator;
......@@ -76,7 +77,7 @@ pub unsafe fn init(kernel_start: usize, kernel_end: usize) {
for (i, entry) in MEMORY_MAP.iter_mut().enumerate() {
*entry = *(0x500 as *const MemoryArea).add(i);
if entry._type != MEMORY_AREA_NULL {
println!("{:?}", entry);
info!("{:?}", entry);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment