More testing with GDT
This commit is contained in:
parent
cc2d5cfea9
commit
f438a722f6
68
Cargo.lock
generated
68
Cargo.lock
generated
@ -13,15 +13,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "align-address"
|
||||
version = "0.3.0"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ac6c08a67736554282858203cd9b7ff53cf55f54c34e85689962748a350cbf0"
|
||||
checksum = "cee078b3ed87e2621e0389729e2f032cc0408a4548768ced01678c9451c62237"
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.5.0"
|
||||
version = "1.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
|
||||
checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
|
||||
|
||||
[[package]]
|
||||
name = "bit_field"
|
||||
@ -31,9 +31,15 @@ checksum = "1e4b40c7323adcfc0a41c4b88143ed58346ff65a288fc144329c5c45e05d70c6"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.10.0"
|
||||
version = "2.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3"
|
||||
checksum = "b4388bee8683e3d04af747c73422af53102d2bd24d9eadb6cbc100baef4b43f8"
|
||||
|
||||
[[package]]
|
||||
name = "const_fn"
|
||||
version = "0.4.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "413d67b29ef1021b4d60f4aa1e925ca031751e213832b4b1d588fae623c05c60"
|
||||
|
||||
[[package]]
|
||||
name = "critical-section"
|
||||
@ -69,9 +75,9 @@ checksum = "b7ac824320a75a52197e8f2d787f6a38b6718bb6897a35142d749af3c0e8f4fe"
|
||||
|
||||
[[package]]
|
||||
name = "free-list"
|
||||
version = "0.3.1"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "810f338a4ef98f319a279c9199f35d7ec366c6002ca6a8f18fdcc94cfef9afab"
|
||||
checksum = "358d33fcfc734d809ab9d4c45de31f1e73e3b973656deaff0db3cd5951782134"
|
||||
dependencies = [
|
||||
"align-address",
|
||||
"smallvec",
|
||||
@ -100,7 +106,7 @@ dependencies = [
|
||||
"num-traits",
|
||||
"once_cell",
|
||||
"raw-cpuid",
|
||||
"spin 0.10.0",
|
||||
"spin 0.12.1",
|
||||
"talc",
|
||||
"x86_64",
|
||||
]
|
||||
@ -124,12 +130,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "limine"
|
||||
version = "0.5.0"
|
||||
version = "0.6.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "af6d2ee42712e7bd2c787365cd1dab06ef59a61becbf87bec7b32b970bd2594b"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
checksum = "29363c0f37e66e18575fadf7141c56ee7ea04ae5fecbeb25eff303f77af203a9"
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
@ -162,9 +165,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.21.3"
|
||||
version = "1.21.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
|
||||
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
||||
dependencies = [
|
||||
"critical-section",
|
||||
"portable-atomic",
|
||||
@ -172,24 +175,24 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "portable-atomic"
|
||||
version = "1.11.1"
|
||||
version = "1.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483"
|
||||
checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.103"
|
||||
version = "1.0.106"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8"
|
||||
checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.42"
|
||||
version = "1.0.46"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f"
|
||||
checksum = "dfbc457d0c7a0759a614551b11a6409e5951f6c7537be1f1b7682b9ae9230368"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
@ -217,9 +220,9 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.15.1"
|
||||
version = "1.15.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
|
||||
checksum = "8ed6a63f02c8539c91a8685a86f4099661ba3da017932f6ebbea6de3f0fa7c90"
|
||||
|
||||
[[package]]
|
||||
name = "spin"
|
||||
@ -229,9 +232,9 @@ checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
|
||||
|
||||
[[package]]
|
||||
name = "spin"
|
||||
version = "0.10.0"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d5fe4ccb98d9c292d56fec89a5e07da7fc4cf0dc11e156b41793132775d3e591"
|
||||
checksum = "bd5231412d905519dca6a5deb0327d407be68d6c941feec004533401d3a0a715"
|
||||
dependencies = [
|
||||
"lock_api",
|
||||
]
|
||||
@ -244,9 +247,9 @@ checksum = "5cdeee85371b1ec1f4b305c91787271a39f56b66e673bdbd73b7742150de5b0e"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.110"
|
||||
version = "2.0.118"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a99801b5bd34ede4cf3fc688c5919368fea4e4814a4664359503e6015b280aea"
|
||||
checksum = "1b9ae57f904213ebb649ce6895b8a66c66f0203b9319718f69a5612a065b1422"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -264,9 +267,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.22"
|
||||
version = "1.0.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5"
|
||||
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
|
||||
|
||||
[[package]]
|
||||
name = "volatile"
|
||||
@ -276,12 +279,13 @@ checksum = "442887c63f2c839b346c192d047a7c87e73d0689c9157b00b53dcc27dd5ea793"
|
||||
|
||||
[[package]]
|
||||
name = "x86_64"
|
||||
version = "0.15.2"
|
||||
version = "0.15.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0f042214de98141e9c8706e8192b73f56494087cc55ebec28ce10f26c5c364ae"
|
||||
checksum = "f7841fa0098ceb15c567d93d3fae292c49e10a7662b4936d5f6a9728594555ba"
|
||||
dependencies = [
|
||||
"bit_field",
|
||||
"bitflags",
|
||||
"const_fn",
|
||||
"rustversion",
|
||||
"volatile",
|
||||
]
|
||||
|
||||
@ -11,11 +11,11 @@ flagset = "0.4.7"
|
||||
free-list = { version = "0.3.1", features = ["x86_64"] }
|
||||
intbits = "0.2.0"
|
||||
lazy_static = { version = "1.5.0", default-features = false, features = ["spin_no_std"] }
|
||||
limine = "0.5.0"
|
||||
limine = "0.6.5"
|
||||
num-derive = "0.4.2"
|
||||
num-traits = { version = "0.2.19", default-features = false }
|
||||
once_cell = { version = "1.21.3", default-features = false, features = ["alloc", "critical-section"] }
|
||||
spin = "0.10.0"
|
||||
spin = "0.12.1"
|
||||
talc = "4.4.3"
|
||||
|
||||
libgila = { path = "../libgila" }
|
||||
|
||||
@ -61,8 +61,9 @@ pub fn dump_gdt() {
|
||||
let flags = x86_64::structures::gdt::DescriptorFlags::from_bits_retain(entry.raw());
|
||||
let seg_type = SegmentType::try_from(entry);
|
||||
log_info!(
|
||||
"GDT entry: type: {:?}, size: {}, raw flags: 0b{:04b}, access: 0b{:08b}",
|
||||
"GDT entry: type: {:?} (ring {}), size: {}, raw flags: 0b{:04b}, access: 0b{:08b}",
|
||||
seg_type.unwrap(),
|
||||
entry.access().bits(5..=6),
|
||||
if flags.contains(gdt::DescriptorFlags::DEFAULT_SIZE) {
|
||||
"32-bit"
|
||||
} else if flags.contains(gdt::DescriptorFlags::LONG_MODE) {
|
||||
@ -71,7 +72,7 @@ pub fn dump_gdt() {
|
||||
"16-bit"
|
||||
},
|
||||
entry.raw().bits(52..=55),
|
||||
entry.access()
|
||||
entry.access(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
pub mod modules;
|
||||
pub mod params;
|
||||
|
||||
use limine::{BaseRevision, request::*};
|
||||
use limine::{BaseRevision, RequestsEndMarker, RequestsStartMarker, request::*};
|
||||
|
||||
#[used]
|
||||
#[unsafe(link_section = ".requests_start_marker")]
|
||||
@ -20,7 +20,7 @@ pub static BASE_REVISION: BaseRevision = limine::BaseRevision::new();
|
||||
|
||||
#[used]
|
||||
#[unsafe(link_section = ".requests")]
|
||||
pub static MP_REQUEST: MpRequest = limine::request::MpRequest::new();
|
||||
pub static MP_REQUEST: MpRequest = limine::request::MpRequest::new(0);
|
||||
|
||||
#[used]
|
||||
#[unsafe(link_section = ".requests")]
|
||||
@ -29,3 +29,7 @@ pub static FRAMEBUFFER_REQUEST: FramebufferRequest = limine::request::Framebuffe
|
||||
#[used]
|
||||
#[unsafe(link_section = ".requests")]
|
||||
pub static FIRMWARE_TYPE_REQUEST: FirmwareTypeRequest = limine::request::FirmwareTypeRequest::new();
|
||||
|
||||
#[used]
|
||||
#[unsafe(link_section = ".requests")]
|
||||
pub static RSDP_REQUEST: RsdpRequest = limine::request::RsdpRequest::new();
|
||||
|
||||
@ -5,10 +5,7 @@ use crate::format;
|
||||
use crate::memory::alloc::string::String;
|
||||
use crate::{LOGGER, LogLevel, log_trace};
|
||||
use lazy_static::lazy_static;
|
||||
use limine::{
|
||||
request::{ExecutableFileRequest, ModuleRequest},
|
||||
response::ModuleResponse,
|
||||
};
|
||||
use limine::request::*;
|
||||
|
||||
#[used]
|
||||
#[unsafe(link_section = ".requests")]
|
||||
@ -16,10 +13,10 @@ pub static FILE_REQUEST: ExecutableFileRequest = limine::request::ExecutableFile
|
||||
|
||||
#[used]
|
||||
#[unsafe(link_section = ".requests")]
|
||||
pub static MODULE_REQUEST: ModuleRequest = limine::request::ModuleRequest::new();
|
||||
pub static MODULE_REQUEST: ModulesRequest = limine::request::ModulesRequest::new();
|
||||
|
||||
lazy_static! {
|
||||
pub static ref MODULE_RESPONSE: Option<&'static ModuleResponse> = MODULE_REQUEST.get_response();
|
||||
pub static ref MODULE_RESPONSE: Option<&'static ModulesResponse> = MODULE_REQUEST.response();
|
||||
}
|
||||
|
||||
pub fn log_modules() {
|
||||
@ -29,7 +26,7 @@ pub fn log_modules() {
|
||||
for module in modules.modules() {
|
||||
log_msg.push_str(&format!(
|
||||
"\t{}",
|
||||
String::from_utf8_lossy(module.path().to_bytes())
|
||||
String::from_utf8_lossy(module.path().as_bytes())
|
||||
));
|
||||
}
|
||||
log_trace!("{log_msg}")
|
||||
|
||||
@ -6,14 +6,18 @@ use crate::memory::alloc;
|
||||
use alloc::string::String;
|
||||
use alloc::vec::Vec;
|
||||
use lazy_static::lazy_static;
|
||||
use limine::response::ExecutableFileResponse;
|
||||
use limine::request::ExecutableFileResponse;
|
||||
|
||||
lazy_static! {
|
||||
pub static ref EXECUTABLE_FILE_RESPONSE: &'static ExecutableFileResponse = FILE_REQUEST
|
||||
.get_response()
|
||||
.response()
|
||||
.expect("Bootloader did not return executable data");
|
||||
pub static ref PARAMS: KernelParameters =
|
||||
get_kernel_params(limine::file::File::string(EXECUTABLE_FILE_RESPONSE.file()).to_bytes());
|
||||
pub static ref PARAMS: KernelParameters = get_kernel_params(
|
||||
EXECUTABLE_FILE_RESPONSE
|
||||
.executable_file()
|
||||
.cmdline()
|
||||
.as_bytes()
|
||||
);
|
||||
}
|
||||
|
||||
pub type KernelParameters = alloc::collections::BTreeMap<String, String>;
|
||||
|
||||
@ -21,11 +21,13 @@ use arch::x86_64::serial::SerialPort;
|
||||
use boot::{BASE_REVISION, params, *};
|
||||
use constants::*;
|
||||
use log::*;
|
||||
use memory::alloc::{boxed::Box, format, string::String, vec};
|
||||
use memory::alloc::{boxed::Box, format, vec};
|
||||
use params::*;
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
use limine::firmware_type::FirmwareType;
|
||||
use limine::firmware::{
|
||||
FIRMWARE_TYPE_EFI32, FIRMWARE_TYPE_EFI64, FIRMWARE_TYPE_SBI, FIRMWARE_TYPE_X86BIOS,
|
||||
};
|
||||
use spin::mutex::Mutex;
|
||||
|
||||
use crate::{
|
||||
@ -86,13 +88,11 @@ unsafe extern "C" fn main() -> ! {
|
||||
|
||||
log_info!(
|
||||
"Kernel cmdline: {}",
|
||||
String::from_utf8_lossy(
|
||||
limine::file::File::string(EXECUTABLE_FILE_RESPONSE.file()).to_bytes()
|
||||
)
|
||||
EXECUTABLE_FILE_RESPONSE.executable_file().cmdline()
|
||||
);
|
||||
log_info!(
|
||||
"Kernel file path: {}",
|
||||
String::from_utf8_lossy(EXECUTABLE_FILE_RESPONSE.file().path().to_bytes())
|
||||
EXECUTABLE_FILE_RESPONSE.executable_file().path()
|
||||
);
|
||||
|
||||
// Branding
|
||||
@ -106,14 +106,14 @@ unsafe extern "C" fn main() -> ! {
|
||||
.log_writeln("\tWelcome to the Gila microkernel!\n");
|
||||
log_info!("Booting gila version {}", kernel_version_string());
|
||||
|
||||
match boot::FIRMWARE_TYPE_REQUEST.get_response() {
|
||||
match boot::FIRMWARE_TYPE_REQUEST.response() {
|
||||
Some(resp) => log_info!(
|
||||
"Firmware type: {}",
|
||||
match resp.firmware_type() {
|
||||
FirmwareType::SBI => "SBI",
|
||||
FirmwareType::UEFI_32 => "UEFI (32-bit)",
|
||||
FirmwareType::UEFI_64 => "UEFI (64-bit)",
|
||||
FirmwareType::X86_BIOS => "x86 BIOS",
|
||||
match resp.firmware_type {
|
||||
FIRMWARE_TYPE_SBI => "SBI",
|
||||
FIRMWARE_TYPE_EFI32 => "UEFI (32-bit)",
|
||||
FIRMWARE_TYPE_EFI64 => "UEFI (64-bit)",
|
||||
FIRMWARE_TYPE_X86BIOS => "x86 BIOS",
|
||||
_ => "Unknown",
|
||||
}
|
||||
),
|
||||
@ -122,20 +122,22 @@ unsafe extern "C" fn main() -> ! {
|
||||
|
||||
log_info!("Trans rights!");
|
||||
|
||||
if let Some(framebuffer_response) = FRAMEBUFFER_REQUEST.get_response() {
|
||||
let fb = framebuffer_response.framebuffers().next().unwrap();
|
||||
if let Some(framebuffer_response) = FRAMEBUFFER_REQUEST.response() {
|
||||
let fb = framebuffer_response.framebuffers_rev1().unwrap()[0];
|
||||
log_info!("Framebuffer response received");
|
||||
log_trace!(
|
||||
"Framebuffer dimensions: {}x{}, {} bits per pixel",
|
||||
fb.width(),
|
||||
fb.height(),
|
||||
fb.bpp()
|
||||
);
|
||||
for mode in fb.modes() {
|
||||
log_trace!(
|
||||
"Mode: {}x{}, {} bits per pixel",
|
||||
mode.width,
|
||||
mode.height,
|
||||
mode.bpp
|
||||
);
|
||||
}
|
||||
} else {
|
||||
log_info!("Framebuffer response absent, graphics disabled",);
|
||||
}
|
||||
|
||||
let smp_response = MP_REQUEST.get_response();
|
||||
let smp_response = MP_REQUEST.response();
|
||||
match smp_response {
|
||||
None => log_info!("Multiprocessing response not received"),
|
||||
Some(resp) => {
|
||||
@ -144,6 +146,15 @@ unsafe extern "C" fn main() -> ! {
|
||||
}
|
||||
}
|
||||
|
||||
let rsdp_response = RSDP_REQUEST.response();
|
||||
match rsdp_response {
|
||||
None => log_info!("RDSP response not received"),
|
||||
Some(resp) => {
|
||||
log_info!("RSDP response received");
|
||||
log_trace!("RSDT address: 0x{:x}", resp.address as usize)
|
||||
}
|
||||
}
|
||||
|
||||
boot::modules::log_modules();
|
||||
|
||||
memory::log_memory();
|
||||
@ -164,7 +175,7 @@ unsafe extern "C" fn main() -> ! {
|
||||
log_info!("Physical address of current L4 table: 0x{:x}", l4_start);
|
||||
log_info!(
|
||||
"Virtual address of current L4 table: 0x{:x}",
|
||||
l4_start.as_u64() + HHDM_RESPONSE.offset()
|
||||
l4_start.as_u64() + HHDM_RESPONSE.offset
|
||||
);
|
||||
|
||||
//iter_table(4, &PML4);
|
||||
|
||||
@ -9,12 +9,9 @@ use crate::{LOGGER, LogLevel, format};
|
||||
use alloc::string::String;
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
use limine::response::MemoryMapResponse;
|
||||
use limine::{
|
||||
memory_map::EntryType,
|
||||
request::{ExecutableAddressRequest, HhdmRequest, MemoryMapRequest, PagingModeRequest},
|
||||
response::HhdmResponse,
|
||||
};
|
||||
use limine::memmap::*;
|
||||
use limine::request::{ExecutableAddressRequest, HhdmRepsonse, HhdmRequest};
|
||||
use limine::request::{MemmapRequest, MemmapResponse};
|
||||
use talc::*;
|
||||
|
||||
pub extern crate alloc;
|
||||
@ -22,8 +19,8 @@ pub extern crate alloc;
|
||||
pub mod paging;
|
||||
|
||||
lazy_static! {
|
||||
pub static ref MEMMAP_RESPONSE: &'static MemoryMapResponse = MEMMAP_REQUEST
|
||||
.get_response()
|
||||
pub static ref MEMMAP_RESPONSE: &'static MemmapResponse = MEMMAP_REQUEST
|
||||
.response()
|
||||
.expect("Bootloader did not supply memory map");
|
||||
}
|
||||
|
||||
@ -40,37 +37,36 @@ pub fn log_memory() {
|
||||
entry.length,
|
||||
entry.length as usize / PAGE_SIZE,
|
||||
entry.base,
|
||||
match entry.entry_type {
|
||||
EntryType::ACPI_NVS => {
|
||||
match entry.type_ {
|
||||
MEMMAP_ACPI_NVS => {
|
||||
hardware += entry.length;
|
||||
"ACPI (reserved)"
|
||||
}
|
||||
EntryType::ACPI_RECLAIMABLE => {
|
||||
MEMMAP_ACPI_RECLAIMABLE => {
|
||||
reclaimable += entry.length;
|
||||
"ACPI (reclaimable)"
|
||||
}
|
||||
EntryType::BAD_MEMORY => {
|
||||
MEMMAP_BAD_MEMORY => {
|
||||
unusable += entry.length;
|
||||
"damaged/unusable"
|
||||
}
|
||||
EntryType::BOOTLOADER_RECLAIMABLE => {
|
||||
MEMMAP_BOOTLOADER_RECLAIMABLE => {
|
||||
reclaimable += entry.length;
|
||||
"bootloader (reclaimable)"
|
||||
}
|
||||
#[allow(unreachable_patterns, deprecated)]
|
||||
EntryType::EXECUTABLE_AND_MODULES | EntryType::KERNEL_AND_MODULES => {
|
||||
MEMMAP_EXECUTABLE_AND_MODULES => {
|
||||
unusable += entry.length;
|
||||
"executable & modules"
|
||||
}
|
||||
EntryType::FRAMEBUFFER => {
|
||||
MEMMAP_FRAMEBUFFER => {
|
||||
hardware += entry.length;
|
||||
"framebuffer"
|
||||
}
|
||||
EntryType::RESERVED => {
|
||||
MEMMAP_RESERVED => {
|
||||
unusable += entry.length;
|
||||
"reserved"
|
||||
}
|
||||
EntryType::USABLE => {
|
||||
MEMMAP_USABLE => {
|
||||
usable += entry.length;
|
||||
"usable"
|
||||
}
|
||||
@ -90,22 +86,19 @@ pub fn log_memory() {
|
||||
}
|
||||
|
||||
pub fn log_address() {
|
||||
if let Some(resp) = ADDRESS_REQUEST.get_response() {
|
||||
log_info!(
|
||||
"Kernel physical start address: 0x{:x}",
|
||||
resp.physical_base()
|
||||
);
|
||||
log_info!("Kernel virtual start address: 0x{:x}", resp.virtual_base());
|
||||
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!(
|
||||
"Kernel physical start address (calculated): 0x{:x}",
|
||||
0i64 - resp.virtual_base() as i64 + resp.physical_base() as i64
|
||||
0i64 - resp.virtual_base as i64 + resp.physical_base as i64
|
||||
);
|
||||
} else {
|
||||
log_warning!("No kernel address response provided.");
|
||||
}
|
||||
log_info!(
|
||||
"Higher Half direct map offset: 0x{:x}",
|
||||
HHDM_RESPONSE.offset()
|
||||
HHDM_RESPONSE.offset
|
||||
);
|
||||
}
|
||||
|
||||
@ -117,10 +110,6 @@ pub fn init_statics() {
|
||||
let _ = MEMMAP_RESPONSE;
|
||||
}
|
||||
|
||||
#[used]
|
||||
#[unsafe(link_section = ".requests")]
|
||||
pub static PAGING_REQUEST: PagingModeRequest = limine::request::PagingModeRequest::new();
|
||||
|
||||
#[used]
|
||||
#[unsafe(link_section = ".requests")]
|
||||
pub static ADDRESS_REQUEST: ExecutableAddressRequest =
|
||||
@ -128,15 +117,15 @@ pub static ADDRESS_REQUEST: ExecutableAddressRequest =
|
||||
|
||||
#[used]
|
||||
#[unsafe(link_section = ".requests")]
|
||||
pub static MEMMAP_REQUEST: MemoryMapRequest = limine::request::MemoryMapRequest::new();
|
||||
pub static MEMMAP_REQUEST: MemmapRequest = limine::request::MemmapRequest::new();
|
||||
|
||||
#[used]
|
||||
#[unsafe(link_section = ".requests")]
|
||||
pub static HHDM_REQUEST: HhdmRequest = limine::request::HhdmRequest::new();
|
||||
|
||||
lazy_static! {
|
||||
pub static ref HHDM_RESPONSE: &'static HhdmResponse = HHDM_REQUEST
|
||||
.get_response()
|
||||
pub static ref HHDM_RESPONSE: &'static HhdmRepsonse = HHDM_REQUEST
|
||||
.response()
|
||||
.expect("Did not get HHDM response from bootloader");
|
||||
}
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@ pub unsafe fn active_level_4_table() -> &'static mut PageTable {
|
||||
let (level_4_table_frame, _) = Cr3::read();
|
||||
|
||||
let phys = level_4_table_frame.start_address();
|
||||
let virt: VirtAddr = VirtAddr::new(HHDM_RESPONSE.offset() + phys.as_u64());
|
||||
let virt: VirtAddr = VirtAddr::new(HHDM_RESPONSE.offset + phys.as_u64());
|
||||
let page_table_ptr: *mut PageTable = virt.as_mut_ptr();
|
||||
|
||||
unsafe { &mut *page_table_ptr }
|
||||
@ -32,7 +32,7 @@ pub fn iter_table(level: usize, table: &PageTable) {
|
||||
log_info!("L{} Entry {}: {:?}", level, i, entry);
|
||||
if (level > 1) & !entry.flags().contains(PageTableFlags::HUGE_PAGE) {
|
||||
let phys = entry.frame().unwrap().start_address();
|
||||
let virt = phys.as_u64() + HHDM_RESPONSE.offset();
|
||||
let virt = phys.as_u64() + HHDM_RESPONSE.offset;
|
||||
let ptr = VirtAddr::new(virt).as_mut_ptr();
|
||||
let new_table: &PageTable = unsafe { &*ptr };
|
||||
iter_table(level - 1, new_table);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user