Compare commits
No commits in common. "c8886495a253aff7f6e47ac19fb67001228425fd" and "9a47052049e1c60719054ced57f46df69ac83e2d" have entirely different histories.
c8886495a2
...
9a47052049
73
Cargo.lock
generated
73
Cargo.lock
generated
@ -4,16 +4,13 @@ version = 4
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "acpi"
|
name = "acpi"
|
||||||
version = "6.0.1"
|
version = "5.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4c85d96f36022f650ee6f184f1353d077124754cecf6a3e91085a708495c6f5a"
|
checksum = "94476c7ef97af4c4d998b3f422c1b01d5211aad57c80ed200baf148d1f1efab6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bit_field",
|
"bit_field",
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"byteorder",
|
|
||||||
"log",
|
"log",
|
||||||
"pci_types",
|
|
||||||
"spinning_top",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -24,15 +21,15 @@ checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bit_field"
|
name = "bit_field"
|
||||||
version = "0.10.3"
|
version = "0.10.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1e4b40c7323adcfc0a41c4b88143ed58346ff65a288fc144329c5c45e05d70c6"
|
checksum = "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitflags"
|
name = "bitflags"
|
||||||
version = "2.9.4"
|
version = "2.9.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2261d10cca569e4643e526d8dc2e62e433cc8aba21ab764233731f8d369bf394"
|
checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "build_const"
|
name = "build_const"
|
||||||
@ -116,7 +113,6 @@ dependencies = [
|
|||||||
"num-derive",
|
"num-derive",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"raw-cpuid",
|
|
||||||
"spin 0.10.0",
|
"spin 0.10.0",
|
||||||
"talc",
|
"talc",
|
||||||
"tar-no-std",
|
"tar-no-std",
|
||||||
@ -159,9 +155,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "log"
|
name = "log"
|
||||||
version = "0.4.28"
|
version = "0.4.27"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432"
|
checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lzma-rs"
|
name = "lzma-rs"
|
||||||
@ -175,9 +171,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "memchr"
|
name = "memchr"
|
||||||
version = "2.7.6"
|
version = "2.7.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273"
|
checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-derive"
|
name = "num-derive"
|
||||||
@ -209,16 +205,6 @@ dependencies = [
|
|||||||
"portable-atomic",
|
"portable-atomic",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "pci_types"
|
|
||||||
version = "0.10.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c4325c6aa3cca3373503b1527e75756f9fbfe5fd76be4b4c8a143ee47430b8e0"
|
|
||||||
dependencies = [
|
|
||||||
"bit_field",
|
|
||||||
"bitflags",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "portable-atomic"
|
name = "portable-atomic"
|
||||||
version = "1.11.1"
|
version = "1.11.1"
|
||||||
@ -227,9 +213,9 @@ checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.101"
|
version = "1.0.95"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de"
|
checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
@ -243,20 +229,11 @@ dependencies = [
|
|||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "raw-cpuid"
|
|
||||||
version = "11.6.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "498cd0dc59d73224351ee52a95fee0f1a617a2eae0e7d9d720cc622c73a54186"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustversion"
|
name = "rustversion"
|
||||||
version = "1.0.22"
|
version = "1.0.21"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
|
checksum = "8a0d197bd2c9dc6e53b84da9556a69ba4cdfab8619eb41a8bd1cc2027a0f6b1d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "scopeguard"
|
name = "scopeguard"
|
||||||
@ -279,20 +256,11 @@ dependencies = [
|
|||||||
"lock_api",
|
"lock_api",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "spinning_top"
|
|
||||||
version = "0.3.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d96d2d1d716fb500937168cc09353ffdc7a012be8475ac7308e1bdf0e3923300"
|
|
||||||
dependencies = [
|
|
||||||
"lock_api",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "2.0.106"
|
version = "2.0.104"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6"
|
checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@ -310,20 +278,21 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tar-no-std"
|
name = "tar-no-std"
|
||||||
version = "0.4.2"
|
version = "0.3.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "715f9a4586706a61c571cb5ee1c3ac2bbb2cf63e15bce772307b95befef5f5ee"
|
checksum = "15574aa79d3c04a12f3cb53ff976d5571e53b9d8e0bdbe4021df0a06473dd1c9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"log",
|
"log",
|
||||||
|
"memchr",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-ident"
|
name = "unicode-ident"
|
||||||
version = "1.0.19"
|
version = "1.0.18"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d"
|
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "volatile"
|
name = "volatile"
|
||||||
|
|||||||
@ -4,7 +4,7 @@ version = "0.3.1"
|
|||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
acpi = { version = "6.0.1", optional = true }
|
acpi = { version = "5.2.0", optional = true }
|
||||||
enumflags2 = "0.7.12"
|
enumflags2 = "0.7.12"
|
||||||
fdt = { git = "https://github.com/repnop/fdt", version = "0.2.0-alpha1", optional = true }
|
fdt = { git = "https://github.com/repnop/fdt", version = "0.2.0-alpha1", optional = true }
|
||||||
flagset = "0.4.7"
|
flagset = "0.4.7"
|
||||||
@ -17,11 +17,10 @@ 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.10.0"
|
||||||
talc = "4.4.3"
|
talc = "4.4.3"
|
||||||
tar-no-std = "0.4.2"
|
tar-no-std = "0.3.4"
|
||||||
|
|
||||||
[target.'cfg(target_arch = "x86_64")'.dependencies]
|
[target.'cfg(target_arch = "x86_64")'.dependencies]
|
||||||
x86_64 = "0.15.2"
|
x86_64 = "0.15.2"
|
||||||
raw-cpuid = "11.6.0"
|
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "gila"
|
name = "gila"
|
||||||
|
|||||||
@ -28,12 +28,6 @@ pub fn write_cr3(val: u64) {
|
|||||||
unsafe { asm!("mov cr3, {0:r}", in(reg) val) }
|
unsafe { asm!("mov cr3, {0:r}", in(reg) val) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read_cr4() -> u64 {
|
|
||||||
let cr4: u64;
|
|
||||||
unsafe { asm!("mov {0:r}, cr4", out(reg) cr4) }
|
|
||||||
cr4
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn interrupt_disable() {
|
pub fn interrupt_disable() {
|
||||||
unsafe {
|
unsafe {
|
||||||
asm!("cli");
|
asm!("cli");
|
||||||
|
|||||||
@ -1,8 +1,7 @@
|
|||||||
// Copyright (c) 2025 shibedrill
|
// Copyright (c) 2025 shibedrill
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
use crate::LogLevel;
|
use crate::format;
|
||||||
use crate::{LOGGER, arch::asm::read_cr2, format, log_trace};
|
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use x86_64::structures::idt::*;
|
use x86_64::structures::idt::*;
|
||||||
|
|
||||||
@ -26,12 +25,6 @@ extern "x86-interrupt" fn double_fault(info: InterruptStackFrame, _: u64) -> ! {
|
|||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
extern "x86-interrupt" fn page_fault(info: InterruptStackFrame, errcode: PageFaultErrorCode) {
|
extern "x86-interrupt" fn page_fault(info: InterruptStackFrame, errcode: PageFaultErrorCode) {
|
||||||
let addr = read_cr2();
|
|
||||||
log_trace!(
|
|
||||||
"Fault: Page fault with address 0x{:x}, error code 0b{:b}",
|
|
||||||
addr,
|
|
||||||
errcode
|
|
||||||
);
|
|
||||||
if errcode.contains(PageFaultErrorCode::USER_MODE) {
|
if errcode.contains(PageFaultErrorCode::USER_MODE) {
|
||||||
// Fault occurred in usermode. Non fatal.
|
// Fault occurred in usermode. Non fatal.
|
||||||
todo!()
|
todo!()
|
||||||
@ -42,10 +35,13 @@ extern "x86-interrupt" fn page_fault(info: InterruptStackFrame, errcode: PageFau
|
|||||||
if errcode.contains(PageFaultErrorCode::PROTECTION_VIOLATION)
|
if errcode.contains(PageFaultErrorCode::PROTECTION_VIOLATION)
|
||||||
| errcode.contains(PageFaultErrorCode::MALFORMED_TABLE)
|
| errcode.contains(PageFaultErrorCode::MALFORMED_TABLE)
|
||||||
{
|
{
|
||||||
|
let addr = unsafe {
|
||||||
|
let a: usize;
|
||||||
|
core::arch::asm! {"mov {}, cr2", out(reg) a};
|
||||||
|
a
|
||||||
|
};
|
||||||
let info_formatted = format!("{info:#?}");
|
let info_formatted = format!("{info:#?}");
|
||||||
crate::interrupt::page_fault(addr, info_formatted)
|
crate::interrupt::page_fault(addr, info_formatted)
|
||||||
} else {
|
|
||||||
todo!()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -65,7 +65,7 @@ impl PageMapLevel5Entry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct PageMapLevel4 {
|
pub struct PageMapLevel4 {
|
||||||
pub entries: [PageMapLevel4Entry; 512],
|
entries: [PageMapLevel4Entry; 512],
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct PageMapLevel4Entry {
|
pub struct PageMapLevel4Entry {
|
||||||
|
|||||||
@ -25,7 +25,6 @@ use arch::x86_64::serial::Serialport;
|
|||||||
|
|
||||||
use boot::{modules::*, params, *};
|
use boot::{modules::*, params, *};
|
||||||
use constants::*;
|
use constants::*;
|
||||||
use intbits::Bits;
|
|
||||||
use limine::firmware_type::FirmwareType;
|
use limine::firmware_type::FirmwareType;
|
||||||
use log::*;
|
use log::*;
|
||||||
use memory::alloc::{format, string::*, vec};
|
use memory::alloc::{format, string::*, vec};
|
||||||
@ -36,17 +35,11 @@ use limine::memory_map::EntryType;
|
|||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use lzma_rs::lzma_decompress;
|
use lzma_rs::lzma_decompress;
|
||||||
|
|
||||||
use crate::arch::paging::PageMapLevel4;
|
|
||||||
use crate::arch::x86_64::interrupts::IDT;
|
|
||||||
|
|
||||||
#[unsafe(no_mangle)]
|
#[unsafe(no_mangle)]
|
||||||
unsafe extern "C" fn main() -> ! {
|
unsafe extern "C" fn main() -> ! {
|
||||||
// Assert supported bootloader version
|
// Assert supported bootloader version
|
||||||
assert!(BASE_REVISION.is_supported());
|
assert!(BASE_REVISION.is_supported());
|
||||||
|
|
||||||
// Ensure IDT exists
|
|
||||||
IDT.load();
|
|
||||||
|
|
||||||
// Set up logging level from params
|
// Set up logging level from params
|
||||||
// Nothing we can do here if this fails since no log subscribers are initialized yet
|
// Nothing we can do here if this fails since no log subscribers are initialized yet
|
||||||
if let Some(level) = PARAMS.get("-loglevel")
|
if let Some(level) = PARAMS.get("-loglevel")
|
||||||
@ -203,30 +196,6 @@ unsafe extern "C" fn main() -> ! {
|
|||||||
|
|
||||||
log_info!("HHDM offset: 0x{:X}", HHDM_RESPONSE.offset());
|
log_info!("HHDM offset: 0x{:X}", HHDM_RESPONSE.offset());
|
||||||
|
|
||||||
log_info!("Paging: {}", arch::asm::read_cr0().bit(31));
|
|
||||||
log_info!("Protection: {}", arch::asm::read_cr0().bit(0));
|
|
||||||
log_info!(
|
|
||||||
"Physical Address Extensions: {}",
|
|
||||||
arch::asm::read_cr4().bit(5)
|
|
||||||
);
|
|
||||||
log_info!("Page Size Extensions: {}", arch::asm::read_cr4().bit(4));
|
|
||||||
log_info!(
|
|
||||||
"Paging mode: {}",
|
|
||||||
match memory::PAGING_REQUEST.get_response().unwrap().mode() {
|
|
||||||
limine::paging::Mode::FOUR_LEVEL => "Four-Level",
|
|
||||||
limine::paging::Mode::FIVE_LEVEL => "Five-Level",
|
|
||||||
_ => unreachable!(),
|
|
||||||
}
|
|
||||||
);
|
|
||||||
log_info!("CR3 Value: 0b{:064b}", arch::asm::read_cr3());
|
|
||||||
// Physical address of Page Map Level 4 Table
|
|
||||||
let pml4_ptr = ((arch::asm::read_cr3().bits(12..=63) << 12) + HHDM_RESPONSE.offset())
|
|
||||||
as *const PageMapLevel4;
|
|
||||||
log_info!("Page Map Level 4 Table Address: 0x{:x}", pml4_ptr.addr());
|
|
||||||
log_info!("Physical address of first entry: {}", unsafe {
|
|
||||||
(*pml4_ptr).entries[0].physical_address()
|
|
||||||
});
|
|
||||||
|
|
||||||
panic!("Bailing");
|
panic!("Bailing");
|
||||||
|
|
||||||
#[allow(unreachable_code)]
|
#[allow(unreachable_code)]
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use limine::{
|
use limine::{
|
||||||
request::{ExecutableAddressRequest, HhdmRequest, MemoryMapRequest, PagingModeRequest},
|
request::{ExecutableAddressRequest, HhdmRequest, MemoryMapRequest},
|
||||||
response::HhdmResponse,
|
response::HhdmResponse,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -11,10 +11,6 @@ use talc::*;
|
|||||||
|
|
||||||
pub extern crate alloc;
|
pub extern crate alloc;
|
||||||
|
|
||||||
#[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 =
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user