Skip to content

Commit 55e1f23

Browse files
committed
Got rid of warnings
Need to get rid of all the warnings when running Clippy
1 parent d759c46 commit 55e1f23

File tree

25 files changed

+135
-136
lines changed

25 files changed

+135
-136
lines changed

kernel/Cargo.lock

Lines changed: 6 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

kernel/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ limine = { version = "0.4.0", optional = true }
88

99
alloc = { version = "1.0.0", package = "rustc-std-workspace-alloc"}
1010

11-
modular-bitfield = { version = "0.11.2"}
11+
modular-bitfield = { version = "0.12"}
1212
utils = { path = "../utils" }
1313
macros = { path = "../macros" }
1414

kernel/src/acpi/mcfg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use core::{ptr::from_ref, slice::from_raw_parts};
44

55
use utils::sanity_assert;
66

7-
use crate::dev::bus::pcie::{self, PcieManager};
7+
use crate::dev::bus::pcie;
88

99
use super::{AcpiError, AcpiTable, SdtHeader};
1010

kernel/src/arch/x86_64/apic/ioapic.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub enum IoApicError {
1919
/// The GSI passed in is invalid
2020
InvalidGsi,
2121
/// IDT Error
22-
IdtError(()),
22+
IdtError,
2323
}
2424

2525
/// An IRQ override mapping
@@ -61,7 +61,7 @@ struct IoApicReg;
6161

6262
/// The IO APIC's redirection table entry, which configure the behaviour and mapping of the
6363
/// external interrupts
64-
#[bitfield]
64+
#[bitfield(bits = 64)]
6565
#[derive(Debug, Clone, Copy)]
6666
#[repr(u64)]
6767
struct RedirectionEntry {
@@ -150,7 +150,7 @@ impl IoApic {
150150
// TODO: Return error if the offset is invalid
151151
unsafe {
152152
self.io_sel.write(offset);
153-
let mut raw: u64 = self.io_win.read() as u64;
153+
let mut raw: u64 = self.io_win.read().into();
154154
self.io_sel.write(offset + IoApicReg::red_tbl_to_index(1));
155155
raw |= (self.io_win.read() as u64) << 32;
156156

kernel/src/arch/x86_64/apic/lapic.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ pub enum DeliveryStatus {
112112
}
113113

114114
/// Represents the LVT register
115-
#[bitfield]
115+
#[bitfield(bits = 32)]
116116
#[derive(Debug, Clone, Copy)]
117117
#[repr(u32)]
118118
pub struct LvtReg {
@@ -161,7 +161,7 @@ impl LocalApic {
161161
);
162162
}
163163

164-
/// Enables the local APIC in the IA32_APIC_BASE MSR, in case firmware didn't do it already
164+
/// Enables the local APIC in the `IA32_APIC_BASE` MSR, in case firmware didn't do it already
165165
#[inline]
166166
fn hardware_enable() {
167167
const APIC_ENABLE: u32 = 1 << 11;
@@ -185,7 +185,7 @@ impl LocalApic {
185185

186186
// Initialize the local APIC
187187
unsafe {
188-
// Make sure the APIC enable bit on the IA32_APIC_BASE MSR is set
188+
// Make sure the APIC enable bit on the `IA32_APIC_BASE` MSR is set
189189
Self::hardware_enable();
190190

191191
// Configure the SIV and software enable the APIC
@@ -416,7 +416,7 @@ pub unsafe fn add(base: PhysAddr, acpi_processor_id: u32, apic_id: u32, flags: u
416416
)));
417417
}
418418

419-
/// Marks the matching processor's LINT as NMI with the passed flags, making the other ExtInt
419+
/// Marks the matching processor's LINT as NMI with the passed flags, making the other `ExtInt`
420420
///
421421
/// SAFTEY:
422422
pub unsafe fn config_lints(acpi_processor_id: u32, lint: u8, flags: u16) {

kernel/src/arch/x86_64/cpu/mod.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub trait Register {
1919
}
2020

2121
#[derive(Clone, Copy)]
22-
#[bitfield]
22+
#[bitfield(bits = 64)]
2323
#[repr(u64)]
2424
pub struct Rflags {
2525
/// Carry flag
@@ -70,7 +70,7 @@ pub struct Rflags {
7070

7171
/// The CR0 register
7272
#[derive(Clone, Copy)]
73-
#[bitfield]
73+
#[bitfield(bits = 64)]
7474
#[repr(u64)]
7575
pub struct Cr0 {
7676
/// Protection enable
@@ -111,7 +111,7 @@ pub struct Cr0 {
111111
pub struct Cr2(pub u64);
112112

113113
/// The CR3 register
114-
#[bitfield]
114+
#[bitfield(bits = 64)]
115115
#[repr(u64)]
116116
pub struct Cr3 {
117117
/// Reserved (must be 0)
@@ -127,7 +127,7 @@ pub struct Cr3 {
127127
}
128128

129129
/// The CR4 register
130-
#[bitfield]
130+
#[bitfield(bits = 64)]
131131
#[repr(u64)]
132132
pub struct Cr4 {
133133
/// Virtual 8086 mode extensions
@@ -208,7 +208,7 @@ pub struct Dr3(VirtAddr);
208208

209209
/// Debug register 6 on AMD CPUs
210210
#[derive(Clone, Copy)]
211-
#[bitfield]
211+
#[bitfield(bits = 64)]
212212
#[repr(u64)]
213213
pub struct AmdDr6 {
214214
/// Debug register 0 condition
@@ -239,7 +239,7 @@ pub struct AmdDr6 {
239239

240240
/// Debug register 7 on AMD CPUs, 64 bit
241241
#[derive(Clone, Copy)]
242-
#[bitfield]
242+
#[bitfield(bits = 64)]
243243
#[repr(u64)]
244244
pub struct AmdDr7 {
245245
/// Local breakpoint 0 enable
@@ -568,6 +568,12 @@ impl Register for Cr4 {
568568
}
569569
}
570570

571+
impl Default for Cr3 {
572+
fn default() -> Self {
573+
Self::new()
574+
}
575+
}
576+
571577
// impl Into<u64> for MsrData {
572578
// fn into(self) -> u64 {
573579
// ((self.high as u64) << 32) | (self.low as u64)

kernel/src/arch/x86_64/cpu/msr.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ pub struct VmCr;
5252
pub struct VmHsavePa;
5353

5454
// TODO: Fix this
55+
#[allow(dead_code)]
5556
impl Efer {
5657
/// System call extension enable
5758
pub const SCE: u64 = 1 << 0;

kernel/src/arch/x86_64/gdt.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub struct FullSegmentSelector {
1919
}
2020

2121
/// A segment descriptor.
22-
#[bitfield]
22+
#[bitfield(bits = 64)]
2323
#[derive(Debug, Clone, Copy)]
2424
#[repr(u64)]
2525
pub struct SegmentDescriptor {
@@ -41,7 +41,7 @@ pub struct Gdt {
4141
}
4242

4343
/// The basic, visible part of a segment selector.
44-
#[bitfield]
44+
#[bitfield(bits = 16)]
4545
#[derive(Debug, Clone, Copy, Default)]
4646
#[repr(u16)]
4747
pub struct SegmentSelector {
@@ -130,24 +130,30 @@ impl SegmentDescriptor {
130130
const ACCESS_DPL_1: u8 = 0b01 << 5;
131131
const ACCESS_P: u8 = 1 << 7; // present
132132

133-
const _FLAGS_RESERVED: u8 = 1 << (4 + 0);
133+
const _FLAGS_RESERVED: u8 = 1 << 4;
134134
const FLAGS_G: u8 = 1 << (4 + 1); // granuality
135135
const FLAGS_DB: u8 = 1 << (4 + 2); // size. 0-> 16 bit protected mode 1-> 32 bit protected
136136
const FLAGS_L: u8 = 1 << (4 + 3); // segment is 64 long mode. when set, DB shouldn't be
137137

138138
#[inline]
139-
fn get_base(&self) -> u32 {
139+
fn get_base(self) -> u32 {
140140
(u32::from(self.base_1()) << 24) | u32::from(self.base_0())
141141
}
142142

143143
// TODO: Make this function const
144144
/// NOTE: The size of the limit is actually 20 bits, not 32
145145
#[inline]
146-
fn get_limit(&self) -> u32 {
146+
fn get_limit(self) -> u32 {
147147
(u32::from(self.limit_1()) << 16) | u32::from(self.limit_0())
148148
}
149149
}
150150

151+
impl Default for SegmentDescriptor {
152+
fn default() -> Self {
153+
Self::new()
154+
}
155+
}
156+
151157
impl Register for Cs {
152158
#[inline]
153159
unsafe fn read() -> Self {

kernel/src/arch/x86_64/interrupts.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub struct Idt([GateDescriptor; IDT_ENTRIES_NUM]);
3232
/// NOTE: That's not the actual ISR, that's only stub.
3333
pub type IsrStub = unsafe extern "C" fn();
3434

35-
#[bitfield]
35+
#[bitfield(bits = 128)]
3636
#[derive(Debug, Clone, Copy)]
3737
#[repr(u128)]
3838
/// A gate descriptor instance. These are the entries of the IDT
@@ -181,7 +181,7 @@ impl Idt {
181181
asm! (
182182
"lidt [{}]",
183183
in(reg) &idtr,
184-
)
184+
);
185185
}
186186

187187
log_info!("Loaded IDT successfully");
@@ -213,7 +213,7 @@ pub unsafe fn install_isr(
213213
gate_type: GateType,
214214
dpl: Dpl,
215215
present: Present,
216-
) -> Result<u8, ()> {
216+
) -> u8 {
217217
let mut idt = IDT.lock();
218218

219219
let (entry_number, entry) = idt
@@ -232,7 +232,7 @@ pub unsafe fn install_isr(
232232
present,
233233
);
234234

235-
Ok(entry_number as u8)
235+
entry_number as u8
236236
}
237237

238238
unsafe extern "C" {

kernel/src/arch/x86_64/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub mod paging;
2020
pub static CPU_VENDOR: FastLazyStatic<CpuVendor> = FastLazyStatic::new(CpuVendor::Invalid);
2121

2222
#[derive(Debug, Clone, Copy, PartialEq)]
23-
/// The x86_64 CPU vendors Funderberker supports
23+
/// The `x86_64` CPU vendors Funderberker supports
2424
pub enum CpuVendor {
2525
/// We're running on an AMD CPU
2626
Amd,

0 commit comments

Comments
 (0)