Fix translation
This commit is contained in:
parent
be027961dc
commit
6997fcba6f
@ -5,6 +5,6 @@ wallpaper_style: centered
|
|||||||
/Gila
|
/Gila
|
||||||
protocol: limine
|
protocol: limine
|
||||||
kernel_path: boot():/boot/${ARCH}/gila
|
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
|
kaslr: yes
|
||||||
randomize_hhdm_base: yes
|
randomize_hhdm_base: yes
|
||||||
|
|||||||
@ -185,14 +185,6 @@ unsafe extern "C" fn main() -> ! {
|
|||||||
addr_of!(*root_ptable_info.0) as usize
|
addr_of!(*root_ptable_info.0) as usize
|
||||||
);
|
);
|
||||||
paging::walk_tables();
|
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());
|
log_info!("Long mode: {}", asm::long_mode());
|
||||||
|
|||||||
@ -5,6 +5,7 @@ const PAGE_SIZE: usize = 4096;
|
|||||||
|
|
||||||
use crate::boot::modules::MODULE_RESPONSE;
|
use crate::boot::modules::MODULE_RESPONSE;
|
||||||
use crate::boot::params::EXECUTABLE_FILE_RESPONSE;
|
use crate::boot::params::EXECUTABLE_FILE_RESPONSE;
|
||||||
|
use crate::memory::paging::virt_to_phys;
|
||||||
use crate::{LOGGER, LogLevel, format};
|
use crate::{LOGGER, LogLevel, format};
|
||||||
use alloc::string::String;
|
use alloc::string::String;
|
||||||
|
|
||||||
@ -12,6 +13,7 @@ use lazy_static::lazy_static;
|
|||||||
use limine::request::{ExecutableAddressRequest, HhdmRepsonse, HhdmRequest};
|
use limine::request::{ExecutableAddressRequest, HhdmRepsonse, HhdmRequest};
|
||||||
use limine::request::{MemmapRequest, MemmapResponse};
|
use limine::request::{MemmapRequest, MemmapResponse};
|
||||||
use talc::*;
|
use talc::*;
|
||||||
|
use x86_64::VirtAddr;
|
||||||
|
|
||||||
pub extern crate alloc;
|
pub extern crate alloc;
|
||||||
|
|
||||||
@ -88,6 +90,16 @@ pub fn log_address() {
|
|||||||
if let Some(resp) = ADDRESS_REQUEST.response() {
|
if let Some(resp) = ADDRESS_REQUEST.response() {
|
||||||
log_info!("Kernel physical start address: 0x{:x}", resp.physical_base);
|
log_info!("Kernel physical start address: 0x{:x}", resp.physical_base);
|
||||||
log_info!("Kernel virtual start address: 0x{:x}", resp.virtual_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 {
|
} else {
|
||||||
log_warning!("No kernel address response provided.");
|
log_warning!("No kernel address response provided.");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
use core::ops::Index;
|
use core::ops::Index;
|
||||||
|
use core::ptr::addr_of;
|
||||||
|
|
||||||
use intbits::Bits;
|
use intbits::Bits;
|
||||||
use x86_64::PhysAddr;
|
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(39..=47) as usize, // Page Map Level 4 index
|
||||||
virt.as_u64().bits(48..=56) as usize, // Page Map Level 5 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]);
|
let current_table_entry = current_table.0.index(table_indices[current_table.1]);
|
||||||
if current_table_entry
|
if current_table_entry
|
||||||
.flags()
|
.flags()
|
||||||
@ -124,5 +127,6 @@ pub fn virt_to_phys(virt: VirtAddr) -> Option<PhysAddr> {
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Current table is level 1
|
||||||
unreachable!()
|
unreachable!()
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user