More testing with GDT
All checks were successful
Continuous Integration / Check (push) Successful in 58s
Continuous Integration / Clippy (push) Successful in 49s

This commit is contained in:
August 2026-06-26 12:15:45 +00:00
parent cc2d5cfea9
commit f438a722f6
Signed by: shibedrill
SSH Key Fingerprint: SHA256:M0m3JW1s38BgO2t0fG146Yxd9OJ2IOqkvCAsuRHQ6Pw
10 changed files with 118 additions and 107 deletions

68
Cargo.lock generated
View File

@ -13,15 +13,15 @@ dependencies = [
[[package]] [[package]]
name = "align-address" name = "align-address"
version = "0.3.0" version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ac6c08a67736554282858203cd9b7ff53cf55f54c34e85689962748a350cbf0" checksum = "cee078b3ed87e2621e0389729e2f032cc0408a4548768ced01678c9451c62237"
[[package]] [[package]]
name = "autocfg" name = "autocfg"
version = "1.5.0" version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
[[package]] [[package]]
name = "bit_field" name = "bit_field"
@ -31,9 +31,15 @@ checksum = "1e4b40c7323adcfc0a41c4b88143ed58346ff65a288fc144329c5c45e05d70c6"
[[package]] [[package]]
name = "bitflags" name = "bitflags"
version = "2.10.0" version = "2.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index" 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]] [[package]]
name = "critical-section" name = "critical-section"
@ -69,9 +75,9 @@ checksum = "b7ac824320a75a52197e8f2d787f6a38b6718bb6897a35142d749af3c0e8f4fe"
[[package]] [[package]]
name = "free-list" name = "free-list"
version = "0.3.1" version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "810f338a4ef98f319a279c9199f35d7ec366c6002ca6a8f18fdcc94cfef9afab" checksum = "358d33fcfc734d809ab9d4c45de31f1e73e3b973656deaff0db3cd5951782134"
dependencies = [ dependencies = [
"align-address", "align-address",
"smallvec", "smallvec",
@ -100,7 +106,7 @@ dependencies = [
"num-traits", "num-traits",
"once_cell", "once_cell",
"raw-cpuid", "raw-cpuid",
"spin 0.10.0", "spin 0.12.1",
"talc", "talc",
"x86_64", "x86_64",
] ]
@ -124,12 +130,9 @@ dependencies = [
[[package]] [[package]]
name = "limine" name = "limine"
version = "0.5.0" version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af6d2ee42712e7bd2c787365cd1dab06ef59a61becbf87bec7b32b970bd2594b" checksum = "29363c0f37e66e18575fadf7141c56ee7ea04ae5fecbeb25eff303f77af203a9"
dependencies = [
"bitflags",
]
[[package]] [[package]]
name = "lock_api" name = "lock_api"
@ -162,9 +165,9 @@ dependencies = [
[[package]] [[package]]
name = "once_cell" name = "once_cell"
version = "1.21.3" version = "1.21.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
dependencies = [ dependencies = [
"critical-section", "critical-section",
"portable-atomic", "portable-atomic",
@ -172,24 +175,24 @@ dependencies = [
[[package]] [[package]]
name = "portable-atomic" name = "portable-atomic"
version = "1.11.1" version = "1.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483" checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49"
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.103" version = "1.0.106"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8" checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
dependencies = [ dependencies = [
"unicode-ident", "unicode-ident",
] ]
[[package]] [[package]]
name = "quote" name = "quote"
version = "1.0.42" version = "1.0.46"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f" checksum = "dfbc457d0c7a0759a614551b11a6409e5951f6c7537be1f1b7682b9ae9230368"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
] ]
@ -217,9 +220,9 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]] [[package]]
name = "smallvec" name = "smallvec"
version = "1.15.1" version = "1.15.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" checksum = "8ed6a63f02c8539c91a8685a86f4099661ba3da017932f6ebbea6de3f0fa7c90"
[[package]] [[package]]
name = "spin" name = "spin"
@ -229,9 +232,9 @@ checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
[[package]] [[package]]
name = "spin" name = "spin"
version = "0.10.0" version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d5fe4ccb98d9c292d56fec89a5e07da7fc4cf0dc11e156b41793132775d3e591" checksum = "bd5231412d905519dca6a5deb0327d407be68d6c941feec004533401d3a0a715"
dependencies = [ dependencies = [
"lock_api", "lock_api",
] ]
@ -244,9 +247,9 @@ checksum = "5cdeee85371b1ec1f4b305c91787271a39f56b66e673bdbd73b7742150de5b0e"
[[package]] [[package]]
name = "syn" name = "syn"
version = "2.0.110" version = "2.0.118"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a99801b5bd34ede4cf3fc688c5919368fea4e4814a4664359503e6015b280aea" checksum = "1b9ae57f904213ebb649ce6895b8a66c66f0203b9319718f69a5612a065b1422"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -264,9 +267,9 @@ dependencies = [
[[package]] [[package]]
name = "unicode-ident" name = "unicode-ident"
version = "1.0.22" version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
[[package]] [[package]]
name = "volatile" name = "volatile"
@ -276,12 +279,13 @@ checksum = "442887c63f2c839b346c192d047a7c87e73d0689c9157b00b53dcc27dd5ea793"
[[package]] [[package]]
name = "x86_64" name = "x86_64"
version = "0.15.2" version = "0.15.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f042214de98141e9c8706e8192b73f56494087cc55ebec28ce10f26c5c364ae" checksum = "f7841fa0098ceb15c567d93d3fae292c49e10a7662b4936d5f6a9728594555ba"
dependencies = [ dependencies = [
"bit_field", "bit_field",
"bitflags", "bitflags",
"const_fn",
"rustversion", "rustversion",
"volatile", "volatile",
] ]

View File

@ -11,11 +11,11 @@ flagset = "0.4.7"
free-list = { version = "0.3.1", features = ["x86_64"] } free-list = { version = "0.3.1", features = ["x86_64"] }
intbits = "0.2.0" intbits = "0.2.0"
lazy_static = { version = "1.5.0", default-features = false, features = ["spin_no_std"] } 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-derive = "0.4.2"
num-traits = { version = "0.2.19", default-features = false } num-traits = { version = "0.2.19", default-features = false }
once_cell = { version = "1.21.3", default-features = false, features = ["alloc", "critical-section"] } 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" talc = "4.4.3"
libgila = { path = "../libgila" } libgila = { path = "../libgila" }

View File

@ -61,8 +61,9 @@ pub fn dump_gdt() {
let flags = x86_64::structures::gdt::DescriptorFlags::from_bits_retain(entry.raw()); let flags = x86_64::structures::gdt::DescriptorFlags::from_bits_retain(entry.raw());
let seg_type = SegmentType::try_from(entry); let seg_type = SegmentType::try_from(entry);
log_info!( 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(), seg_type.unwrap(),
entry.access().bits(5..=6),
if flags.contains(gdt::DescriptorFlags::DEFAULT_SIZE) { if flags.contains(gdt::DescriptorFlags::DEFAULT_SIZE) {
"32-bit" "32-bit"
} else if flags.contains(gdt::DescriptorFlags::LONG_MODE) { } else if flags.contains(gdt::DescriptorFlags::LONG_MODE) {
@ -71,7 +72,7 @@ pub fn dump_gdt() {
"16-bit" "16-bit"
}, },
entry.raw().bits(52..=55), entry.raw().bits(52..=55),
entry.access() entry.access(),
); );
} }
} }

View File

@ -4,7 +4,7 @@
pub mod modules; pub mod modules;
pub mod params; pub mod params;
use limine::{BaseRevision, request::*}; use limine::{BaseRevision, RequestsEndMarker, RequestsStartMarker, request::*};
#[used] #[used]
#[unsafe(link_section = ".requests_start_marker")] #[unsafe(link_section = ".requests_start_marker")]
@ -20,7 +20,7 @@ pub static BASE_REVISION: BaseRevision = limine::BaseRevision::new();
#[used] #[used]
#[unsafe(link_section = ".requests")] #[unsafe(link_section = ".requests")]
pub static MP_REQUEST: MpRequest = limine::request::MpRequest::new(); pub static MP_REQUEST: MpRequest = limine::request::MpRequest::new(0);
#[used] #[used]
#[unsafe(link_section = ".requests")] #[unsafe(link_section = ".requests")]
@ -29,3 +29,7 @@ pub static FRAMEBUFFER_REQUEST: FramebufferRequest = limine::request::Framebuffe
#[used] #[used]
#[unsafe(link_section = ".requests")] #[unsafe(link_section = ".requests")]
pub static FIRMWARE_TYPE_REQUEST: FirmwareTypeRequest = limine::request::FirmwareTypeRequest::new(); pub static FIRMWARE_TYPE_REQUEST: FirmwareTypeRequest = limine::request::FirmwareTypeRequest::new();
#[used]
#[unsafe(link_section = ".requests")]
pub static RSDP_REQUEST: RsdpRequest = limine::request::RsdpRequest::new();

View File

@ -5,10 +5,7 @@ use crate::format;
use crate::memory::alloc::string::String; use crate::memory::alloc::string::String;
use crate::{LOGGER, LogLevel, log_trace}; use crate::{LOGGER, LogLevel, log_trace};
use lazy_static::lazy_static; use lazy_static::lazy_static;
use limine::{ use limine::request::*;
request::{ExecutableFileRequest, ModuleRequest},
response::ModuleResponse,
};
#[used] #[used]
#[unsafe(link_section = ".requests")] #[unsafe(link_section = ".requests")]
@ -16,10 +13,10 @@ pub static FILE_REQUEST: ExecutableFileRequest = limine::request::ExecutableFile
#[used] #[used]
#[unsafe(link_section = ".requests")] #[unsafe(link_section = ".requests")]
pub static MODULE_REQUEST: ModuleRequest = limine::request::ModuleRequest::new(); pub static MODULE_REQUEST: ModulesRequest = limine::request::ModulesRequest::new();
lazy_static! { 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() { pub fn log_modules() {
@ -29,7 +26,7 @@ pub fn log_modules() {
for module in modules.modules() { for module in modules.modules() {
log_msg.push_str(&format!( log_msg.push_str(&format!(
"\t{}", "\t{}",
String::from_utf8_lossy(module.path().to_bytes()) String::from_utf8_lossy(module.path().as_bytes())
)); ));
} }
log_trace!("{log_msg}") log_trace!("{log_msg}")

View File

@ -6,14 +6,18 @@ use crate::memory::alloc;
use alloc::string::String; use alloc::string::String;
use alloc::vec::Vec; use alloc::vec::Vec;
use lazy_static::lazy_static; use lazy_static::lazy_static;
use limine::response::ExecutableFileResponse; use limine::request::ExecutableFileResponse;
lazy_static! { lazy_static! {
pub static ref EXECUTABLE_FILE_RESPONSE: &'static ExecutableFileResponse = FILE_REQUEST pub static ref EXECUTABLE_FILE_RESPONSE: &'static ExecutableFileResponse = FILE_REQUEST
.get_response() .response()
.expect("Bootloader did not return executable data"); .expect("Bootloader did not return executable data");
pub static ref PARAMS: KernelParameters = pub static ref PARAMS: KernelParameters = get_kernel_params(
get_kernel_params(limine::file::File::string(EXECUTABLE_FILE_RESPONSE.file()).to_bytes()); EXECUTABLE_FILE_RESPONSE
.executable_file()
.cmdline()
.as_bytes()
);
} }
pub type KernelParameters = alloc::collections::BTreeMap<String, String>; pub type KernelParameters = alloc::collections::BTreeMap<String, String>;

View File

@ -21,11 +21,13 @@ use arch::x86_64::serial::SerialPort;
use boot::{BASE_REVISION, params, *}; use boot::{BASE_REVISION, params, *};
use constants::*; use constants::*;
use log::*; use log::*;
use memory::alloc::{boxed::Box, format, string::String, vec}; use memory::alloc::{boxed::Box, format, vec};
use params::*; use params::*;
use lazy_static::lazy_static; 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 spin::mutex::Mutex;
use crate::{ use crate::{
@ -86,13 +88,11 @@ unsafe extern "C" fn main() -> ! {
log_info!( log_info!(
"Kernel cmdline: {}", "Kernel cmdline: {}",
String::from_utf8_lossy( EXECUTABLE_FILE_RESPONSE.executable_file().cmdline()
limine::file::File::string(EXECUTABLE_FILE_RESPONSE.file()).to_bytes()
)
); );
log_info!( log_info!(
"Kernel file path: {}", "Kernel file path: {}",
String::from_utf8_lossy(EXECUTABLE_FILE_RESPONSE.file().path().to_bytes()) EXECUTABLE_FILE_RESPONSE.executable_file().path()
); );
// Branding // Branding
@ -106,14 +106,14 @@ unsafe extern "C" fn main() -> ! {
.log_writeln("\tWelcome to the Gila microkernel!\n"); .log_writeln("\tWelcome to the Gila microkernel!\n");
log_info!("Booting gila version {}", kernel_version_string()); 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!( Some(resp) => log_info!(
"Firmware type: {}", "Firmware type: {}",
match resp.firmware_type() { match resp.firmware_type {
FirmwareType::SBI => "SBI", FIRMWARE_TYPE_SBI => "SBI",
FirmwareType::UEFI_32 => "UEFI (32-bit)", FIRMWARE_TYPE_EFI32 => "UEFI (32-bit)",
FirmwareType::UEFI_64 => "UEFI (64-bit)", FIRMWARE_TYPE_EFI64 => "UEFI (64-bit)",
FirmwareType::X86_BIOS => "x86 BIOS", FIRMWARE_TYPE_X86BIOS => "x86 BIOS",
_ => "Unknown", _ => "Unknown",
} }
), ),
@ -122,20 +122,22 @@ unsafe extern "C" fn main() -> ! {
log_info!("Trans rights!"); log_info!("Trans rights!");
if let Some(framebuffer_response) = FRAMEBUFFER_REQUEST.get_response() { if let Some(framebuffer_response) = FRAMEBUFFER_REQUEST.response() {
let fb = framebuffer_response.framebuffers().next().unwrap(); let fb = framebuffer_response.framebuffers_rev1().unwrap()[0];
log_info!("Framebuffer response received"); log_info!("Framebuffer response received");
log_trace!( for mode in fb.modes() {
"Framebuffer dimensions: {}x{}, {} bits per pixel", log_trace!(
fb.width(), "Mode: {}x{}, {} bits per pixel",
fb.height(), mode.width,
fb.bpp() mode.height,
); mode.bpp
);
}
} else { } else {
log_info!("Framebuffer response absent, graphics disabled",); log_info!("Framebuffer response absent, graphics disabled",);
} }
let smp_response = MP_REQUEST.get_response(); let smp_response = MP_REQUEST.response();
match smp_response { match smp_response {
None => log_info!("Multiprocessing response not received"), None => log_info!("Multiprocessing response not received"),
Some(resp) => { 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(); boot::modules::log_modules();
memory::log_memory(); 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!("Physical address of current L4 table: 0x{:x}", l4_start);
log_info!( log_info!(
"Virtual address of current L4 table: 0x{:x}", "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); //iter_table(4, &PML4);

View File

@ -9,12 +9,9 @@ use crate::{LOGGER, LogLevel, format};
use alloc::string::String; use alloc::string::String;
use lazy_static::lazy_static; use lazy_static::lazy_static;
use limine::response::MemoryMapResponse; use limine::memmap::*;
use limine::{ use limine::request::{ExecutableAddressRequest, HhdmRepsonse, HhdmRequest};
memory_map::EntryType, use limine::request::{MemmapRequest, MemmapResponse};
request::{ExecutableAddressRequest, HhdmRequest, MemoryMapRequest, PagingModeRequest},
response::HhdmResponse,
};
use talc::*; use talc::*;
pub extern crate alloc; pub extern crate alloc;
@ -22,8 +19,8 @@ pub extern crate alloc;
pub mod paging; pub mod paging;
lazy_static! { lazy_static! {
pub static ref MEMMAP_RESPONSE: &'static MemoryMapResponse = MEMMAP_REQUEST pub static ref MEMMAP_RESPONSE: &'static MemmapResponse = MEMMAP_REQUEST
.get_response() .response()
.expect("Bootloader did not supply memory map"); .expect("Bootloader did not supply memory map");
} }
@ -40,37 +37,36 @@ pub fn log_memory() {
entry.length, entry.length,
entry.length as usize / PAGE_SIZE, entry.length as usize / PAGE_SIZE,
entry.base, entry.base,
match entry.entry_type { match entry.type_ {
EntryType::ACPI_NVS => { MEMMAP_ACPI_NVS => {
hardware += entry.length; hardware += entry.length;
"ACPI (reserved)" "ACPI (reserved)"
} }
EntryType::ACPI_RECLAIMABLE => { MEMMAP_ACPI_RECLAIMABLE => {
reclaimable += entry.length; reclaimable += entry.length;
"ACPI (reclaimable)" "ACPI (reclaimable)"
} }
EntryType::BAD_MEMORY => { MEMMAP_BAD_MEMORY => {
unusable += entry.length; unusable += entry.length;
"damaged/unusable" "damaged/unusable"
} }
EntryType::BOOTLOADER_RECLAIMABLE => { MEMMAP_BOOTLOADER_RECLAIMABLE => {
reclaimable += entry.length; reclaimable += entry.length;
"bootloader (reclaimable)" "bootloader (reclaimable)"
} }
#[allow(unreachable_patterns, deprecated)] MEMMAP_EXECUTABLE_AND_MODULES => {
EntryType::EXECUTABLE_AND_MODULES | EntryType::KERNEL_AND_MODULES => {
unusable += entry.length; unusable += entry.length;
"executable & modules" "executable & modules"
} }
EntryType::FRAMEBUFFER => { MEMMAP_FRAMEBUFFER => {
hardware += entry.length; hardware += entry.length;
"framebuffer" "framebuffer"
} }
EntryType::RESERVED => { MEMMAP_RESERVED => {
unusable += entry.length; unusable += entry.length;
"reserved" "reserved"
} }
EntryType::USABLE => { MEMMAP_USABLE => {
usable += entry.length; usable += entry.length;
"usable" "usable"
} }
@ -90,22 +86,19 @@ pub fn log_memory() {
} }
pub fn log_address() { pub fn log_address() {
if let Some(resp) = ADDRESS_REQUEST.get_response() { if let Some(resp) = ADDRESS_REQUEST.response() {
log_info!( log_info!("Kernel physical start address: 0x{:x}", resp.physical_base);
"Kernel physical start address: 0x{:x}", log_info!("Kernel virtual start address: 0x{:x}", resp.virtual_base);
resp.physical_base()
);
log_info!("Kernel virtual start address: 0x{:x}", resp.virtual_base());
log_info!( log_info!(
"Kernel physical start address (calculated): 0x{:x}", "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 { } else {
log_warning!("No kernel address response provided."); log_warning!("No kernel address response provided.");
} }
log_info!( log_info!(
"Higher Half direct map offset: 0x{:x}", "Higher Half direct map offset: 0x{:x}",
HHDM_RESPONSE.offset() HHDM_RESPONSE.offset
); );
} }
@ -117,10 +110,6 @@ pub fn init_statics() {
let _ = MEMMAP_RESPONSE; let _ = MEMMAP_RESPONSE;
} }
#[used]
#[unsafe(link_section = ".requests")]
pub static PAGING_REQUEST: PagingModeRequest = limine::request::PagingModeRequest::new();
#[used] #[used]
#[unsafe(link_section = ".requests")] #[unsafe(link_section = ".requests")]
pub static ADDRESS_REQUEST: ExecutableAddressRequest = pub static ADDRESS_REQUEST: ExecutableAddressRequest =
@ -128,15 +117,15 @@ pub static ADDRESS_REQUEST: ExecutableAddressRequest =
#[used] #[used]
#[unsafe(link_section = ".requests")] #[unsafe(link_section = ".requests")]
pub static MEMMAP_REQUEST: MemoryMapRequest = limine::request::MemoryMapRequest::new(); pub static MEMMAP_REQUEST: MemmapRequest = limine::request::MemmapRequest::new();
#[used] #[used]
#[unsafe(link_section = ".requests")] #[unsafe(link_section = ".requests")]
pub static HHDM_REQUEST: HhdmRequest = limine::request::HhdmRequest::new(); pub static HHDM_REQUEST: HhdmRequest = limine::request::HhdmRequest::new();
lazy_static! { lazy_static! {
pub static ref HHDM_RESPONSE: &'static HhdmResponse = HHDM_REQUEST pub static ref HHDM_RESPONSE: &'static HhdmRepsonse = HHDM_REQUEST
.get_response() .response()
.expect("Did not get HHDM response from bootloader"); .expect("Did not get HHDM response from bootloader");
} }

View File

@ -14,7 +14,7 @@ pub unsafe fn active_level_4_table() -> &'static mut PageTable {
let (level_4_table_frame, _) = Cr3::read(); let (level_4_table_frame, _) = Cr3::read();
let phys = level_4_table_frame.start_address(); 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(); let page_table_ptr: *mut PageTable = virt.as_mut_ptr();
unsafe { &mut *page_table_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); log_info!("L{} Entry {}: {:?}", level, i, entry);
if (level > 1) & !entry.flags().contains(PageTableFlags::HUGE_PAGE) { if (level > 1) & !entry.flags().contains(PageTableFlags::HUGE_PAGE) {
let phys = entry.frame().unwrap().start_address(); 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 ptr = VirtAddr::new(virt).as_mut_ptr();
let new_table: &PageTable = unsafe { &*ptr }; let new_table: &PageTable = unsafe { &*ptr };
iter_table(level - 1, new_table); iter_table(level - 1, new_table);

View File

@ -19,8 +19,9 @@ pkgs.mkShell {
]; ];
shellHook = '' shellHook = ''
echo $TMPDIR;
rustup default nightly; rustup default nightly;
rustup target add x86_64-unknown-none rustup target add x86_64-unknown-none;
export LIMINEDIR="${pkgs.limine-full}/share/limine" export LIMINEDIR="${pkgs.limine-full}/share/limine"
''; '';