diff --git a/Cargo.lock b/Cargo.lock index 9f8eee0..6afea4f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,15 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "acid_alloc" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b28c4f9c0c9c9c8f1045f71a22fd5f7524f562c086f604929492ea410dae8348" +dependencies = [ + "sptr", +] + [[package]] name = "acpi" version = "6.0.1" @@ -122,6 +131,7 @@ dependencies = [ name = "gila" version = "0.3.1" dependencies = [ + "acid_alloc", "acpi", "enumflags2", "fdt", @@ -312,6 +322,12 @@ dependencies = [ "lock_api", ] +[[package]] +name = "sptr" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cdeee85371b1ec1f4b305c91787271a39f56b66e673bdbd73b7742150de5b0e" + [[package]] name = "syn" version = "2.0.106" diff --git a/Cargo.toml b/Cargo.toml index 0bfe55d..ac45a84 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,7 @@ version = "0.3.1" edition = "2024" [dependencies] +acid_alloc = { version = "0.1.0", features = ["alloc"] } acpi = { version = "6.0.1", optional = true } enumflags2 = "0.7.12" fdt = { git = "https://github.com/repnop/fdt", version = "0.2.0-alpha1", optional = true } diff --git a/src/kernel/main.rs b/src/kernel/main.rs index 19bb4a8..4dc8ced 100644 --- a/src/kernel/main.rs +++ b/src/kernel/main.rs @@ -3,8 +3,6 @@ #![no_std] #![no_main] -#![feature(allocator_api)] -#![feature(str_from_raw_parts)] #![feature(abi_x86_interrupt)] mod arch; @@ -17,11 +15,12 @@ mod log; mod memory; mod panic; mod process; -#[macro_use] mod util; use arch::x86_64::interrupts::IDT; +use arch::x86_64::serial::SerialPort; use boot::{BASE_REVISION, params, *}; +use constants::*; use log::*; use memory::alloc::{ boxed::Box, @@ -31,8 +30,6 @@ use memory::alloc::{ }; use params::*; -use crate::arch::x86_64::serial::SerialPort; -use crate::constants::*; use lazy_static::lazy_static; use limine::firmware_type::FirmwareType; use spin::mutex::Mutex; diff --git a/src/kernel/memory.rs b/src/kernel/memory.rs index a28ad34..4b6a05e 100644 --- a/src/kernel/memory.rs +++ b/src/kernel/memory.rs @@ -5,6 +5,7 @@ use crate::boot::modules::MODULE_RESPONSE; use crate::boot::params::EXECUTABLE_FILE_RESPONSE; use crate::{LOGGER, LogLevel, format, log_info, log_trace}; use alloc::string::String; + use free_list::{AllocError, FreeList, PAGE_SIZE, PageRange}; use lazy_static::lazy_static; use limine::response::MemoryMapResponse; @@ -28,7 +29,7 @@ lazy_static! { } pub fn round_up_to(multiple: usize, input: usize) -> usize { - if input % multiple == 0 { + if input.is_multiple_of(multiple) { input } else { input - (input % multiple) + multiple @@ -36,7 +37,7 @@ pub fn round_up_to(multiple: usize, input: usize) -> usize { } fn round_down_to(multiple: usize, input: usize) -> usize { - if input % multiple == 0 { + if input.is_multiple_of(multiple) { input } else { input - (input % multiple) diff --git a/src/kernel/panic.rs b/src/kernel/panic.rs index ea7b578..fc08dc7 100644 --- a/src/kernel/panic.rs +++ b/src/kernel/panic.rs @@ -1,11 +1,9 @@ // Copyright (c) 2025 shibedrill // SPDX-License-Identifier: GPL-3.0-or-later -use core::arch::asm; use core::panic::*; use crate::format; - use crate::{LOGGER, LogLevel}; #[panic_handler] @@ -14,8 +12,6 @@ pub fn panic(info: &PanicInfo) -> ! { // TODO: If any userspace facilities are still working, *attempt* to flush panic info and // logs to disk or whatever else. Then kill all processes and reboot. loop { - unsafe { - asm!("nop"); - } + crate::arch::asm::nop(); } }