From 6e20d338175951fbf95892ad7c39dfd0cf956de0 Mon Sep 17 00:00:00 2001 From: Able Date: Wed, 23 Nov 2022 04:02:02 -0600 Subject: [PATCH] limine compiling booting and not panicking --- ableos/src/arch/x86_64/init.rs | 17 +++++++++-------- ableos/src/arch/x86_64/interrupts.rs | 8 ++++++-- ableos/src/hardware/mod.rs | 6 +++--- ableos/src/kmain.rs | 7 ++++--- ableos/src/print.rs | 13 +++++++------ ableos/src/scratchpad.rs | 28 ++++++++++++++++------------ ableos/src/vterm.rs | 1 + repbuild/src/main.rs | 21 ++++++++++++--------- 8 files changed, 58 insertions(+), 43 deletions(-) diff --git a/ableos/src/arch/x86_64/init.rs b/ableos/src/arch/x86_64/init.rs index d607d788..1cf801a5 100644 --- a/ableos/src/arch/x86_64/init.rs +++ b/ableos/src/arch/x86_64/init.rs @@ -1,6 +1,7 @@ // #![allow(clippy::print_literal)] use super::{gdt, interrupts}; -use crate::{logger, serial_println, TERM}; +// use crate::{logger, serial_println, TERM}; +use crate::{logger, serial_println}; /// x86_64 initialization pub fn init() { @@ -24,14 +25,14 @@ pub fn init() { interrupts::init_idt(); unsafe { interrupts::PICS.lock().initialize() }; - trace!("term"); - let term = &*TERM; - trace!("term.lock()"); - let mut term = term.lock(); + // trace!("term"); + // let term = &*TERM; + // trace!("term.lock()"); + // let mut term = term.lock(); // term.initialize(); - term.set_dirty(true); - term.draw_term(); - drop(term); + // term.set_dirty(true); + // term.draw_term(); + // drop(term); x86_64::instructions::interrupts::enable(); } diff --git a/ableos/src/arch/x86_64/interrupts.rs b/ableos/src/arch/x86_64/interrupts.rs index 12f35e97..3ee396c6 100644 --- a/ableos/src/arch/x86_64/interrupts.rs +++ b/ableos/src/arch/x86_64/interrupts.rs @@ -12,7 +12,10 @@ use pic8259::ChainedPics; use qrcode::QrCode; use seq_macro::seq; use spin::Lazy; -use x86_64::{structures::idt::{InterruptDescriptorTable, InterruptStackFrame, PageFaultErrorCode}, registers::control::Cr2}; +use x86_64::{ + registers::control::Cr2, + structures::idt::{InterruptDescriptorTable, InterruptStackFrame, PageFaultErrorCode}, +}; use super::sloop; @@ -96,10 +99,11 @@ extern "x86-interrupt" fn breakpoint_handler(stack_frame: InterruptStackFrame) { extern "x86-interrupt" fn page_fault_handler( stack_frame: InterruptStackFrame, - error_code: PageFaultErrorCode + error_code: PageFaultErrorCode, ) { error!("EXCEPTION: PAGE FAULT {error_code:?}\n{:#?}", stack_frame); trace!("CR2: {:x}", Cr2::read_raw()); + trace!("SCREE"); loop {} } diff --git a/ableos/src/hardware/mod.rs b/ableos/src/hardware/mod.rs index dd39a864..f35b76bb 100644 --- a/ableos/src/hardware/mod.rs +++ b/ableos/src/hardware/mod.rs @@ -103,9 +103,9 @@ fn on_complete(mouse_state: MouseState) { mouse.change_y(delta_y); x86_64::instructions::interrupts::without_interrupts(|| { - use crate::TERM; - let mut term = TERM.lock(); - term.set_dirty(true); + // use crate::TERM; + // let mut term = TERM.lock(); + // term.set_dirty(true); }); // draw_mouse((mouse.get_x() as usize, mouse.get_y() as usize)); diff --git a/ableos/src/kmain.rs b/ableos/src/kmain.rs index 5bf23c6c..d88f59fc 100644 --- a/ableos/src/kmain.rs +++ b/ableos/src/kmain.rs @@ -12,7 +12,8 @@ use crate::arch::memory::BootInfoFrameAllocator; use crate::arch::{drivers::sysinfo::master, init, sloop}; use crate::devices::pci; use crate::relib::network::socket::{SimpleSock, Socket}; -use crate::{boot_conf::KernelConfig, scratchpad, systeminfo::RELEASE_TYPE, TERM}; +use crate::{boot_conf::KernelConfig, scratchpad, systeminfo::RELEASE_TYPE}; +// use crate::{boot_conf::KernelConfig, scratchpad, systeminfo::RELEASE_TYPE, TERM}; use crate::{filesystem, hardware}; use kernel::KERNEL_VERSION; use spin::Lazy; @@ -144,9 +145,9 @@ pub static TICK: AtomicU64 = AtomicU64::new(0); pub fn tick() { x86_64::instructions::interrupts::without_interrupts(|| { - let mut term = TERM.lock(); + // let mut term = TERM.lock(); - term.draw_term(); + // term.draw_term(); use core::sync::atomic::Ordering::Relaxed; let mut data = TICK.load(Relaxed); diff --git a/ableos/src/print.rs b/ableos/src/print.rs index 6af2a8ff..23650420 100644 --- a/ableos/src/print.rs +++ b/ableos/src/print.rs @@ -23,7 +23,7 @@ impl core::fmt::Write for Stdout { fn write_str(&mut self, s: &str) -> Result<(), Error> { // use mini_backtrace::Backtrace; - use crate::TERM; + // use crate::TERM; // Capture up to 16 frames. This is returned using an ArrayVec that doesn't // perform any dynamic memory allocation. @@ -38,14 +38,15 @@ impl core::fmt::Write for Stdout { } */ - // trace!("printing"); + trace!("printing"); + trace!("PRINT: {}", s); // x86_64::instructions::interrupts::without_interrupts(|| { - let mut term = TERM.lock(); + // let mut term = TERM.lock(); - term.set_dirty(true); - term.print(s); + // term.set_dirty(true); + // term.print(s); - drop(term); + // drop(term); // }); // trace!("Finished printing"); Ok(()) diff --git a/ableos/src/scratchpad.rs b/ableos/src/scratchpad.rs index a6d64311..d0922613 100644 --- a/ableos/src/scratchpad.rs +++ b/ableos/src/scratchpad.rs @@ -43,17 +43,19 @@ impl acpi::AcpiHandler for AcpiStruct { } } -pub static TERM: Lazy> = Lazy::new(|| { - trace!("mutex"); - let mutex = spin::Mutex::new({ - trace!("vterm"); - let vterm = VTerm::new(); - trace!("vterm-done"); - vterm - }); - trace!("mutex-done"); - mutex -}); +// pub static TERM: Lazy> = Lazy::new(|| { +// trace!("mutex"); + +// loop {} +// let mutex = spin::Mutex::new({ +// trace!("vterm"); +// let vterm = VTerm::new(); +// trace!("vterm-done"); +// vterm +// }); +// trace!("mutex-done"); +// mutex +// }); #[derive(Debug)] pub struct Path { @@ -143,7 +145,9 @@ pub fn scratchpad() { let mut pci_ide_device = pci_ide_device.lock(); if let PciDevice::Ide(device) = &mut *pci_ide_device { let mut first_sector = Vec::with_capacity(512); - device.read(Channel::Primary, Drive::Master, 0, 1, &mut first_sector).unwrap(); + device + .read(Channel::Primary, Drive::Master, 0, 1, &mut first_sector) + .unwrap(); trace!("IDE Primary/Master sector 0: {first_sector:?}"); } } diff --git a/ableos/src/vterm.rs b/ableos/src/vterm.rs index 2ebc75b8..0d1f37c4 100644 --- a/ableos/src/vterm.rs +++ b/ableos/src/vterm.rs @@ -27,6 +27,7 @@ pub struct VTerm { impl VTerm { /// Construct a new VTerm pub fn new() -> Self { + trace!("Setting vga mode"); let mode = VGAE.lock(); mode.set_mode(); // let fb = mode.get_frame_buffer(); diff --git a/repbuild/src/main.rs b/repbuild/src/main.rs index 990e4699..38062941 100644 --- a/repbuild/src/main.rs +++ b/repbuild/src/main.rs @@ -5,7 +5,10 @@ * SPDX-License-Identifier: MPL-2.0 */ -use std::{fs::{self, File}, process::Command}; +use std::{ + fs::{self, File}, + process::Command, +}; use colored::*; @@ -259,9 +262,9 @@ fn main() { .args(["/dev/loop0p1", "./disk"]) .status() .unwrap(); - - // copy the kernel over to ./disk/boot/kernel - Command::new("sudo") + + // copy the kernel over to ./disk/boot/kernel + Command::new("sudo") .arg("cp") .arg("./target/x86_64-ableos/debug/ableos") .arg("./disk/boot/kernel") @@ -293,7 +296,7 @@ fn main() { .args(["-m", "4G"]) .args(["-serial", "stdio"]) .args(["-smp", "cores=2"]) - .args(["-soundhw", "pcspk"]) + // .args(["-soundhw", "pcspk"]) // .args(["-device", "VGA"]) // .args(["-device", "virtio-gpu-pci"]) .args(["-device", "vmware-svga"]) @@ -326,9 +329,9 @@ fn main() { .args(["/dev/loop0p1", "./disk"]) .status() .unwrap(); - - // copy the kernel over to ./disk/boot/kernel - Command::new("sudo") + + // copy the kernel over to ./disk/boot/kernel + Command::new("sudo") .arg("cp") .arg("./target/x86_64-ableos/release/ableos") .arg("./disk/boot/kernel") @@ -360,7 +363,7 @@ fn main() { .args(["-m", "4G"]) .args(["-serial", "stdio"]) .args(["-smp", "cores=2"]) - .args(["-soundhw", "pcspk"]) + // .args(["-soundhw", "pcspk"]) // .args(["-device", "VGA"]) // .args(["-device", "virtio-gpu-pci"]) .args(["-device", "vmware-svga"])