Skip to content

Commit

Permalink
ci: update toolchain version and fix lints
Browse files Browse the repository at this point in the history
  • Loading branch information
Qix- committed Oct 20, 2024
1 parent 4342b03 commit d695053
Show file tree
Hide file tree
Showing 28 changed files with 49 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "Two"
style_edition = "2024"
unstable_features = true

# Non-default settings
Expand Down
2 changes: 1 addition & 1 deletion oro-acpi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ pub trait AcpiTable: Sized {
let len =
header.Length.read() as usize - core::mem::size_of::<sys::acpi_table_header>();
let data_base = core::ptr::from_ref(header).add(1).cast::<u8>();
return core::slice::from_raw_parts(data_base, len);
core::slice::from_raw_parts(data_base, len)
}
}

Expand Down
7 changes: 4 additions & 3 deletions oro-arch-aarch64/src/boot/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use core::arch::asm;

use oro_boot_protocol::{memory_map::MemoryMapKind, MemoryMapEntry, MemoryMapEntryType};
use oro_boot_protocol::{MemoryMapEntry, MemoryMapEntryType, memory_map::MemoryMapKind};
use oro_debug::{dbg, dbg_warn};
use oro_macro::assert;
use oro_mem::{
Expand Down Expand Up @@ -81,6 +81,7 @@ pub unsafe fn prepare_memory() -> PreparedMemory {
let linear_offset = linear_map_regions(&otf, &mut pfa_iter, mmap_iter)
.expect("ran out of memory while linear mapping regions");

#[expect(static_mut_refs)]
GLOBAL_PAT.set_offset(
usize::try_from(linear_offset).expect("linear offset doesn't fit into a usize"),
);
Expand Down Expand Up @@ -420,7 +421,7 @@ impl<'a> MemoryMapPfa<'a> {
}
}

impl<'a> Iterator for MemoryMapPfa<'a> {
impl Iterator for MemoryMapPfa<'_> {
type Item = u64;

fn next(&mut self) -> Option<Self::Item> {
Expand Down Expand Up @@ -496,7 +497,7 @@ impl<'a> MemoryMapIterator<'a> {
}
}

impl<'a> Iterator for MemoryMapIterator<'a> {
impl Iterator for MemoryMapIterator<'_> {
type Item = MemoryMapEntry;

fn next(&mut self) -> Option<Self::Item> {
Expand Down
2 changes: 2 additions & 0 deletions oro-arch-aarch64/src/boot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ mod protocol;
mod secondary;

use oro_debug::dbg;
#[cfg(debug_assertions)]
use oro_mem::phys::{Phys, PhysAddr};

/// The number of pages to allocate for the secondary core stacks.
Expand Down Expand Up @@ -38,6 +39,7 @@ pub unsafe fn boot_primary() -> ! {
crate::init::initialize_primary(pfa);

{
#[expect(static_mut_refs)]
let mut pfa = crate::init::KERNEL_STATE.assume_init_ref().pfa().lock();

// Boot secondaries.
Expand Down
1 change: 1 addition & 0 deletions oro-arch-aarch64/src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ pub unsafe fn initialize_primary(pfa: crate::Pfa) {
/// (i.e. boot, or powerdown/subsequent bringup).
pub unsafe fn boot() -> ! {
// SAFETY(qix-): THIS MUST ABSOLUTELY BE FIRST.
#[expect(static_mut_refs)]
let _kernel = crate::Kernel::initialize_for_core(
0, // TODO(qix-): pass in the core ID
KERNEL_STATE.assume_init_ref(),
Expand Down
7 changes: 4 additions & 3 deletions oro-arch-x86_64/src/boot/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//! several memory facilities usable by the kernel (e.g. a page frame
//! allocator, linear map translator, etc.).
use oro_boot_protocol::{memory_map::MemoryMapKind, MemoryMapEntry, MemoryMapEntryType};
use oro_boot_protocol::{MemoryMapEntry, MemoryMapEntryType, memory_map::MemoryMapKind};
use oro_debug::{dbg, dbg_warn};
use oro_macro::assert;
use oro_mem::{
Expand Down Expand Up @@ -124,6 +124,7 @@ pub unsafe fn prepare_memory() -> PreparedMemory {
let linear_offset = linear_map_regions(&otf_mapper, &mut mmap_pfa, mmap_iterator)
.expect("system ran out of memory during linear map");

#[expect(static_mut_refs)]
GLOBAL_PAT.set_offset(
usize::try_from(linear_offset).expect("linear offset doesn't fit into a usize"),
);
Expand Down Expand Up @@ -380,7 +381,7 @@ impl<'a> MemoryMapPfa<'a> {
}
}

impl<'a> Iterator for MemoryMapPfa<'a> {
impl Iterator for MemoryMapPfa<'_> {
type Item = u64;

fn next(&mut self) -> Option<Self::Item> {
Expand Down Expand Up @@ -460,7 +461,7 @@ impl<'a> MemoryMapIterator<'a> {
}
}

impl<'a> Iterator for MemoryMapIterator<'a> {
impl Iterator for MemoryMapIterator<'_> {
type Item = MemoryMapEntry;

fn next(&mut self) -> Option<Self::Item> {
Expand Down
4 changes: 3 additions & 1 deletion oro-arch-x86_64/src/boot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ pub(crate) mod protocol;
mod secondary;

use oro_acpi::{
AcpiTable,
madt::{LocalApicEx as _, MadtEntry},
sys as acpi_sys, AcpiTable,
sys as acpi_sys,
};
use oro_boot_protocol::acpi::AcpiKind;
use oro_debug::{dbg, dbg_warn};
Expand Down Expand Up @@ -121,6 +122,7 @@ pub unsafe fn boot_primary() -> ! {
crate::init::initialize_primary(pfa);

{
#[expect(static_mut_refs)]
let mut pfa = crate::init::KERNEL_STATE.assume_init_ref().pfa().lock();

let num_cores = if has_cs89 {
Expand Down
2 changes: 2 additions & 0 deletions oro-arch-x86_64/src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ pub unsafe fn initialize_primary(pfa: crate::Pfa) {
KernelState::init(&mut KERNEL_STATE, FairMutex::new(pfa))
.expect("failed to create global kernel state");

#[expect(static_mut_refs)]
let state = KERNEL_STATE.assume_init_ref();

// TODO(qix-): Not sure that I like that this is ELF-aware. This may get
Expand Down Expand Up @@ -223,6 +224,7 @@ pub unsafe fn initialize_primary(pfa: crate::Pfa) {
/// **Interrupts must be disabled upon entering this function.**
pub unsafe fn boot(lapic: Lapic) -> ! {
// SAFETY(qix-): THIS MUST ABSOLUTELY BE FIRST.
#[expect(static_mut_refs)]
let kernel = crate::Kernel::initialize_for_core(
lapic.id().into(),
KERNEL_STATE.assume_init_ref(),
Expand Down
4 changes: 2 additions & 2 deletions oro-arch-x86_64/src/interrupt.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Interrupt handling for x86_64 architecture.
use core::arch::asm;
use core::arch::{asm, naked_asm};

use oro_mem::mapper::AddressSegment;

Expand Down Expand Up @@ -181,7 +181,7 @@ unsafe extern "C" fn isr_apic_svr_rust() {
/// The ISR (Interrupt Service Routine) trampoline stub for the APIC spurious interrupt.
#[naked]
unsafe extern "C" fn isr_apic_svr() -> ! {
asm!("cli", "jmp isr_apic_svr_rust", options(noreturn));
naked_asm!("cli", "jmp isr_apic_svr_rust");
}

/// Aligns a `T` value to 16 bytes.
Expand Down
2 changes: 1 addition & 1 deletion oro-arch-x86_64/src/mem/paging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ impl From<PageTableEntry> for u64 {
/// A struct for manipulating the available fields of a page table entry.
pub struct AvailableFields<'a>(&'a mut u64);

impl<'a> AvailableFields<'a> {
impl AvailableFields<'_> {
/// Gets the first block of available bits as a u8.
#[inline]
#[must_use]
Expand Down
23 changes: 6 additions & 17 deletions oro-arch-x86_64/src/task.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Task (context) switching routines.
use core::arch::asm;
use core::arch::naked_asm;

use oro_mem::mapper::{AddressSegment, AddressSpace};

Expand Down Expand Up @@ -87,7 +87,7 @@ pub fn initialize_user_irq_stack(page_slice: &mut [u64], entry_point: u64) -> u6
pub unsafe extern "C" fn oro_x86_64_kernel_to_user() {
// Push all general purpose registers
// and then store the stack state.
asm!(
naked_asm!(
"mov [r10], rsp",
"push rax",
"push rbx",
Expand Down Expand Up @@ -133,7 +133,6 @@ pub unsafe extern "C" fn oro_x86_64_kernel_to_user() {
"sti",
"iretq",
const (crate::gdt::USER_DS | 3),
options(noreturn)
);
}

Expand Down Expand Up @@ -169,7 +168,7 @@ pub unsafe extern "C" fn oro_x86_64_kernel_to_user() {
pub unsafe extern "C" fn oro_x86_64_user_to_user() {
// Push all general purpose registers
// and then store the stack state.
asm!(
naked_asm!(
"mov cr3, rax",
"mov rsp, rdx",
"mov ax, {}",
Expand All @@ -196,7 +195,6 @@ pub unsafe extern "C" fn oro_x86_64_user_to_user() {
"sti",
"iretq",
const (crate::gdt::USER_DS | 3),
options(noreturn)
);
}

Expand All @@ -220,7 +218,7 @@ pub unsafe extern "C" fn oro_x86_64_user_to_user() {
#[macro_export]
macro_rules! isr_store_user_task_and_jmp {
($jmp_to:ident) => {
asm!(
naked_asm!(
"cli",
"push rax",
"push rbx",
Expand All @@ -241,7 +239,6 @@ macro_rules! isr_store_user_task_and_jmp {
"mov rcx, rsp",
concat!("jmp ", stringify!($jmp_to)),
"ud2",
options(noreturn)
);
};
}
Expand Down Expand Up @@ -271,7 +268,7 @@ macro_rules! isr_store_user_task_and_jmp {
#[no_mangle]
#[naked]
pub unsafe extern "C" fn oro_x86_64_return_to_kernel() {
asm!(
naked_asm!(
"popfq",
"pop r15",
"pop r14",
Expand All @@ -290,7 +287,6 @@ pub unsafe extern "C" fn oro_x86_64_return_to_kernel() {
"pop rax",
"mov rsp, r9",
"ret",
options(noreturn)
);
}

Expand Down Expand Up @@ -319,12 +315,5 @@ pub unsafe extern "C" fn oro_x86_64_return_to_kernel() {
#[no_mangle]
#[naked]
pub unsafe extern "C" fn oro_x86_64_kernel_to_idle() {
asm!(
"mov [r9], rsp",
"sti",
"4: hlt",
"jmp 4b",
"ud2",
options(noreturn)
);
naked_asm!("mov [r9], rsp", "sti", "4: hlt", "jmp 4b", "ud2",);
}
2 changes: 1 addition & 1 deletion oro-boot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ mod pfa;
mod target;

use oro_boot_protocol::{
util::{RequestData, RequestScanner, TrySendError},
DataRevision, RequestTag,
util::{RequestData, RequestScanner, TrySendError},
};
use oro_debug::{dbg, dbg_warn};
use oro_elf::ElfSegmentType;
Expand Down
2 changes: 1 addition & 1 deletion oro-boot/src/target/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use core::arch::asm;

pub use oro_arch_aarch64::{ELF_CLASS, ELF_ENDIANNESS, ELF_MACHINE};
use oro_arch_aarch64::{
mair::MairEntry,
mem::address_space::{AddressSpaceLayout, Ttbr1Handle},
Expand All @@ -13,7 +14,6 @@ use oro_arch_aarch64::{
},
},
};
pub use oro_arch_aarch64::{ELF_CLASS, ELF_ENDIANNESS, ELF_MACHINE};
use oro_macro::asm_buffer;
use oro_mem::{
mapper::{AddressSegment, MapError},
Expand Down
8 changes: 4 additions & 4 deletions oro-boot/src/target/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ mod x86_64;

#[cfg(target_arch = "aarch64")]
pub use self::aarch64::{
prepare_transfer, transfer, AddressSpace, SupervisorHandle, ELF_CLASS, ELF_ENDIANNESS,
ELF_MACHINE,
AddressSpace, ELF_CLASS, ELF_ENDIANNESS, ELF_MACHINE, SupervisorHandle, prepare_transfer,
transfer,
};
#[cfg(target_arch = "x86_64")]
pub use self::x86_64::{
prepare_transfer, transfer, AddressSpace, SupervisorHandle, ELF_CLASS, ELF_ENDIANNESS,
ELF_MACHINE,
AddressSpace, ELF_CLASS, ELF_ENDIANNESS, ELF_MACHINE, SupervisorHandle, prepare_transfer,
transfer,
};
2 changes: 1 addition & 1 deletion oro-bootloader-limine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ use core::{ffi::CStr, str::FromStr};
#[cfg(debug_assertions)]
use limine::request::StackSizeRequest;
use limine::{
BaseRevision,
memory_map::EntryType,
modules::{InternalModule, ModuleFlags},
request::{BootTimeRequest, HhdmRequest, MemoryMapRequest, ModuleRequest, RsdpRequest},
BaseRevision,
};
use oro_debug::{dbg, dbg_err};

Expand Down
3 changes: 2 additions & 1 deletion oro-dbgutil/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ pub extern "C" fn __oro_dbgutil_kernel_will_transfer() {
#[no_mangle]
#[naked]
pub extern "C" fn __oro_dbgutil_ATS1E1R() -> ! {
use core::arch::naked_asm;
unsafe {
asm!("AT S1E1R, x0", "nop", options(noreturn));
naked_asm!("AT S1E1R, x0", "nop");
}
}

Expand Down
6 changes: 3 additions & 3 deletions oro-elf/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use core::{
fmt,
mem::{transmute, ManuallyDrop},
mem::{ManuallyDrop, transmute},
ptr::from_ref,
};

Expand Down Expand Up @@ -390,7 +390,7 @@ pub trait ElfSegment {
fn target_size(&self) -> usize;
}

impl<'a> fmt::Debug for ElfSegmentHeader<'a> {
impl fmt::Debug for ElfSegmentHeader<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("ElfSegment")
.field("ty", &self.ty())
Expand All @@ -402,7 +402,7 @@ impl<'a> fmt::Debug for ElfSegmentHeader<'a> {
}
}

impl<'a> ElfSegment for ElfSegmentHeader<'a> {
impl ElfSegment for ElfSegmentHeader<'_> {
fn ty(&self) -> ElfSegmentType {
let (flags, ptype) = match self {
ElfSegmentHeader::Elf32(_, hdr) => (hdr.flags, hdr.ty),
Expand Down
2 changes: 1 addition & 1 deletion oro-kernel/src/instance.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//! Module instance types and functionality.
use crate::{
Arch, UserHandle,
module::Module,
port::Port,
registry::{Handle, List},
ring::Ring,
thread::Thread,
Arch, UserHandle,
};

/// A singular module instance.
Expand Down
2 changes: 1 addition & 1 deletion oro-kernel/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
use oro_id::{Id, IdType};

use crate::{
Arch, UserHandle,
instance::Instance,
registry::{Handle, List},
Arch, UserHandle,
};

/// Module metadata.
Expand Down
2 changes: 1 addition & 1 deletion oro-kernel/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

use core::{
marker::PhantomData,
mem::{size_of, ManuallyDrop, MaybeUninit},
mem::{ManuallyDrop, MaybeUninit, size_of},
ops::Deref,
sync::atomic::{AtomicUsize, Ordering},
};
Expand Down
2 changes: 1 addition & 1 deletion oro-kernel/src/ring.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//! Implements Oro rings in the kernel.
use crate::{
Arch,
instance::Instance,
registry::{Handle, List},
Arch,
};

/// A singular ring.
Expand Down
Loading

0 comments on commit d695053

Please sign in to comment.