Fix translation
Some checks failed
Continuous Integration / Check (push) Failing after 42s
Continuous Integration / Clippy (push) Failing after 41s

This commit is contained in:
August 2026-06-30 12:46:03 +00:00
parent be027961dc
commit 6997fcba6f
Signed by: shibedrill
SSH Key Fingerprint: SHA256:M0m3JW1s38BgO2t0fG146Yxd9OJ2IOqkvCAsuRHQ6Pw
4 changed files with 18 additions and 10 deletions

View File

@ -5,6 +5,6 @@ wallpaper_style: centered
/Gila
protocol: limine
kernel_path: boot():/boot/${ARCH}/gila
cmdline: -loglevel=Info -logdev=display,serial -initramfs=/boot/${ARCH}/initramfs.tar.lzma
cmdline: -loglevel=Trace -logdev=display,serial -initramfs=/boot/${ARCH}/initramfs.tar.lzma
kaslr: yes
randomize_hhdm_base: yes

View File

@ -185,14 +185,6 @@ unsafe extern "C" fn main() -> ! {
addr_of!(*root_ptable_info.0) as usize
);
paging::walk_tables();
log_info!(
"Testing virt_to_phys: 0x{:x}",
addr_of!(*root_ptable_info.0) as usize
);
log_info!(
"Result: 0x{:x}",
virt_to_phys(VirtAddr::new(addr_of!(*root_ptable_info.0) as u64)).unwrap()
);
}
log_info!("Long mode: {}", asm::long_mode());

View File

@ -5,6 +5,7 @@ const PAGE_SIZE: usize = 4096;
use crate::boot::modules::MODULE_RESPONSE;
use crate::boot::params::EXECUTABLE_FILE_RESPONSE;
use crate::memory::paging::virt_to_phys;
use crate::{LOGGER, LogLevel, format};
use alloc::string::String;
@ -12,6 +13,7 @@ use lazy_static::lazy_static;
use limine::request::{ExecutableAddressRequest, HhdmRepsonse, HhdmRequest};
use limine::request::{MemmapRequest, MemmapResponse};
use talc::*;
use x86_64::VirtAddr;
pub extern crate alloc;
@ -88,6 +90,16 @@ pub fn log_address() {
if let Some(resp) = ADDRESS_REQUEST.response() {
log_info!("Kernel physical start address: 0x{:x}", resp.physical_base);
log_info!("Kernel virtual start address: 0x{:x}", resp.virtual_base);
log_info!(
"Testing virt_to_phys: 0x{:x}",
resp.virtual_base
);
let hhdm_vaddr = VirtAddr::new(resp.virtual_base);
let hhdm_paddr = virt_to_phys(hhdm_vaddr);
log_info!(
"Result: 0x{:x}",
hhdm_paddr.unwrap()
);
} else {
log_warning!("No kernel address response provided.");
}

View File

@ -1,4 +1,5 @@
use core::ops::Index;
use core::ptr::addr_of;
use intbits::Bits;
use x86_64::PhysAddr;
@ -87,7 +88,9 @@ pub fn virt_to_phys(virt: VirtAddr) -> Option<PhysAddr> {
virt.as_u64().bits(39..=47) as usize, // Page Map Level 4 index
virt.as_u64().bits(48..=56) as usize, // Page Map Level 5 index
];
while current_table.1 > 1 {
while current_table.1 > 0 {
log_trace!("Searching through a level {} table at 0x{:x}", current_table.1, addr_of!(*current_table.0) as usize);
log_trace!("Index: {}", table_indices[current_table.1]);
let current_table_entry = current_table.0.index(table_indices[current_table.1]);
if current_table_entry
.flags()
@ -124,5 +127,6 @@ pub fn virt_to_phys(virt: VirtAddr) -> Option<PhysAddr> {
return None;
}
}
// Current table is level 1
unreachable!()
}