Bump edition to now stable 2024 edition (shiny!).

This commit is contained in:
2025-02-23 11:52:54 +00:00
parent 9f83c5f295
commit b8aa203c05
14 changed files with 214 additions and 171 deletions
+4 -2
View File
@@ -1,7 +1,8 @@
[package]
name = "foundry_os"
version = "0.1.0"
edition = "2021"
edition.workspace = true
version.workspace = true
authors.workspace = true
[dependencies]
limine = "0.3.1"
@@ -20,3 +21,4 @@ default = []
[[bin]]
name = "kernel"
path = "src/main.rs"
test = false
+3 -3
View File
@@ -7,11 +7,11 @@ use limine::{
use spin::Lazy;
#[used]
#[link_section = ".requests"]
#[unsafe(link_section = ".requests")]
static MEMORY_MAP_REQUEST: MemoryMapRequest = MemoryMapRequest::new();
#[used]
#[link_section = ".requests"]
#[unsafe(link_section = ".requests")]
static HIGHER_HALF_DIRECT_MAP_REQUEST: HhdmRequest = HhdmRequest::new();
/// ```rs
@@ -26,7 +26,7 @@ pub static PHYSICAL_MEMORY_OFFSET: Lazy<u64> = Lazy::new(|| {
});
#[used]
#[link_section = ".requests"]
#[unsafe(link_section = ".requests")]
static KERNEL_ADDRESS_REQUEST: KernelAddressRequest = KernelAddressRequest::new();
/// Converts virtual addresses in the kernel to a physical address like this:
+8 -6
View File
@@ -1,6 +1,8 @@
// use lib_alloc::allocator::FoundryAllocator;
use limine::{memory_map::EntryType, response::MemoryMapResponse};
use x86_64::{
PhysAddr,
VirtAddr,
// addr,
registers::control::Cr3,
structures::paging::{
@@ -11,8 +13,6 @@ use x86_64::{
PhysFrame,
Size4KiB,
},
PhysAddr,
VirtAddr,
};
/// Returns a mutable reference to the current level 4 page table.
@@ -27,7 +27,7 @@ unsafe fn active_l4_table(physical_memory_offset: VirtAddr) -> &'static mut Page
let phys_addr = level_4_frame.start_address();
let virt = phys_addr.as_u64() + physical_memory_offset.as_u64();
&mut *(virt as *mut PageTable)
unsafe { &mut *(virt as *mut PageTable) }
}
/// Initializes the `OffsetPageTable` for the current CPU architecture.
@@ -49,8 +49,10 @@ unsafe fn active_l4_table(physical_memory_offset: VirtAddr) -> &'static mut Page
/// Returns an `OffsetPageTable` that allows for manipulation of the page
/// tables for the current CPU architecture.
pub unsafe fn init(physical_memory_offset: VirtAddr) -> OffsetPageTable<'static> {
let l4_table = active_l4_table(physical_memory_offset);
OffsetPageTable::new(l4_table, physical_memory_offset)
unsafe {
let l4_table = active_l4_table(physical_memory_offset);
OffsetPageTable::new(l4_table, physical_memory_offset)
}
}
pub(crate) struct FoundryOSFrameAllocator {
@@ -76,7 +78,7 @@ impl FoundryOSFrameAllocator {
/// Yields one `PhysFrame` for each available 4KiB frame in the memory map.
///
/// This function is used to allocate frames for the pagemap.
fn usable_frames(&self) -> impl Iterator<Item = PhysFrame> {
fn usable_frames(&self) -> impl Iterator<Item = PhysFrame> + use<> {
let regions = self.memory_map.entries().iter();
let usable_regions = regions.filter(|region| region.entry_type == EntryType::USABLE);
+1 -1
View File
@@ -18,7 +18,7 @@ mod arch;
/// Be sure to mark all limine requests with #[used], otherwise they may be removed by the compiler.
#[used]
// The .requests section allows limine to find the requests faster and more safely.
#[link_section = ".requests"]
#[unsafe(link_section = ".requests")]
static BASE_REVISION: BaseRevision = BaseRevision::new();
#[panic_handler]
+1 -1
View File
@@ -9,7 +9,7 @@ use libk::{
scheduling::task::{Executor, Task},
};
#[no_mangle]
#[unsafe(no_mangle)]
extern "C" fn kmain() -> ! {
println_log!(" [ Initialising Kernel Systems ] ");
if let Err(err) = foundry_os::boot() {