Added basic logging support
This commit is contained in:
parent
7652bbf402
commit
8fbf7b5a5a
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -585,7 +585,6 @@ dependencies = [
|
|||
"crossbeam-queue",
|
||||
"limine",
|
||||
"linked_list_allocator",
|
||||
"log",
|
||||
"slab",
|
||||
"spin 0.9.4",
|
||||
"tracing",
|
||||
|
|
|
@ -15,7 +15,7 @@ use crate::relib::network::socket::{SimpleSock, Socket};
|
|||
use crate::{boot_conf::KernelConfig, scratchpad, systeminfo::RELEASE_TYPE};
|
||||
// use crate::{boot_conf::KernelConfig, scratchpad, systeminfo::RELEASE_TYPE, TERM};
|
||||
use crate::{filesystem, graphics_limine, hardware};
|
||||
use kernel::KERNEL_VERSION;
|
||||
use kernel::VERSION;
|
||||
use limine::LimineSmpInfo;
|
||||
use limine::{LimineFramebufferRequest, LimineSmpRequest};
|
||||
|
||||
|
@ -151,7 +151,7 @@ pub fn cpu_socket_startup() {
|
|||
}
|
||||
|
||||
pub fn log_version_data() {
|
||||
info!("{} v{}", RELEASE_TYPE, KERNEL_VERSION);
|
||||
info!("{} v{}", RELEASE_TYPE, VERSION);
|
||||
info!(
|
||||
"Brand String: {}",
|
||||
master().unwrap().brand_string().unwrap()
|
||||
|
|
|
@ -5,11 +5,10 @@ version = "0.2.0"
|
|||
|
||||
[dependencies]
|
||||
linked_list_allocator = "0.9"
|
||||
log = "0.4.14"
|
||||
slab = { version = "0.4", default-features = false }
|
||||
spin = "0.9"
|
||||
versioning = { git = "https://git.ablecorp.us/able/aos_userland" }
|
||||
tracing = { version = "0.1.37", default-features = false, features = ["attributes"] }
|
||||
tracing = { version = "0.1", default-features = false, features = ["attributes"] }
|
||||
|
||||
[dependencies.crossbeam-queue]
|
||||
version = "0.3"
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
//! Memory allocator
|
||||
|
||||
use log::trace;
|
||||
|
||||
///
|
||||
pub const HEAP_START: usize = 0x_4444_4444_0000;
|
||||
|
||||
|
@ -16,7 +14,5 @@ pub const HEAP_SIZE: usize = HEAP_BASE * HEAP_MULTIPLIER;
|
|||
|
||||
#[alloc_error_handler]
|
||||
fn alloc_error_handler(layout: alloc::alloc::Layout) -> ! {
|
||||
trace!("allocation error: {:?}", layout);
|
||||
loop {}
|
||||
// panic!("allocation error: {:?}", layout)
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ macro_rules! arch_cond {
|
|||
#[cfg(target_arch = $str)]
|
||||
pub mod $arch;
|
||||
#[cfg(target_arch = $str)]
|
||||
pub use ::$arch::*;
|
||||
pub use self::$arch::*;
|
||||
)*};
|
||||
}
|
||||
|
||||
|
|
|
@ -12,13 +12,10 @@ use crate::allocator::{HEAP_SIZE, HEAP_START};
|
|||
static ALLOCATOR: LockedHeap = LockedHeap::empty();
|
||||
|
||||
pub unsafe fn init_alloc() -> Result<(), MapToError<Size4KiB>> {
|
||||
let page_range = {
|
||||
let heap_start = VirtAddr::new(HEAP_START as u64);
|
||||
let heap_end = heap_start + HEAP_SIZE - 1u64;
|
||||
let heap_start_page = Page::containing_address(heap_start);
|
||||
let heap_end_page = Page::containing_address(heap_end);
|
||||
Page::range_inclusive(heap_start_page, heap_end_page)
|
||||
};
|
||||
let page_range = Page::range_inclusive(
|
||||
Page::containing_address(VirtAddr::new(HEAP_START as u64)),
|
||||
Page::containing_address(VirtAddr::new(HEAP_START as u64) + HEAP_SIZE - 1u64),
|
||||
);
|
||||
|
||||
let mut frame_allocator = super::memory::FRAME_ALLOC
|
||||
.get()
|
||||
|
|
|
@ -1,14 +1,23 @@
|
|||
use limine::{LimineHhdmRequest, LimineMmapRequest};
|
||||
use spin::Mutex;
|
||||
use uart_16550::SerialPort;
|
||||
use x86_64::VirtAddr;
|
||||
|
||||
mod allocator;
|
||||
mod memory;
|
||||
|
||||
static SERIAL_CONSOLE: Mutex<SerialPort> = Mutex::new(unsafe { SerialPort::new(0x3f8) });
|
||||
|
||||
#[no_mangle]
|
||||
unsafe extern "C" fn _kernel_start() -> ! {
|
||||
static HDHM_REQ: LimineHhdmRequest = LimineHhdmRequest::new(0);
|
||||
static MMAP_REQ: LimineMmapRequest = LimineMmapRequest::new(0);
|
||||
|
||||
let _ = serial_fmt(format_args!(
|
||||
"Initialising AbleOS Kernel {}\r\n",
|
||||
crate::VERSION
|
||||
));
|
||||
|
||||
memory::init_pt(VirtAddr::new(
|
||||
HDHM_REQ
|
||||
.get_response()
|
||||
|
@ -26,14 +35,13 @@ unsafe extern "C" fn _kernel_start() -> ! {
|
|||
);
|
||||
|
||||
allocator::init_alloc().expect("tried to initialise allocator");
|
||||
|
||||
unsafe {
|
||||
use uart_16550::SerialPort;
|
||||
use core::fmt::Write;
|
||||
let mut sp = SerialPort::new(0x3F8);
|
||||
sp.init();
|
||||
sp.write_str("Hello from AbleOS x86_64 entrypoint!");
|
||||
}
|
||||
SERIAL_CONSOLE.lock().init();
|
||||
|
||||
crate::kmain::kmain()
|
||||
}
|
||||
|
||||
/// Format args to serial console
|
||||
pub fn serial_fmt(args: core::fmt::Arguments<'_>) -> core::fmt::Result {
|
||||
use core::fmt::Write;
|
||||
SERIAL_CONSOLE.lock().write_fmt(args)
|
||||
}
|
||||
|
|
1
kernel/src/debug.rs
Normal file
1
kernel/src/debug.rs
Normal file
|
@ -0,0 +1 @@
|
|||
// TODO: Tracing Subscriber serial print implementation
|
|
@ -7,13 +7,14 @@ extern crate alloc;
|
|||
|
||||
pub mod allocator;
|
||||
pub mod arch;
|
||||
pub mod debug;
|
||||
pub mod kmain;
|
||||
pub mod task;
|
||||
|
||||
use versioning::Version;
|
||||
|
||||
/// Kernel's version
|
||||
pub const KERNEL_VERSION: Version = Version {
|
||||
pub const VERSION: Version = Version {
|
||||
major: 0,
|
||||
minor: 2,
|
||||
patch: 0,
|
||||
|
|
Loading…
Reference in a new issue