Format: Display memory values in hex

This commit is contained in:
August 2025-07-17 23:28:06 -04:00
parent 74ac9835c3
commit d1ea875699
Signed by: shibedrill
GPG Key ID: 5FE0CB25945EFAA2
5 changed files with 25 additions and 21 deletions

View File

@ -53,7 +53,7 @@ You do not need to clean any files after making changes. The `lib`, `kernel`, an
### Configuration
- Variable `LIMINEDIR`: Location of binary files for limine. Default is `/usr/share/limine`.
- Variable `TARGET`: rustc target triple to compile for. Default is `x86_64-unknown-none`. Options are listed [here](#targets).
- Variable `TARGET`: rustc target triple to compile for. Default is `x86_64-unknown-none`. Options are listed [in the targets section](#targets).
- Argument `-p`: Rust build profile to use. Default is `dev`. Options are `dev` and `release`.
> [!NOTE]
@ -70,7 +70,7 @@ Gila has four optional features, which I made optional in anticipation of a pote
### Targets
Gila currently supports four different CPU architectures:
Gila currently supports four different CPU architectures:
- `x86_64`
- `aarch64`

View File

@ -1,8 +1,15 @@
// Copyright (c) 2025 shibedrill
// SPDX-License-Identifier: GPL-3.0-or-later
#[cfg(not(any(target_arch = "x86_64", target_arch = "aarch64", target_arch = "riscv64", target_arch = "loongarch64")))]
compile_error!("Gila does not support compiling for this architecture! Supported architectures are: x86_64, aarch64, riscv64, loongarch64");
#[cfg(not(any(
target_arch = "x86_64",
target_arch = "aarch64",
target_arch = "riscv64",
target_arch = "loongarch64"
)))]
compile_error!(
"Gila does not support compiling for this architecture! Supported architectures are: x86_64, aarch64, riscv64, loongarch64"
);
#[cfg(target_arch = "x86_64")]
pub mod x86_64;

View File

@ -13,30 +13,22 @@ lazy_static! {
};
}
// For all these handlers, they will be called from a purely naked ASM
// For all these handlers, they will be called from a purely naked ASM
// function. That function will first push all registers to the stack.
// It is the responsibility of these functions to recover this info.
// Recoverable exception: Occurs on division failure.
#[unsafe(no_mangle)]
pub extern "C" fn x86_divide_error() {
}
pub extern "C" fn x86_divide_error() {}
// Recoverable exception: Occurs on failure in BOUND instruction.
#[unsafe(no_mangle)]
pub extern "C" fn x86_bound_range() {
}
pub extern "C" fn x86_bound_range() {}
// Recoverable exception: Invalid opcode.
#[unsafe(no_mangle)]
pub extern "C" fn x86_invalid_opcode() {
}
pub extern "C" fn x86_invalid_opcode() {}
// Recoverable exception: FPU not available or enabled.
#[unsafe(no_mangle)]
pub extern "C" fn x86_device_unavailable() {
}
pub extern "C" fn x86_device_unavailable() {}

View File

@ -5,7 +5,7 @@ use core::str;
#[unsafe(no_mangle)]
extern "C" fn double_fault(info: *const u8, info_len: usize) -> ! {
let info_slice = unsafe {&str::from_raw_parts(info, info_len)};
let info_slice = unsafe { &str::from_raw_parts(info, info_len) };
panic!("Double fault: {}", info_slice);
}
@ -13,4 +13,4 @@ extern "C" fn double_fault(info: *const u8, info_len: usize) -> ! {
pub extern "C" fn page_fault(addr: usize, info: *const u8, info_len: usize) -> ! {
let info_slice = unsafe { &str::from_raw_parts(info, info_len) };
panic!("Page fault at 0x{:X}: {}", addr, info_slice);
}
}

View File

@ -180,9 +180,14 @@ unsafe extern "C" fn main() -> ! {
log_trace!("{log_msg}");
let total = usable + reclaimable + hardware + unusable;
log_info!(
"Boot: Memory report:\n\t\tFree: {usable}\n\t\tAvailable: {reclaimable}\n\t\tUsable: {}\n\t\tHardware: {hardware}\n\t\tUnusable: {unusable}\n\t\tTotal: {}",
"Boot: Memory report:
\tFree: 0x{usable:X}
\tAvailable: 0x{reclaimable:X}
\tUsable: 0x{:X}
\tHardware: 0x{hardware:X}
\tUnusable: 0x{unusable:X}
\tTotal: 0x{total:X}",
usable + reclaimable,
total
);
} else {
panic!("Memory map contains no entries");