Lots of warnings but clippy is setup now

This commit is contained in:
Arthur Beck 2025-02-22 15:59:10 -06:00
parent 3c13ffe6ae
commit c5ec673970
Signed by: ArthurB
GPG key ID: ACE3D14F5CEF14BF
15 changed files with 49 additions and 22 deletions

View file

@ -96,10 +96,13 @@
real_target=$(basename $real_target) real_target=$(basename $real_target)
if [[ $check = "true" ]]; then if [[ $check = "true" ]]; then
echo "[INFO] Checking target $target(with rust target of $real_target)" echo "[INFO] Checking target $target(with rust target of $real_target)"
cargo check --target "$real_target" --release -Zbuild-std=core,alloc --bin entrypoint_$target cargo clippy --target "$real_target" --release -Zbuild-std=core,alloc --bin entrypoint_$target
else else
echo "[INFO] Compiling target $target(with rust target of $real_target)" echo "[INFO] Compiling target $target(with rust target of $real_target)"
cargo build --target "$real_target" --release -Zbuild-std=core,alloc --bin entrypoint_$target echo "[INFO] Running clippy"
cargo clippy --target "$real_target" --release -Zbuild-std=core,alloc --bin entrypoint_$target
echo "[INFO] Building"
cargo build --target "$real_target" --release -Zbuild-std=core,alloc --bin entrypoint_$target 2>/dev/null
cp "target/$(echo $real_target | sed 's/\.json//')/release/entrypoint_$target" kernel-$target cp "target/$(echo $real_target | sed 's/\.json//')/release/entrypoint_$target" kernel-$target
if [[ "$CONFIG_BUILD_GRUB" = "true" ]]; then if [[ "$CONFIG_BUILD_GRUB" = "true" ]]; then

View file

@ -95,6 +95,16 @@ pub mod interrupts {
} }
} }
} }
impl Default for IdtBuilder {
fn default() -> Self {
IdtBuilder {
vectors: [0; 256],
funcs: [MaybeUninit::uninit(); 256],
idx: 0,
}
}
}
} }
pub mod output { pub mod output {

View file

@ -1,5 +1,5 @@
//! Constants used throughout kernel code. //! Constants used throughout kernel code.
#![cfg(any(target_arch = "x86"))] #![cfg(target_arch = "x86")]
/// The assembly port number to output debug messages to. /// The assembly port number to output debug messages to.
pub(super) const DEBUG_PORT: u16 = 0xE9; pub(super) const DEBUG_PORT: u16 = 0xE9;

View file

@ -1,5 +1,5 @@
//! Stuff for writing and reading to the EGA text buffer. //! Stuff for writing and reading to the EGA text buffer.
#![cfg(any(target_arch = "x86"))] #![cfg(target_arch = "x86")]
use crate::display::Color; use crate::display::Color;
@ -109,6 +109,6 @@ impl FramebufferInfo {
super::ports::outb(0x3D4, 0x0E); super::ports::outb(0x3D4, 0x0E);
addr |= (super::ports::inb(0x3D5) as u32) << 8; addr |= (super::ports::inb(0x3D5) as u32) << 8;
return (addr % self.width, addr / self.width); (addr % self.width, addr / self.width)
} }
} }

View file

@ -1,4 +1,5 @@
//! GDT initalization. //! GDT initalization.
#![cfg(target_arch = "x86")]
use core::alloc::Layout; use core::alloc::Layout;

View file

@ -1,5 +1,5 @@
//! Provides interrupt-related functions //! Provides interrupt-related functions
#![cfg(any(target_arch = "x86"))] #![cfg(target_arch = "x86")]
#![allow(static_mut_refs)] #![allow(static_mut_refs)]
use core::{ use core::{
@ -69,21 +69,20 @@ pub fn restore_irq(flags: PoppedInterrupts) {
} }
/// The IDTR. Used internally in [load_idt]. /// The IDTR. Used internally in [load_idt].
#[repr(packed)] #[repr(C, packed)]
#[repr(C)] struct Idtr {
struct IDTR {
base: *const u8, base: *const u8,
size: usize, size: usize,
} }
unsafe impl Send for IDTR {} unsafe impl Send for Idtr {}
unsafe impl Sync for IDTR {} unsafe impl Sync for Idtr {}
/// Loads an interrupt descriptor table. /// Loads an interrupt descriptor table.
fn load_idt(base: *const u8, size: usize) { fn load_idt(base: *const u8, size: usize) {
static mut IDTR: MaybeUninit<IDTR> = MaybeUninit::uninit(); static mut IDTR: MaybeUninit<Idtr> = MaybeUninit::uninit();
unsafe { unsafe {
IDTR.write(IDTR { base, size }); IDTR.write(Idtr { base, size });
} }
unsafe { asm!("lidt {}", in(reg) IDTR.as_ptr() as usize) } unsafe { asm!("lidt {}", in(reg) IDTR.as_ptr() as usize) }
} }
@ -148,3 +147,14 @@ impl IdtBuilder {
} }
} }
} }
impl Default for IdtBuilder {
fn default() -> Self {
IdtBuilder {
vectors: [0; 256],
funcs: [MaybeUninit::uninit(); 256],
user_callable: [false; 256],
idx: 0,
}
}
}

View file

@ -1,4 +1,5 @@
//! Hardware-level memory sections. Unimplemented for certain hardware, x86 implements with GDT. //! Hardware-level memory sections. Unimplemented for certain hardware, x86 implements with GDT.
#![cfg(target_arch = "x86")]
use core::arch::asm; use core::arch::asm;

View file

@ -1,5 +1,5 @@
//! General x86 functions //! General x86 functions
#![cfg(any(target_arch = "x86"))] #![cfg(target_arch = "x86")]
use core::arch::asm; use core::arch::asm;
@ -13,7 +13,7 @@ pub mod ports;
mod constants; mod constants;
pub(self) use constants::*; use constants::*;
use interrupts::{pop_irq, restore_irq}; use interrupts::{pop_irq, restore_irq};
use ports::{inb, outb}; use ports::{inb, outb};

View file

@ -1,5 +1,5 @@
//! Functions to output to various things //! Functions to output to various things
#![cfg(any(target_arch = "x86"))] #![cfg(target_arch = "x86")]
use super::ports; use super::ports;
use paste::paste; use paste::paste;

View file

@ -1,4 +1,5 @@
//! Functions and types related to paging. //! Functions and types related to paging.
#![cfg(target_arch = "x86")]
use core::arch::asm; use core::arch::asm;

View file

@ -1,5 +1,5 @@
//! Provides utilities for interacting with assembly ports //! Provides utilities for interacting with assembly ports
#![cfg(any(target_arch = "x86"))] #![cfg(target_arch = "x86")]
use core::arch::asm; use core::arch::asm;

View file

@ -126,7 +126,7 @@ impl core::iter::Iterator for MemoryMap {
type Item = MemoryMapping; type Item = MemoryMapping;
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {
self.idx += 1; self.idx += 1;
if self.sections.len() <= self.idx - 1 { if self.sections.len() < self.idx {
self.reset_iter(); self.reset_iter();
return None; return None;
} }

View file

@ -7,7 +7,7 @@ macro_rules! cfg_int {
paste::paste! { paste::paste! {
{ {
let cfg = env!($cfg).as_bytes(); let cfg = env!($cfg).as_bytes();
crate::[< str_as_ $type >](cfg) $crate::[< str_as_ $type >](cfg)
} }
} }
}; };

View file

@ -303,7 +303,7 @@ impl<'a> MemoryMapAlloc<'a> {
let mut i = 0; let mut i = 0;
while i < num_allocs { while i < num_allocs {
let current = unsafe { let current = unsafe {
&mut *((self.allocations as usize + size_of::<Allocation>() * (i as usize)) &mut *((self.allocations as usize + size_of::<Allocation>() * (i as usize))
as *mut Allocation) as *mut Allocation)
}; };
@ -524,7 +524,7 @@ unsafe impl<'a> Allocator for MemoryMapAlloc<'a> {
if alloc.used && alloc.addr == addr { if alloc.used && alloc.addr == addr {
// Zero the memory // Zero the memory
unsafe { core::ptr::write_bytes(addr as *mut u8, 0, alloc.len as usize) }; unsafe { core::ptr::write_bytes(addr as *mut u8, 0, alloc.len as usize) };
// Mark as free // Mark as free
alloc.used = false; alloc.used = false;
found = true; found = true;
@ -664,4 +664,4 @@ unsafe impl<'a> GlobalAlloc for MemoryMapAlloc<'a> {
/// The last status of memory allocation or deallocation for a [MemoryMapAlloc]. /// The last status of memory allocation or deallocation for a [MemoryMapAlloc].
/// This can be used for more insight to why an allocation or deallocation failed. /// This can be used for more insight to why an allocation or deallocation failed.
pub static mut LAST_MEMMAP_ERR: Result<(), crate::Error<'static>> = Ok(()); pub static mut LAST_MEMMAP_ERR: Result<(), crate::Error<'static>> = Ok(());

View file

@ -1,6 +1,7 @@
//! This provides raw methods for internal kernel usage for the Aphrodite kernel. See aphrodite_user for userspace. //! This provides raw methods for internal kernel usage for the Aphrodite kernel. See aphrodite_user for userspace.
#![no_std] #![no_std]
#![warn(missing_docs)] #![warn(missing_docs)]
#![warn(clippy::missing_docs_in_private_items)]
#![warn(rustdoc::missing_crate_level_docs)] #![warn(rustdoc::missing_crate_level_docs)]
#![deny(rustdoc::invalid_html_tags)] #![deny(rustdoc::invalid_html_tags)]
#![deny(rustdoc::invalid_rust_codeblocks)] #![deny(rustdoc::invalid_rust_codeblocks)]