1
0
Fork 0
forked from koniifer/ableos

limine compiling booting and not panicking

This commit is contained in:
Able 2022-11-23 04:02:02 -06:00
parent 23c355762c
commit 6e20d33817
8 changed files with 58 additions and 43 deletions

View file

@ -1,6 +1,7 @@
// #![allow(clippy::print_literal)] // #![allow(clippy::print_literal)]
use super::{gdt, interrupts}; use super::{gdt, interrupts};
use crate::{logger, serial_println, TERM}; // use crate::{logger, serial_println, TERM};
use crate::{logger, serial_println};
/// x86_64 initialization /// x86_64 initialization
pub fn init() { pub fn init() {
@ -24,14 +25,14 @@ pub fn init() {
interrupts::init_idt(); interrupts::init_idt();
unsafe { interrupts::PICS.lock().initialize() }; unsafe { interrupts::PICS.lock().initialize() };
trace!("term"); // trace!("term");
let term = &*TERM; // let term = &*TERM;
trace!("term.lock()"); // trace!("term.lock()");
let mut term = term.lock(); // let mut term = term.lock();
// term.initialize(); // term.initialize();
term.set_dirty(true); // term.set_dirty(true);
term.draw_term(); // term.draw_term();
drop(term); // drop(term);
x86_64::instructions::interrupts::enable(); x86_64::instructions::interrupts::enable();
} }

View file

@ -12,7 +12,10 @@ use pic8259::ChainedPics;
use qrcode::QrCode; use qrcode::QrCode;
use seq_macro::seq; use seq_macro::seq;
use spin::Lazy; 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; use super::sloop;
@ -96,10 +99,11 @@ extern "x86-interrupt" fn breakpoint_handler(stack_frame: InterruptStackFrame) {
extern "x86-interrupt" fn page_fault_handler( extern "x86-interrupt" fn page_fault_handler(
stack_frame: InterruptStackFrame, stack_frame: InterruptStackFrame,
error_code: PageFaultErrorCode error_code: PageFaultErrorCode,
) { ) {
error!("EXCEPTION: PAGE FAULT {error_code:?}\n{:#?}", stack_frame); error!("EXCEPTION: PAGE FAULT {error_code:?}\n{:#?}", stack_frame);
trace!("CR2: {:x}", Cr2::read_raw()); trace!("CR2: {:x}", Cr2::read_raw());
trace!("SCREE");
loop {} loop {}
} }

View file

@ -103,9 +103,9 @@ fn on_complete(mouse_state: MouseState) {
mouse.change_y(delta_y); mouse.change_y(delta_y);
x86_64::instructions::interrupts::without_interrupts(|| { x86_64::instructions::interrupts::without_interrupts(|| {
use crate::TERM; // use crate::TERM;
let mut term = TERM.lock(); // let mut term = TERM.lock();
term.set_dirty(true); // term.set_dirty(true);
}); });
// draw_mouse((mouse.get_x() as usize, mouse.get_y() as usize)); // draw_mouse((mouse.get_x() as usize, mouse.get_y() as usize));

View file

@ -12,7 +12,8 @@ use crate::arch::memory::BootInfoFrameAllocator;
use crate::arch::{drivers::sysinfo::master, init, sloop}; use crate::arch::{drivers::sysinfo::master, init, sloop};
use crate::devices::pci; use crate::devices::pci;
use crate::relib::network::socket::{SimpleSock, Socket}; 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 crate::{filesystem, hardware};
use kernel::KERNEL_VERSION; use kernel::KERNEL_VERSION;
use spin::Lazy; use spin::Lazy;
@ -144,9 +145,9 @@ pub static TICK: AtomicU64 = AtomicU64::new(0);
pub fn tick() { pub fn tick() {
x86_64::instructions::interrupts::without_interrupts(|| { 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; use core::sync::atomic::Ordering::Relaxed;
let mut data = TICK.load(Relaxed); let mut data = TICK.load(Relaxed);

View file

@ -23,7 +23,7 @@ impl core::fmt::Write for Stdout {
fn write_str(&mut self, s: &str) -> Result<(), Error> { fn write_str(&mut self, s: &str) -> Result<(), Error> {
// use mini_backtrace::Backtrace; // use mini_backtrace::Backtrace;
use crate::TERM; // use crate::TERM;
// Capture up to 16 frames. This is returned using an ArrayVec that doesn't // Capture up to 16 frames. This is returned using an ArrayVec that doesn't
// perform any dynamic memory allocation. // 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(|| { // x86_64::instructions::interrupts::without_interrupts(|| {
let mut term = TERM.lock(); // let mut term = TERM.lock();
term.set_dirty(true); // term.set_dirty(true);
term.print(s); // term.print(s);
drop(term); // drop(term);
// }); // });
// trace!("Finished printing"); // trace!("Finished printing");
Ok(()) Ok(())

View file

@ -43,17 +43,19 @@ impl acpi::AcpiHandler for AcpiStruct {
} }
} }
pub static TERM: Lazy<spin::Mutex<VTerm>> = Lazy::new(|| { // pub static TERM: Lazy<spin::Mutex<VTerm>> = Lazy::new(|| {
trace!("mutex"); // trace!("mutex");
let mutex = spin::Mutex::new({
trace!("vterm"); // loop {}
let vterm = VTerm::new(); // let mutex = spin::Mutex::new({
trace!("vterm-done"); // trace!("vterm");
vterm // let vterm = VTerm::new();
}); // trace!("vterm-done");
trace!("mutex-done"); // vterm
mutex // });
}); // trace!("mutex-done");
// mutex
// });
#[derive(Debug)] #[derive(Debug)]
pub struct Path { pub struct Path {
@ -143,7 +145,9 @@ pub fn scratchpad() {
let mut pci_ide_device = pci_ide_device.lock(); let mut pci_ide_device = pci_ide_device.lock();
if let PciDevice::Ide(device) = &mut *pci_ide_device { if let PciDevice::Ide(device) = &mut *pci_ide_device {
let mut first_sector = Vec::with_capacity(512); 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:?}"); trace!("IDE Primary/Master sector 0: {first_sector:?}");
} }
} }

View file

@ -27,6 +27,7 @@ pub struct VTerm {
impl VTerm { impl VTerm {
/// Construct a new VTerm /// Construct a new VTerm
pub fn new() -> Self { pub fn new() -> Self {
trace!("Setting vga mode");
let mode = VGAE.lock(); let mode = VGAE.lock();
mode.set_mode(); mode.set_mode();
// let fb = mode.get_frame_buffer(); // let fb = mode.get_frame_buffer();

View file

@ -5,7 +5,10 @@
* SPDX-License-Identifier: MPL-2.0 * SPDX-License-Identifier: MPL-2.0
*/ */
use std::{fs::{self, File}, process::Command}; use std::{
fs::{self, File},
process::Command,
};
use colored::*; use colored::*;
@ -260,8 +263,8 @@ fn main() {
.status() .status()
.unwrap(); .unwrap();
// copy the kernel over to ./disk/boot/kernel // copy the kernel over to ./disk/boot/kernel
Command::new("sudo") Command::new("sudo")
.arg("cp") .arg("cp")
.arg("./target/x86_64-ableos/debug/ableos") .arg("./target/x86_64-ableos/debug/ableos")
.arg("./disk/boot/kernel") .arg("./disk/boot/kernel")
@ -293,7 +296,7 @@ fn main() {
.args(["-m", "4G"]) .args(["-m", "4G"])
.args(["-serial", "stdio"]) .args(["-serial", "stdio"])
.args(["-smp", "cores=2"]) .args(["-smp", "cores=2"])
.args(["-soundhw", "pcspk"]) // .args(["-soundhw", "pcspk"])
// .args(["-device", "VGA"]) // .args(["-device", "VGA"])
// .args(["-device", "virtio-gpu-pci"]) // .args(["-device", "virtio-gpu-pci"])
.args(["-device", "vmware-svga"]) .args(["-device", "vmware-svga"])
@ -327,8 +330,8 @@ fn main() {
.status() .status()
.unwrap(); .unwrap();
// copy the kernel over to ./disk/boot/kernel // copy the kernel over to ./disk/boot/kernel
Command::new("sudo") Command::new("sudo")
.arg("cp") .arg("cp")
.arg("./target/x86_64-ableos/release/ableos") .arg("./target/x86_64-ableos/release/ableos")
.arg("./disk/boot/kernel") .arg("./disk/boot/kernel")
@ -360,7 +363,7 @@ fn main() {
.args(["-m", "4G"]) .args(["-m", "4G"])
.args(["-serial", "stdio"]) .args(["-serial", "stdio"])
.args(["-smp", "cores=2"]) .args(["-smp", "cores=2"])
.args(["-soundhw", "pcspk"]) // .args(["-soundhw", "pcspk"])
// .args(["-device", "VGA"]) // .args(["-device", "VGA"])
// .args(["-device", "virtio-gpu-pci"]) // .args(["-device", "virtio-gpu-pci"])
.args(["-device", "vmware-svga"]) .args(["-device", "vmware-svga"])