forked from LowLevelDevs/FoundryOS
Fixed most of the clippy warnings/suggestions.
This commit is contained in:
@@ -19,8 +19,8 @@ static TSS: Lazy<TaskStateSegment> = Lazy::new(|| {
|
||||
static mut STACK: [u8; STACK_SIZE] = [0; STACK_SIZE];
|
||||
|
||||
let stack_start = VirtAddr::from_ptr(&raw const STACK);
|
||||
let stack_end = stack_start + STACK_SIZE.try_into().unwrap();
|
||||
stack_end
|
||||
|
||||
stack_start + STACK_SIZE.try_into().unwrap()
|
||||
};
|
||||
tss
|
||||
});
|
||||
@@ -40,8 +40,8 @@ static GDT: Lazy<(GlobalDescriptorTable, Selectors)> = Lazy::new(|| {
|
||||
Selectors {
|
||||
code_selector,
|
||||
data_selector,
|
||||
user_code_selector,
|
||||
user_data_selector,
|
||||
_user_code_selector: user_code_selector,
|
||||
_user_data_selector: user_data_selector,
|
||||
tss_selector,
|
||||
},
|
||||
)
|
||||
@@ -50,8 +50,8 @@ static GDT: Lazy<(GlobalDescriptorTable, Selectors)> = Lazy::new(|| {
|
||||
struct Selectors {
|
||||
code_selector: SegmentSelector,
|
||||
data_selector: SegmentSelector,
|
||||
user_code_selector: SegmentSelector,
|
||||
user_data_selector: SegmentSelector,
|
||||
_user_code_selector: SegmentSelector,
|
||||
_user_data_selector: SegmentSelector,
|
||||
tss_selector: SegmentSelector,
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use lib_ascii::{print, println, println_log};
|
||||
use lib_ascii::println_log;
|
||||
use lib_serial::serial_println;
|
||||
use x86_64::instructions::port::Port;
|
||||
// use x86_64::instructions::port::Port;
|
||||
use x86_64::registers::control::Cr2;
|
||||
use x86_64::structures::idt::{InterruptDescriptorTable, InterruptStackFrame, PageFaultErrorCode};
|
||||
|
||||
@@ -81,7 +81,8 @@ extern "x86-interrupt" fn double_fault_handler(
|
||||
}
|
||||
|
||||
extern "x86-interrupt" fn keyboard_interrupt_handler(_stack_frame: InterruptStackFrame) {
|
||||
use pc_keyboard::{layouts, DecodedKey, HandleControl, Keyboard, ScancodeSet1};
|
||||
use pc_keyboard::{layouts, HandleControl, Keyboard, ScancodeSet1};
|
||||
// use pc_keyboard::DecodedKey;
|
||||
use spin::Mutex;
|
||||
use x86_64::instructions::port::Port;
|
||||
|
||||
@@ -93,7 +94,7 @@ extern "x86-interrupt" fn keyboard_interrupt_handler(_stack_frame: InterruptStac
|
||||
))
|
||||
});
|
||||
|
||||
let mut keyboard = KEYBOARD.lock();
|
||||
let _keyboard = KEYBOARD.lock();
|
||||
let mut port = Port::new(0x60);
|
||||
|
||||
let scancode: u8 = unsafe { port.read() };
|
||||
|
||||
@@ -35,7 +35,7 @@ static KERNEL_ADDRESS_REQUEST: KernelAddressRequest = KernelAddressRequest::new(
|
||||
/// ```
|
||||
///
|
||||
/// Returns (virtual_base, physical_base)
|
||||
pub static KERNEL_PHYSICAL_MEMORY_OFFSET: Lazy<(u64, u64)> = Lazy::new(|| {
|
||||
pub static _KERNEL_PHYSICAL_MEMORY_OFFSET: Lazy<(u64, u64)> = Lazy::new(|| {
|
||||
let resp = KERNEL_ADDRESS_REQUEST.get_response().unwrap();
|
||||
|
||||
// These are base addresses, using Limine's built in page table.
|
||||
@@ -49,7 +49,7 @@ pub static KERNEL_PHYSICAL_MEMORY_OFFSET: Lazy<(u64, u64)> = Lazy::new(|| {
|
||||
/// Panics if the memory map was not found in MEMORY_MAP_REQUEST.
|
||||
pub fn get_memory_map() -> &'static MemoryMapResponse {
|
||||
if let Some(memory_map) = MEMORY_MAP_REQUEST.get_response() {
|
||||
return memory_map;
|
||||
memory_map
|
||||
} else {
|
||||
unreachable!("Could not fetch memory map from Limine.")
|
||||
}
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
use lib_alloc::allocator::FoundryAllocator;
|
||||
// use lib_alloc::allocator::FoundryAllocator;
|
||||
use limine::{memory_map::EntryType, response::MemoryMapResponse};
|
||||
use x86_64::{
|
||||
addr,
|
||||
// addr,
|
||||
registers::control::Cr3,
|
||||
structures::paging::{
|
||||
page_table::FrameError, FrameAllocator, OffsetPageTable, PageTable, PhysFrame, Size4KiB,
|
||||
// page_table::FrameError,
|
||||
FrameAllocator,
|
||||
OffsetPageTable,
|
||||
PageTable,
|
||||
PhysFrame,
|
||||
Size4KiB,
|
||||
},
|
||||
PhysAddr, VirtAddr,
|
||||
PhysAddr,
|
||||
VirtAddr,
|
||||
};
|
||||
|
||||
/// Returns a mutable reference to the current level 4 page table.
|
||||
@@ -93,7 +99,6 @@ unsafe impl FrameAllocator<Size4KiB> for FoundryOSFrameAllocator {
|
||||
///
|
||||
/// - `Some(PhysFrame)`: If a usable frame is available.
|
||||
/// - `None`: If there are no more usable frames to allocate.
|
||||
|
||||
fn allocate_frame(&mut self) -> Option<PhysFrame> {
|
||||
let frame = self.usable_frames().nth(self.next);
|
||||
self.next += 1;
|
||||
|
||||
+5
-13
@@ -5,13 +5,13 @@ extern crate alloc;
|
||||
|
||||
use core::arch::asm;
|
||||
use lib_alloc::allocator::init_heap;
|
||||
use limine::request::{RequestsEndMarker, RequestsStartMarker};
|
||||
use limine::BaseRevision;
|
||||
|
||||
pub use lib_ascii::{print, print_log, println, println_log, WRITER};
|
||||
pub use lib_serial::{serial_print, serial_println, serial_read};
|
||||
use x86_64::structures::paging::Translate;
|
||||
use x86_64::{PhysAddr, VirtAddr};
|
||||
// use x86_64::structures::paging::Translate;
|
||||
// use x86_64::PhysAddr;
|
||||
use x86_64::VirtAddr;
|
||||
|
||||
mod arch;
|
||||
|
||||
@@ -23,14 +23,6 @@ mod arch;
|
||||
#[link_section = ".requests"]
|
||||
static BASE_REVISION: BaseRevision = BaseRevision::new();
|
||||
|
||||
/// Define the stand and end markers for Limine requests.
|
||||
#[used]
|
||||
#[link_section = ".requests_start_marker"]
|
||||
static _START_MARKER: RequestsStartMarker = RequestsStartMarker::new();
|
||||
#[used]
|
||||
#[link_section = ".requests_end_marker"]
|
||||
static _END_MARKER: RequestsEndMarker = RequestsEndMarker::new();
|
||||
|
||||
#[panic_handler]
|
||||
fn rust_panic(_info: &core::panic::PanicInfo) -> ! {
|
||||
println!("Kernel panic: {}", _info);
|
||||
@@ -82,8 +74,8 @@ pub fn boot() -> Result<(), &'static str> {
|
||||
println_log!("[Success]");
|
||||
|
||||
print_log!(" Initialising Heap... ");
|
||||
if let Err(e) = init_heap(&mut l4_table, &mut frame_allocator) {
|
||||
return Err("Failed to initialise heap");
|
||||
if init_heap(&mut l4_table, &mut frame_allocator).is_err() {
|
||||
return Err("Failed to initialise heap: error");
|
||||
}
|
||||
println_log!("[Success]");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user