Bug fixing and investigation
This commit is contained in:
parent
c2f9343bbf
commit
9295b6f3f7
@ -5,3 +5,5 @@ timeout: 0
|
|||||||
kernel_path: boot():/boot/${ARCH}/gila
|
kernel_path: boot():/boot/${ARCH}/gila
|
||||||
cmdline: -loglevel=Trace -logdev=display,serial -initramfs=/boot/${ARCH}/initramfs.tar.lzma
|
cmdline: -loglevel=Trace -logdev=display,serial -initramfs=/boot/${ARCH}/initramfs.tar.lzma
|
||||||
module_path: boot():/boot/${ARCH}/initramfs.tar.lzma
|
module_path: boot():/boot/${ARCH}/initramfs.tar.lzma
|
||||||
|
kaslr: yes
|
||||||
|
randomize_hhdm_base: yes
|
||||||
|
|||||||
@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
use crate::{LOGGER, LogLevel, format, log_info};
|
use crate::{format, log_info, memory::HHDM_RESPONSE, LogLevel, LOGGER};
|
||||||
use x86_64::registers::control::*;
|
use x86_64::{registers::control::*, structures::paging::{Page, PageTable, PageTableFlags}, PhysAddr, VirtAddr};
|
||||||
|
|
||||||
pub fn get_mappings() {
|
pub fn get_mappings() {
|
||||||
log_info!("Paging: {}", Cr0::read().contains(Cr0Flags::PAGING));
|
log_info!("Paging: {}", Cr0::read().contains(Cr0Flags::PAGING));
|
||||||
@ -28,8 +28,8 @@ pub fn get_mappings() {
|
|||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
let pml4_addr = Cr3::read_raw().0.start_address();
|
let pml4_phys_addr = Cr3::read_raw().0.start_address();
|
||||||
log_info!("Page Map Level 4 Address: 0x{:x}", pml4_addr.as_u64());
|
log_info!("Page Map Level 4 Address: 0x{:x}", pml4_phys_addr.as_u64());
|
||||||
log_info!(
|
log_info!(
|
||||||
"Page-Level Write-Through: {}",
|
"Page-Level Write-Through: {}",
|
||||||
Cr3::read().1.contains(Cr3Flags::PAGE_LEVEL_WRITETHROUGH)
|
Cr3::read().1.contains(Cr3Flags::PAGE_LEVEL_WRITETHROUGH)
|
||||||
@ -38,4 +38,30 @@ pub fn get_mappings() {
|
|||||||
"Page-Level Cache Disable: {}",
|
"Page-Level Cache Disable: {}",
|
||||||
Cr3::read().1.contains(Cr3Flags::PAGE_LEVEL_CACHE_DISABLE)
|
Cr3::read().1.contains(Cr3Flags::PAGE_LEVEL_CACHE_DISABLE)
|
||||||
);
|
);
|
||||||
|
let pml4: &'static mut PageTable = table_from_phys_addr(pml4_phys_addr);
|
||||||
|
|
||||||
|
iter_table(pml4, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn table_from_phys_addr(address: PhysAddr) -> &'static mut PageTable {
|
||||||
|
let virt_addr: VirtAddr = VirtAddr::new(address.as_u64() + HHDM_RESPONSE.offset());
|
||||||
|
let ptr: *mut PageTable = virt_addr.as_mut_ptr();
|
||||||
|
unsafe { &mut *ptr }
|
||||||
|
}
|
||||||
|
|
||||||
|
fn iter_table(table: &'static mut PageTable, level: usize) {
|
||||||
|
if level == 1 {
|
||||||
|
for page_entry in table.iter() {
|
||||||
|
if page_entry.flags().contains(PageTableFlags::PRESENT) {
|
||||||
|
log_info!("Page entry: 0x{:x}, flags: {:?}", page_entry.addr(), page_entry.flags());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for table_entry in table.iter() {
|
||||||
|
if table_entry.flags().contains(PageTableFlags::PRESENT) {
|
||||||
|
log_info!("Table entry: 0x{:x}, flags: {:?}", table_entry.addr(), table_entry.flags());
|
||||||
|
iter_table(table_from_phys_addr(table_entry.addr()), level - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -79,7 +79,7 @@ pub enum TriggerLevel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
#[derive(FromPrimitive)]
|
#[derive(FromPrimitive, PartialEq, Eq)]
|
||||||
pub enum InterruptState {
|
pub enum InterruptState {
|
||||||
ModemStatus = 0b00,
|
ModemStatus = 0b00,
|
||||||
TransmitterEmpty = 0b01,
|
TransmitterEmpty = 0b01,
|
||||||
@ -123,6 +123,7 @@ pub enum ModemStatus {
|
|||||||
DataCarrierDetect = 0b10000000,
|
DataCarrierDetect = 0b10000000,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Ensure we don't clobber the tx buffer and prevent some data from getting printed
|
||||||
impl SerialPort {
|
impl SerialPort {
|
||||||
pub fn log_write(&mut self, msg: &str) {
|
pub fn log_write(&mut self, msg: &str) {
|
||||||
if self.crlf == Crlf::Crlf {
|
if self.crlf == Crlf::Crlf {
|
||||||
@ -137,6 +138,11 @@ impl SerialPort {
|
|||||||
self.write_char(c);
|
self.write_char(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn is_transmit_empty(&mut self) -> bool {
|
||||||
|
self.get_interrupt_state() != InterruptState::TransmitterEmpty
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn log_writeln(&mut self, msg: &str) {
|
pub fn log_writeln(&mut self, msg: &str) {
|
||||||
|
|||||||
@ -77,7 +77,7 @@ pub static ASCII_LOGO: [&str; 6] = [
|
|||||||
" / __ `/ / / __ `/",
|
" / __ `/ / / __ `/",
|
||||||
"/ /_/ / / / /_/ / ",
|
"/ /_/ / / / /_/ / ",
|
||||||
"\\__, /_/_/\\__,_/ ",
|
"\\__, /_/_/\\__,_/ ",
|
||||||
"/____/ ",
|
"/___/ ",
|
||||||
];
|
];
|
||||||
|
|
||||||
// FUCKING ADD CONST UNWRAP!!!
|
// FUCKING ADD CONST UNWRAP!!!
|
||||||
|
|||||||
@ -34,7 +34,7 @@ use lazy_static::lazy_static;
|
|||||||
use limine::firmware_type::FirmwareType;
|
use limine::firmware_type::FirmwareType;
|
||||||
use spin::mutex::Mutex;
|
use spin::mutex::Mutex;
|
||||||
|
|
||||||
use crate::arch::x86_64::cpuid::{CPUID, virt_supported};
|
use crate::{arch::x86_64::cpuid::{CPUID, virt_supported}, panic::panic};
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
pub static ref SERIAL_3F8: Mutex<SerialPort> =
|
pub static ref SERIAL_3F8: Mutex<SerialPort> =
|
||||||
@ -150,8 +150,5 @@ unsafe extern "C" fn main() -> ! {
|
|||||||
}
|
}
|
||||||
log_info!("Virtualization provider: {:?}", virt_supported());
|
log_info!("Virtualization provider: {:?}", virt_supported());
|
||||||
|
|
||||||
log_info!("Done boot!");
|
panic!("Finished boot, but cannot start init because processes not implemented!");
|
||||||
loop {
|
|
||||||
arch::asm::nop();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user