Something went wrong. Try again.
A custom OS written in Zig
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031use core::fmt::Debug;use limine::request::HhdmRepsonse;
use crate::limine_requests::HHDM_REQUEST;
/// A wrapper around u64 that represents the actual HHDM offset, and cannot be accidentally made./// Remember though that even though this wraps unsafeness in safeness, it is only safe if the assumption that all available memory is mapped in the current Cr3 value according to the HHDM offset (and cache is not invalid)#[derive(Clone, Copy)]pub struct HhdmOffset(u64);
impl Debug for HhdmOffset { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { write!(f, "HhdmOffset(0x{:X})", self.0) }}
impl From<&'static HhdmRepsonse> for HhdmOffset { fn from(value: &'static HhdmRepsonse) -> Self { Self(value.offset) }}
impl From<HhdmOffset> for u64 { fn from(value: HhdmOffset) -> Self { value.0 }}
pub fn hhdm_offset() -> HhdmOffset { HHDM_REQUEST.response().unwrap().into()}