Messed with some stuff

This commit is contained in:
Arthur Beck 2025-02-20 17:04:23 -06:00
parent a9798a1ce8
commit 7bb8a99b56
Signed by: ArthurB
GPG key ID: ACE3D14F5CEF14BF
6 changed files with 27 additions and 8 deletions

View file

@ -4,7 +4,7 @@ CONT_WITH_DIFFERENT_VERSION=true
# Begin metadata
# Set VERSION=generate to attempt to autogenerate a version based on git information
# Set VERSION=generate(or unset) to attempt to autogenerate a version based on git information
VERSION=generate
# SUFFIX is unset

View file

@ -7,6 +7,9 @@
//! actual architecture, of course):
//! #![cfg(any(target_arch = "arch"))]
// DO NOT have this in your actual code:
#![allow(dead_code)]
/// Returns the most specific architecture available.
pub const fn get_arch() -> super::Architecture {
super::Architecture::ExampleDummy

View file

@ -13,7 +13,7 @@ pub enum PageDirectoryEntry {
}
impl PageDirectoryEntry {
const fn create_fourmb(
pub const fn create_fourmb(
mut bits32to22: u16,
bits39to32: u8,
pat: bool,
@ -64,7 +64,7 @@ impl PageDirectoryEntry {
Self::FourMb(out)
}
const fn create_other(
pub const fn create_other(
mut bits31to12: u32,
pat: bool,
mut available: u8,

View file

@ -22,7 +22,8 @@ fn indep_boot_entry(
) -> ! {
assert_ne!(
crate::arch::get_arch(),
crate::arch::Architecture::ExampleDummy
crate::arch::Architecture::ExampleDummy,
"Somehow the kernel successfully booted into IndepBootEntry with a dummy architecture"
);
crate::arch::output::sdebugsln("IndepBootEntry called");

View file

@ -76,6 +76,18 @@ fn get_allocator() -> Option<&'static MemoryMapAlloc<'static>> {
}
}
/// The unsafe counterpart of [MemMapAlloc()]. Doesn't check if the allocator is initalized.
/// Internally, uses [MaybeUninit::assume_init_ref].
///
/// # Safety
///
/// Calling this instead of [MemMapAlloc] or when the allocator is uninitalized causes
/// undefined behavior; check [MaybeUninit::assume_init_ref] for safety guarantees.
pub unsafe fn get_allocator_unchecked() -> &'static MemoryMapAlloc<'static> {
#[allow(static_mut_refs)]
unsafe { ALLOCATOR.assume_init_ref() }
}
#[kernel_item(MemMapAllocInit)]
fn memory_map_alloc_init(memmap: crate::boot::MemoryMap) -> Result<(), crate::Error<'static>> {
#[allow(static_mut_refs)]
@ -107,19 +119,19 @@ pub struct MemoryMapAlloc<'a> {
}
/// Too many allocations have been created, pushing the size of [MemoryMapAlloc::allocations] over [MemoryMapAlloc::max_allocations_size].
const TOO_MANY_ALLOCATIONS: i16 = -2;
pub const TOO_MANY_ALLOCATIONS: i16 = -2;
/// There isn't enough space for 32 allocations(the minimum available).
pub const ALLOCATIONS_NOT_ENOUGH_SPACE: i16 = -3;
/// The index provided to [MemoryMapAlloc::extend_allocation] is too big.
const EXTEND_ALLOCATION_INVALID_INDEX: i16 = -4;
pub const EXTEND_ALLOCATION_INVALID_INDEX: i16 = -4;
/// The allocation provided to [MemoryMapAlloc::extend_allocation] is unused.
const EXTEND_ALLOCATION_ALLOCATION_UNUSED: i16 = -5;
pub const EXTEND_ALLOCATION_ALLOCATION_UNUSED: i16 = -5;
/// The allocation provided to [MemoryMapAlloc::extend_allocation], if extended, would extend into another allocation.
const EXTEND_ALLOCATION_OTHER_ALLOCATION: i16 = -6;
pub const EXTEND_ALLOCATION_OTHER_ALLOCATION: i16 = -6;
impl<'a> Debug for MemoryMapAlloc<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {

View file

@ -4,6 +4,7 @@
#![warn(rustdoc::missing_crate_level_docs)]
#![deny(rustdoc::invalid_html_tags)]
#![deny(rustdoc::invalid_rust_codeblocks)]
#![deny(unsafe_op_in_unsafe_fn)]
// tidy-alphabetical-start
#![feature(ptr_metadata)]
#![feature(const_trait_impl)]
@ -48,10 +49,12 @@ pub use util::*;
#[allow(unused_imports)] // if there are no traits, then it gives a warning
pub use traits::*;
/// Returns the version of aphrodite.
pub const fn version() -> &'static str {
env!("VERSION")
}
/// Returns the version of the config for aphrodite.
pub const fn cfg_version() -> &'static str {
env!("CFG_VERSION")
}