From 5af29efe17af80a8126d918e48970f98a851054e Mon Sep 17 00:00:00 2001 From: able Date: Tue, 23 May 2023 05:16:14 -0500 Subject: [PATCH] Remove warnings --- kernel/Cargo.toml | 2 +- kernel/src/allocator.rs | 2 +- kernel/src/arch/x86_64/graphics.rs | 7 ++-- kernel/src/arch/x86_64/interrupts.rs | 2 +- kernel/src/arch/x86_64/logging.rs | 5 ++- kernel/src/arch/x86_64/mod.rs | 51 ++++++++++++---------------- kernel/src/arch/x86_64/pci/mod.rs | 2 +- kernel/src/arch/x86_64/virtio/mod.rs | 13 ++++--- kernel/src/device_tree.rs | 2 +- kernel/src/handle.rs | 2 +- kernel/src/host_functions.rs | 18 +++++----- kernel/src/ipc/mod.rs | 22 ------------ kernel/src/kmain.rs | 18 +++++----- kernel/src/lib.rs | 9 ++--- kernel/src/logger.rs | 2 +- repbuild/src/main.rs | 1 + 16 files changed, 65 insertions(+), 93 deletions(-) diff --git a/kernel/Cargo.toml b/kernel/Cargo.toml index f992bf1..0e831a9 100644 --- a/kernel/Cargo.toml +++ b/kernel/Cargo.toml @@ -2,7 +2,7 @@ edition = "2021" name = "kernel" version = "0.2.0" -resolver = "2" + [dependencies] diff --git a/kernel/src/allocator.rs b/kernel/src/allocator.rs index 2375d22..4df7f73 100644 --- a/kernel/src/allocator.rs +++ b/kernel/src/allocator.rs @@ -326,6 +326,6 @@ impl Heap { unsafe impl Send for Heap {} #[alloc_error_handler] -fn alloc_error_handler(layout: alloc::alloc::Layout) -> ! { +fn alloc_error_handler(_layout: alloc::alloc::Layout) -> ! { crate::arch::sloop() } diff --git a/kernel/src/arch/x86_64/graphics.rs b/kernel/src/arch/x86_64/graphics.rs index 642faa3..8f7f333 100644 --- a/kernel/src/arch/x86_64/graphics.rs +++ b/kernel/src/arch/x86_64/graphics.rs @@ -1,12 +1,11 @@ -use {limine::NonNullPtr, virtio_drivers::transport::Transport}; +use {limine::NonNullPtr}; use { - crate::{arch::virtio::AbleosHal, kmain::DEVICE_TREE}, + crate::{kmain::DEVICE_TREE}, able_graphics_library::raw_pixel::Display, embedded_graphics::{pixelcolor::Rgb888, prelude::*}, limine::{Framebuffer, FramebufferRequest}, spin::{Lazy, Mutex}, - virtio_drivers::device::gpu::VirtIOGpu, }; pub static DISPLAY: Lazy> = Lazy::new(|| { @@ -23,7 +22,7 @@ pub static DISPLAY: Lazy> = Lazy::new(|| { disp.set_attribute("bits per pixel", fb1.bpp); dt.devices.insert("Displays".to_string(), alloc::vec![disp]); } - let size: usize = (fb1.width * fb1.height).try_into().unwrap(); + let _size: usize = (fb1.width * fb1.height).try_into().unwrap(); let back_buffer: alloc::vec::Vec = alloc::vec![0; 800*600]; let m = Mutex::new(Display { diff --git a/kernel/src/arch/x86_64/interrupts.rs b/kernel/src/arch/x86_64/interrupts.rs index 9abdc1b..7c08d59 100644 --- a/kernel/src/arch/x86_64/interrupts.rs +++ b/kernel/src/arch/x86_64/interrupts.rs @@ -64,7 +64,7 @@ extern "x86-interrupt" fn page_fault( panic!("Page fault ({error_code:?}): {stack_frame:?}") } -extern "x86-interrupt" fn timer(isf: InterruptStackFrame) { +extern "x86-interrupt" fn timer(_isf: InterruptStackFrame) { unsafe { LAPIC.lock().end_of_interrupt() }; } diff --git a/kernel/src/arch/x86_64/logging.rs b/kernel/src/arch/x86_64/logging.rs index 2e1ba55..4827817 100644 --- a/kernel/src/arch/x86_64/logging.rs +++ b/kernel/src/arch/x86_64/logging.rs @@ -1,9 +1,12 @@ //! Logging (as in terms of console / serial output) +#![allow(deprecated)] + +use spin::Lazy; use { core::fmt::Write, limine::{TerminalRequest, TerminalResponse}, - spin::{Lazy, Mutex}, + spin::Mutex, uart_16550::SerialPort, }; diff --git a/kernel/src/arch/x86_64/mod.rs b/kernel/src/arch/x86_64/mod.rs index 6293db9..9bd4705 100644 --- a/kernel/src/arch/x86_64/mod.rs +++ b/kernel/src/arch/x86_64/mod.rs @@ -80,25 +80,25 @@ unsafe extern "C" fn _kernel_start() -> ! { cpu.set_attribute("core count", core_count); cpu.set_attribute("brand string", brand_string); - let cpu_speed = 0; + let _cpu_speed = 0; cpu.set_attribute("speed", "Unknown"); if false { // disable() // disable interrupts (if still not done) - let i = 0; + let _i = 0; let start = cpuinfo.time_stamp_counter(); log::info!("{:?}", start.unwrap().invariant_tsc()); - for x in 0..1000 {} - let end = cpuinfo.time_stamp_counter(); + for _x in 0..1000 {} + let _end = cpuinfo.time_stamp_counter(); } let mut cpu_features = xml::XMLElement::new("CPU Features"); { let x2 = cpuinfo.x2apic(); let apic = cpuinfo.apic(); - let avx = cpuinfo.avx(); + let _avx = cpuinfo.avx(); cpu_features.set_attribute("apic", apic.to_string()); cpu_features.set_attribute("avx", apic.to_string()); @@ -113,16 +113,9 @@ unsafe extern "C" fn _kernel_start() -> ! { { graphics::init(); let mut dis = DISPLAY.lock(); - use {able_graphics_library::raw_pixel, embedded_graphics::prelude::RgbColor}; - // dis.set_color(Rgb888::GREEN); - // dis.line(400, 400, 700, 100, 50); + use embedded_graphics::prelude::RgbColor; - // dis.set_color(Rgb888::new(100, 23, 100)); - - // dis.line(100, 100, 400, 400, 3); - - // dis.line(100, 100, 700, 100, 1); - dis.set_color(Rgb888::YELLOW); + let _ = dis.set_color(Rgb888::YELLOW); let thick = 3; let p1 = (400, 30); let p2 = (200, 150); @@ -134,20 +127,20 @@ unsafe extern "C" fn _kernel_start() -> ! { { //HEXAGON - dis.line(p1.0, p1.1, p2.0, p2.1, thick); - dis.line(p1.0, p1.1, p3.0, p3.1, thick); - dis.line(p2.0, p2.1, p4.0, p4.1, thick); - dis.line(p3.0, p3.1, p5.0, p5.1, thick); - dis.line(p6.0, p6.1, p4.0, p4.1, thick); - dis.line(p6.0, p6.1, p5.0, p5.1, thick); + let _ = dis.line(p1.0, p1.1, p2.0, p2.1, thick); + let _ = dis.line(p1.0, p1.1, p3.0, p3.1, thick); + let _ = dis.line(p2.0, p2.1, p4.0, p4.1, thick); + let _ = dis.line(p3.0, p3.1, p5.0, p5.1, thick); + let _ = dis.line(p6.0, p6.1, p4.0, p4.1, thick); + let _ = dis.line(p6.0, p6.1, p5.0, p5.1, thick); } { - dis.line(600, 150, 200, 350, thick); - dis.line(600, 350, 400, 250, thick); + let _ = dis.line(600, 150, 200, 350, thick); + let _ = dis.line(600, 350, 400, 250, thick); } { - dis.set_color(Rgb888::WHITE); + let _ = dis.set_color(Rgb888::WHITE); let hp1 = (350, 150); let hp2 = (350, 350); let hp3 = (450, 250); @@ -155,15 +148,15 @@ unsafe extern "C" fn _kernel_start() -> ! { let hp5 = (450, 150); let hp6 = (450, 350); - dis.line(hp1.0, hp1.1, hp2.0, hp2.1, thick); - dis.line(hp3.0, hp3.1, hp4.0, hp4.1, thick); - dis.line(hp5.0, hp5.1, hp6.0, hp6.1, thick); + let _ = dis.line(hp1.0, hp1.1, hp2.0, hp2.1, thick); + let _ = dis.line(hp3.0, hp3.1, hp4.0, hp4.1, thick); + let _ = dis.line(hp5.0, hp5.1, hp6.0, hp6.1, thick); } dis.swap_buffers(); - } + }; - let rand = xml::XMLElement::new("Random"); + let _rand = xml::XMLElement::new("Random"); crate::kmain::kmain( KFILE_REQ @@ -189,7 +182,7 @@ unsafe extern "C" fn _kernel_start() -> ! { }), ) } -use embedded_graphics::prelude::WebColors; + /// Spin loop pub fn sloop() -> ! { loop { diff --git a/kernel/src/arch/x86_64/pci/mod.rs b/kernel/src/arch/x86_64/pci/mod.rs index 2556eba..1765220 100644 --- a/kernel/src/arch/x86_64/pci/mod.rs +++ b/kernel/src/arch/x86_64/pci/mod.rs @@ -271,7 +271,7 @@ use core::fmt::Display; use crate::kmain::DEVICE_TREE; -use {alloc::fmt::format, x86_64::instructions::port::Port}; +use {x86_64::instructions::port::Port}; #[allow(non_camel_case_types, dead_code)] #[derive(Debug, Clone, Copy, PartialEq)] diff --git a/kernel/src/arch/x86_64/virtio/mod.rs b/kernel/src/arch/x86_64/virtio/mod.rs index 4af981d..bcc4906 100644 --- a/kernel/src/arch/x86_64/virtio/mod.rs +++ b/kernel/src/arch/x86_64/virtio/mod.rs @@ -1,21 +1,20 @@ use { - alloc::alloc::{alloc_zeroed, dealloc, handle_alloc_error}, - core::{alloc::Layout, ptr::NonNull}, - virtio_drivers::{BufferDirection, Hal, PhysAddr, PAGE_SIZE}, + core::{ptr::NonNull}, + virtio_drivers::{BufferDirection, Hal, PhysAddr}, }; pub fn test() { - let ps = virtio_drivers::PAGE_SIZE; + let _ps = virtio_drivers::PAGE_SIZE; } pub struct AbleosHal; unsafe impl Hal for AbleosHal { - fn dma_alloc(pages: usize, _direction: BufferDirection) -> (PhysAddr, NonNull) { + fn dma_alloc(_pages: usize, _direction: BufferDirection) -> (PhysAddr, NonNull) { todo!(); } - unsafe fn dma_dealloc(_paddr: PhysAddr, vaddr: NonNull, pages: usize) -> i32 { + unsafe fn dma_dealloc(_paddr: PhysAddr, _vaddr: NonNull, _pages: usize) -> i32 { todo!() } @@ -23,7 +22,7 @@ unsafe impl Hal for AbleosHal { NonNull::new(paddr as _).unwrap() } - unsafe fn share(buffer: NonNull<[u8]>, _direction: BufferDirection) -> PhysAddr { + unsafe fn share(_buffer: NonNull<[u8]>, _direction: BufferDirection) -> PhysAddr { todo!() } diff --git a/kernel/src/device_tree.rs b/kernel/src/device_tree.rs index 97bc9b1..c13538c 100644 --- a/kernel/src/device_tree.rs +++ b/kernel/src/device_tree.rs @@ -46,7 +46,7 @@ use crate::utils::TAB; impl fmt::Display for DeviceTree { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - writeln!(f); + writeln!(f)?; for (device_type, devices) in &self.devices { writeln!(f, "\r{TAB}{}/\r", device_type)?; for device in devices { diff --git a/kernel/src/handle.rs b/kernel/src/handle.rs index d402a39..1e5d9ee 100644 --- a/kernel/src/handle.rs +++ b/kernel/src/handle.rs @@ -39,7 +39,7 @@ impl Handle { impl fmt::Display for Handle { fn fmt(&self, w: &mut Formatter<'_>) -> Result<(), core::fmt::Error> { - write!(w, "{:?}", self.id); + write!(w, "{:?}", self.id)?; Ok(()) } } diff --git a/kernel/src/host_functions.rs b/kernel/src/host_functions.rs index bd2fd29..4bb3414 100644 --- a/kernel/src/host_functions.rs +++ b/kernel/src/host_functions.rs @@ -1,17 +1,17 @@ -use {alloc::collections::VecDeque, hbvm::engine::Engine}; +use {hbvm::engine::Engine}; use { crossbeam_queue::{ArrayQueue, SegQueue}, log::trace, }; -use crate::{ipc::message::Message, kmain::DEVICE_TREE}; +use crate::{ipc::message::Message}; pub enum HostError { MemoryError, } pub fn ipc_send(engine: &mut Engine) -> Result<(), HostError> { - let handle = engine.registers.f0; + let _handle = engine.registers.f0; let message_start = engine.registers.f1; let message_length = engine.registers.f2; @@ -28,7 +28,7 @@ pub fn ipc_send(engine: &mut Engine) -> Result<(), HostError> { Ok(()) } -pub fn ipc_recv(engine: &mut Engine) {} +pub fn ipc_recv(_engine: &mut Engine) {} /// Check f0 for the buffer type /// 0 means an unbound buffer @@ -41,17 +41,17 @@ pub fn ipc_mkbuf(engine: &mut Engine) { match engine.registers.f0 as usize { 0 => { trace!("Making a new ipc unbound buffer"); - let buf: SegQueue = SegQueue::new(); + let _buf: SegQueue = SegQueue::new(); } 1 => { let buf_len = engine.registers.f1 as usize; trace!("Making a new ipc buffer with capacity {}", buf_len); - let buf: ArrayQueue = ArrayQueue::new(buf_len); + let _buf: ArrayQueue = ArrayQueue::new(buf_len); } _ => {} } } -pub fn rpc_discover(engine: &mut Engine) {} -pub fn rpc_register(engine: &mut Engine) {} -pub fn rpc_call(engine: &mut Engine) {} +pub fn rpc_discover(_engine: &mut Engine) {} +pub fn rpc_register(_engine: &mut Engine) {} +pub fn rpc_call(_engine: &mut Engine) {} diff --git a/kernel/src/ipc/mod.rs b/kernel/src/ipc/mod.rs index b392926..11b4c20 100644 --- a/kernel/src/ipc/mod.rs +++ b/kernel/src/ipc/mod.rs @@ -1,24 +1,2 @@ pub mod buffer; pub mod message; - -use alloc::string::ToString; - -pub struct IpcV1 { - abc: alloc::string::String, -} - -pub struct IpcV2 { - abc: alloc::string::String, -} - -pub fn IPCV1_to_IPCV2(ipc_v1: IpcV1) -> IpcV2 { - return IpcV2 { - abc: "abc".to_string(), - }; -} - -pub fn IPCV2_to_IPCV1(ipc_v2: IpcV2) -> IpcV1 { - return IpcV1 { - abc: "abc".to_string(), - }; -} diff --git a/kernel/src/kmain.rs b/kernel/src/kmain.rs index 3a5b555..a1dd992 100644 --- a/kernel/src/kmain.rs +++ b/kernel/src/kmain.rs @@ -7,10 +7,10 @@ use { spin::{Lazy, Mutex}, }; -use {embedded_graphics::pixelcolor::Rgb888, hbvm::engine::Engine}; +use hbvm::engine::Engine; use crate::{ - arch::{graphics::DISPLAY, logging::SERIAL_CONSOLE}, + arch::logging::SERIAL_CONSOLE, device_tree::DeviceTree, // host_functions::read_device_tree, }; @@ -37,24 +37,24 @@ pub fn kmain(cmdline: &str, bootstrap: Option<&'static [u8]>) -> ! { let bootstrap = bootstrap/*.expect("no bootstrap found")*/; match bootstrap { - Some(bootstrap_mod) => {} + Some(_bootstrap_mod) => {} None => { info!("No bootstrap module loaded.") } } - let mut dt = DEVICE_TREE.lock(); + let dt = DEVICE_TREE.lock(); info!("Device Tree {}", &dt); let bytes = alloc::vec![0]; let mut prog = Engine::new(bytes); // prog.enviroment_call_table[0] = read_device_tree; - prog.run(); + let _ = prog.run(); prog.dump(); // TODO: change this to a driver { - let mut buf = [8; 128 * 4]; + let _buf = [8; 128 * 4]; let mut sc = SERIAL_CONSOLE.lock(); loop { @@ -66,13 +66,11 @@ pub fn kmain(cmdline: &str, bootstrap: Option<&'static [u8]>) -> ! { } } - crate::arch::sloop() + // crate::arch::sloop() } -use embedded_graphics::prelude::RgbColor; -use hbvm::bytecode::ops::Operations::*; pub static DEVICE_TREE: Lazy> = Lazy::new(|| { - let mut dt = DeviceTree::new(); + let dt = DeviceTree::new(); Mutex::new(dt) }); diff --git a/kernel/src/lib.rs b/kernel/src/lib.rs index ff84060..aed3a2f 100644 --- a/kernel/src/lib.rs +++ b/kernel/src/lib.rs @@ -1,5 +1,6 @@ //! The ableOS kernel. +#![no_std] #![feature( abi_x86_interrupt, alloc_error_handler, @@ -7,11 +8,11 @@ panic_info_message, pointer_is_aligned, prelude_import, - ptr_sub_ptr + ptr_sub_ptr, + custom_test_frameworks )] -#![deny(clippy::pedantic)] -#![no_std] -#![feature(custom_test_frameworks)] +#![deny(clippy::pedantic, warnings)] +#![allow(dead_code)] #![test_runner(crate::test_runner)] // #![deny(missing_docs)] diff --git a/kernel/src/logger.rs b/kernel/src/logger.rs index f0bfa0a..c8ddfac 100644 --- a/kernel/src/logger.rs +++ b/kernel/src/logger.rs @@ -8,7 +8,7 @@ pub fn init() -> Result<(), SetLoggerError> { struct Logger; impl log::Log for Logger { - fn enabled(&self, metadata: &log::Metadata) -> bool { + fn enabled(&self, _metadata: &log::Metadata) -> bool { true } diff --git a/repbuild/src/main.rs b/repbuild/src/main.rs index 1e57fb8..cb31167 100644 --- a/repbuild/src/main.rs +++ b/repbuild/src/main.rs @@ -164,6 +164,7 @@ fn run(release: bool, target: Target) -> Result<(), Error> { // "-serial", "stdio", "-smp", "cores=4", "-vga", "cirrus", + // "-device", "ati-vga", "-device", "virtio-gpu-pci", "-device", "virtio-serial,id=virtio-serial0",