refactor: resolve clippy warnings
This commit is contained in:
parent
b9e2998248
commit
e8e2705384
@ -10,6 +10,7 @@ use alloc::{boxed::Box, vec::Vec};
|
||||
use device_api::interrupt::{LocalInterruptController, MessageInterruptController};
|
||||
use kernel_arch_interface::{
|
||||
cpu::{CpuImpl, IpiQueue},
|
||||
guard::IrqGuard,
|
||||
task::Scheduler,
|
||||
util::OneTimeInit,
|
||||
Architecture,
|
||||
@ -71,6 +72,13 @@ impl Architecture for ArchitectureImpl {
|
||||
aarch64_cpu::asm::wfi();
|
||||
}
|
||||
|
||||
fn halt() -> ! {
|
||||
let _irq = IrqGuard::<Self>::acquire();
|
||||
loop {
|
||||
aarch64_cpu::asm::wfi();
|
||||
}
|
||||
}
|
||||
|
||||
unsafe fn set_local_cpu(cpu: *mut ()) {
|
||||
TPIDR_EL1.set(cpu as _);
|
||||
}
|
||||
|
@ -110,4 +110,12 @@ impl Architecture for ArchitectureImpl {
|
||||
fn idle_task() -> extern "C" fn(usize) -> ! {
|
||||
idle_task
|
||||
}
|
||||
|
||||
fn halt() -> ! {
|
||||
loop {
|
||||
unsafe {
|
||||
core::arch::asm!("cli; hlt");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,10 +5,10 @@ use kernel_arch_interface::{
|
||||
};
|
||||
use libk_mm_interface::{
|
||||
address::{AsPhysicalAddress, PhysicalAddress},
|
||||
table::page_count,
|
||||
table::{page_count, EntryLevel},
|
||||
KernelImageObject,
|
||||
};
|
||||
use table::{PageAttributes, PageEntry, L3};
|
||||
use table::{PageAttributes, PageEntry, L0, L3};
|
||||
use yggdrasil_abi::error::Error;
|
||||
|
||||
pub mod fixed;
|
||||
@ -66,6 +66,11 @@ impl KernelTableManager for KernelTableManagerImpl {
|
||||
}
|
||||
}
|
||||
|
||||
/// Sets up fixed MMU translation tables.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// Only meant to be called once during early OS init.
|
||||
pub unsafe fn init_fixed_tables() {
|
||||
// Unmap lower stuff
|
||||
for (i, entry) in KERNEL_TABLES.l0.lower.iter_mut().enumerate() {
|
||||
@ -75,8 +80,8 @@ pub unsafe fn init_fixed_tables() {
|
||||
|
||||
// Map the rest of fixed translation
|
||||
for (i, entry) in KERNEL_TABLES.l0.kernel.iter_mut().enumerate() {
|
||||
let virt = KERNEL_VIRT_OFFSET + i << 22;
|
||||
let phys = (i << 22) as u32;
|
||||
let virt = KERNEL_VIRT_OFFSET + (i << L0::SHIFT);
|
||||
let phys = (i << L0::SHIFT) as u32;
|
||||
*entry = PageEntry::block(PhysicalAddress::from_u32(phys), PageAttributes::WRITABLE);
|
||||
flush_tlb_entry(virt);
|
||||
}
|
||||
|
@ -54,6 +54,8 @@ pub trait Architecture: Sized {
|
||||
unsafe fn set_interrupt_mask(mask: bool) -> bool;
|
||||
fn wait_for_interrupt();
|
||||
|
||||
fn halt() -> !;
|
||||
|
||||
// Architectural devices
|
||||
fn local_interrupt_controller() -> &'static dyn LocalInterruptController {
|
||||
unimplemented!()
|
||||
|
@ -65,6 +65,12 @@ pub trait KernelTableManager: Sized + fmt::Debug {
|
||||
/// Only meant to be called from "safer" wrappers like [RawDeviceMemoryMapping].
|
||||
unsafe fn unmap_device_pages(mapping: &RawDeviceMemoryMapping<Self>);
|
||||
|
||||
/// Releases a "virtualized" physical address.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// The address will/may become invalid after the call.
|
||||
/// Caller must guarantee the address will no longer be used.
|
||||
#[allow(unused)]
|
||||
unsafe fn unmap_physical_address(virt: usize) {}
|
||||
}
|
||||
|
@ -155,6 +155,14 @@ impl Architecture for ArchitectureImpl {
|
||||
}
|
||||
}
|
||||
|
||||
fn halt() -> ! {
|
||||
loop {
|
||||
unsafe {
|
||||
core::arch::asm!("cli; hlt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn local_interrupt_controller() -> &'static dyn LocalInterruptController {
|
||||
let local = Self::local_cpu_data().unwrap();
|
||||
local.local_apic
|
||||
|
@ -213,6 +213,11 @@ impl<L: EntryLevel> PageTable<L> {
|
||||
Ok(table)
|
||||
}
|
||||
|
||||
/// Recursively clears and deallocates the translation table.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// The caller must ensure the table is no longer in use and is not referenced anymore.
|
||||
pub unsafe fn free<TA: TableAllocator>(this: PhysicalRefMut<Self, KernelTableManagerImpl>) {
|
||||
let physical = this.as_physical_address();
|
||||
TA::free_page_table(physical);
|
||||
|
@ -274,15 +274,11 @@ impl AhciPort {
|
||||
let ci = inner.regs.CI.get();
|
||||
|
||||
for i in 0..MAX_COMMANDS {
|
||||
if ci & (1 << i) == 0 {
|
||||
if self.command_completion[i]
|
||||
.1
|
||||
.swap(status.into(), Ordering::Release)
|
||||
== CMD_PENDING
|
||||
{
|
||||
log::info!("port{}: completion on slot {}", self.index, i);
|
||||
self.command_completion[i].0.wake();
|
||||
}
|
||||
if ci & (1 << i) == 0
|
||||
&& self.command_completion[i].1.swap(status, Ordering::Release) == CMD_PENDING
|
||||
{
|
||||
log::info!("port{}: completion on slot {}", self.index, i);
|
||||
self.command_completion[i].0.wake();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#![cfg_attr(not(test), no_std)]
|
||||
#![allow(clippy::new_ret_no_self)]
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
@ -45,9 +46,8 @@ pub struct Ext2Fs {
|
||||
|
||||
impl Ext2Fs {
|
||||
pub async fn create(device: &'static dyn BlockDevice) -> Result<NodeRef, Error> {
|
||||
let fs = Self::create_fs(device).await.map_err(|e| {
|
||||
let fs = Self::create_fs(device).await.inspect_err(|e| {
|
||||
log::error!("Ext2 init error: {:?}", e);
|
||||
e
|
||||
})?;
|
||||
let fs = Arc::new(fs);
|
||||
let root = fs.load_node(data::ROOT_INODE).await?;
|
||||
@ -177,7 +177,7 @@ impl Ext2Fs {
|
||||
core::slice::from_raw_parts(&block[0] as *const _ as *const _, self.pointers_per_block)
|
||||
};
|
||||
|
||||
return Ok(indirect[index]);
|
||||
Ok(indirect[index])
|
||||
}
|
||||
|
||||
async fn inode_block_index(&self, inode: &Inode, index: u32) -> Result<u32, Error> {
|
||||
|
@ -1,3 +1,4 @@
|
||||
#![allow(clippy::type_complexity)]
|
||||
use core::{
|
||||
hash::{BuildHasher, Hash},
|
||||
ops::AsyncFnOnce,
|
||||
@ -63,8 +64,6 @@ impl<K: Eq, V> LruCacheBucket<K, V> {
|
||||
// Safety: just checked it's not None above, so safe
|
||||
let (key, value) = unsafe { cursor.remove_current().unwrap_unchecked() };
|
||||
|
||||
drop(cursor);
|
||||
|
||||
self.data.push_front((key, value));
|
||||
|
||||
// Safety: just pushed here, so safe
|
||||
@ -138,11 +137,11 @@ impl<K: Hash + Eq, V, H: BuildHasher> LruCache<K, V, H> {
|
||||
&mut self.buckets[h as usize % bucket_count]
|
||||
}
|
||||
|
||||
pub async fn try_get_or_insert_with_async<'a, F, E>(
|
||||
&'a mut self,
|
||||
pub async fn try_get_or_insert_with_async<F, E>(
|
||||
&mut self,
|
||||
key: K,
|
||||
supplier: F,
|
||||
) -> Result<(&'a mut V, Option<(K, V)>), E>
|
||||
) -> Result<(&mut V, Option<(K, V)>), E>
|
||||
where
|
||||
F: AsyncFnOnce() -> Result<V, E>,
|
||||
{
|
||||
|
@ -1,3 +1,4 @@
|
||||
#![allow(clippy::missing_transmute_annotations)]
|
||||
use core::ops::{Deref, DerefMut};
|
||||
|
||||
use alloc::sync::Arc;
|
||||
@ -75,6 +76,7 @@ impl BlockCache {
|
||||
})))
|
||||
}
|
||||
|
||||
#[allow(clippy::needless_lifetimes)]
|
||||
async fn entry<'a>(
|
||||
&'a self,
|
||||
address: u64,
|
||||
@ -105,13 +107,13 @@ impl BlockCache {
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn get<'a>(&'a self, address: u64) -> Result<CachedBlockRef, Error> {
|
||||
pub async fn get(&self, address: u64) -> Result<CachedBlockRef, Error> {
|
||||
self.entry(address)
|
||||
.await
|
||||
.map(|e| CachedBlockRef::new(e.deref()))
|
||||
}
|
||||
|
||||
pub async fn get_mut<'a>(&'a self, address: u64) -> Result<CachedBlockMut, Error> {
|
||||
pub async fn get_mut(&self, address: u64) -> Result<CachedBlockMut, Error> {
|
||||
self.entry(address)
|
||||
.await
|
||||
.map(|mut e| CachedBlockMut::new(e.deref_mut()))
|
||||
|
@ -242,6 +242,11 @@ extern "C" fn __i686_syscall_handler(frame: *mut SyscallFrame) {
|
||||
}
|
||||
}
|
||||
|
||||
/// Initializes interrupt descriptor table with exception, interrupt and system call vectors.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// Only meant to be called once during OS init.
|
||||
pub unsafe fn init_exceptions() {
|
||||
extern "C" {
|
||||
static __i686_exception_vectors: [usize; 32];
|
||||
@ -254,8 +259,8 @@ pub unsafe fn init_exceptions() {
|
||||
IDT[i] = Entry::new(entry, 0x08, Entry::PRESENT | Entry::INT32);
|
||||
}
|
||||
|
||||
for i in 32..256 {
|
||||
IDT[i] = Entry::new(
|
||||
for entry in IDT.iter_mut().skip(32) {
|
||||
*entry = Entry::new(
|
||||
__i686_dummy_vector as usize,
|
||||
0x08,
|
||||
Entry::PRESENT | Entry::INT32 | Entry::DPL3,
|
||||
|
@ -6,6 +6,7 @@ use device_api::{
|
||||
Device, ResetDevice,
|
||||
};
|
||||
use git_version::git_version;
|
||||
use kernel_arch::{Architecture, ArchitectureImpl};
|
||||
use kernel_arch_i686::{mem::table::L3, PerCpuData};
|
||||
use kernel_fs::devfs::{self, CharDeviceType};
|
||||
use libk::{
|
||||
@ -83,7 +84,7 @@ impl Platform for I686 {
|
||||
type L3 = L3;
|
||||
|
||||
unsafe fn reset(&self) -> ! {
|
||||
loop {}
|
||||
ArchitectureImpl::halt();
|
||||
}
|
||||
|
||||
unsafe fn send_ipi(&self, _target: IpiDeliveryTarget, _msg: IpiMessage) -> Result<(), Error> {
|
||||
|
@ -117,7 +117,7 @@ mod imp {
|
||||
pub(super) unsafe fn load_gdt(gdt: &'static [Entry]) {
|
||||
let gdt_addr = gdt.as_ptr().addr();
|
||||
let gdtr = Pointer {
|
||||
limit: (gdt.len() * size_of::<Entry>()) as u16 - 1,
|
||||
limit: size_of_val(gdt) as u16 - 1,
|
||||
offset: gdt_addr,
|
||||
};
|
||||
|
||||
@ -253,7 +253,7 @@ mod imp {
|
||||
pub(super) unsafe fn load_gdt(gdt: &'static [Entry]) {
|
||||
let gdt_addr = gdt.as_ptr().addr();
|
||||
let gdtr = Pointer {
|
||||
limit: (gdt.len() * size_of::<Entry>()) as u16 - 1,
|
||||
limit: size_of_val(gdt) as u16 - 1,
|
||||
offset: gdt_addr,
|
||||
};
|
||||
|
||||
|
@ -154,7 +154,7 @@ impl I8259 {
|
||||
inner.slave_data.write(ICW4_8086);
|
||||
|
||||
// Mask everything (except IRQ#2 on master, used for cascading)
|
||||
inner.master_data.write(0xFF & !(1 << 2));
|
||||
inner.master_data.write(!(1 << 2));
|
||||
inner.slave_data.write(0xFF);
|
||||
|
||||
inner.master_cmd.write(0x20);
|
||||
|
Loading…
x
Reference in New Issue
Block a user